Viewing your favourites is now accessible on the main menu.
This commit is contained in:
parent
dab6807bff
commit
e59c0534c7
7 changed files with 116 additions and 36 deletions
|
@ -0,0 +1,43 @@
|
|||
/* Copyright 2017 Andrew Dawson
|
||||
*
|
||||
* This file is part of Tusky.
|
||||
*
|
||||
* Tusky is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Tusky. If not, see
|
||||
* <http://www.gnu.org/licenses/>. */
|
||||
|
||||
package com.keylesspalace.tusky;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
||||
public class FavouritesActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_favourites);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
ActionBar bar = getSupportActionBar();
|
||||
if (bar != null) {
|
||||
bar.setTitle(getString(R.string.title_favourites));
|
||||
}
|
||||
|
||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
Fragment fragment = TimelineFragment.newInstance(TimelineFragment.Kind.FAVOURITES);
|
||||
fragmentTransaction.add(R.id.fragment_container, fragment);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
}
|
|
@ -161,37 +161,6 @@ public class MainActivity extends BaseActivity {
|
|||
Log.e(TAG, "Failed to fetch user info. " + exception.getMessage());
|
||||
}
|
||||
|
||||
private void compose() {
|
||||
Intent intent = new Intent(this, ComposeActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void viewProfile() {
|
||||
Intent intent = new Intent(this, AccountActivity.class);
|
||||
intent.putExtra("id", loggedInAccountId);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void viewPreferences() {
|
||||
Intent intent = new Intent(this, PreferencesActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void logOut() {
|
||||
if (notificationServiceEnabled) {
|
||||
alarmManager.cancel(serviceAlarmIntent);
|
||||
}
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
getString(R.string.preferences_file_key), Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.remove("domain");
|
||||
editor.remove("accessToken");
|
||||
editor.apply();
|
||||
Intent intent = new Intent(this, SplashActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main_toolbar, menu);
|
||||
|
@ -202,19 +171,39 @@ public class MainActivity extends BaseActivity {
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_compose: {
|
||||
compose();
|
||||
Intent intent = new Intent(this, ComposeActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_profile: {
|
||||
viewProfile();
|
||||
Intent intent = new Intent(this, AccountActivity.class);
|
||||
intent.putExtra("id", loggedInAccountId);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_preferences: {
|
||||
viewPreferences();
|
||||
Intent intent = new Intent(this, PreferencesActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_favourites: {
|
||||
Intent intent = new Intent(this, FavouritesActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_logout: {
|
||||
logOut();
|
||||
if (notificationServiceEnabled) {
|
||||
alarmManager.cancel(serviceAlarmIntent);
|
||||
}
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
getString(R.string.preferences_file_key), Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.remove("domain");
|
||||
editor.remove("accessToken");
|
||||
editor.apply();
|
||||
Intent intent = new Intent(this, SplashActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ public class TimelineFragment extends SFragment implements
|
|||
PUBLIC,
|
||||
TAG,
|
||||
USER,
|
||||
FAVOURITES
|
||||
}
|
||||
|
||||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
|
@ -154,7 +155,7 @@ public class TimelineFragment extends SFragment implements
|
|||
}
|
||||
|
||||
private boolean jumpToTopAllowed() {
|
||||
return kind != Kind.TAG;
|
||||
return kind != Kind.TAG && kind != Kind.FAVOURITES;
|
||||
}
|
||||
|
||||
private void jumpToTop() {
|
||||
|
@ -186,6 +187,10 @@ public class TimelineFragment extends SFragment implements
|
|||
endpoint = String.format(getString(R.string.endpoint_statuses), hashtagOrId);
|
||||
break;
|
||||
}
|
||||
case FAVOURITES: {
|
||||
endpoint = getString(R.string.endpoint_favourites);
|
||||
break;
|
||||
}
|
||||
}
|
||||
String url = "https://" + domain + endpoint;
|
||||
if (fromId != null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue