From 0f7b10fa14af39eb591eb37c786037c88ea65837 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 12 Oct 2021 19:35:50 +0800 Subject: Change flotaing action button options in anonymous mode. --- .../infinityforreddit/activities/MainActivity.java | 1 - .../settings/CustomizeBottomAppBarFragment.java | 31 ++++++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) (limited to 'app/src/main/java/ml') 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 7e7fd30c..12616a96 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -1591,7 +1591,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb if (position == 1) { postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR); name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, ""); - Toast.makeText(MainActivity.this, postType + " s", Toast.LENGTH_SHORT).show(); } else { postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL); name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, ""); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java index fd768282..d80442eb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java @@ -121,13 +121,18 @@ public class CustomizeBottomAppBarFragment extends Fragment { Resources resources = activity.getResources(); String[] mainActivityOptions = resources.getStringArray(R.array.settings_main_activity_bottom_app_bar_options); - String[] fabOptions = resources.getStringArray(R.array.settings_bottom_app_bar_fab_options); + String[] fabOptions; + if (accountName == null) { + fabOptions = resources.getStringArray(R.array.settings_bottom_app_bar_fab_options_anonymous); + } else { + fabOptions = resources.getStringArray(R.array.settings_bottom_app_bar_fab_options); + } mainActivityOptionCount = sharedPreferences.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4); mainActivityOption1 = sharedPreferences.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, 0); mainActivityOption2 = sharedPreferences.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, 1); mainActivityOption3 = sharedPreferences.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, 2); mainActivityOption4 = sharedPreferences.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, 3); - mainActivityFAB = sharedPreferences.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, 0); + mainActivityFAB = sharedPreferences.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, accountName == null ? 7: 0); mainActivityOptionCountTextView.setText(Integer.toString(mainActivityOptionCount)); mainActivityOption1TextView.setText(mainActivityOptions[mainActivityOption1]); @@ -200,7 +205,15 @@ public class CustomizeBottomAppBarFragment extends Fragment { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_bottom_app_bar_fab) .setSingleChoiceItems(fabOptions, mainActivityFAB, (dialogInterface, i) -> { - mainActivityFAB = i; + if (accountName == null) { + if (i == 7) { + mainActivityFAB = 9; + } else { + mainActivityFAB = i + 1; + } + } else { + mainActivityFAB = i; + } sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, mainActivityFAB).apply(); mainActivityFABTextView.setText(fabOptions[mainActivityFAB]); dialogInterface.dismiss(); @@ -214,7 +227,7 @@ public class CustomizeBottomAppBarFragment extends Fragment { otherActivitiesOption2 = sharedPreferences.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, 1); otherActivitiesOption3 = sharedPreferences.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, 2); otherActivitiesOption4 = sharedPreferences.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, 3); - otherActivitiesFAB = sharedPreferences.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, 0); + otherActivitiesFAB = sharedPreferences.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, accountName == null ? 7: 0); otherActivitiesOptionCountTextView.setText(Integer.toString(otherActivitiesOptionCount)); otherActivitiesOption1TextView.setText(otherActivitiesOptions[otherActivitiesOption1]); @@ -287,7 +300,15 @@ public class CustomizeBottomAppBarFragment extends Fragment { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_bottom_app_bar_fab) .setSingleChoiceItems(fabOptions, otherActivitiesFAB, (dialogInterface, i) -> { - otherActivitiesFAB = i; + if (accountName == null) { + if (i == 7) { + otherActivitiesFAB = 9; + } else { + otherActivitiesFAB = i + 1; + } + } else { + otherActivitiesFAB = i; + } sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, otherActivitiesFAB).apply(); otherActivitiesFABTextView.setText(fabOptions[otherActivitiesFAB]); dialogInterface.dismiss(); -- cgit v1.2.3