aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java64
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java87
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java38
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java73
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java43
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java61
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java60
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeConfirmToExitEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java37
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/MiscellaneousPreferenceFragment.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java5
-rw-r--r--app/src/main/res/menu/account_posts_activity.xml8
-rw-r--r--app/src/main/res/menu/account_saved_thing_activity.xml8
-rw-r--r--app/src/main/res/menu/filtered_posts_activity.xml8
-rw-r--r--app/src/main/res/menu/main_activity.xml6
-rw-r--r--app/src/main/res/menu/post_fragment.xml8
-rw-r--r--app/src/main/res/menu/view_multi_reddit_detail_activity.xml12
-rw-r--r--app/src/main/res/menu/view_subreddit_detail_activity.xml18
-rw-r--r--app/src/main/res/menu/view_user_detail_activity.xml20
-rw-r--r--app/src/main/res/values/arrays.xml12
-rw-r--r--app/src/main/res/values/strings.xml4
-rw-r--r--app/src/main/res/xml/miscellaneous_preferences.xml11
26 files changed, 158 insertions, 489 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java
index 2f569409..2bd6a247 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountPostsActivity.java
@@ -46,7 +46,6 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
static final String EXTRA_USER_WHERE = "EUW";
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final String FRAGMENT_OUT_STATE = "FOS";
@BindView(R.id.coordinator_layout_account_posts_activity)
@@ -68,13 +67,10 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
- private boolean isInLazyMode = false;
private String mAccessToken;
private String mAccountName;
private String mUserWhere;
private Fragment mFragment;
- private Menu mMenu;
- private AppBarLayout.LayoutParams params;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
@Override
@@ -129,16 +125,12 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar);
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
-
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
if (savedInstanceState != null) {
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
-
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_account_posts_activity, mFragment).commit();
} else {
@@ -188,54 +180,23 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.account_posts_activity, menu);
applyMenuItemTheme(menu);
- mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_account_posts_activity);
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- }
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
- switch (item.getItemId()) {
- case R.id.action_refresh_account_posts_activity:
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_account_posts_activity).setTitle(R.string.action_start_lazy_mode);
- }
- if (mFragment != null) {
- ((PostFragment) mFragment).refresh();
- }
- return true;
- case R.id.action_lazy_mode_account_posts_activity:
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_account_posts_activity);
- if (isInLazyMode) {
- ((FragmentCommunicator) mFragment).stopLazyMode();
- isInLazyMode = false;
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- if (((FragmentCommunicator) mFragment).startLazyMode()) {
- isInLazyMode = true;
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- }
- }
- return true;
- case R.id.action_change_post_layout_account_posts_activity:
- postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
- return true;
- case android.R.id.home:
- finish();
- return true;
+ int itemId = item.getItemId();
+ if (itemId == R.id.action_refresh_account_posts_activity) {
+ if (mFragment != null) {
+ ((PostFragment) mFragment).refresh();
+ }
+ return true;
+ } else if (itemId == R.id.action_change_post_layout_account_posts_activity) {
+ postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
+ return true;
+ } else if (itemId == android.R.id.home) {
+ finish();
+ return true;
}
return false;
}
@@ -244,7 +205,6 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE, mFragment);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java
index a006ac26..bbdb74f0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/AccountSavedThingActivity.java
@@ -38,7 +38,6 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
-import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface;
import ml.docilealligator.infinityforreddit.R;
@@ -58,8 +57,6 @@ import retrofit2.Retrofit;
public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface,
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, MarkPostAsReadInterface {
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
-
@BindView(R.id.coordinator_layout_account_saved_thing_activity)
CoordinatorLayout coordinatorLayout;
@BindView(R.id.collapsing_toolbar_layout_account_saved_thing_activity)
@@ -93,11 +90,8 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
private SlidrInterface mSlidrInterface;
- private Menu mMenu;
- private AppBarLayout.LayoutParams params;
private String mAccessToken;
private String mAccountName;
- private boolean isInLazyMode = false;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
@Override
@@ -141,8 +135,6 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar);
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
-
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
fragmentManager = getSupportFragmentManager();
@@ -150,9 +142,6 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
- if (savedInstanceState != null) {
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
- }
initializeViewPager();
}
@@ -216,67 +205,26 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.account_saved_thing_activity, menu);
applyMenuItemTheme(menu);
- mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_account_saved_thing_activity);
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- }
-
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- finish();
- return true;
- case R.id.action_refresh_account_saved_thing_activity:
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_account_saved_thing_activity).setTitle(R.string.action_start_lazy_mode);
- }
- sectionsPagerAdapter.refresh();
- return true;
- case R.id.action_lazy_mode_account_saved_thing_activity:
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_account_saved_thing_activity);
- if (isInLazyMode) {
- isInLazyMode = false;
- sectionsPagerAdapter.stopLazyMode();
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = true;
- if (sectionsPagerAdapter.startLazyMode()) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- appBarLayout.setExpanded(false);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = false;
- }
- }
- return true;
- case R.id.action_change_post_layout_account_saved_thing_activity:
- postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
- return true;
+ int itemId = item.getItemId();
+ if (itemId == android.R.id.home) {
+ finish();
+ return true;
+ } else if (itemId == R.id.action_refresh_account_saved_thing_activity) {
+ sectionsPagerAdapter.refresh();
+ return true;
+ } else if (itemId == R.id.action_change_post_layout_account_saved_thing_activity) {
+ postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
+ return true;
}
return false;
}
@Override
- protected void onSaveInstanceState(@NonNull Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
- }
-
- @Override
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
@@ -382,21 +330,6 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
}
}
- boolean startLazyMode() {
- Fragment fragment = getCurrentFragment();
- if (fragment instanceof FragmentCommunicator) {
- return ((FragmentCommunicator) fragment).startLazyMode();
- }
- return false;
- }
-
- void stopLazyMode() {
- Fragment fragment = getCurrentFragment();
- if (fragment instanceof FragmentCommunicator) {
- ((FragmentCommunicator) fragment).stopLazyMode();
- }
- }
-
public void changeNSFW(boolean nsfw) {
Fragment fragment = getCurrentFragment();
if (fragment instanceof PostFragment) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java
index 989eb34f..cadaa8d5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java
@@ -15,6 +15,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import org.greenrobot.eventbus.EventBus;
@@ -27,6 +28,9 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Infinity;
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.adapters.CustomizeThemeRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.asynctasks.GetCustomTheme;
import ml.docilealligator.infinityforreddit.asynctasks.InsertCustomTheme;
@@ -34,9 +38,6 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeSettingsItem;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent;
-import ml.docilealligator.infinityforreddit.Infinity;
-import ml.docilealligator.infinityforreddit.R;
-import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils;
public class CustomizeThemeActivity extends BaseActivity {
@@ -231,6 +232,16 @@ public class CustomizeThemeActivity extends BaseActivity {
}
@Override
+ public void onBackPressed() {
+ new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.discard)
+ .setPositiveButton(R.string.discard_dialog_button, (dialogInterface, i)
+ -> super.onBackPressed())
+ .setNegativeButton(R.string.no, null)
+ .show();
+ }
+
+ @Override
protected SharedPreferences getDefaultSharedPreferences() {
return sharedPreferences;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
index c9c43953..7d9ef895 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
@@ -68,7 +68,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
public static final String EXTRA_POST_TYPE = "EPT";
public static final String EXTRA_USER_WHERE = "EUW";
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final String FRAGMENT_OUT_STATE = "FOS";
private static final int CUSTOMIZE_POST_FILTER_ACTIVITY_REQUEST_CODE = 1000;
@@ -97,7 +96,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
- private boolean isInLazyMode = false;
private String mAccessToken;
private String mAccountName;
private String name;
@@ -105,7 +103,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
private int postType;
private PostFragment mFragment;
private Menu mMenu;
- private AppBarLayout.LayoutParams params;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -155,8 +152,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setToolbarGoToTop(toolbar);
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
-
name = getIntent().getStringExtra(EXTRA_NAME);
postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE);
int filter = getIntent().getIntExtra(EXTRA_FILTER, -1000);
@@ -231,7 +226,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
if (savedInstanceState != null) {
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
mFragment = (PostFragment) getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_filtered_posts_activity, mFragment).commit();
bindView(postFilter, false);
@@ -342,17 +336,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
getMenuInflater().inflate(R.menu.filtered_posts_activity, menu);
applyMenuItemTheme(menu);
mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_filtered_thing_activity);
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- }
-
if (userWhere != null && !PostPagingSource.USER_WHERE_SUBMITTED.equals(userWhere)) {
mMenu.findItem(R.id.action_sort_filtered_thing_activity).setVisible(false);
}
@@ -408,30 +391,10 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
}
return true;
} else if (itemId == R.id.action_refresh_filtered_thing_activity) {
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_filtered_thing_activity).setTitle(R.string.action_start_lazy_mode);
- }
if (mFragment != null) {
((FragmentCommunicator) mFragment).refresh();
}
return true;
- } else if (itemId == R.id.action_lazy_mode_filtered_thing_activity) {
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_filtered_thing_activity);
- if (isInLazyMode) {
- ((FragmentCommunicator) mFragment).stopLazyMode();
- isInLazyMode = false;
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- if (((FragmentCommunicator) mFragment).startLazyMode()) {
- isInLazyMode = true;
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- }
- }
- return true;
} else if (itemId == R.id.action_change_post_layout_filtered_post_activity) {
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
@@ -454,7 +417,6 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE, mFragment);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
index 47a62003..1b25dffa 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -98,7 +98,6 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomS
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
-import ml.docilealligator.infinityforreddit.events.ChangeConfirmToExitEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDisableSwipingBetweenTabsEvent;
import ml.docilealligator.infinityforreddit.events.ChangeLockBottomAppBarEvent;
import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent;
@@ -140,7 +139,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private static final String FETCH_USER_INFO_STATE = "FUIS";
private static final String FETCH_SUBSCRIPTIONS_STATE = "FSS";
private static final String DRAWER_ON_ACCOUNT_SWITCH_STATE = "DOASS";
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final String ACCESS_TOKEN_STATE = "ATS";
private static final String ACCOUNT_NAME_STATE = "ANS";
private static final String MESSAGE_FULLNAME_STATE = "MFS";
@@ -222,7 +220,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
Executor mExecutor;
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
- private AppBarLayout.LayoutParams params;
private NavigationDrawerRecyclerViewAdapter adapter;
private Call<String> subredditAutocompleteCall;
private String mAccessToken;
@@ -232,10 +229,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private boolean mDrawerOnAccountSwitch = false;
private String mMessageFullname;
private String mNewAccountName;
- private Menu mMenu;
- private boolean isInLazyMode = false;
private boolean showBottomAppBar;
- private boolean mConfirmToExit;
+ private int mBackButtonAction;
private boolean mLockBottomAppBar;
private boolean mDisableSwipingBetweenTabs;
private boolean mShowFavoriteMultiReddits;
@@ -315,10 +310,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
});
toggle.syncState();
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
-
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, true);
- mConfirmToExit = mSharedPreferences.getBoolean(SharedPreferencesUtils.CONFIRM_TO_EXIT, false);
+ mBackButtonAction = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION, "0"));
mLockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
mDisableSwipingBetweenTabs = mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false);
@@ -331,7 +324,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
mFetchSubscriptionsSuccess = savedInstanceState.getBoolean(FETCH_SUBSCRIPTIONS_STATE);
mDrawerOnAccountSwitch = savedInstanceState.getBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE);
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
inboxCount = savedInstanceState.getInt(INBOX_COUNT_STATE);
@@ -1086,19 +1078,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_activity, menu);
applyMenuItemTheme(menu);
- mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity);
-
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- }
-
return true;
}
@@ -1122,30 +1101,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
changeSortType();
return true;
} else if (itemId == R.id.action_refresh_main_activity) {
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_main_activity).setTitle(R.string.action_start_lazy_mode);
- }
sectionsPagerAdapter.refresh();
mFetchUserInfoSuccess = false;
loadUserData();
return true;
- } else if (itemId == R.id.action_lazy_mode_main_activity) {
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity);
- if (isInLazyMode) {
- sectionsPagerAdapter.stopLazyMode();
- isInLazyMode = false;
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- if (sectionsPagerAdapter.startLazyMode()) {
- isInLazyMode = true;
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- }
- }
- return true;
} else if (itemId == R.id.action_change_post_layout_main_activity) {
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
@@ -1159,13 +1118,15 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
- if (mConfirmToExit) {
+ if (mBackButtonAction == SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION_CONFIRM_EXIT) {
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
.setTitle(R.string.exit_app)
.setPositiveButton(R.string.yes, (dialogInterface, i)
-> finish())
.setNegativeButton(R.string.no, null)
.show();
+ } else if (mBackButtonAction == SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION_OPEN_NAVIGATION_DRAWER) {
+ drawer.openDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
@@ -1187,7 +1148,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
outState.putBoolean(FETCH_SUBSCRIPTIONS_STATE, mFetchSubscriptionsSuccess);
outState.putBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE, mDrawerOnAccountSwitch);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
outState.putString(ACCESS_TOKEN_STATE, mAccessToken);
outState.putString(ACCOUNT_NAME_STATE, mAccountName);
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
@@ -1287,11 +1247,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
@Subscribe
- public void onChangeConfirmToExitEvent(ChangeConfirmToExitEvent changeConfirmToExitEvent) {
- mConfirmToExit = changeConfirmToExitEvent.confirmToExit;
- }
-
- @Subscribe
public void onChangeLockBottomAppBar(ChangeLockBottomAppBarEvent changeLockBottomAppBarEvent) {
mLockBottomAppBar = changeLockBottomAppBarEvent.lockBottomAppBar;
}
@@ -1806,24 +1761,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
return false;
}
- boolean startLazyMode() {
- PostFragment currentFragment = getCurrentFragment();
- if (currentFragment != null) {
- return currentFragment.startLazyMode();
- }
-
- return false;
- }
-
- void stopLazyMode() {
- for (int i = 0; i < getItemCount(); i++) {
- Fragment fragment = fragmentManager.findFragmentByTag("f" + i);
- if (fragment instanceof PostFragment && ((PostFragment) fragment).isInLazyMode()) {
- ((PostFragment) fragment).stopLazyMode();
- }
- }
- }
-
int getCurrentPostType() {
PostFragment currentFragment = getCurrentFragment();
if (currentFragment != null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
index ca1a5887..7f0282f3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java
@@ -81,6 +81,9 @@ public class TrendingActivity extends BaseActivity {
@BindView(R.id.fetch_trending_search_text_view_trending_activity)
TextView errorTextView;
@Inject
+ @Named("no_oauth")
+ Retrofit mRetrofit;
+ @Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
@@ -178,6 +181,8 @@ public class TrendingActivity extends BaseActivity {
swipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true));
swipeRefreshLayout.setOnRefreshListener(this::fetchTrendingSearches);
+ errorLinearLayout.setOnClickListener(view -> fetchTrendingSearches());
+
if (savedInstanceState != null) {
trendingSearches = savedInstanceState.getParcelableArrayList(TRENDING_SEARCHES_STATE);
}
@@ -200,7 +205,13 @@ public class TrendingActivity extends BaseActivity {
trendingSearches = null;
adapter.setTrendingSearches(null);
Handler handler = new Handler();
- mOauthRetrofit.create(RedditAPI.class).getTrendingSearches(APIUtils.getOAuthHeader(mAccessToken)).enqueue(new Callback<String>() {
+ Call<String> trendingCall;
+ if (mAccessToken == null) {
+ trendingCall = mRetrofit.create(RedditAPI.class).getTrendingSearches();
+ } else {
+ trendingCall = mOauthRetrofit.create(RedditAPI.class).getTrendingSearchesOauth(APIUtils.getOAuthHeader(mAccessToken));
+ }
+ trendingCall.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
index 2b2cd198..012742d4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java
@@ -62,7 +62,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
public static final String EXTRA_MULTIREDDIT_PATH = "EMP";
private static final String FRAGMENT_OUT_STATE_KEY = "FOSK";
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
@BindView(R.id.coordinator_layout_view_multi_reddit_detail_activity)
CoordinatorLayout coordinatorLayout;
@@ -99,10 +98,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
private String mAccessToken;
private String mAccountName;
private String multiPath;
- private boolean isInLazyMode = false;
private Fragment mFragment;
- private Menu mMenu;
- private AppBarLayout.LayoutParams params;
private SortTypeBottomSheetFragment sortTypeBottomSheetFragment;
private SortTimeBottomSheetFragment sortTimeBottomSheetFragment;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
@@ -163,8 +159,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
if (savedInstanceState != null) {
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
-
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE_KEY);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_multi_reddit_detail_activity, mFragment).commit();
} else {
@@ -179,8 +173,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
-
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
}
private void initializeFragment() {
@@ -198,17 +190,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_multi_reddit_detail_activity, menu);
applyMenuItemTheme(menu);
- mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_multi_reddit_detail_activity);
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- }
return true;
}
@@ -226,33 +207,10 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
startActivity(intent);
return true;
} else if (itemId == R.id.action_refresh_view_multi_reddit_detail_activity) {
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_view_multi_reddit_detail_activity).setTitle(R.string.action_start_lazy_mode);
- }
if (mFragment instanceof FragmentCommunicator) {
((FragmentCommunicator) mFragment).refresh();
}
return true;
- } else if (itemId == R.id.action_lazy_mode_view_multi_reddit_detail_activity) {
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_multi_reddit_detail_activity);
- if (isInLazyMode) {
- isInLazyMode = false;
- ((FragmentCommunicator) mFragment).stopLazyMode();
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = true;
- if (((FragmentCommunicator) mFragment).startLazyMode()) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- appBarLayout.setExpanded(false);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = false;
- }
- }
- return true;
} else if (itemId == R.id.action_change_post_layout_view_multi_reddit_detail_activity) {
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
return true;
@@ -302,7 +260,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE_KEY, mFragment);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
index c6695f41..727a35fe 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -135,7 +135,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private static final String FETCH_SUBREDDIT_INFO_STATE = "FSIS";
private static final String CURRENT_ONLINE_SUBSCRIBERS_STATE = "COSS";
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final String MESSAGE_FULLNAME_STATE = "MFS";
private static final String NEW_ACCOUNT_NAME_STATE = "NANS";
private static final int ADD_TO_MULTIREDDIT_REQUEST_CODE = 1;
@@ -228,15 +227,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private int mNCurrentOnlineSubscribers = 0;
private boolean isNsfwSubreddit = false;
private boolean subscriptionReady = false;
- private boolean isInLazyMode = false;
private boolean showToast = false;
private boolean showBottomAppBar;
private boolean lockBottomAppBar;
private String mMessageFullname;
private String mNewAccountName;
private RequestManager glide;
- private Menu mMenu;
- private AppBarLayout.LayoutParams params;
private int expandedTabTextColor;
private int expandedTabBackgroundColor;
private int expandedTabIndicatorColor;
@@ -359,7 +355,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
} else {
mFetchSubredditInfoSuccess = savedInstanceState.getBoolean(FETCH_SUBREDDIT_INFO_STATE);
mNCurrentOnlineSubscribers = savedInstanceState.getInt(CURRENT_ONLINE_SUBSCRIBERS_STATE);
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
@@ -372,8 +367,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
fetchSubredditData();
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
-
String title = "r/" + subredditName;
subredditNameTextView.setText(title);
@@ -1091,18 +1084,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_subreddit_detail_activity, menu);
applyMenuItemTheme(menu);
- mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_subreddit_detail_activity);
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS |
- AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- }
return true;
}
@@ -1121,38 +1102,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
startActivity(intent);
return true;
} else if (itemId == R.id.action_refresh_view_subreddit_detail_activity) {
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_view_subreddit_detail_activity).setTitle(R.string.action_start_lazy_mode);
- }
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.refresh();
mFetchSubredditInfoSuccess = false;
fetchSubredditData();
}
return true;
- } else if (itemId == R.id.action_lazy_mode_view_subreddit_detail_activity) {
- if (sectionsPagerAdapter != null) {
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_subreddit_detail_activity);
- if (isInLazyMode) {
- isInLazyMode = false;
- sectionsPagerAdapter.stopLazyMode();
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS |
- AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = true;
- if (sectionsPagerAdapter.startLazyMode()) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- appBarLayout.setExpanded(false);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = false;
- }
- }
- }
- return true;
} else if (itemId == R.id.action_change_post_layout_view_subreddit_detail_activity) {
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
@@ -1231,7 +1186,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
super.onSaveInstanceState(outState);
outState.putBoolean(FETCH_SUBREDDIT_INFO_STATE, mFetchSubredditInfoSuccess);
outState.putInt(CURRENT_ONLINE_SUBSCRIBERS_STATE, mNCurrentOnlineSubscribers);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
}
@@ -1637,21 +1591,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
}
- boolean startLazyMode() {
- Fragment fragment = getCurrentFragment();
- if (fragment instanceof FragmentCommunicator) {
- return ((FragmentCommunicator) fragment).startLazyMode();
- }
- return false;
- }
-
- void stopLazyMode() {
- Fragment fragment = getCurrentFragment();
- if (fragment instanceof FragmentCommunicator) {
- ((FragmentCommunicator) fragment).stopLazyMode();
- }
- }
-
public void changeSortType(SortType sortType) {
Fragment fragment = getCurrentFragment();
if (fragment instanceof PostFragment) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
index 5d748bef..e1b5314c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -131,7 +131,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
public static final int ADD_TO_MULTIREDDIT_REQUEST_CODE = 400;
private static final String FETCH_USER_INFO_STATE = "FSIS";
- private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
private static final String MESSAGE_FULLNAME_STATE = "MFS";
private static final String NEW_ACCOUNT_NAME_STATE = "NANS";
@@ -211,8 +210,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
private RequestManager glide;
- private Menu mMenu;
- private AppBarLayout.LayoutParams params;
private UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment;
private SortTimeBottomSheetFragment sortTimeBottomSheetFragment;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
@@ -222,7 +219,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private String username;
private boolean subscriptionReady = false;
private boolean mFetchUserInfoSuccess = false;
- private boolean isInLazyMode = false;
private int expandedTabTextColor;
private int expandedTabBackgroundColor;
private int expandedTabIndicatorColor;
@@ -271,7 +267,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
} else {
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
- isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
}
@@ -280,8 +275,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
fetchUserInfo();
- params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
-
Resources resources = getResources();
adjustToolbar(toolbar);
@@ -923,19 +916,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_user_detail_activity, menu);
applyMenuItemTheme(menu);
- mMenu = menu;
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity);
- if (isInLazyMode) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS |
- AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- }
-
return true;
}
@@ -955,34 +935,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
startActivity(intent);
return true;
} else if (itemId == R.id.action_refresh_view_user_detail_activity) {
- if (mMenu != null) {
- mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity).setTitle(R.string.action_start_lazy_mode);
- }
sectionsPagerAdapter.refresh();
mFetchUserInfoSuccess = false;
fetchUserInfo();
return true;
- } else if (itemId == R.id.action_lazy_mode_view_user_detail_activity) {
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity);
- if (isInLazyMode) {
- isInLazyMode = false;
- sectionsPagerAdapter.stopLazyMode();
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS |
- AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = true;
- if (sectionsPagerAdapter.startLazyMode()) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- appBarLayout.setExpanded(false);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = false;
- }
- }
- return true;
} else if (itemId == R.id.action_change_post_layout_view_user_detail_activity) {
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
return true;
@@ -1100,7 +1056,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
- outState.putBoolean(IS_IN_LAZY_MODE_STATE, isInLazyMode);
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
}
@@ -1528,21 +1483,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
}
- boolean startLazyMode() {
- Fragment fragment = getCurrentFragment();
- if (fragment instanceof FragmentCommunicator) {
- return ((FragmentCommunicator) fragment).startLazyMode();
- }
- return false;
- }
-
- void stopLazyMode() {
- Fragment fragment = getCurrentFragment();
- if (fragment instanceof FragmentCommunicator) {
- ((FragmentCommunicator) fragment).stopLazyMode();
- }
- }
-
public void changeSortType(SortType sortType) {
Fragment fragment = getCurrentFragment();
if (fragment instanceof PostFragment) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java
index bf9dea5b..3fa436b4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java
@@ -555,6 +555,14 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp;
break;
case 2:
+ stringId = R.string.rpan;
+ drawableId = R.drawable.ic_rpan_24dp;
+ break;
+ case 3:
+ stringId = R.string.trending;
+ drawableId = R.drawable.ic_trending_24dp;
+ break;
+ case 4:
if ((resources.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
stringId = R.string.dark_theme;
drawableId = R.drawable.ic_dark_theme_24dp;
@@ -563,7 +571,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
drawableId = R.drawable.ic_light_theme_24dp;
}
break;
- case 3:
+ case 5:
setOnClickListener = false;
if (isNSFWEnabled) {
stringId = R.string.disable_nsfw;
@@ -587,7 +595,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
}
});
break;
- case 4:
+ case 6:
stringId = R.string.settings;
drawableId = R.drawable.ic_settings_24dp;
}
@@ -761,7 +769,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
- (collapsePostSection ? POST_SECTION_ITEMS : 0)
- (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0);
} else {
- return 5;
+ return 7;
}
} else {
if (isLoggedIn) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
index a7c67893..dd9efb33 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java
@@ -292,7 +292,10 @@ public interface RedditAPI {
Call<String> submitGalleryPost(@HeaderMap Map<String, String> headers, @Body String body);
@GET("/api/trending_searches_v1.json?withAds=0&raw_json=1&gilding_detail=1")
- Call<String> getTrendingSearches(@HeaderMap Map<String, String> headers);
+ Call<String> getTrendingSearches();
+
+ @GET("/api/trending_searches_v1.json?withAds=0&raw_json=1&gilding_detail=1")
+ Call<String> getTrendingSearchesOauth(@HeaderMap Map<String, String> headers);
default Call<String> getWiki(@Path("subredditName") String subredditName) {
return getWikiPage(subredditName, "index");
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeConfirmToExitEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeConfirmToExitEvent.java
deleted file mode 100644
index fbfc4ae3..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeConfirmToExitEvent.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package ml.docilealligator.infinityforreddit.events;
-
-public class ChangeConfirmToExitEvent {
- public boolean confirmToExit;
-
- public ChangeConfirmToExitEvent(boolean confirmToExit) {
- this.confirmToExit = confirmToExit;
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index cd066a1f..a1c76724 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -18,10 +18,12 @@ import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.util.DisplayMetrics;
-import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
@@ -211,12 +213,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
private AppCompatActivity activity;
private LinearLayoutManagerBugFixed mLinearLayoutManager;
private StaggeredGridLayoutManager mStaggeredGridLayoutManager;
+ private MenuItem lazyModeItem;
private long postFragmentId;
private int postType;
private boolean isInLazyMode = false;
private boolean isLazyModePaused = false;
private boolean hasPost = false;
- private boolean isShown = false;
private boolean savePostFeedScrolledPosition;
private boolean rememberMutingOptionInPostFeed;
private Boolean masterMutingOption;
@@ -259,7 +261,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void onResume() {
super.onResume();
- isShown = true;
if (mAdapter != null) {
mAdapter.setCanStartActivity(true);
}
@@ -306,6 +307,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
unbinder = ButterKnife.bind(this, rootView);
+ setHasOptionsMenu(true);
+
EventBus.getDefault().register(this);
applyTheme();
@@ -1275,6 +1278,31 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
view -> mAdapter.retry())));
}
+ @Override
+ public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
+ inflater.inflate(R.menu.post_fragment, menu);
+ lazyModeItem = menu.findItem(R.id.action_lazy_mode_post_fragment);
+
+ if (isInLazyMode) {
+ lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
+ } else {
+ lazyModeItem.setTitle(R.string.action_start_lazy_mode);
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+ if (item.getItemId() == R.id.action_lazy_mode_post_fragment) {
+ if (isInLazyMode) {
+ stopLazyMode();
+ } else {
+ startLazyMode();
+ }
+ return true;
+ }
+ return false;
+ }
+
private void noPostFound() {
hasPost = false;
if (isInLazyMode) {
@@ -1434,6 +1462,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
return false;
}
+ lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
+
if (mAdapter != null && mAdapter.isAutoplay()) {
mAdapter.setAutoplay(false);
refreshAdapter();
@@ -1453,6 +1483,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void stopLazyMode() {
+ lazyModeItem.setTitle(R.string.action_start_lazy_mode);
if (mAdapter != null) {
String autoplayString = mSharedPreferences.getString(SharedPreferencesUtils.VIDEO_AUTOPLAY, SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_NEVER);
if (autoplayString.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ALWAYS_ON) ||
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MiscellaneousPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MiscellaneousPreferenceFragment.java
index f33dd57f..b98f37e5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MiscellaneousPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/MiscellaneousPreferenceFragment.java
@@ -39,12 +39,12 @@ public class MiscellaneousPreferenceFragment extends PreferenceFragmentCompat {
((Infinity) activity.getApplication()).getAppComponent().inject(this);
- SwitchPreference confirmToExitSwitch = findPreference(SharedPreferencesUtils.CONFIRM_TO_EXIT);
+ ListPreference mainPageBackButtonActionListPreference = findPreference(SharedPreferencesUtils.MAIN_PAGE_BACK_BUTTON_ACTION);
SwitchPreference savePostFeedScrolledPositionSwitch = findPreference(SharedPreferencesUtils.SAVE_FRONT_PAGE_SCROLLED_POSITION);
ListPreference languageListPreference = findPreference(SharedPreferencesUtils.LANGUAGE);
- if (confirmToExitSwitch != null) {
- confirmToExitSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ if (mainPageBackButtonActionListPreference != null) {
+ mainPageBackButtonActionListPreference.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new RecreateActivityEvent());
return true;
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
index e1694e47..6e83f822 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -105,7 +105,9 @@ public class SharedPreferencesUtils {
public static final String SWAP_TAP_AND_LONG_COMMENTS = "swap_tap_and_long_in_comments";
public static final String SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "swipe_up_to_hide_jump_to_next_top_level_comments_button";
public static final String SHOW_TOP_LEVEL_COMMENTS_FIRST = "show_top_level_comments_first";
- public static final String CONFIRM_TO_EXIT = "confirm_to_exit";
+ public static final String MAIN_PAGE_BACK_BUTTON_ACTION = "main_page_back_button_action";
+ public static final int MAIN_PAGE_BACK_BUTTON_ACTION_CONFIRM_EXIT = 1;
+ public static final int MAIN_PAGE_BACK_BUTTON_ACTION_OPEN_NAVIGATION_DRAWER = 2;
public static final String LOCK_BOTTOM_APP_BAR = "lock_bottom_app_bar";
public static final String COMMENT_TOOLBAR_HIDDEN = "comment_toolbar_hidden";
public static final String COMMENT_TOOLBAR_HIDE_ON_CLICK = "comment_toolbar_hide_on_click";
@@ -358,4 +360,5 @@ public class SharedPreferencesUtils {
public static final String NSFW_KEY_LEGACY = "nsfw";
public static final String BLUR_NSFW_KEY_LEGACY = "blur_nsfw";
public static final String BLUR_SPOILER_KEY_LEGACY = "blur_spoiler";
+ public static final String CONFIRM_TO_EXIT_LEGACY = "confirm_to_exit";
}
diff --git a/app/src/main/res/menu/account_posts_activity.xml b/app/src/main/res/menu/account_posts_activity.xml
index 96174315..2d8e6578 100644
--- a/app/src/main/res/menu/account_posts_activity.xml
+++ b/app/src/main/res/menu/account_posts_activity.xml
@@ -8,14 +8,8 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_account_posts_activity"
- android:orderInCategory="2"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_account_posts_activity"
- android:orderInCategory="3"
+ android:orderInCategory="2"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/account_saved_thing_activity.xml b/app/src/main/res/menu/account_saved_thing_activity.xml
index 483c27a3..4efb3689 100644
--- a/app/src/main/res/menu/account_saved_thing_activity.xml
+++ b/app/src/main/res/menu/account_saved_thing_activity.xml
@@ -9,14 +9,8 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_account_saved_thing_activity"
- android:orderInCategory="2"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_account_saved_thing_activity"
- android:orderInCategory="3"
+ android:orderInCategory="2"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
</menu>
diff --git a/app/src/main/res/menu/filtered_posts_activity.xml b/app/src/main/res/menu/filtered_posts_activity.xml
index 6e826b5a..d4414d5b 100644
--- a/app/src/main/res/menu/filtered_posts_activity.xml
+++ b/app/src/main/res/menu/filtered_posts_activity.xml
@@ -16,14 +16,8 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_filtered_thing_activity"
- android:orderInCategory="3"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_filtered_post_activity"
- android:orderInCategory="4"
+ android:orderInCategory="3"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/main_activity.xml b/app/src/main/res/menu/main_activity.xml
index f4e275bc..c043a812 100644
--- a/app/src/main/res/menu/main_activity.xml
+++ b/app/src/main/res/menu/main_activity.xml
@@ -25,12 +25,6 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_main_activity"
- android:orderInCategory="4"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_main_activity"
android:orderInCategory="5"
android:title="@string/action_change_post_layout"
diff --git a/app/src/main/res/menu/post_fragment.xml b/app/src/main/res/menu/post_fragment.xml
new file mode 100644
index 00000000..d29054d3
--- /dev/null
+++ b/app/src/main/res/menu/post_fragment.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <item
+ android:id="@+id/action_lazy_mode_post_fragment"
+ android:orderInCategory="100"
+ app:showAsAction="never" />
+</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/view_multi_reddit_detail_activity.xml b/app/src/main/res/menu/view_multi_reddit_detail_activity.xml
index c214a6d3..aabbdc96 100644
--- a/app/src/main/res/menu/view_multi_reddit_detail_activity.xml
+++ b/app/src/main/res/menu/view_multi_reddit_detail_activity.xml
@@ -23,26 +23,20 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_view_multi_reddit_detail_activity"
- android:orderInCategory="4"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_view_multi_reddit_detail_activity"
- android:orderInCategory="5"
+ android:orderInCategory="4"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
<item
android:id="@+id/action_edit_view_multi_reddit_detail_activity"
- android:orderInCategory="6"
+ android:orderInCategory="5"
android:title="@string/action_edit_multi_reddit"
app:showAsAction="never" />
<item
android:id="@+id/action_delete_view_multi_reddit_detail_activity"
- android:orderInCategory="7"
+ android:orderInCategory="6"
android:title="@string/action_delete_multi_reddit"
app:showAsAction="never" />
</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/view_subreddit_detail_activity.xml b/app/src/main/res/menu/view_subreddit_detail_activity.xml
index cb92de44..b72aa93f 100644
--- a/app/src/main/res/menu/view_subreddit_detail_activity.xml
+++ b/app/src/main/res/menu/view_subreddit_detail_activity.xml
@@ -24,44 +24,38 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_view_subreddit_detail_activity"
- android:orderInCategory="4"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_view_subreddit_detail_activity"
- android:orderInCategory="5"
+ android:orderInCategory="4"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
<item
android:id="@+id/action_select_user_flair_view_subreddit_detail_activity"
- android:orderInCategory="6"
+ android:orderInCategory="5"
android:title="@string/action_select_user_flair"
app:showAsAction="never" />
<item
android:id="@+id/action_add_to_multireddit_view_subreddit_detail_activity"
- android:orderInCategory="7"
+ android:orderInCategory="6"
android:title="@string/action_add_to_multireddit"
app:showAsAction="never" />
<item
android:id="@+id/action_add_to_post_filter_view_subreddit_detail_activity"
- android:orderInCategory="8"
+ android:orderInCategory="7"
android:title="@string/action_add_to_post_filter"
app:showAsAction="never" />
<item
android:id="@+id/action_share_view_subreddit_detail_activity"
- android:orderInCategory="9"
+ android:orderInCategory="8"
android:title="@string/action_share"
app:showAsAction="never" />
<item
android:id="@+id/action_go_to_wiki_activity"
- android:orderInCategory="10"
+ android:orderInCategory="9"
android:title="@string/action_go_to_wiki"
app:showAsAction="never" />
</menu>
diff --git a/app/src/main/res/menu/view_user_detail_activity.xml b/app/src/main/res/menu/view_user_detail_activity.xml
index 8d89ff08..437c6e23 100644
--- a/app/src/main/res/menu/view_user_detail_activity.xml
+++ b/app/src/main/res/menu/view_user_detail_activity.xml
@@ -21,48 +21,42 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_lazy_mode_view_user_detail_activity"
- android:orderInCategory="4"
- android:title="@string/action_start_lazy_mode"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_change_post_layout_view_user_detail_activity"
- android:orderInCategory="5"
+ android:orderInCategory="4"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
<item
android:id="@+id/action_send_private_message_view_user_detail_activity"
- android:orderInCategory="6"
+ android:orderInCategory="5"
android:title="@string/action_send_private_message"
app:showAsAction="never" />
<item
android:id="@+id/action_share_view_user_detail_activity"
- android:orderInCategory="7"
+ android:orderInCategory="6"
android:title="@string/action_share"
app:showAsAction="never" />
<item
android:id="@+id/action_add_to_multireddit_view_user_detail_activity"
- android:orderInCategory="8"
+ android:orderInCategory="7"
android:title="@string/action_add_to_multireddit"
app:showAsAction="never" />
<item
android:id="@+id/action_add_to_post_filter_view_user_detail_activity"
- android:orderInCategory="9"
+ android:orderInCategory="8"
android:title="@string/action_add_to_post_filter"
app:showAsAction="never" />
<item
android:id="@+id/action_report_view_user_detail_activity"
- android:orderInCategory="10"
+ android:orderInCategory="9"
android:title="@string/action_report" />
<item
android:id="@+id/action_block_user_view_user_detail_activity"
- android:orderInCategory="11"
+ android:orderInCategory="10"
android:title="@string/action_block_user" />
</menu>
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 330abd60..e59c5abd 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -508,4 +508,16 @@
<item>86400000</item>
</string-array>
+ <string-array name="main_page_back_button_action">
+ <item>@string/default_in_array</item>
+ <item>@string/settings_confirm_to_exit</item>
+ <item>@string/settings_open_navigation_drawer</item>
+ </string-array>
+
+ <string-array name="main_page_back_button_action_values">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ </string-array>
+
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0a66d129..203126ca 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -190,7 +190,7 @@
<string name="send_message_failed">Could not send this message</string>
<string name="select_a_subreddit">Please select a subreddit first</string>
- <string name="title_required">The post need a good title</string>
+ <string name="title_required">The post needs a good title</string>
<string name="link_required">Hey where is the link?</string>
<string name="select_an_image">Please select an image first</string>
<string name="posting">Posting</string>
@@ -391,7 +391,9 @@
<string name="settings_automatically_try_redgifs_title">Automatically Try Accessing Redgifs if Videos on Gfycat are Removed.</string>
<string name="settings_video_player_ignore_nav_bar_title">Ignore Navigation Bar in Video Player</string>
<string name="settings_video_player_ignore_nav_bar_summary">Prevent the Video Controller Having Extra Margin</string>
+ <string name="settings_main_page_back_button_action">Main Page Back Button Action</string>
<string name="settings_confirm_to_exit">Confirm to Exit</string>
+ <string name="settings_open_navigation_drawer">Open Navigation Drawer</string>
<string name="settings_category_comment_title">Comment</string>
<string name="settings_show_top_level_comments_first_title">Show Top-level Comments First</string>
<string name="settings_show_comment_divider_title">Show Comment Divider</string>
diff --git a/app/src/main/res/xml/miscellaneous_preferences.xml b/app/src/main/res/xml/miscellaneous_preferences.xml
index b17e7545..67a78aca 100644
--- a/app/src/main/res/xml/miscellaneous_preferences.xml
+++ b/app/src/main/res/xml/miscellaneous_preferences.xml
@@ -13,11 +13,14 @@
app:key="open_link_in_app"
app:title="@string/settings_open_link_in_app_title" />
- <SwitchPreference
- app:defaultValue="false"
- app:key="confirm_to_exit"
+ <ListPreference
+ app:defaultValue="0"
+ app:entries="@array/main_page_back_button_action"
+ app:entryValues="@array/main_page_back_button_action_values"
+ app:key="main_page_back_button_action"
app:icon="@drawable/ic_exit_24dp"
- app:title="@string/settings_confirm_to_exit" />
+ app:title="@string/settings_main_page_back_button_action"
+ app:useSimpleSummaryProvider="true" />
<SwitchPreference
app:defaultValue="true"