diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-09-25 04:08:17 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-09-25 04:08:17 +0000 |
commit | b6ebcf1c4c4b849e581c95110c8eeb36926ac72d (patch) | |
tree | b925fe7adb9d1b7b99ab33d65dcd6df0f5fa1658 /app/src/main | |
parent | 73c4ead2c05609b20bd1a6cabb45f4fe61a9b042 (diff) | |
download | infinity-for-reddit-b6ebcf1c4c4b849e581c95110c8eeb36926ac72d.tar infinity-for-reddit-b6ebcf1c4c4b849e581c95110c8eeb36926ac72d.tar.gz infinity-for-reddit-b6ebcf1c4c4b849e581c95110c8eeb36926ac72d.tar.bz2 infinity-for-reddit-b6ebcf1c4c4b849e581c95110c8eeb36926ac72d.tar.lz infinity-for-reddit-b6ebcf1c4c4b849e581c95110c8eeb36926ac72d.tar.xz infinity-for-reddit-b6ebcf1c4c4b849e581c95110c8eeb36926ac72d.tar.zst infinity-for-reddit-b6ebcf1c4c4b849e581c95110c8eeb36926ac72d.zip |
Add options to customize bottom app bar.
Diffstat (limited to '')
12 files changed, 750 insertions, 9 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java index f1c296e3..bd6f7ef1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java @@ -28,6 +28,7 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.Settings.AboutPreferenceFragment; +import ml.docilealligator.infinityforreddit.Settings.CustomizeBottomAppBarFragment; import ml.docilealligator.infinityforreddit.Settings.CustomizeMainPageTabsFragment; import ml.docilealligator.infinityforreddit.Settings.FontPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.GesturesAndButtonsPreferenceFragment; @@ -162,6 +163,8 @@ public class SettingsActivity extends BaseActivity implements args.putString(CustomizeMainPageTabsFragment.EXTRA_ACCOUNT_NAME, mAccountName); } else if (fragment instanceof NsfwAndBlurringFragment) { args.putString(NsfwAndBlurringFragment.EXTRA_ACCOUNT_NAME, mAccountName); + } else if (fragment instanceof CustomizeBottomAppBarFragment) { + args.putString(CustomizeBottomAppBarFragment.EXTRA_ACCOUNT_NAME, mAccountName); } fragment.setArguments(args); fragment.setTargetFragment(caller, 0); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java index 461f263c..31f91c07 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java @@ -61,6 +61,7 @@ import ml.docilealligator.infinityforreddit.Service.DownloadMediaService; import ml.docilealligator.infinityforreddit.Service.DownloadRedditVideoService; import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import ml.docilealligator.infinityforreddit.Settings.AdvancedPreferenceFragment; +import ml.docilealligator.infinityforreddit.Settings.CustomizeBottomAppBarFragment; import ml.docilealligator.infinityforreddit.Settings.CustomizeMainPageTabsFragment; import ml.docilealligator.infinityforreddit.Settings.DownloadLocationPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.GesturesAndButtonsPreferenceFragment; @@ -209,4 +210,6 @@ public interface AppComponent { void inject(SecurityPreferenceFragment securityPreferenceFragment); void inject(NsfwAndBlurringFragment nsfwAndBlurringFragment); + + void inject(CustomizeBottomAppBarFragment customizeBottomAppBarFragment); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java index 069540ef..18f4ac7d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java @@ -217,6 +217,12 @@ class AppModule { } @Provides + @Named("bottom_app_bar") + SharedPreferences provideBottomAppBarSharedPreferences() { + return mApplication.getSharedPreferences(SharedPreferencesUtils.BOTTOM_APP_BAR_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE); + } + + @Provides @Singleton CustomThemeWrapper provideCustomThemeWrapper(@Named("light_theme") SharedPreferences lightThemeSharedPreferences, @Named("dark_theme") SharedPreferences darkThemeSharedPreferences, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeBottomAppBarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeBottomAppBarFragment.java new file mode 100644 index 00000000..8fd5b464 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeBottomAppBarFragment.java @@ -0,0 +1,287 @@ +package ml.docilealligator.infinityforreddit.Settings; + +import android.app.Activity; +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + +import javax.inject.Inject; +import javax.inject.Named; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.Infinity; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; + +public class CustomizeBottomAppBarFragment extends Fragment { + + public static final String EXTRA_ACCOUNT_NAME = "EAN"; + + @BindView(R.id.info_text_view_customize_bottom_app_bar_fragment) + TextView infoTextView; + @BindView(R.id.divider_1_customize_bottom_app_bar_fragment) + View divider1; + @BindView(R.id.main_activity_group_summary_customize_bottom_app_bar_fragment) + TextView mainActivityGroupSummaryTextView; + @BindView(R.id.main_activity_option_count_linear_layout_customize_bottom_app_bar_fragment) + LinearLayout mainActivityOptionCountLinearLayout; + @BindView(R.id.main_activity_option_count_text_view_customize_bottom_app_bar_fragment) + TextView mainActivityOptionCountTextView; + @BindView(R.id.main_activity_option_1_linear_layout_customize_bottom_app_bar_fragment) + LinearLayout mainActivityOption1LinearLayout; + @BindView(R.id.main_activity_option_1_text_view_customize_bottom_app_bar_fragment) + TextView mainActivityOption1TextView; + @BindView(R.id.main_activity_option_2_linear_layout_customize_bottom_app_bar_fragment) + LinearLayout mainActivityOption2LinearLayout; + @BindView(R.id.main_activity_option_2_text_view_customize_bottom_app_bar_fragment) + TextView mainActivityOption2TextView; + @BindView(R.id.main_activity_option_3_linear_layout_customize_bottom_app_bar_fragment) + LinearLayout mainActivityOption3LinearLayout; + @BindView(R.id.main_activity_option_3_text_view_customize_bottom_app_bar_fragment) + TextView mainActivityOption3TextView; + @BindView(R.id.main_activity_option_4_linear_layout_customize_bottom_app_bar_fragment) + LinearLayout mainActivityOption4LinearLayout; + @BindView(R.id.main_activity_option_4_text_view_customize_bottom_app_bar_fragment) + TextView mainActivityOption4TextView; + + @BindView(R.id.divider_2_customize_bottom_app_bar_fragment) + View divider2; + @BindView(R.id.other_activities_group_summary_customize_bottom_app_bar_fragment) + TextView otherActivitiesGroupSummaryTextView; + @BindView(R.id.other_activities_option_count_linear_layout_customize_bottom_app_bar_fragment) + LinearLayout otherActivitiesOptionCountLinearLayout; + @BindView(R.id.other_activities_option_count_text_view_customize_bottom_app_bar_fragment) + TextView otherActivitiesOptionCountTextView; + @BindView(R.id.other_activities_option_1_linear_layout_customize_bottom_app_bar_fragment) + LinearLayout otherActivitiesOption1LinearLayout; + @BindView(R.id.other_activities_option_1_text_view_customize_bottom_app_bar_fragment) + TextView otherActivitiesOption1TextView; + @BindView(R.id.other_activities_option_2_linear_layout_customize_bottom_app_bar_fragment) + LinearLayout otherActivitiesOption2LinearLayout; + @BindView(R.id.other_activities_option_2_text_view_customize_bottom_app_bar_fragment) + TextView otherActivitiesOption2TextView; + @BindView(R.id.other_activities_option_3_linear_layout_customize_bottom_app_bar_fragment) + LinearLayout otherActivitiesOption3LinearLayout; + @BindView(R.id.other_activities_option_3_text_view_customize_bottom_app_bar_fragment) + TextView otherActivitiesOption3TextView; + @BindView(R.id.other_activities_option_4_linear_layout_customize_bottom_app_bar_fragment) + LinearLayout otherActivitiesOption4LinearLayout; + @BindView(R.id.other_activities_option_4_text_view_customize_bottom_app_bar_fragment) + TextView otherActivitiesOption4TextView; + @Inject + @Named("bottom_app_bar") + SharedPreferences sharedPreferences; + private Activity activity; + private int mainActivityOptionCount; + private int mainActivityOption1; + private int mainActivityOption2; + private int mainActivityOption3; + private int mainActivityOption4; + private int otherActivitiesOptionCount; + private int otherActivitiesOption1; + private int otherActivitiesOption2; + private int otherActivitiesOption3; + private int otherActivitiesOption4; + + public CustomizeBottomAppBarFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View rootView = inflater.inflate(R.layout.fragment_customize_bottom_app_bar, container, false); + + ((Infinity) activity.getApplication()).getAppComponent().inject(this); + + ButterKnife.bind(this, rootView); + + String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME); + + if (accountName == null) { + infoTextView.setText(R.string.only_for_logged_in_user); + divider1.setVisibility(View.GONE); + mainActivityGroupSummaryTextView.setVisibility(View.GONE); + mainActivityOptionCountLinearLayout.setVisibility(View.GONE); + mainActivityOption1LinearLayout.setVisibility(View.GONE); + mainActivityOption2LinearLayout.setVisibility(View.GONE); + mainActivityOption3LinearLayout.setVisibility(View.GONE); + mainActivityOption4LinearLayout.setVisibility(View.GONE); + divider2.setVisibility(View.GONE); + otherActivitiesGroupSummaryTextView.setVisibility(View.GONE); + otherActivitiesOptionCountLinearLayout.setVisibility(View.GONE); + otherActivitiesOption1LinearLayout.setVisibility(View.GONE); + otherActivitiesOption2LinearLayout.setVisibility(View.GONE); + otherActivitiesOption3LinearLayout.setVisibility(View.GONE); + otherActivitiesOption4LinearLayout.setVisibility(View.GONE); + + return rootView; + } + + String[] mainActivityOptions = activity.getResources().getStringArray(R.array.settings_main_activity_bottom_app_bar_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); + + mainActivityOptionCountTextView.setText(Integer.toString(mainActivityOptionCount)); + mainActivityOption1TextView.setText(mainActivityOptions[mainActivityOption1]); + mainActivityOption2TextView.setText(mainActivityOptions[mainActivityOption2]); + mainActivityOption3TextView.setText(mainActivityOptions[mainActivityOption3]); + mainActivityOption4TextView.setText(mainActivityOptions[mainActivityOption4]); + + mainActivityOptionCountLinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_tab_count) + .setSingleChoiceItems(R.array.settings_bottom_app_bar_option_count_options, mainActivityOptionCount / 2 - 1, (dialogInterface, i) -> { + mainActivityOptionCount = (i + 1) * 2; + sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, mainActivityOptionCount).apply(); + mainActivityOptionCountTextView.setText(Integer.toString(mainActivityOptionCount)); + dialogInterface.dismiss(); + }) + .show(); + }); + + mainActivityOption1LinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_bottom_app_bar_option_1) + .setSingleChoiceItems(mainActivityOptions, mainActivityOption1, (dialogInterface, i) -> { + mainActivityOption1 = i; + sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, mainActivityOption1).apply(); + mainActivityOption1TextView.setText(mainActivityOptions[mainActivityOption1]); + dialogInterface.dismiss(); + }) + .show(); + }); + + mainActivityOption2LinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_bottom_app_bar_option_2) + .setSingleChoiceItems(mainActivityOptions, mainActivityOption2, (dialogInterface, i) -> { + mainActivityOption2 = i; + sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, mainActivityOption2).apply(); + mainActivityOption2TextView.setText(mainActivityOptions[mainActivityOption2]); + dialogInterface.dismiss(); + }) + .show(); + }); + + mainActivityOption3LinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_bottom_app_bar_option_3) + .setSingleChoiceItems(mainActivityOptions, mainActivityOption3, (dialogInterface, i) -> { + mainActivityOption3 = i; + sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, mainActivityOption3).apply(); + mainActivityOption3TextView.setText(mainActivityOptions[mainActivityOption3]); + dialogInterface.dismiss(); + }) + .show(); + }); + + mainActivityOption4LinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_bottom_app_bar_option_4) + .setSingleChoiceItems(mainActivityOptions, mainActivityOption4, (dialogInterface, i) -> { + mainActivityOption4 = i; + sharedPreferences.edit().putInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, mainActivityOption4).apply(); + mainActivityOption4TextView.setText(mainActivityOptions[mainActivityOption4]); + dialogInterface.dismiss(); + }) + .show(); + }); + + String[] otherActivitiesOptions = activity.getResources().getStringArray(R.array.settings_other_activities_bottom_app_bar_options); + otherActivitiesOptionCount = sharedPreferences.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4); + otherActivitiesOption1 = sharedPreferences.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, 0); + 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); + + otherActivitiesOptionCountTextView.setText(Integer.toString(otherActivitiesOptionCount)); + otherActivitiesOption1TextView.setText(otherActivitiesOptions[otherActivitiesOption1]); + otherActivitiesOption2TextView.setText(otherActivitiesOptions[otherActivitiesOption2]); + otherActivitiesOption3TextView.setText(otherActivitiesOptions[otherActivitiesOption3]); + otherActivitiesOption4TextView.setText(otherActivitiesOptions[otherActivitiesOption4]); + + otherActivitiesOptionCountLinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_tab_count) + .setSingleChoiceItems(R.array.settings_bottom_app_bar_option_count_options, otherActivitiesOptionCount / 2 - 1, (dialogInterface, i) -> { + otherActivitiesOptionCount = (i + 1) * 2; + sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, otherActivitiesOptionCount).apply(); + otherActivitiesOptionCountTextView.setText(Integer.toString(otherActivitiesOptionCount)); + dialogInterface.dismiss(); + }) + .show(); + }); + + otherActivitiesOption1LinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_bottom_app_bar_option_1) + .setSingleChoiceItems(otherActivitiesOptions, otherActivitiesOption1, (dialogInterface, i) -> { + otherActivitiesOption1 = i; + sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, otherActivitiesOption1).apply(); + otherActivitiesOption1TextView.setText(otherActivitiesOptions[otherActivitiesOption1]); + dialogInterface.dismiss(); + }) + .show(); + }); + + otherActivitiesOption2LinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_bottom_app_bar_option_2) + .setSingleChoiceItems(otherActivitiesOptions, otherActivitiesOption2, (dialogInterface, i) -> { + otherActivitiesOption2 = i; + sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, otherActivitiesOption2).apply(); + otherActivitiesOption2TextView.setText(otherActivitiesOptions[otherActivitiesOption2]); + dialogInterface.dismiss(); + }) + .show(); + }); + + otherActivitiesOption3LinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_bottom_app_bar_option_3) + .setSingleChoiceItems(otherActivitiesOptions, otherActivitiesOption3, (dialogInterface, i) -> { + otherActivitiesOption3 = i; + sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, otherActivitiesOption3).apply(); + otherActivitiesOption3TextView.setText(otherActivitiesOptions[otherActivitiesOption3]); + dialogInterface.dismiss(); + }) + .show(); + }); + + otherActivitiesOption4LinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_bottom_app_bar_option_4) + .setSingleChoiceItems(otherActivitiesOptions, otherActivitiesOption4, (dialogInterface, i) -> { + otherActivitiesOption4 = i; + sharedPreferences.edit().putInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, otherActivitiesOption4).apply(); + otherActivitiesOption4TextView.setText(otherActivitiesOptions[otherActivitiesOption4]); + dialogInterface.dismiss(); + }) + .show(); + }); + + return rootView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + activity = (Activity) context; + } +}
\ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeMainPageTabsFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeMainPageTabsFragment.java index bdc19942..979c2728 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeMainPageTabsFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeMainPageTabsFragment.java @@ -141,7 +141,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME); if (accountName == null) { - infoTextView.setText(R.string.settings_customize_tabs_in_main_page_summary); + infoTextView.setText(R.string.only_for_logged_in_user); divider1.setVisibility(View.GONE); tabCountLinearLayout.setVisibility(View.GONE); showTabNamesLinearLayout.setVisibility(View.GONE); 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 8d08c696..80111e23 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -151,6 +151,18 @@ public class SharedPreferencesUtils { public static final String MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS = "_main_page_show_subscribed_subreddits"; public static final String MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS = "_main_page_show_favorite_subscribed_subreddits"; + public static final String BOTTOM_APP_BAR_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.bottom_app_bar"; + public static final String MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT = "main_activity_bottom_app_bar_option_count"; + public static final String MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1 = "main_activity_bottom_app_bar_option_1"; + public static final String MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2 = "main_activity_bottom_app_bar_option_2"; + public static final String MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3 = "main_activity_bottom_app_bar_option_3"; + public static final String MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4 = "main_activity_bottom_app_bar_option_4"; + public static final String OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT = "other_activities_bottom_app_bar_option_count"; + public static final String OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1 = "other_activities_bottom_app_bar_option_1"; + public static final String OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2 = "other_activities_bottom_app_bar_option_2"; + public static final String OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3 = "other_activities_bottom_app_bar_option_3"; + public static final String OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4 = "other_activities_bottom_app_bar_option_4"; + public static final String NSFW_AND_SPOILER_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.nsfw_and_spoiler"; public static final String NSFW_BASE = "_nsfw"; public static final String BLUR_NSFW_BASE = "_blur_nsfw"; diff --git a/app/src/main/res/layout/fragment_customize_bottom_app_bar.xml b/app/src/main/res/layout/fragment_customize_bottom_app_bar.xml new file mode 100644 index 00000000..281f7448 --- /dev/null +++ b/app/src/main/res/layout/fragment_customize_bottom_app_bar.xml @@ -0,0 +1,399 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto" + tools:context=".Settings.CustomizeBottomAppBarFragment"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:id="@+id/info_text_view_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + android:drawablePadding="32dp" + android:text="@string/restart_app_see_changes" + android:textColor="@color/settingsSubtitleColor" + android:gravity="center_vertical" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" + app:drawableStartCompat="@drawable/ic_info_preference_24dp" /> + + <View + android:id="@+id/divider_1_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="1dp" + android:background="@color/dividerColor" /> + + <TextView + android:id="@+id/main_activity_group_summary_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:text="@string/settings_main_activity_bottom_app_bar_group_summary" + android:textColor="@color/colorAccent" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + <LinearLayout + android:id="@+id/main_activity_option_count_linear_layout_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:layout_gravity="center_vertical" + android:text="@string/settings_bottom_app_bar_option_count" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_16" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/main_activity_option_count_text_view_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:layout_gravity="center_vertical" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/main_activity_option_1_linear_layout_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:text="@string/settings_bottom_app_bar_option_1" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_16" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/main_activity_option_1_text_view_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/main_activity_option_2_linear_layout_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:text="@string/settings_bottom_app_bar_option_2" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_16" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/main_activity_option_2_text_view_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/main_activity_option_3_linear_layout_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:text="@string/settings_bottom_app_bar_option_3" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_16" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/main_activity_option_3_text_view_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/main_activity_option_4_linear_layout_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:text="@string/settings_bottom_app_bar_option_4" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_16" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/main_activity_option_4_text_view_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <View + android:id="@+id/divider_2_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="1dp" + android:background="@color/dividerColor" /> + + <TextView + android:id="@+id/other_activities_group_summary_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:text="@string/settings_other_activities_bottom_app_bar_group_summary" + android:textColor="@color/colorAccent" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + <LinearLayout + android:id="@+id/other_activities_option_count_linear_layout_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:layout_gravity="center_vertical" + android:text="@string/settings_bottom_app_bar_option_count" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_16" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/other_activities_option_count_text_view_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:layout_gravity="center_vertical" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/other_activities_option_1_linear_layout_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:text="@string/settings_bottom_app_bar_option_1" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_16" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/other_activities_option_1_text_view_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/other_activities_option_2_linear_layout_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:text="@string/settings_bottom_app_bar_option_2" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_16" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/other_activities_option_2_text_view_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/other_activities_option_3_linear_layout_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:text="@string/settings_bottom_app_bar_option_3" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_16" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/other_activities_option_3_text_view_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/other_activities_option_4_linear_layout_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:text="@string/settings_bottom_app_bar_option_4" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_16" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/other_activities_option_4_text_view_customize_bottom_app_bar_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + </LinearLayout> + +</androidx.core.widget.NestedScrollView>
\ No newline at end of file diff --git a/app/src/main/res/layout/fragment_customize_main_page_tabs.xml b/app/src/main/res/layout/fragment_customize_main_page_tabs.xml index f20ec4d3..03ba6d4d 100644 --- a/app/src/main/res/layout/fragment_customize_main_page_tabs.xml +++ b/app/src/main/res/layout/fragment_customize_main_page_tabs.xml @@ -17,7 +17,7 @@ android:layout_height="wrap_content" android:padding="16dp" android:drawablePadding="32dp" - android:text="@string/settings_tab_info" + android:text="@string/restart_app_see_changes" android:textColor="@color/settingsSubtitleColor" android:gravity="center_vertical" android:textSize="?attr/font_default" @@ -40,7 +40,6 @@ <TextView android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_weight="1" android:layout_marginEnd="16dp" android:layout_gravity="center_vertical" android:text="@string/settings_tab_count" @@ -52,10 +51,8 @@ android:id="@+id/tab_count_text_view_customize_main_page_tabs_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_weight="1" android:layout_marginEnd="16dp" android:layout_gravity="center_vertical" - android:text="@string/settings_more_tabs_show_subscribed_subreddits_title" android:textColor="?attr/secondaryTextColor" android:textSize="?attr/font_default" android:fontFamily="?attr/font_family" /> diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index fd1a386c..5fef81f8 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -230,4 +230,23 @@ <item>2</item> <item>3</item> </string-array> + + <string-array name="settings_bottom_app_bar_option_count_options"> + <item>2</item> + <item>4</item> + </string-array> + + <string-array name="settings_main_activity_bottom_app_bar_options"> + <item>Subscriptions</item> + <item>Multireddits</item> + <item>Inbox</item> + <item>Profile</item> + </string-array> + + <string-array name="settings_other_activities_bottom_app_bar_options"> + <item>Home</item> + <item>Subscriptions</item> + <item>Inbox</item> + <item>Profile</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 5a30de5a..dc160ad2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -345,7 +345,7 @@ <string name="settings_immersive_interface_ignore_nav_bar_title">Ignore Navigation Bar in Immersive Interface</string> <string name="settings_immersive_interface_ignore_nav_bar_summary">Prevent the Bottom Navigation Bar Having Extra Padding</string> <string name="settings_customize_tabs_in_main_page_title">Customize Tabs in Main Page</string> - <string name="settings_customize_tabs_in_main_page_summary">Only for Logged-in User</string> + <string name="only_for_logged_in_user">Only for Logged-in User</string> <string name="settings_enable_bottom_app_bar_title">Enable Bottom Navigation</string> <string name="settings_enable_bottom_app_bar_summary">Has No Effect in Anonymous Mode</string> <string name="settings_category_post_and_comment_title">Post and Comment</string> @@ -446,7 +446,7 @@ <string name="settings_delete_all_legacy_settings_title">Delete All Legacy Settings</string> <string name="settings_reset_all_settings_title">Reset All Settings</string> <string name="settings_advanced_settings_summary">Clean the database and shared preferences</string> - <string name="settings_tab_info">Restart the app to see the changes</string> + <string name="restart_app_see_changes">Restart the app to see the changes</string> <string name="settings_tab_count">Tab Count</string> <string name="settings_show_tab_names">Show Tab Names</string> <string name="settings_tab_1_summary">Tab 1</string> @@ -476,6 +476,14 @@ <string name="settings_require_authentication_to_go_to_account_section_in_navigation_drawer_title">Require Authentication to Go to Account Section in Navigation Drawer</string> <string name="settings_long_press_to_hide_toolbar_in_compact_layout_title">Long Press to Hide Toolbar in Compact Layout</string> <string name="settings_post_compact_layout_toolbar_hidden_by_default_title">Toolbar in Compact Layout Hidden by Default</string> + <string name="settings_customize_bottom_app_bar_title">Customize Bottom Navigation Bar</string> + <string name="settings_main_activity_bottom_app_bar_group_summary">Main Page</string> + <string name="settings_other_activities_bottom_app_bar_group_summary">Other Pages</string> + <string name="settings_bottom_app_bar_option_count">Option Count</string> + <string name="settings_bottom_app_bar_option_1">Option 1</string> + <string name="settings_bottom_app_bar_option_2">Option 2</string> + <string name="settings_bottom_app_bar_option_3">Option 3</string> + <string name="settings_bottom_app_bar_option_4">Option 4</string> <string name="no_link_available">Cannot get the link</string> @@ -882,5 +890,7 @@ <string name="unlock_account_section">Unlock Account Section</string> <string name="unlock">Unlock</string> + <!-- TODO: Remove or change this placeholder text --> + <string name="hello_blank_fragment">Hello blank fragment</string> </resources> diff --git a/app/src/main/res/xml/interface_preference.xml b/app/src/main/res/xml/interface_preference.xml index f898291c..0b767200 100644 --- a/app/src/main/res/xml/interface_preference.xml +++ b/app/src/main/res/xml/interface_preference.xml @@ -15,9 +15,14 @@ <Preference app:title="@string/settings_customize_tabs_in_main_page_title" - app:summary="@string/settings_customize_tabs_in_main_page_summary" + app:summary="@string/only_for_logged_in_user" app:fragment="ml.docilealligator.infinityforreddit.Settings.CustomizeMainPageTabsFragment" /> + <Preference + app:title="@string/settings_customize_bottom_app_bar_title" + app:summary="@string/only_for_logged_in_user" + app:fragment="ml.docilealligator.infinityforreddit.Settings.CustomizeBottomAppBarFragment" /> + <SwitchPreference app:defaultValue="false" app:key="bottom_app_bar" diff --git a/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml b/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml index cbaea03e..6626a523 100644 --- a/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml +++ b/app/src/main/res/xml/number_of_columns_in_post_feed_preferences.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> <Preference android:icon="@drawable/ic_info_preference_24dp" - app:summary="@string/settings_tab_info" + app:summary="@string/restart_app_see_changes" app:enabled="false" /> <ListPreference |