diff options
Diffstat (limited to 'app/src/main/java')
5 files changed, 22 insertions, 14 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java index 35d6c66e..5096e5f7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java @@ -185,7 +185,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect if (savedInstanceState != null) { mInsertSearchQuerySuccess = savedInstanceState.getBoolean(INSERT_SEARCH_QUERY_SUCCESS_STATE); } - bindView(); + bindView(savedInstanceState); } @Override @@ -214,7 +214,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect applyFABTheme(fab); } - private void bindView() { + private void bindView(Bundle savedInstanceState) { sectionsPagerAdapter = new SectionsPagerAdapter(this); viewPager2.setAdapter(sectionsPagerAdapter); viewPager2.setOffscreenPageLimit(3); @@ -246,6 +246,10 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect }).attach(); fixViewPager2Sensitivity(viewPager2); + if (savedInstanceState == null) { + viewPager2.setCurrentItem(Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_SEARCH_RESULT_TAB, "0")), false); + } + fabOption = bottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SUBMIT_POSTS); switch (fabOption) { case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_REFRESH: 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 1ecd8b25..d89c0160 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java @@ -99,7 +99,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re this.accountName = accountName; isNSFWEnabled = nsfwAndSpoilerSharedPreferences.getBoolean((accountName == null ? "" : accountName) + SharedPreferencesUtils.NSFW_BASE, false); requireAuthToAccountSection = sharedPreferences.getBoolean(SharedPreferencesUtils.REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER, false); - showAvatarOnTheRightInTheNavigationDrawer = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT_IN_THE_NAVIGATION_DRAWER, false); + showAvatarOnTheRightInTheNavigationDrawer = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false); isLoggedIn = accountName != null; collapseAccountSection = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.COLLAPSE_ACCOUNT_SECTION, false); collapsePostSection = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.COLLAPSE_POST_SECTION, false); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java index 0d16cb45..2ef43ebf 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/InterfacePreferenceFragment.java @@ -11,7 +11,6 @@ import androidx.preference.SwitchPreference; import org.greenrobot.eventbus.EventBus; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.events.ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent; import ml.docilealligator.infinityforreddit.events.ChangeVoteButtonsPositionEvent; import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; @@ -24,7 +23,6 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat { Preference immersiveInterfaceEntryPreference = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_ENTRY_KEY); SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY); - SwitchPreference showAvatarOnTheRightInTheNavigationDrawer = findPreference(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT_IN_THE_NAVIGATION_DRAWER); SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY); if (immersiveInterfaceEntryPreference != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @@ -38,13 +36,6 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat { }); } - if (showAvatarOnTheRightInTheNavigationDrawer != null) { - showAvatarOnTheRightInTheNavigationDrawer.setOnPreferenceChangeListener((preference, newValue) -> { - EventBus.getDefault().post(new ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent((Boolean) newValue)); - return true; - }); - } - if (voteButtonsOnTheRightSwitch != null) { voteButtonsOnTheRightSwitch.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new ChangeVoteButtonsPositionEvent((Boolean) newValue)); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NavigationDrawerPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NavigationDrawerPreferenceFragment.java index 85751e38..6b6d7c04 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NavigationDrawerPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NavigationDrawerPreferenceFragment.java @@ -4,8 +4,12 @@ import android.os.Bundle; import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceManager; +import androidx.preference.SwitchPreference; + +import org.greenrobot.eventbus.EventBus; import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.events.ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; public class NavigationDrawerPreferenceFragment extends PreferenceFragmentCompat { @@ -15,5 +19,14 @@ public class NavigationDrawerPreferenceFragment extends PreferenceFragmentCompat PreferenceManager preferenceManager = getPreferenceManager(); preferenceManager.setSharedPreferencesName(SharedPreferencesUtils.NAVIGATION_DRAWER_SHARED_PREFERENCES_FILE); setPreferencesFromResource(R.xml.navigation_drawer_preferences, rootKey); + + SwitchPreference showAvatarOnTheRightSwitch = findPreference(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT); + + if (showAvatarOnTheRightSwitch != null) { + showAvatarOnTheRightSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent((Boolean) newValue)); + return true; + }); + } } }
\ No newline at end of file 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 74b882b0..48714674 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -38,7 +38,8 @@ public class SharedPreferencesUtils { public static final String DISABLE_IMMERSIVE_INTERFACE_IN_LANDSCAPE_MODE = "disable_immersive_interface_in_landscape_mode"; public static final String BOTTOM_APP_BAR_KEY = "bottom_app_bar"; public static final String VOTE_BUTTONS_ON_THE_RIGHT_KEY = "vote_buttons_on_the_right"; - public static final String SHOW_AVATAR_ON_THE_RIGHT_IN_THE_NAVIGATION_DRAWER = "show_avatar_on_the_right_in_the_navigation_drawer"; + public static final String SHOW_AVATAR_ON_THE_RIGHT = "show_avatar_on_the_right"; + public static final String DEFAULT_SEARCH_RESULT_TAB = "default_search_result_tab"; public static final String SORT_TYPE_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.sort_type"; public static final String SORT_TYPE_BEST_POST = "sort_type_best_post"; @@ -145,7 +146,6 @@ public class SharedPreferencesUtils { public static final String DATA_SAVING_MODE_ALWAYS = "2"; public static final String NATIONAL_FLAGS = "national_flags"; public static final String RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE = "respect_subreddit_recommended_comment_sort_type"; - public static final String SUBREDDIT_FILTER_POPULAR_AND_ALL = "subreddit_filter_popular_and_all"; public static final String UFO_CAPTURING_ANIMATION = "ufo_capturing_animation"; public static final String HIDE_SUBREDDIT_DESCRIPTION = "hide_subreddit_description"; public static final String DISABLE_IMAGE_PREVIEW = "disable_image_preview"; |