Change flotaing action button options in anonymous mode.

This commit is contained in:
Alex Ning 2021-10-12 19:35:50 +08:00
parent 9054cd6590
commit 0f7b10fa14
3 changed files with 37 additions and 6 deletions

View File

@ -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, "");

View File

@ -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) -> {
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) -> {
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();

View File

@ -332,6 +332,17 @@
<item>@string/filter_posts</item>
</string-array>
<string-array name="settings_bottom_app_bar_fab_options_anonymous">
<item>@string/refresh</item>
<item>@string/change_sort_type</item>
<item>@string/change_post_layout</item>
<item>@string/search</item>
<item>@string/go_to_subreddit</item>
<item>@string/go_to_user</item>
<item>@string/random</item>
<item>@string/filter_posts</item>
</string-array>
<string-array name="settings_swipe_action_threshold">
<item>0.1</item>
<item>0.2</item>