From 230f49ae184ddea9ce8185981599cf11457b5140 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 13 Oct 2021 09:18:32 +0800 Subject: Fix wrong values in customize bottom navigation bar settings page in anonymous mode. --- .../settings/CustomizeBottomAppBarFragment.java | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'app/src/main/java') 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 5690521f..2736bcb6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java @@ -16,6 +16,9 @@ import androidx.fragment.app.Fragment; import com.google.android.material.dialog.MaterialAlertDialogBuilder; +import java.util.ArrayList; +import java.util.Arrays; + import javax.inject.Inject; import javax.inject.Named; @@ -124,11 +127,6 @@ public class CustomizeBottomAppBarFragment extends Fragment { String[] mainActivityOptionAnonymous = resources.getStringArray(R.array.settings_main_activity_bottom_app_bar_options_anonymous); String[] mainActivityOptionAnonymousValues = resources.getStringArray(R.array.settings_main_activity_bottom_app_bar_options_anonymous_values); 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((accountName == null ? "-" : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4); mainActivityOption1 = sharedPreferences.getInt((accountName == null ? "-" : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, 0); mainActivityOption2 = sharedPreferences.getInt((accountName == null ? "-" : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, 1); @@ -141,6 +139,18 @@ public class CustomizeBottomAppBarFragment extends Fragment { mainActivityOption2TextView.setText(mainActivityOptions[mainActivityOption2]); mainActivityOption3TextView.setText(mainActivityOptions[mainActivityOption3]); mainActivityOption4TextView.setText(mainActivityOptions[mainActivityOption4]); + + if (accountName == null) { + fabOptions = resources.getStringArray(R.array.settings_bottom_app_bar_fab_options_anonymous); + ArrayList mainActivityOptionAnonymousValuesList = new ArrayList<>(Arrays.asList(mainActivityOptionAnonymousValues)); + mainActivityOption1 = mainActivityOptionAnonymousValuesList.indexOf(Integer.toString(mainActivityOption1)); + mainActivityOption2 = mainActivityOptionAnonymousValuesList.indexOf(Integer.toString(mainActivityOption2)); + mainActivityOption3 = mainActivityOptionAnonymousValuesList.indexOf(Integer.toString(mainActivityOption3)); + mainActivityOption4 = mainActivityOptionAnonymousValuesList.indexOf(Integer.toString(mainActivityOption4)); + } else { + fabOptions = resources.getStringArray(R.array.settings_bottom_app_bar_fab_options); + } + mainActivityFABTextView.setText(fabOptions[mainActivityFAB]); mainActivityOptionCountLinearLayout.setOnClickListener(view -> { @@ -244,6 +254,15 @@ public class CustomizeBottomAppBarFragment extends Fragment { otherActivitiesOption2TextView.setText(otherActivitiesOptions[otherActivitiesOption2]); otherActivitiesOption3TextView.setText(otherActivitiesOptions[otherActivitiesOption3]); otherActivitiesOption4TextView.setText(otherActivitiesOptions[otherActivitiesOption4]); + + if (accountName == null) { + ArrayList otherActivitiesOptionAnonymousValuesList = new ArrayList<>(Arrays.asList(otherActivitiesOptionAnonymousValues)); + otherActivitiesOption1 = otherActivitiesOptionAnonymousValuesList.indexOf(Integer.toString(otherActivitiesOption1)); + otherActivitiesOption2 = otherActivitiesOptionAnonymousValuesList.indexOf(Integer.toString(otherActivitiesOption2)); + otherActivitiesOption3 = otherActivitiesOptionAnonymousValuesList.indexOf(Integer.toString(otherActivitiesOption3)); + otherActivitiesOption4 = otherActivitiesOptionAnonymousValuesList.indexOf(Integer.toString(otherActivitiesOption4)); + } + otherActivitiesFABTextView.setText(fabOptions[otherActivitiesFAB]); otherActivitiesOptionCountLinearLayout.setOnClickListener(view -> { -- cgit v1.2.3