diff options
Diffstat (limited to 'app')
9 files changed, 49 insertions, 20 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"; diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index cb475059..2c65f6e0 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -409,4 +409,16 @@ <item>ALL</item> </string-array> + <string-array name="settings_default_search_result_tab"> + <item>@string/posts</item> + <item>@string/subreddits</item> + <item>@string/users</item> + </string-array> + + <string-array name="settings_default_search_result_tab_values"> + <item>0</item> + <item>1</item> + <item>2</item> + </string-array> + </resources>
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 70f5f6eb..e6a546f7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -542,7 +542,7 @@ <string name="settings_hide_subreddit_and_user_prefix">Hide Subreddit and User Prefix</string> <string name="settings_hide_the_number_of_votes">Hide the Number of Votes</string> <string name="settings_hide_the_number_of_comments">Hide the Number of Comments</string> - <string name="settings_show_avatar_on_the_right_in_the_navigation_drawer">Show Avatar on the Left in the Navigation Drawer</string> + <string name="settings_show_avatar_on_the_right">Show Avatar on the Left</string> <string name="settings_backup_settings_title">Backup Settings</string> <string name="settings_restore_settings_title">Restore Settings</string> <string name="settings_credits_love_animation_title">Love Animation</string> @@ -555,6 +555,7 @@ <string name="settings_collapse_subscribed_subreddits_section_title">Collapse Subscribed Subreddits Section</string> <string name="settings_hide_favorite_subreddits_sections_title">Hide Favorite Subreddits Section</string> <string name="settings_hide_subscribed_subreddits_sections_title">Hide Subscribed Subreddits Section</string> + <string name="settings_default_search_result_tab">Default Search Result Tab</string> <string name="no_link_available">Cannot get the link</string> diff --git a/app/src/main/res/xml/interface_preferences.xml b/app/src/main/res/xml/interface_preferences.xml index 1d45da42..6387a850 100644 --- a/app/src/main/res/xml/interface_preferences.xml +++ b/app/src/main/res/xml/interface_preferences.xml @@ -33,15 +33,18 @@ app:title="@string/settings_enable_bottom_app_bar_title" app:summary="@string/settings_enable_bottom_app_bar_summary" /> - <SwitchPreference - app:defaultValue="false" - app:key="show_avatar_on_the_right_in_the_navigation_drawer" - app:title="@string/settings_show_avatar_on_the_right_in_the_navigation_drawer" /> - <Preference app:title="@string/settings_time_format_title" app:fragment="ml.docilealligator.infinityforreddit.settings.TimeFormatPreferenceFragment" /> + <ListPreference + app:defaultValue="0" + app:entries="@array/settings_default_search_result_tab" + app:entryValues="@array/settings_default_search_result_tab_values" + app:key="default_search_result_tab" + app:title="@string/settings_default_search_result_tab" + app:useSimpleSummaryProvider="true" /> + <SwitchPreference app:defaultValue="false" app:key="hide_subreddit_description" diff --git a/app/src/main/res/xml/navigation_drawer_preferences.xml b/app/src/main/res/xml/navigation_drawer_preferences.xml index 12873fa3..3fb31b88 100644 --- a/app/src/main/res/xml/navigation_drawer_preferences.xml +++ b/app/src/main/res/xml/navigation_drawer_preferences.xml @@ -8,6 +8,11 @@ <SwitchPreference app:defaultValue="false" + app:key="show_avatar_on_the_right" + app:title="@string/settings_show_avatar_on_the_right" /> + + <SwitchPreference + app:defaultValue="false" app:key="collapse_account_section" app:title="@string/settings_collapse_account_section_title" /> |