diff options
Diffstat (limited to '')
8 files changed, 272 insertions, 562 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AcknowledgementFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AcknowledgementFragment.java index 89d3fcc6..b88ae296 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AcknowledgementFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AcknowledgementFragment.java @@ -10,24 +10,19 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.SettingsActivity; import ml.docilealligator.infinityforreddit.adapters.AcknowledgementRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed; +import ml.docilealligator.infinityforreddit.databinding.FragmentAcknowledgementBinding; /** * A simple {@link Fragment} subclass. */ public class AcknowledgementFragment extends Fragment { - @BindView(R.id.recycler_view_acknowledgement_fragment) - RecyclerView recyclerView; private SettingsActivity activity; public AcknowledgementFragment() { @@ -35,10 +30,9 @@ public class AcknowledgementFragment extends Fragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_acknowledgement, container, false); - ButterKnife.bind(this, rootView); + FragmentAcknowledgementBinding binding = FragmentAcknowledgementBinding.inflate(inflater, container, false); ArrayList<Acknowledgement> acknowledgements = new ArrayList<>(); acknowledgements.add(new Acknowledgement("ExoPlayer", @@ -124,12 +118,12 @@ public class AcknowledgementFragment extends Fragment { Uri.parse("https://github.com/natario1/ZoomLayout"))); AcknowledgementRecyclerViewAdapter adapter = new AcknowledgementRecyclerViewAdapter(activity, acknowledgements); - recyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(activity)); - recyclerView.setAdapter(adapter); + binding.getRoot().setLayoutManager(new LinearLayoutManagerBugFixed(activity)); + binding.getRoot().setAdapter(adapter); - rootView.setBackgroundColor(activity.customThemeWrapper.getBackgroundColor()); + binding.getRoot().setBackgroundColor(activity.customThemeWrapper.getBackgroundColor()); - return rootView; + return binding.getRoot(); } @Override 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 8bcabd05..6bfd4af6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeBottomAppBarFragment.java @@ -8,8 +8,6 @@ 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; @@ -22,98 +20,17 @@ import java.util.Arrays; 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.account.Account; import ml.docilealligator.infinityforreddit.activities.SettingsActivity; +import ml.docilealligator.infinityforreddit.databinding.FragmentCustomizeBottomAppBarBinding; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; public class CustomizeBottomAppBarFragment extends Fragment { - @BindView(R.id.info_text_view_customize_bottom_app_bar_fragment) - TextView infoTextView; - @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_title_text_view_customize_bottom_app_bar_fragment) - TextView mainActivityOptionCountTitleTextView; - @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_title_text_view_customize_bottom_app_bar_fragment) - TextView mainActivityOption1TitleTextView; - @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_title_text_view_customize_bottom_app_bar_fragment) - TextView mainActivityOption2TitleTextView; - @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_title_text_view_customize_bottom_app_bar_fragment) - TextView mainActivityOption3TitleTextView; - @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_title_text_view_customize_bottom_app_bar_fragment) - TextView mainActivityOption4TitleTextView; - @BindView(R.id.main_activity_option_4_text_view_customize_bottom_app_bar_fragment) - TextView mainActivityOption4TextView; - @BindView(R.id.main_activity_fab_linear_layout_customize_bottom_app_bar_fragment) - LinearLayout mainActivityFABLinearLayout; - @BindView(R.id.main_activity_fab_title_text_view_customize_bottom_app_bar_fragment) - TextView mainActivityFABTitleTextView; - @BindView(R.id.main_activity_fab_text_view_customize_bottom_app_bar_fragment) - TextView mainActivityFABTextView; - - @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_title_text_view_customize_bottom_app_bar_fragment) - TextView otherActivitiesOptionCountTitleTextView; - @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_title_text_view_customize_bottom_app_bar_fragment) - TextView otherActivitiesOption1TitleTextView; - @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_title_text_view_customize_bottom_app_bar_fragment) - TextView otherActivitiesOption2TitleTextView; - @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_title_text_view_customize_bottom_app_bar_fragment) - TextView otherActivitiesOption3TitleTextView; - @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_title_text_view_customize_bottom_app_bar_fragment) - TextView otherActivitiesOption4TitleTextView; - @BindView(R.id.other_activities_option_4_text_view_customize_bottom_app_bar_fragment) - TextView otherActivitiesOption4TextView; - @BindView(R.id.other_activities_fab_linear_layout_customize_bottom_app_bar_fragment) - LinearLayout otherActivitiesFABLinearLayout; - @BindView(R.id.other_activities_fab_title_text_view_customize_bottom_app_bar_fragment) - TextView otherActivitiesFABTitleTextView; - @BindView(R.id.other_activities_fab_text_view_customize_bottom_app_bar_fragment) - TextView otherActivitiesFABTextView; + private FragmentCustomizeBottomAppBarBinding binding; @Inject @Named("bottom_app_bar") SharedPreferences sharedPreferences; @@ -136,21 +53,19 @@ public class CustomizeBottomAppBarFragment extends Fragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull 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); + binding = FragmentCustomizeBottomAppBarBinding.inflate(inflater, container, false); ((Infinity) activity.getApplication()).getAppComponent().inject(this); - ButterKnife.bind(this, rootView); - - rootView.setBackgroundColor(activity.customThemeWrapper.getBackgroundColor()); + binding.getRoot().setBackgroundColor(activity.customThemeWrapper.getBackgroundColor()); applyCustomTheme(); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } Resources resources = activity.getResources(); @@ -170,11 +85,11 @@ public class CustomizeBottomAppBarFragment extends Fragment { mainActivityOption3 = Utils.fixIndexOutOfBounds(mainActivityOptions, mainActivityOption3); mainActivityOption4 = Utils.fixIndexOutOfBounds(mainActivityOptions, mainActivityOption4); - mainActivityOptionCountTextView.setText(Integer.toString(mainActivityOptionCount)); - mainActivityOption1TextView.setText(mainActivityOptions[mainActivityOption1]); - mainActivityOption2TextView.setText(mainActivityOptions[mainActivityOption2]); - mainActivityOption3TextView.setText(mainActivityOptions[mainActivityOption3]); - mainActivityOption4TextView.setText(mainActivityOptions[mainActivityOption4]); + binding.mainActivityOptionCountTextViewCustomizeBottomAppBarFragment.setText(Integer.toString(mainActivityOptionCount)); + binding.mainActivityOption1TextViewCustomizeBottomAppBarFragment.setText(mainActivityOptions[mainActivityOption1]); + binding.mainActivityOption2TextViewCustomizeBottomAppBarFragment.setText(mainActivityOptions[mainActivityOption2]); + binding.mainActivityOption3TextViewCustomizeBottomAppBarFragment.setText(mainActivityOptions[mainActivityOption3]); + binding.mainActivityOption4TextViewCustomizeBottomAppBarFragment.setText(mainActivityOptions[mainActivityOption4]); if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) { fabOptions = resources.getStringArray(R.array.settings_bottom_app_bar_fab_options_anonymous); @@ -189,73 +104,73 @@ public class CustomizeBottomAppBarFragment extends Fragment { fabOptions = resources.getStringArray(R.array.settings_bottom_app_bar_fab_options); } - mainActivityFABTextView.setText(fabOptions[mainActivityFAB]); + binding.mainActivityFabTextViewCustomizeBottomAppBarFragment.setText(fabOptions[mainActivityFAB]); - mainActivityOptionCountLinearLayout.setOnClickListener(view -> { + binding.mainActivityOptionCountLinearLayoutCustomizeBottomAppBarFragment.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((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, mainActivityOptionCount).apply(); - mainActivityOptionCountTextView.setText(Integer.toString(mainActivityOptionCount)); + binding.mainActivityOptionCountTextViewCustomizeBottomAppBarFragment.setText(Integer.toString(mainActivityOptionCount)); dialogInterface.dismiss(); }) .show(); }); - mainActivityOption1LinearLayout.setOnClickListener(view -> { + binding.mainActivityOption1LinearLayoutCustomizeBottomAppBarFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_bottom_app_bar_option_1) .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption1, (dialogInterface, i) -> { mainActivityOption1 = i; int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption1; sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, optionToSaveToPreference).apply(); - mainActivityOption1TextView.setText(mainActivityOptions[optionToSaveToPreference]); + binding.mainActivityOption1TextViewCustomizeBottomAppBarFragment.setText(mainActivityOptions[optionToSaveToPreference]); dialogInterface.dismiss(); }) .show(); }); - mainActivityOption2LinearLayout.setOnClickListener(view -> { + binding.mainActivityOption2LinearLayoutCustomizeBottomAppBarFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_bottom_app_bar_option_2) .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption2, (dialogInterface, i) -> { mainActivityOption2 = i; int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption2; sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, optionToSaveToPreference).apply(); - mainActivityOption2TextView.setText(mainActivityOptions[optionToSaveToPreference]); + binding.mainActivityOption2TextViewCustomizeBottomAppBarFragment.setText(mainActivityOptions[optionToSaveToPreference]); dialogInterface.dismiss(); }) .show(); }); - mainActivityOption3LinearLayout.setOnClickListener(view -> { + binding.mainActivityOption3LinearLayoutCustomizeBottomAppBarFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_bottom_app_bar_option_3) .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption3, (dialogInterface, i) -> { mainActivityOption3 = i; int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption3; sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_3, optionToSaveToPreference).apply(); - mainActivityOption3TextView.setText(mainActivityOptions[optionToSaveToPreference]); + binding.mainActivityOption3TextViewCustomizeBottomAppBarFragment.setText(mainActivityOptions[optionToSaveToPreference]); dialogInterface.dismiss(); }) .show(); }); - mainActivityOption4LinearLayout.setOnClickListener(view -> { + binding.mainActivityOption4LinearLayoutCustomizeBottomAppBarFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_bottom_app_bar_option_4) .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? mainActivityOptionAnonymous : mainActivityOptions, mainActivityOption4, (dialogInterface, i) -> { mainActivityOption4 = i; int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(mainActivityOptionAnonymousValues[i]) : mainActivityOption4; sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_4, optionToSaveToPreference).apply(); - mainActivityOption4TextView.setText(mainActivityOptions[optionToSaveToPreference]); + binding.mainActivityOption4TextViewCustomizeBottomAppBarFragment.setText(mainActivityOptions[optionToSaveToPreference]); dialogInterface.dismiss(); }) .show(); }); - mainActivityFABLinearLayout.setOnClickListener(view -> { + binding.mainActivityFabLinearLayoutCustomizeBottomAppBarFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_bottom_app_bar_fab) .setSingleChoiceItems(fabOptions, mainActivityFAB, (dialogInterface, i) -> { @@ -271,7 +186,7 @@ public class CustomizeBottomAppBarFragment extends Fragment { optionToSaveToPreference = i; } sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB, optionToSaveToPreference).apply(); - mainActivityFABTextView.setText(fabOptions[mainActivityFAB]); + binding.mainActivityFabTextViewCustomizeBottomAppBarFragment.setText(fabOptions[mainActivityFAB]); dialogInterface.dismiss(); }) .show(); @@ -292,11 +207,11 @@ public class CustomizeBottomAppBarFragment extends Fragment { otherActivitiesOption3 = Utils.fixIndexOutOfBounds(otherActivitiesOptions, otherActivitiesOption3); otherActivitiesOption4 = Utils.fixIndexOutOfBounds(otherActivitiesOptions, otherActivitiesOption4); - otherActivitiesOptionCountTextView.setText(Integer.toString(otherActivitiesOptionCount)); - otherActivitiesOption1TextView.setText(otherActivitiesOptions[otherActivitiesOption1]); - otherActivitiesOption2TextView.setText(otherActivitiesOptions[otherActivitiesOption2]); - otherActivitiesOption3TextView.setText(otherActivitiesOptions[otherActivitiesOption3]); - otherActivitiesOption4TextView.setText(otherActivitiesOptions[otherActivitiesOption4]); + binding.otherActivitiesOptionCountTextViewCustomizeBottomAppBarFragment.setText(Integer.toString(otherActivitiesOptionCount)); + binding.otherActivitiesOption1TextViewCustomizeBottomAppBarFragment.setText(otherActivitiesOptions[otherActivitiesOption1]); + binding.otherActivitiesOption2TextViewCustomizeBottomAppBarFragment.setText(otherActivitiesOptions[otherActivitiesOption2]); + binding.otherActivitiesOption3TextViewCustomizeBottomAppBarFragment.setText(otherActivitiesOptions[otherActivitiesOption3]); + binding.otherActivitiesOption4TextViewCustomizeBottomAppBarFragment.setText(otherActivitiesOptions[otherActivitiesOption4]); if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) { ArrayList<String> otherActivitiesOptionAnonymousValuesList = new ArrayList<>(Arrays.asList(otherActivitiesOptionAnonymousValues)); @@ -307,73 +222,73 @@ public class CustomizeBottomAppBarFragment extends Fragment { otherActivitiesFAB = otherActivitiesFAB >= 9 ? otherActivitiesFAB - 2 : otherActivitiesFAB - 1; } - otherActivitiesFABTextView.setText(fabOptions[otherActivitiesFAB]); + binding.otherActivitiesFabTextViewCustomizeBottomAppBarFragment.setText(fabOptions[otherActivitiesFAB]); - otherActivitiesOptionCountLinearLayout.setOnClickListener(view -> { + binding.otherActivitiesOptionCountLinearLayoutCustomizeBottomAppBarFragment.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((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, otherActivitiesOptionCount).apply(); - otherActivitiesOptionCountTextView.setText(Integer.toString(otherActivitiesOptionCount)); + binding.otherActivitiesOptionCountTextViewCustomizeBottomAppBarFragment.setText(Integer.toString(otherActivitiesOptionCount)); dialogInterface.dismiss(); }) .show(); }); - otherActivitiesOption1LinearLayout.setOnClickListener(view -> { + binding.otherActivitiesOption1LinearLayoutCustomizeBottomAppBarFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_bottom_app_bar_option_1) .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption1, (dialogInterface, i) -> { otherActivitiesOption1 = i; int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption1; sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, optionToSaveToPreference).apply(); - otherActivitiesOption1TextView.setText(otherActivitiesOptions[optionToSaveToPreference]); + binding.otherActivitiesOption1TextViewCustomizeBottomAppBarFragment.setText(otherActivitiesOptions[optionToSaveToPreference]); dialogInterface.dismiss(); }) .show(); }); - otherActivitiesOption2LinearLayout.setOnClickListener(view -> { + binding.otherActivitiesOption2LinearLayoutCustomizeBottomAppBarFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_bottom_app_bar_option_2) .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption2, (dialogInterface, i) -> { otherActivitiesOption2 = i; int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption2; sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, optionToSaveToPreference).apply(); - otherActivitiesOption2TextView.setText(otherActivitiesOptions[optionToSaveToPreference]); + binding.otherActivitiesOption2TextViewCustomizeBottomAppBarFragment.setText(otherActivitiesOptions[optionToSaveToPreference]); dialogInterface.dismiss(); }) .show(); }); - otherActivitiesOption3LinearLayout.setOnClickListener(view -> { + binding.otherActivitiesOption3LinearLayoutCustomizeBottomAppBarFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_bottom_app_bar_option_3) .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption3, (dialogInterface, i) -> { otherActivitiesOption3 = i; int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption3; sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_3, optionToSaveToPreference).apply(); - otherActivitiesOption3TextView.setText(otherActivitiesOptions[optionToSaveToPreference]); + binding.otherActivitiesOption3TextViewCustomizeBottomAppBarFragment.setText(otherActivitiesOptions[optionToSaveToPreference]); dialogInterface.dismiss(); }) .show(); }); - otherActivitiesOption4LinearLayout.setOnClickListener(view -> { + binding.otherActivitiesOption4LinearLayoutCustomizeBottomAppBarFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_bottom_app_bar_option_4) .setSingleChoiceItems(activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? otherActivitiesOptionAnonymous : otherActivitiesOptions, otherActivitiesOption4, (dialogInterface, i) -> { otherActivitiesOption4 = i; int optionToSaveToPreference = activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Integer.parseInt(otherActivitiesOptionAnonymousValues[i]) : otherActivitiesOption4; sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_4, optionToSaveToPreference).apply(); - otherActivitiesOption4TextView.setText(otherActivitiesOptions[optionToSaveToPreference]); + binding.otherActivitiesOption4TextViewCustomizeBottomAppBarFragment.setText(otherActivitiesOptions[optionToSaveToPreference]); dialogInterface.dismiss(); }) .show(); }); - otherActivitiesFABLinearLayout.setOnClickListener(view -> { + binding.otherActivitiesFabLinearLayoutCustomizeBottomAppBarFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_bottom_app_bar_fab) .setSingleChoiceItems(fabOptions, otherActivitiesFAB, (dialogInterface, i) -> { @@ -389,49 +304,49 @@ public class CustomizeBottomAppBarFragment extends Fragment { optionToSaveToPreference = i; } sharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? Account.ANONYMOUS_ACCOUNT : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB, optionToSaveToPreference).apply(); - otherActivitiesFABTextView.setText(fabOptions[otherActivitiesFAB]); + binding.otherActivitiesFabTextViewCustomizeBottomAppBarFragment.setText(fabOptions[otherActivitiesFAB]); dialogInterface.dismiss(); }) .show(); }); - return rootView; + return binding.getRoot(); } private void applyCustomTheme() { int primaryTextColor = activity.customThemeWrapper.getPrimaryTextColor(); int secondaryTextColor = activity.customThemeWrapper.getSecondaryTextColor(); int accentColor = activity.customThemeWrapper.getColorAccent(); - infoTextView.setTextColor(secondaryTextColor); + binding.infoTextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); Drawable infoDrawable = Utils.getTintedDrawable(activity, R.drawable.ic_info_preference_24dp, activity.customThemeWrapper.getPrimaryIconColor()); - infoTextView.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null); - mainActivityGroupSummaryTextView.setTextColor(accentColor); - mainActivityOptionCountTitleTextView.setTextColor(primaryTextColor); - mainActivityOptionCountTextView.setTextColor(secondaryTextColor); - mainActivityOption1TitleTextView.setTextColor(primaryTextColor); - mainActivityOption1TextView.setTextColor(secondaryTextColor); - mainActivityOption2TitleTextView.setTextColor(primaryTextColor); - mainActivityOption2TextView.setTextColor(secondaryTextColor); - mainActivityOption3TitleTextView.setTextColor(primaryTextColor); - mainActivityOption3TextView.setTextColor(secondaryTextColor); - mainActivityOption4TitleTextView.setTextColor(primaryTextColor); - mainActivityOption4TextView.setTextColor(secondaryTextColor); - mainActivityFABTitleTextView.setTextColor(primaryTextColor); - mainActivityFABTextView.setTextColor(secondaryTextColor); - - otherActivitiesGroupSummaryTextView.setTextColor(accentColor); - otherActivitiesOptionCountTitleTextView.setTextColor(primaryTextColor); - otherActivitiesOptionCountTextView.setTextColor(secondaryTextColor); - otherActivitiesOption1TitleTextView.setTextColor(primaryTextColor); - otherActivitiesOption1TextView.setTextColor(secondaryTextColor); - otherActivitiesOption2TitleTextView.setTextColor(primaryTextColor); - otherActivitiesOption2TextView.setTextColor(secondaryTextColor); - otherActivitiesOption3TitleTextView.setTextColor(primaryTextColor); - otherActivitiesOption3TextView.setTextColor(secondaryTextColor); - otherActivitiesOption4TitleTextView.setTextColor(primaryTextColor); - otherActivitiesOption4TextView.setTextColor(secondaryTextColor); - otherActivitiesFABTitleTextView.setTextColor(primaryTextColor); - otherActivitiesFABTextView.setTextColor(secondaryTextColor); + binding.infoTextViewCustomizeBottomAppBarFragment.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null); + binding.mainActivityGroupSummaryCustomizeBottomAppBarFragment.setTextColor(accentColor); + binding.mainActivityOptionCountTitleTextViewCustomizeBottomAppBarFragment.setTextColor(primaryTextColor); + binding.mainActivityOptionCountTextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); + binding.mainActivityOption1TitleTextViewCustomizeBottomAppBarFragment.setTextColor(primaryTextColor); + binding.mainActivityOption1TextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); + binding.mainActivityOption2TitleTextViewCustomizeBottomAppBarFragment.setTextColor(primaryTextColor); + binding.mainActivityOption2TextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); + binding.mainActivityOption3TitleTextViewCustomizeBottomAppBarFragment.setTextColor(primaryTextColor); + binding.mainActivityOption3TextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); + binding.mainActivityOption4TitleTextViewCustomizeBottomAppBarFragment.setTextColor(primaryTextColor); + binding.mainActivityOption4TextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); + binding.mainActivityFabTitleTextViewCustomizeBottomAppBarFragment.setTextColor(primaryTextColor); + binding.mainActivityFabTextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); + + binding.otherActivitiesGroupSummaryCustomizeBottomAppBarFragment.setTextColor(accentColor); + binding.otherActivitiesOptionCountTitleTextViewCustomizeBottomAppBarFragment.setTextColor(primaryTextColor); + binding.otherActivitiesOptionCountTextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); + binding.otherActivitiesOption1TitleTextViewCustomizeBottomAppBarFragment.setTextColor(primaryTextColor); + binding.otherActivitiesOption1TextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); + binding.otherActivitiesOption2TitleTextViewCustomizeBottomAppBarFragment.setTextColor(primaryTextColor); + binding.otherActivitiesOption2TextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); + binding.otherActivitiesOption3TitleTextViewCustomizeBottomAppBarFragment.setTextColor(primaryTextColor); + binding.otherActivitiesOption3TextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); + binding.otherActivitiesOption4TitleTextViewCustomizeBottomAppBarFragment.setTextColor(primaryTextColor); + binding.otherActivitiesOption4TextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); + binding.otherActivitiesFabTitleTextViewCustomizeBottomAppBarFragment.setTextColor(primaryTextColor); + binding.otherActivitiesFabTextViewCustomizeBottomAppBarFragment.setTextColor(secondaryTextColor); } @Override 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 44d07901..55beeac2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java @@ -11,8 +11,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; @@ -21,13 +19,10 @@ import androidx.constraintlayout.widget.ConstraintLayout; import androidx.fragment.app.Fragment; import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.materialswitch.MaterialSwitch; 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.account.Account; @@ -35,128 +30,14 @@ import ml.docilealligator.infinityforreddit.activities.MultiredditSelectionActiv import ml.docilealligator.infinityforreddit.activities.SearchActivity; import ml.docilealligator.infinityforreddit.activities.SettingsActivity; import ml.docilealligator.infinityforreddit.activities.SubredditSelectionActivity; +import ml.docilealligator.infinityforreddit.databinding.FragmentCustomizeMainPageTabsBinding; import ml.docilealligator.infinityforreddit.multireddit.MultiReddit; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; public class CustomizeMainPageTabsFragment extends Fragment { - @BindView(R.id.info_text_view_customize_main_page_tabs_fragment) - TextView infoTextView; - @BindView(R.id.tab_count_linear_layout_customize_main_page_tabs_fragment) - LinearLayout tabCountLinearLayout; - @BindView(R.id.tab_count_title_text_view_customize_main_page_tabs_fragment) - TextView tabCountTitleTextView; - @BindView(R.id.tab_count_text_view_customize_main_page_tabs_fragment) - TextView tabCountTextView; - @BindView(R.id.show_tab_names_linear_layout_customize_main_page_tabs_fragment) - LinearLayout showTabNamesLinearLayout; - @BindView(R.id.show_tab_names_title_text_view_customize_main_page_tabs_fragment) - TextView showTabNamesTitleTextView; - @BindView(R.id.show_tab_names_switch_material_customize_main_page_tabs_fragment) - MaterialSwitch showTabNamesSwitch; - @BindView(R.id.divider_1_customize_main_page_tabs_fragment) - View divider1; - @BindView(R.id.tab_1_group_summary_customize_main_page_tabs_fragment) - TextView tab1GroupSummaryTextView; - @BindView(R.id.tab_1_title_linear_layout_customize_main_page_tabs_fragment) - LinearLayout tab1TitleLinearLayout; - @BindView(R.id.tab_1_title_title_text_view_customize_main_page_tabs_fragment) - TextView tab1TitleTitleTextView; - @BindView(R.id.tab_1_title_summary_text_view_customize_main_page_tabs_fragment) - TextView tab1TitleSummaryTextView; - @BindView(R.id.tab_1_type_linear_layout_customize_main_page_tabs_fragment) - LinearLayout tab1TypeLinearLayout; - @BindView(R.id.tab_1_type_title_text_view_customize_main_page_tabs_fragment) - TextView tab1TypeTitleTextView; - @BindView(R.id.tab_1_type_summary_text_view_customize_main_page_tabs_fragment) - TextView tab1TypeSummaryTextView; - @BindView(R.id.tab_1_name_constraint_layout_customize_main_page_tabs_fragment) - ConstraintLayout tab1NameConstraintLayout; - @BindView(R.id.tab_1_name_title_text_view_customize_main_page_tabs_fragment) - TextView tab1NameTitleTextView; - @BindView(R.id.tab_1_name_summary_text_view_customize_main_page_tabs_fragment) - TextView tab1NameSummaryTextView; - @BindView(R.id.tab_1_name_add_image_view_customize_main_page_tabs_fragment) - ImageView tab1AddImageView; - @BindView(R.id.divider_2_customize_main_page_tabs_fragment) - View divider2; - @BindView(R.id.tab_2_group_summary_customize_main_page_tabs_fragment) - TextView tab2GroupSummaryTextView; - @BindView(R.id.tab_2_title_linear_layout_customize_main_page_tabs_fragment) - LinearLayout tab2TitleLinearLayout; - @BindView(R.id.tab_2_title_title_text_view_customize_main_page_tabs_fragment) - TextView tab2TitleTitleTextView; - @BindView(R.id.tab_2_title_summary_text_view_customize_main_page_tabs_fragment) - TextView tab2TitleSummaryTextView; - @BindView(R.id.tab_2_type_linear_layout_customize_main_page_tabs_fragment) - LinearLayout tab2TypeLinearLayout; - @BindView(R.id.tab_2_type_title_text_view_customize_main_page_tabs_fragment) - TextView tab2TypeTitleTextView; - @BindView(R.id.tab_2_type_summary_text_view_customize_main_page_tabs_fragment) - TextView tab2TypeSummaryTextView; - @BindView(R.id.tab_2_name_constraint_layout_customize_main_page_tabs_fragment) - ConstraintLayout tab2NameConstraintLayout; - @BindView(R.id.tab_2_name_title_text_view_customize_main_page_tabs_fragment) - TextView tab2NameTitleTextView; - @BindView(R.id.tab_2_name_summary_text_view_customize_main_page_tabs_fragment) - TextView tab2NameSummaryTextView; - @BindView(R.id.tab_2_name_add_image_view_customize_main_page_tabs_fragment) - ImageView tab2AddImageView; - @BindView(R.id.divider_3_customize_main_page_tabs_fragment) - View divider3; - @BindView(R.id.tab_3_group_summary_customize_main_page_tabs_fragment) - TextView tab3GroupSummaryTextView; - @BindView(R.id.tab_3_title_linear_layout_customize_main_page_tabs_fragment) - LinearLayout tab3TitleLinearLayout; - @BindView(R.id.tab_3_title_title_text_view_customize_main_page_tabs_fragment) - TextView tab3TitleTitleTextView; - @BindView(R.id.tab_3_title_summary_text_view_customize_main_page_tabs_fragment) - TextView tab3TitleSummaryTextView; - @BindView(R.id.tab_3_type_linear_layout_customize_main_page_tabs_fragment) - LinearLayout tab3TypeLinearLayout; - @BindView(R.id.tab_3_type_title_text_view_customize_main_page_tabs_fragment) - TextView tab3TypeTitleTextView; - @BindView(R.id.tab_3_type_summary_text_view_customize_main_page_tabs_fragment) - TextView tab3TypeSummaryTextView; - @BindView(R.id.tab_3_name_constraint_layout_customize_main_page_tabs_fragment) - ConstraintLayout tab3NameConstraintLayout; - @BindView(R.id.tab_3_name_title_text_view_customize_main_page_tabs_fragment) - TextView tab3NameTitleTextView; - @BindView(R.id.tab_3_name_summary_text_view_customize_main_page_tabs_fragment) - TextView tab3NameSummaryTextView; - @BindView(R.id.tab_3_name_add_image_view_customize_main_page_tabs_fragment) - ImageView tab3AddImageView; - @BindView(R.id.divider_4_customize_main_page_tabs_fragment) - View divider4; - @BindView(R.id.more_tabs_group_summary_customize_main_page_tabs_fragment) - TextView moreTabsGroupSummaryTextView; - @BindView(R.id.more_tabs_info_text_view_customize_main_page_tabs_fragment) - TextView moreTabsInfoTextView; - @BindView(R.id.show_favorite_multireddits_linear_layout_customize_main_page_tabs_fragment) - LinearLayout showFavoriteMultiredditsLinearLayout; - @BindView(R.id.show_favorite_multireddits_title_text_view_customize_main_page_tabs_fragment) - TextView showFavoriteMultiredditsTitleTextView; - @BindView(R.id.show_favorite_multireddits_switch_material_customize_main_page_tabs_fragment) - MaterialSwitch showFavoriteMultiredditsSwitchMaterial; - @BindView(R.id.show_multireddits_linear_layout_customize_main_page_tabs_fragment) - LinearLayout showMultiredditsLinearLayout; - @BindView(R.id.show_multireddits_title_text_view_customize_main_page_tabs_fragment) - TextView showMultiredditsTitleTextView; - @BindView(R.id.show_multireddits_switch_material_customize_main_page_tabs_fragment) - MaterialSwitch showMultiredditsSwitchMaterial; - @BindView(R.id.show_subscribed_subreddits_linear_layout_customize_main_page_tabs_fragment) - LinearLayout showSubscribedSubredditsLinearLayout; - @BindView(R.id.show_subscribed_subreddits_title_text_view_customize_main_page_tabs_fragment) - TextView showSubscribedSubredditsTitleTextView; - @BindView(R.id.show_subscribed_subreddits_switch_material_customize_main_page_tabs_fragment) - MaterialSwitch showSubscribedSubredditsSwitchMaterial; - @BindView(R.id.show_favorite_subscribed_subreddits_linear_layout_customize_main_page_tabs_fragment) - LinearLayout showFavoriteSubscribedSubredditsLinearLayout; - @BindView(R.id.show_favorite_subscribed_subreddits_title_text_view_customize_main_page_tabs_fragment) - TextView showFavoriteSubscribedSubredditsTitleTextView; - @BindView(R.id.show_favorite_subscribed_subreddits_switch_material_customize_main_page_tabs_fragment) - MaterialSwitch showFavoriteSubscribedSubredditsSwitchMaterial; + private FragmentCustomizeMainPageTabsBinding binding; @Inject @Named("main_activity_tabs") SharedPreferences mainActivityTabsSharedPreferences; @@ -180,17 +61,15 @@ public class CustomizeMainPageTabsFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_customize_main_page_tabs, container, false); + binding = FragmentCustomizeMainPageTabsBinding.inflate(inflater, container, false); ((Infinity) activity.getApplication()).getAppComponent().inject(this); - ButterKnife.bind(this, rootView); - - rootView.setBackgroundColor(activity.customThemeWrapper.getBackgroundColor()); + binding.getRoot().setBackgroundColor(activity.customThemeWrapper.getBackgroundColor()); applyCustomTheme(); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } String[] typeValues; @@ -201,23 +80,23 @@ public class CustomizeMainPageTabsFragment extends Fragment { } tabCount = mainActivityTabsSharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, 3); - tabCountTextView.setText(Integer.toString(tabCount)); - tabCountLinearLayout.setOnClickListener(view -> { + binding.tabCountTextViewCustomizeMainPageTabsFragment.setText(Integer.toString(tabCount)); + binding.tabCountLinearLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_tab_count) .setSingleChoiceItems(R.array.settings_main_page_tab_count, tabCount - 1, (dialogInterface, i) -> { tabCount = i + 1; mainActivityTabsSharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_COUNT, tabCount).apply(); - tabCountTextView.setText(Integer.toString(tabCount)); + binding.tabCountTextViewCustomizeMainPageTabsFragment.setText(Integer.toString(tabCount)); dialogInterface.dismiss(); }) .show(); }); boolean showTabNames = mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true); - showTabNamesSwitch.setChecked(showTabNames); - showTabNamesSwitch.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, b).apply()); - showTabNamesLinearLayout.setOnClickListener(view -> showTabNamesSwitch.performClick()); + binding.showTabNamesSwitchMaterialCustomizeMainPageTabsFragment.setChecked(showTabNames); + binding.showTabNamesSwitchMaterialCustomizeMainPageTabsFragment.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, b).apply()); + binding.showTabNamesLinearLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> binding.showTabNamesSwitchMaterialCustomizeMainPageTabsFragment.performClick()); tab1CurrentTitle = mainActivityTabsSharedPreferences.getString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)); tab1CurrentPostType = mainActivityTabsSharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME); @@ -225,15 +104,15 @@ public class CustomizeMainPageTabsFragment extends Fragment { tab1CurrentPostType = Utils.fixIndexOutOfBoundsUsingPredetermined(typeValues, tab1CurrentPostType, 1); } tab1CurrentName = mainActivityTabsSharedPreferences.getString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, ""); - tab1TypeSummaryTextView.setText(typeValues[tab1CurrentPostType]); - tab1TitleSummaryTextView.setText(tab1CurrentTitle); - tab1NameSummaryTextView.setText(tab1CurrentName); - applyTab1NameView(tab1NameConstraintLayout, tab1NameTitleTextView, tab1CurrentPostType); + binding.tab1TypeSummaryTextViewCustomizeMainPageTabsFragment.setText(typeValues[tab1CurrentPostType]); + binding.tab1TitleSummaryTextViewCustomizeMainPageTabsFragment.setText(tab1CurrentTitle); + binding.tab1NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab1CurrentName); + applyTab1NameView(binding.tab1NameConstraintLayoutCustomizeMainPageTabsFragment, binding.tab1NameTitleTextViewCustomizeMainPageTabsFragment, tab1CurrentPostType); View dialogView = activity.getLayoutInflater().inflate(R.layout.dialog_edit_text, null); EditText editText = dialogView.findViewById(R.id.edit_text_edit_text_dialog); - tab1TitleLinearLayout.setOnClickListener(view -> { + binding.tab1TitleLinearLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { editText.setHint(R.string.settings_tab_title); editText.setText(tab1CurrentTitle); editText.requestFocus(); @@ -248,7 +127,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { -> { tab1CurrentTitle = editText.getText().toString(); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, tab1CurrentTitle).apply(); - tab1TitleSummaryTextView.setText(tab1CurrentTitle); + binding.tab1TitleSummaryTextViewCustomizeMainPageTabsFragment.setText(tab1CurrentTitle); Utils.hideKeyboard(activity); }) .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { @@ -257,21 +136,21 @@ public class CustomizeMainPageTabsFragment extends Fragment { .show(); }); - tab1TypeLinearLayout.setOnClickListener(view -> { + binding.tab1TypeLinearLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_tab_title) .setSingleChoiceItems(typeValues, tab1CurrentPostType, (dialogInterface, i) -> { tab1CurrentPostType = i; mainActivityTabsSharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, i).apply(); - tab1TypeSummaryTextView.setText(typeValues[i]); - applyTab1NameView(tab1NameConstraintLayout, tab1NameTitleTextView, i); + binding.tab1TypeSummaryTextViewCustomizeMainPageTabsFragment.setText(typeValues[i]); + applyTab1NameView(binding.tab1NameConstraintLayoutCustomizeMainPageTabsFragment, binding.tab1NameTitleTextViewCustomizeMainPageTabsFragment, i); dialogInterface.dismiss(); }) .setNegativeButton(R.string.cancel, null) .show(); }); - tab1NameConstraintLayout.setOnClickListener(view -> { + binding.tab1NameConstraintLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { int titleId; switch (tab1CurrentPostType) { case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: @@ -300,7 +179,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { -> { tab1CurrentName = editText.getText().toString(); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply(); - tab1NameSummaryTextView.setText(tab1CurrentName); + binding.tab1NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab1CurrentName); Utils.hideKeyboard(activity); }) .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { @@ -309,7 +188,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { .show(); }); - tab1AddImageView.setOnClickListener(view -> selectName(0)); + binding.tab1NameAddImageViewCustomizeMainPageTabsFragment.setOnClickListener(view -> selectName(0)); tab2CurrentTitle = mainActivityTabsSharedPreferences.getString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular)); tab2CurrentPostType = mainActivityTabsSharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR); @@ -317,12 +196,12 @@ public class CustomizeMainPageTabsFragment extends Fragment { tab2CurrentPostType = Utils.fixIndexOutOfBoundsUsingPredetermined(typeValues, tab2CurrentPostType, 1); } tab2CurrentName = mainActivityTabsSharedPreferences.getString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, ""); - tab2TypeSummaryTextView.setText(typeValues[tab2CurrentPostType]); - tab2TitleSummaryTextView.setText(tab2CurrentTitle); - tab2NameSummaryTextView.setText(tab2CurrentName); - applyTab2NameView(tab2NameConstraintLayout, tab2NameTitleTextView, tab2CurrentPostType); + binding.tab2TypeSummaryTextViewCustomizeMainPageTabsFragment.setText(typeValues[tab2CurrentPostType]); + binding.tab2TitleSummaryTextViewCustomizeMainPageTabsFragment.setText(tab2CurrentTitle); + binding.tab2NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab2CurrentName); + applyTab2NameView(binding.tab2NameConstraintLayoutCustomizeMainPageTabsFragment, binding.tab2NameTitleTextViewCustomizeMainPageTabsFragment, tab2CurrentPostType); - tab2TitleLinearLayout.setOnClickListener(view -> { + binding.tab2TitleLinearLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { editText.setHint(R.string.settings_tab_title); editText.setText(tab2CurrentTitle); editText.requestFocus(); @@ -337,7 +216,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { -> { tab2CurrentTitle = editText.getText().toString(); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, tab2CurrentTitle).apply(); - tab2TitleSummaryTextView.setText(tab2CurrentTitle); + binding.tab2TitleSummaryTextViewCustomizeMainPageTabsFragment.setText(tab2CurrentTitle); Utils.hideKeyboard(activity); }) .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { @@ -346,21 +225,21 @@ public class CustomizeMainPageTabsFragment extends Fragment { .show(); }); - tab2TypeLinearLayout.setOnClickListener(view -> { + binding.tab2TypeLinearLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_tab_title) .setSingleChoiceItems(typeValues, tab2CurrentPostType, (dialogInterface, i) -> { tab2CurrentPostType = i; mainActivityTabsSharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, i).apply(); - tab2TypeSummaryTextView.setText(typeValues[i]); - applyTab2NameView(tab2NameConstraintLayout, tab2NameTitleTextView, i); + binding.tab2TypeSummaryTextViewCustomizeMainPageTabsFragment.setText(typeValues[i]); + applyTab2NameView(binding.tab2NameConstraintLayoutCustomizeMainPageTabsFragment, binding.tab2NameTitleTextViewCustomizeMainPageTabsFragment, i); dialogInterface.dismiss(); }) .setNegativeButton(R.string.cancel, null) .show(); }); - tab2NameConstraintLayout.setOnClickListener(view -> { + binding.tab2NameConstraintLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { int titleId; switch (tab2CurrentPostType) { case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: @@ -389,7 +268,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { -> { tab2CurrentName = editText.getText().toString(); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply(); - tab2NameSummaryTextView.setText(tab2CurrentName); + binding.tab2NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab2CurrentName); Utils.hideKeyboard(activity); }) .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { @@ -398,7 +277,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { .show(); }); - tab2AddImageView.setOnClickListener(view -> selectName(1)); + binding.tab2NameAddImageViewCustomizeMainPageTabsFragment.setOnClickListener(view -> selectName(1)); tab3CurrentTitle = mainActivityTabsSharedPreferences.getString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)); tab3CurrentPostType = mainActivityTabsSharedPreferences.getInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL); @@ -406,12 +285,12 @@ public class CustomizeMainPageTabsFragment extends Fragment { tab3CurrentPostType = Utils.fixIndexOutOfBoundsUsingPredetermined(typeValues, tab3CurrentPostType, 1); } tab3CurrentName = mainActivityTabsSharedPreferences.getString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, ""); - tab3TypeSummaryTextView.setText(typeValues[tab3CurrentPostType]); - tab3TitleSummaryTextView.setText(tab3CurrentTitle); - tab3NameSummaryTextView.setText(tab3CurrentName); - applyTab3NameView(tab3NameConstraintLayout, tab3NameTitleTextView, tab3CurrentPostType); + binding.tab3TypeSummaryTextViewCustomizeMainPageTabsFragment.setText(typeValues[tab3CurrentPostType]); + binding.tab3TitleSummaryTextViewCustomizeMainPageTabsFragment.setText(tab3CurrentTitle); + binding.tab3NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab3CurrentName); + applyTab3NameView(binding.tab3NameConstraintLayoutCustomizeMainPageTabsFragment, binding.tab3NameTitleTextViewCustomizeMainPageTabsFragment, tab3CurrentPostType); - tab3TitleLinearLayout.setOnClickListener(view -> { + binding.tab3TitleLinearLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { editText.setHint(R.string.settings_tab_title); editText.setText(tab3CurrentTitle); editText.requestFocus(); @@ -426,7 +305,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { -> { tab3CurrentTitle = editText.getText().toString(); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, tab3CurrentTitle).apply(); - tab3TitleSummaryTextView.setText(tab3CurrentTitle); + binding.tab3TitleSummaryTextViewCustomizeMainPageTabsFragment.setText(tab3CurrentTitle); Utils.hideKeyboard(activity); }) .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { @@ -435,21 +314,21 @@ public class CustomizeMainPageTabsFragment extends Fragment { .show(); }); - tab3TypeLinearLayout.setOnClickListener(view -> { + binding.tab3TypeLinearLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) .setTitle(R.string.settings_tab_title) .setSingleChoiceItems(typeValues, tab3CurrentPostType, (dialogInterface, i) -> { tab3CurrentPostType = i; mainActivityTabsSharedPreferences.edit().putInt((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, i).apply(); - tab3TypeSummaryTextView.setText(typeValues[i]); - applyTab3NameView(tab3NameConstraintLayout, tab3NameTitleTextView, i); + binding.tab3TypeSummaryTextViewCustomizeMainPageTabsFragment.setText(typeValues[i]); + applyTab3NameView(binding.tab3NameConstraintLayoutCustomizeMainPageTabsFragment, binding.tab3NameTitleTextViewCustomizeMainPageTabsFragment, i); dialogInterface.dismiss(); }) .setNegativeButton(R.string.cancel, null) .show(); }); - tab3NameConstraintLayout.setOnClickListener(view -> { + binding.tab3NameConstraintLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { int titleId; switch (tab3CurrentPostType) { case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: @@ -478,7 +357,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { -> { tab3CurrentName = editText.getText().toString(); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply(); - tab3NameSummaryTextView.setText(tab3CurrentName); + binding.tab3NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab3CurrentName); Utils.hideKeyboard(activity); }) .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { @@ -487,33 +366,33 @@ public class CustomizeMainPageTabsFragment extends Fragment { .show(); }); - tab3AddImageView.setOnClickListener(view -> selectName(2)); + binding.tab3NameAddImageViewCustomizeMainPageTabsFragment.setOnClickListener(view -> selectName(2)); - showMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false)); - showMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, b).apply()); - showMultiredditsLinearLayout.setOnClickListener(view -> { - showMultiredditsSwitchMaterial.performClick(); + binding.showMultiredditsSwitchMaterialCustomizeMainPageTabsFragment.setChecked(mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, false)); + binding.showMultiredditsSwitchMaterialCustomizeMainPageTabsFragment.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_MULTIREDDITS, b).apply()); + binding.showMultiredditsLinearLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { + binding.showMultiredditsSwitchMaterialCustomizeMainPageTabsFragment.performClick(); }); - showFavoriteMultiredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false)); - showFavoriteMultiredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, b).apply()); - showFavoriteMultiredditsLinearLayout.setOnClickListener(view -> { - showFavoriteMultiredditsSwitchMaterial.performClick(); + binding.showFavoriteMultiredditsSwitchMaterialCustomizeMainPageTabsFragment.setChecked(mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, false)); + binding.showFavoriteMultiredditsSwitchMaterialCustomizeMainPageTabsFragment.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_MULTIREDDITS, b).apply()); + binding.showFavoriteMultiredditsLinearLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { + binding.showFavoriteMultiredditsSwitchMaterialCustomizeMainPageTabsFragment.performClick(); }); - showSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false)); - showSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, b).apply()); - showSubscribedSubredditsLinearLayout.setOnClickListener(view -> { - showSubscribedSubredditsSwitchMaterial.performClick(); + binding.showSubscribedSubredditsSwitchMaterialCustomizeMainPageTabsFragment.setChecked(mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, false)); + binding.showSubscribedSubredditsSwitchMaterialCustomizeMainPageTabsFragment.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_SUBSCRIBED_SUBREDDITS, b).apply()); + binding.showSubscribedSubredditsLinearLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { + binding.showSubscribedSubredditsSwitchMaterialCustomizeMainPageTabsFragment.performClick(); }); - showFavoriteSubscribedSubredditsSwitchMaterial.setChecked(mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false)); - showFavoriteSubscribedSubredditsSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, b).apply()); - showFavoriteSubscribedSubredditsLinearLayout.setOnClickListener(view -> { - showFavoriteSubscribedSubredditsSwitchMaterial.performClick(); + binding.showFavoriteSubscribedSubredditsSwitchMaterialCustomizeMainPageTabsFragment.setChecked(mainActivityTabsSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, false)); + binding.showFavoriteSubscribedSubredditsSwitchMaterialCustomizeMainPageTabsFragment.setOnCheckedChangeListener((compoundButton, b) -> mainActivityTabsSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_FAVORITE_SUBSCRIBED_SUBREDDITS, b).apply()); + binding.showFavoriteSubscribedSubredditsLinearLayoutCustomizeMainPageTabsFragment.setOnClickListener(view -> { + binding.showFavoriteSubscribedSubredditsSwitchMaterialCustomizeMainPageTabsFragment.performClick(); }); - return rootView; + return binding.getRoot(); } private void applyCustomTheme() { @@ -521,43 +400,43 @@ public class CustomizeMainPageTabsFragment extends Fragment { int secondaryTextColor = activity.customThemeWrapper.getSecondaryTextColor(); int colorAccent = activity.customThemeWrapper.getColorAccent(); int primaryIconColor = activity.customThemeWrapper.getPrimaryIconColor(); - infoTextView.setTextColor(secondaryTextColor); + binding.infoTextViewCustomizeMainPageTabsFragment.setTextColor(secondaryTextColor); Drawable infoDrawable = Utils.getTintedDrawable(activity, R.drawable.ic_info_preference_24dp, secondaryTextColor); - infoTextView.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null); - tabCountTitleTextView.setTextColor(primaryTextColor); - tabCountTextView.setTextColor(secondaryTextColor); - showTabNamesTitleTextView.setTextColor(primaryTextColor); - tab1GroupSummaryTextView.setTextColor(colorAccent); - tab1TitleTitleTextView.setTextColor(primaryTextColor); - tab1TitleSummaryTextView.setTextColor(secondaryTextColor); - tab1TypeTitleTextView.setTextColor(primaryTextColor); - tab1TypeSummaryTextView.setTextColor(secondaryTextColor); - tab1NameTitleTextView.setTextColor(primaryTextColor); - tab1NameSummaryTextView.setTextColor(secondaryTextColor); - tab1AddImageView.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); - tab2GroupSummaryTextView.setTextColor(colorAccent); - tab2TitleTitleTextView.setTextColor(primaryTextColor); - tab2TitleSummaryTextView.setTextColor(secondaryTextColor); - tab2TypeTitleTextView.setTextColor(primaryTextColor); - tab2TypeSummaryTextView.setTextColor(secondaryTextColor); - tab2NameTitleTextView.setTextColor(primaryTextColor); - tab2NameSummaryTextView.setTextColor(secondaryTextColor); - tab2AddImageView.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); - tab3GroupSummaryTextView.setTextColor(colorAccent); - tab3TitleTitleTextView.setTextColor(primaryTextColor); - tab3TitleSummaryTextView.setTextColor(secondaryTextColor); - tab3TypeTitleTextView.setTextColor(primaryTextColor); - tab3TypeSummaryTextView.setTextColor(secondaryTextColor); - tab3NameTitleTextView.setTextColor(primaryTextColor); - tab3NameSummaryTextView.setTextColor(secondaryTextColor); - tab3AddImageView.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); - moreTabsGroupSummaryTextView.setTextColor(colorAccent); - moreTabsInfoTextView.setTextColor(secondaryTextColor); - moreTabsInfoTextView.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null); - showFavoriteMultiredditsTitleTextView.setTextColor(primaryTextColor); - showMultiredditsTitleTextView.setTextColor(primaryTextColor); - showSubscribedSubredditsTitleTextView.setTextColor(primaryTextColor); - showFavoriteSubscribedSubredditsTitleTextView.setTextColor(primaryTextColor); + binding.infoTextViewCustomizeMainPageTabsFragment.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null); + binding.tabCountTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.tabCountTextViewCustomizeMainPageTabsFragment.setTextColor(secondaryTextColor); + binding.showTabNamesTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.tab1GroupSummaryCustomizeMainPageTabsFragment.setTextColor(colorAccent); + binding.tab1TitleTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.tab1TitleSummaryTextViewCustomizeMainPageTabsFragment.setTextColor(secondaryTextColor); + binding.tab1TypeTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.tab1TypeSummaryTextViewCustomizeMainPageTabsFragment.setTextColor(secondaryTextColor); + binding.tab1NameTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.tab1NameSummaryTextViewCustomizeMainPageTabsFragment.setTextColor(secondaryTextColor); + binding.tab1NameAddImageViewCustomizeMainPageTabsFragment.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); + binding.tab2GroupSummaryCustomizeMainPageTabsFragment.setTextColor(colorAccent); + binding.tab2TitleTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.tab2TitleSummaryTextViewCustomizeMainPageTabsFragment.setTextColor(secondaryTextColor); + binding.tab2TypeTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.tab2TypeSummaryTextViewCustomizeMainPageTabsFragment.setTextColor(secondaryTextColor); + binding.tab2NameTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.tab2NameSummaryTextViewCustomizeMainPageTabsFragment.setTextColor(secondaryTextColor); + binding.tab2NameAddImageViewCustomizeMainPageTabsFragment.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); + binding.tab3GroupSummaryCustomizeMainPageTabsFragment.setTextColor(colorAccent); + binding.tab3TitleTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.tab3TitleSummaryTextViewCustomizeMainPageTabsFragment.setTextColor(secondaryTextColor); + binding.tab3TypeTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.tab3TypeSummaryTextViewCustomizeMainPageTabsFragment.setTextColor(secondaryTextColor); + binding.tab3NameTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.tab3NameSummaryTextViewCustomizeMainPageTabsFragment.setTextColor(secondaryTextColor); + binding.tab3NameAddImageViewCustomizeMainPageTabsFragment.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN); + binding.moreTabsGroupSummaryCustomizeMainPageTabsFragment.setTextColor(colorAccent); + binding.moreTabsInfoTextViewCustomizeMainPageTabsFragment.setTextColor(secondaryTextColor); + binding.moreTabsInfoTextViewCustomizeMainPageTabsFragment.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null); + binding.showFavoriteMultiredditsTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.showMultiredditsTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.showSubscribedSubredditsTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); + binding.showFavoriteSubscribedSubredditsTitleTextViewCustomizeMainPageTabsFragment.setTextColor(primaryTextColor); } private void applyTab1NameView(ConstraintLayout constraintLayout, TextView titleTextView, int postType) { @@ -690,54 +569,54 @@ public class CustomizeMainPageTabsFragment extends Fragment { case 0: if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME)) { tab1CurrentName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME); - tab1NameSummaryTextView.setText(tab1CurrentName); + binding.tab1NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab1CurrentName); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply(); } else if (data.hasExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT)) { MultiReddit multireddit = data.getParcelableExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT); if (multireddit != null) { tab1CurrentName = multireddit.getPath(); - tab1NameSummaryTextView.setText(tab1CurrentName); + binding.tab1NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab1CurrentName); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply(); } } else if (data.hasExtra(SearchActivity.EXTRA_RETURN_USER_NAME)) { tab1CurrentName = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME); - tab1NameSummaryTextView.setText(tab1CurrentName); + binding.tab1NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab1CurrentName); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply(); } break; case 1: if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME)) { tab2CurrentName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME); - tab2NameSummaryTextView.setText(tab2CurrentName); + binding.tab2NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab2CurrentName); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply(); } else if (data.hasExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT)) { MultiReddit multireddit = data.getParcelableExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT); if (multireddit != null) { tab2CurrentName = multireddit.getPath(); - tab2NameSummaryTextView.setText(tab2CurrentName); + binding.tab2NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab2CurrentName); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply(); } } else if (data.hasExtra(SearchActivity.EXTRA_RETURN_USER_NAME)) { tab2CurrentName = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME); - tab2NameSummaryTextView.setText(tab2CurrentName); + binding.tab2NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab2CurrentName); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply(); } break; case 2: if (data.hasExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME)) { tab3CurrentName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME); - tab3NameSummaryTextView.setText(tab3CurrentName); + binding.tab3NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab3CurrentName); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply(); } else if (data.hasExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT)) { MultiReddit multireddit = data.getParcelableExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT); if (multireddit != null) { tab3CurrentName = multireddit.getPath(); - tab3NameSummaryTextView.setText(tab3CurrentName); + binding.tab3NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab3CurrentName); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply(); } } else if (data.hasExtra(SearchActivity.EXTRA_RETURN_USER_NAME)) { tab3CurrentName = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME); - tab3NameSummaryTextView.setText(tab3CurrentName); + binding.tab3NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab3CurrentName); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply(); } break; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java index e003df8f..6cebdc41 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/NsfwAndSpoilerFragment.java @@ -6,26 +6,22 @@ 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 com.google.android.material.materialswitch.MaterialSwitch; import org.greenrobot.eventbus.EventBus; 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.account.Account; import ml.docilealligator.infinityforreddit.activities.SettingsActivity; +import ml.docilealligator.infinityforreddit.databinding.FragmentNsfwAndSpoilerBinding; import ml.docilealligator.infinityforreddit.events.ChangeNSFWBlurEvent; import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.events.ChangeSpoilerBlurEvent; @@ -34,38 +30,7 @@ import ml.docilealligator.infinityforreddit.utils.Utils; public class NsfwAndSpoilerFragment extends Fragment { - @BindView(R.id.enable_nsfw_linear_layout_nsfw_and_spoiler_fragment) - LinearLayout enableNsfwLinearLayout; - @BindView(R.id.enable_nsfw_text_view_nsfw_and_spoiler_fragment) - TextView enableNsfwTextView; - @BindView(R.id.enable_nsfw_switch_nsfw_and_spoiler_fragment) - MaterialSwitch enableNsfwSwitchMaterial; - @BindView(R.id.blur_nsfw_linear_layout_nsfw_and_spoiler_fragment) - LinearLayout blurNsfwLinearLayout; - @BindView(R.id.blur_nsfw_text_view_nsfw_and_spoiler_fragment) - TextView blurNsfwTextView; - @BindView(R.id.blur_nsfw_switch_nsfw_and_spoiler_fragment) - MaterialSwitch blurNsfwSwitchMaterial; - @BindView(R.id.do_not_blur_nsfw_in_nsfw_subreddits_linear_layout_nsfw_and_spoiler_fragment) - LinearLayout doNotBlurNsfwInNsfwSubredditsLinearLayout; - @BindView(R.id.do_not_blur_nsfw_text_view_nsfw_and_spoiler_fragment) - TextView doNotBlurNsfwInNsfwSubredditsTextView; - @BindView(R.id.do_not_blur_nsfw_in_nsfw_subreddits_switch_nsfw_and_spoiler_fragment) - MaterialSwitch doNotBlurNsfwInNsfwSubredditsSwitch; - @BindView(R.id.blur_spoiler_linear_layout_nsfw_and_spoiler_fragment) - LinearLayout blurSpoilerLinearLayout; - @BindView(R.id.blur_spoiler_text_view_nsfw_and_spoiler_fragment) - TextView blurSpoilerTextView; - @BindView(R.id.blur_spoiler_switch_nsfw_and_spoiler_fragment) - MaterialSwitch blurSpoilerSwitchMaterial; - @BindView(R.id.dangerous_text_view_nsfw_and_spoiler_fragment) - TextView dangerousTextView; - @BindView(R.id.disable_nsfw_forever_linear_layout_nsfw_and_spoiler_fragment) - LinearLayout disableNsfwForeverLinearLayout; - @BindView(R.id.disable_nsfw_forever_text_view_nsfw_and_spoiler_fragment) - TextView disableNsfwForeverTextView; - @BindView(R.id.disable_nsfw_forever_switch_nsfw_and_spoiler_fragment) - MaterialSwitch disableNsfwForeverSwitchMaterial; + private FragmentNsfwAndSpoilerBinding binding; @Inject @Named("default") SharedPreferences sharedPreferences; @@ -84,21 +49,19 @@ public class NsfwAndSpoilerFragment extends Fragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_nsfw_and_spoiler, container, false); + binding = FragmentNsfwAndSpoilerBinding.inflate(inflater, container, false); ((Infinity) activity.getApplication()).getAppComponent().inject(this); - ButterKnife.bind(this, rootView); - applyCustomTheme(); - rootView.setBackgroundColor(activity.customThemeWrapper.getBackgroundColor()); + binding.getRoot().setBackgroundColor(activity.customThemeWrapper.getBackgroundColor()); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } boolean enableNsfw = nsfwAndBlurringSharedPreferences.getBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.NSFW_BASE, false); @@ -108,58 +71,58 @@ public class NsfwAndSpoilerFragment extends Fragment { disableNsfwForever = sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, false); if (enableNsfw) { - blurNsfwLinearLayout.setVisibility(View.VISIBLE); - doNotBlurNsfwInNsfwSubredditsLinearLayout.setVisibility(View.VISIBLE); + binding.blurNsfwLinearLayoutNsfwAndSpoilerFragment.setVisibility(View.VISIBLE); + binding.doNotBlurNsfwInNsfwSubredditsLinearLayoutNsfwAndSpoilerFragment.setVisibility(View.VISIBLE); } - enableNsfwSwitchMaterial.setChecked(enableNsfw); - blurNsfwSwitchMaterial.setChecked(blurNsfw); - doNotBlurNsfwInNsfwSubredditsSwitch.setChecked(doNotBlurNsfwInNsfwSubreddits); - blurSpoilerSwitchMaterial.setChecked(blurSpoiler); - disableNsfwForeverSwitchMaterial.setChecked(disableNsfwForever); - disableNsfwForeverSwitchMaterial.setEnabled(!disableNsfwForever); + binding.enableNsfwSwitchNsfwAndSpoilerFragment.setChecked(enableNsfw); + binding.blurNsfwSwitchNsfwAndSpoilerFragment.setChecked(blurNsfw); + binding.doNotBlurNsfwInNsfwSubredditsSwitchNsfwAndSpoilerFragment.setChecked(doNotBlurNsfwInNsfwSubreddits); + binding.blurSpoilerSwitchNsfwAndSpoilerFragment.setChecked(blurSpoiler); + binding.disableNsfwForeverSwitchNsfwAndSpoilerFragment.setChecked(disableNsfwForever); + binding.disableNsfwForeverSwitchNsfwAndSpoilerFragment.setEnabled(!disableNsfwForever); if (disableNsfwForever) { - disableNsfwForeverTextView.setTextColor(activity.customThemeWrapper.getSecondaryTextColor()); - disableNsfwForeverLinearLayout.setEnabled(false); + binding.disableNsfwForeverTextViewNsfwAndSpoilerFragment.setTextColor(activity.customThemeWrapper.getSecondaryTextColor()); + binding.disableNsfwForeverLinearLayoutNsfwAndSpoilerFragment.setEnabled(false); } - enableNsfwLinearLayout.setOnClickListener(view -> enableNsfwSwitchMaterial.performClick()); - enableNsfwSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> { + binding.enableNsfwLinearLayoutNsfwAndSpoilerFragment.setOnClickListener(view -> binding.enableNsfwSwitchNsfwAndSpoilerFragment.performClick()); + binding.enableNsfwSwitchNsfwAndSpoilerFragment.setOnCheckedChangeListener((compoundButton, b) -> { nsfwAndBlurringSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.NSFW_BASE, b).apply(); if (b) { - blurNsfwLinearLayout.setVisibility(View.VISIBLE); - doNotBlurNsfwInNsfwSubredditsLinearLayout.setVisibility(View.VISIBLE); + binding.blurNsfwLinearLayoutNsfwAndSpoilerFragment.setVisibility(View.VISIBLE); + binding.doNotBlurNsfwInNsfwSubredditsLinearLayoutNsfwAndSpoilerFragment.setVisibility(View.VISIBLE); } else { - blurNsfwLinearLayout.setVisibility(View.GONE); - doNotBlurNsfwInNsfwSubredditsLinearLayout.setVisibility(View.GONE); + binding.blurNsfwLinearLayoutNsfwAndSpoilerFragment.setVisibility(View.GONE); + binding.doNotBlurNsfwInNsfwSubredditsLinearLayoutNsfwAndSpoilerFragment.setVisibility(View.GONE); } EventBus.getDefault().post(new ChangeNSFWEvent(b)); }); - blurNsfwLinearLayout.setOnClickListener(view -> blurNsfwSwitchMaterial.performClick()); - blurNsfwSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> { + binding.blurNsfwLinearLayoutNsfwAndSpoilerFragment.setOnClickListener(view -> binding.blurNsfwSwitchNsfwAndSpoilerFragment.performClick()); + binding.blurNsfwSwitchNsfwAndSpoilerFragment.setOnCheckedChangeListener((compoundButton, b) -> { nsfwAndBlurringSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.BLUR_NSFW_BASE, b).apply(); EventBus.getDefault().post(new ChangeNSFWBlurEvent(b, doNotBlurNsfwInNsfwSubreddits)); }); - doNotBlurNsfwInNsfwSubredditsLinearLayout.setOnClickListener(view -> { - doNotBlurNsfwInNsfwSubredditsSwitch.performClick(); + binding.doNotBlurNsfwInNsfwSubredditsLinearLayoutNsfwAndSpoilerFragment.setOnClickListener(view -> { + binding.doNotBlurNsfwInNsfwSubredditsSwitchNsfwAndSpoilerFragment.performClick(); }); - doNotBlurNsfwInNsfwSubredditsSwitch.setOnCheckedChangeListener((compoundButton, b) -> { + binding.doNotBlurNsfwInNsfwSubredditsSwitchNsfwAndSpoilerFragment.setOnCheckedChangeListener((compoundButton, b) -> { nsfwAndBlurringSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.DO_NOT_BLUR_NSFW_IN_NSFW_SUBREDDITS, b).apply(); EventBus.getDefault().post(new ChangeNSFWBlurEvent(blurNsfw, b)); }); - blurSpoilerLinearLayout.setOnClickListener(view -> blurSpoilerSwitchMaterial.performClick()); - blurSpoilerSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> { + binding.blurSpoilerLinearLayoutNsfwAndSpoilerFragment.setOnClickListener(view -> binding.blurSpoilerSwitchNsfwAndSpoilerFragment.performClick()); + binding.blurSpoilerSwitchNsfwAndSpoilerFragment.setOnCheckedChangeListener((compoundButton, b) -> { nsfwAndBlurringSharedPreferences.edit().putBoolean((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.BLUR_SPOILER_BASE, b).apply(); EventBus.getDefault().post(new ChangeSpoilerBlurEvent(b)); }); - disableNsfwForeverLinearLayout.setOnClickListener(view -> { - disableNsfwForeverSwitchMaterial.performClick(); + binding.disableNsfwForeverLinearLayoutNsfwAndSpoilerFragment.setOnClickListener(view -> { + binding.disableNsfwForeverSwitchNsfwAndSpoilerFragment.performClick(); }); - disableNsfwForeverSwitchMaterial.setOnCheckedChangeListener((compoundButton, b) -> { + binding.disableNsfwForeverSwitchNsfwAndSpoilerFragment.setOnCheckedChangeListener((compoundButton, b) -> { if (manuallyCheckDisableNsfwForever) { manuallyCheckDisableNsfwForever = false; new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) @@ -169,37 +132,37 @@ public class NsfwAndSpoilerFragment extends Fragment { -> { sharedPreferences.edit().putBoolean(SharedPreferencesUtils.DISABLE_NSFW_FOREVER, true).apply(); disableNsfwForever = true; - disableNsfwForeverSwitchMaterial.setEnabled(false); - disableNsfwForeverLinearLayout.setEnabled(false); - disableNsfwForeverSwitchMaterial.setChecked(true); - disableNsfwForeverTextView.setTextColor(activity.customThemeWrapper.getSecondaryTextColor()); + binding.disableNsfwForeverSwitchNsfwAndSpoilerFragment.setEnabled(false); + binding.disableNsfwForeverLinearLayoutNsfwAndSpoilerFragment.setEnabled(false); + binding.disableNsfwForeverSwitchNsfwAndSpoilerFragment.setChecked(true); + binding.disableNsfwForeverTextViewNsfwAndSpoilerFragment.setTextColor(activity.customThemeWrapper.getSecondaryTextColor()); EventBus.getDefault().post(new ChangeNSFWEvent(false)); }) .setNegativeButton(R.string.no, (dialogInterface, i) -> { - disableNsfwForeverSwitchMaterial.setChecked(false); + binding.disableNsfwForeverSwitchNsfwAndSpoilerFragment.setChecked(false); manuallyCheckDisableNsfwForever = true; }) .setOnDismissListener(dialogInterface -> { if (!disableNsfwForever) { - disableNsfwForeverSwitchMaterial.setChecked(false); + binding.disableNsfwForeverSwitchNsfwAndSpoilerFragment.setChecked(false); } manuallyCheckDisableNsfwForever = true; }) .show(); } }); - return rootView; + return binding.getRoot(); } private void applyCustomTheme() { int primaryTextColor = activity.customThemeWrapper.getPrimaryTextColor(); - enableNsfwTextView.setCompoundDrawablesWithIntrinsicBounds(Utils.getTintedDrawable(activity, R.drawable.ic_nsfw_on_24dp, activity.customThemeWrapper.getPrimaryIconColor()), null, null, null); - enableNsfwTextView.setTextColor(primaryTextColor); - blurNsfwTextView.setTextColor(primaryTextColor); - doNotBlurNsfwInNsfwSubredditsTextView.setTextColor(primaryTextColor); - blurSpoilerTextView.setTextColor(primaryTextColor); - dangerousTextView.setTextColor(primaryTextColor); - disableNsfwForeverTextView.setTextColor(primaryTextColor); + binding.enableNsfwTextViewNsfwAndSpoilerFragment.setCompoundDrawablesWithIntrinsicBounds(Utils.getTintedDrawable(activity, R.drawable.ic_nsfw_on_24dp, activity.customThemeWrapper.getPrimaryIconColor()), null, null, null); + binding.enableNsfwTextViewNsfwAndSpoilerFragment.setTextColor(primaryTextColor); + binding.blurNsfwTextViewNsfwAndSpoilerFragment.setTextColor(primaryTextColor); + binding.doNotBlurNsfwTextViewNsfwAndSpoilerFragment.setTextColor(primaryTextColor); + binding.blurSpoilerTextViewNsfwAndSpoilerFragment.setTextColor(primaryTextColor); + binding.dangerousTextViewNsfwAndSpoilerFragment.setTextColor(primaryTextColor); + binding.disableNsfwForeverTextViewNsfwAndSpoilerFragment.setTextColor(primaryTextColor); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java index 8c446ceb..123679a5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostHistoryFragment.java @@ -7,54 +7,24 @@ 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.materialswitch.MaterialSwitch; - 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.account.Account; import ml.docilealligator.infinityforreddit.activities.SettingsActivity; +import ml.docilealligator.infinityforreddit.databinding.FragmentPostHistoryBinding; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; public class PostHistoryFragment extends Fragment { - @BindView(R.id.info_text_view_post_history_fragment) - TextView infoTextView; - @BindView(R.id.mark_posts_as_read_linear_layout_post_history_fragment) - LinearLayout markPostsAsReadLinearLayout; - @BindView(R.id.mark_posts_as_read_text_view_post_history_fragment) - TextView markPostsAsReadTextView; - @BindView(R.id.mark_posts_as_read_switch_post_history_fragment) - MaterialSwitch markPostsAsReadSwitch; - @BindView(R.id.mark_posts_as_read_after_voting_linear_layout_post_history_fragment) - LinearLayout markPostsAsReadAfterVotingLinearLayout; - @BindView(R.id.mark_posts_as_read_after_voting_text_view_post_history_fragment) - TextView markPostsAsReadAfterVotingTextView; - @BindView(R.id.mark_posts_as_read_after_voting_switch_post_history_fragment) - MaterialSwitch markPostsAsReadAfterVotingSwitch; - @BindView(R.id.mark_posts_as_read_on_scroll_linear_layout_post_history_fragment) - LinearLayout markPostsAsReadOnScrollLinearLayout; - @BindView(R.id.mark_posts_as_read_on_scroll_text_view_post_history_fragment) - TextView markPostsAsReadOnScrollTextView; - @BindView(R.id.mark_posts_as_read_on_scroll_switch_post_history_fragment) - MaterialSwitch markPostsAsReadOnScrollSwitch; - @BindView(R.id.hide_read_posts_automatically_linear_layout_post_history_fragment) - LinearLayout hideReadPostsAutomaticallyLinearLayout; - @BindView(R.id.hide_read_posts_automatically_text_view_post_history_fragment) - TextView hideReadPostsAutomaticallyTextView; - @BindView(R.id.hide_read_posts_automatically_switch_post_history_fragment) - MaterialSwitch hideReadPostsAutomaticallySwitch; + private FragmentPostHistoryBinding binding; @Inject @Named("post_history") SharedPreferences postHistorySharedPreferences; @@ -65,72 +35,70 @@ public class PostHistoryFragment extends Fragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_post_history, container, false); + binding = FragmentPostHistoryBinding.inflate(inflater, container, false); ((Infinity) activity.getApplication()).getAppComponent().inject(this); - ButterKnife.bind(this, rootView); - - rootView.setBackgroundColor(activity.customThemeWrapper.getBackgroundColor()); + binding.getRoot().setBackgroundColor(activity.customThemeWrapper.getBackgroundColor()); applyCustomTheme(); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } if (activity.accountName.equals(Account.ANONYMOUS_ACCOUNT)) { - infoTextView.setText(R.string.only_for_logged_in_user); - markPostsAsReadLinearLayout.setVisibility(View.GONE); - markPostsAsReadAfterVotingLinearLayout.setVisibility(View.GONE); - markPostsAsReadOnScrollLinearLayout.setVisibility(View.GONE); - hideReadPostsAutomaticallyLinearLayout.setVisibility(View.GONE); - return rootView; + binding.infoTextViewPostHistoryFragment.setText(R.string.only_for_logged_in_user); + binding.markPostsAsReadLinearLayoutPostHistoryFragment.setVisibility(View.GONE); + binding.markPostsAsReadAfterVotingLinearLayoutPostHistoryFragment.setVisibility(View.GONE); + binding.markPostsAsReadOnScrollLinearLayoutPostHistoryFragment.setVisibility(View.GONE); + binding.hideReadPostsAutomaticallyLinearLayoutPostHistoryFragment.setVisibility(View.GONE); + return binding.getRoot(); } - markPostsAsReadSwitch.setChecked(postHistorySharedPreferences.getBoolean( + binding.markPostsAsReadSwitchPostHistoryFragment.setChecked(postHistorySharedPreferences.getBoolean( activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false)); - markPostsAsReadAfterVotingSwitch.setChecked(postHistorySharedPreferences.getBoolean( + binding.markPostsAsReadAfterVotingSwitchPostHistoryFragment.setChecked(postHistorySharedPreferences.getBoolean( activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, false)); - markPostsAsReadOnScrollSwitch.setChecked(postHistorySharedPreferences.getBoolean( + binding.markPostsAsReadOnScrollSwitchPostHistoryFragment.setChecked(postHistorySharedPreferences.getBoolean( activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_ON_SCROLL_BASE, false)); - hideReadPostsAutomaticallySwitch.setChecked(postHistorySharedPreferences.getBoolean( + binding.hideReadPostsAutomaticallySwitchPostHistoryFragment.setChecked(postHistorySharedPreferences.getBoolean( activity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false)); - markPostsAsReadLinearLayout.setOnClickListener(view -> { - markPostsAsReadSwitch.performClick(); + binding.markPostsAsReadLinearLayoutPostHistoryFragment.setOnClickListener(view -> { + binding.markPostsAsReadSwitchPostHistoryFragment.performClick(); }); - markPostsAsReadSwitch.setOnCheckedChangeListener((compoundButton, b) -> + binding.markPostsAsReadSwitchPostHistoryFragment.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, b).apply()); - markPostsAsReadAfterVotingLinearLayout.setOnClickListener(view -> markPostsAsReadAfterVotingSwitch.performClick()); + binding.markPostsAsReadAfterVotingLinearLayoutPostHistoryFragment.setOnClickListener(view -> binding.markPostsAsReadAfterVotingSwitchPostHistoryFragment.performClick()); - markPostsAsReadAfterVotingSwitch.setOnCheckedChangeListener((compoundButton, b) -> + binding.markPostsAsReadAfterVotingSwitchPostHistoryFragment.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, b).apply()); - markPostsAsReadOnScrollLinearLayout.setOnClickListener(view -> markPostsAsReadOnScrollSwitch.performClick()); + binding.markPostsAsReadOnScrollLinearLayoutPostHistoryFragment.setOnClickListener(view -> binding.markPostsAsReadOnScrollSwitchPostHistoryFragment.performClick()); - markPostsAsReadOnScrollSwitch.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_ON_SCROLL_BASE, b).apply()); + binding.markPostsAsReadOnScrollSwitchPostHistoryFragment.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(activity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_ON_SCROLL_BASE, b).apply()); - hideReadPostsAutomaticallyLinearLayout.setOnClickListener(view -> hideReadPostsAutomaticallySwitch.performClick()); + binding.hideReadPostsAutomaticallyLinearLayoutPostHistoryFragment.setOnClickListener(view -> binding.hideReadPostsAutomaticallySwitchPostHistoryFragment.performClick()); - hideReadPostsAutomaticallySwitch.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(activity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, b).apply()); + binding.hideReadPostsAutomaticallySwitchPostHistoryFragment.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(activity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, b).apply()); - return rootView; + return binding.getRoot(); } private void applyCustomTheme() { - infoTextView.setTextColor(activity.customThemeWrapper.getSecondaryTextColor()); + binding.infoTextViewPostHistoryFragment.setTextColor(activity.customThemeWrapper.getSecondaryTextColor()); Drawable infoDrawable = Utils.getTintedDrawable(activity, R.drawable.ic_info_preference_24dp, activity.customThemeWrapper.getPrimaryIconColor()); - infoTextView.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null); + binding.infoTextViewPostHistoryFragment.setCompoundDrawablesWithIntrinsicBounds(infoDrawable, null, null, null); int primaryTextColor = activity.customThemeWrapper.getPrimaryTextColor(); - markPostsAsReadTextView.setTextColor(primaryTextColor); - markPostsAsReadAfterVotingTextView.setTextColor(primaryTextColor); - markPostsAsReadOnScrollTextView.setTextColor(primaryTextColor); - hideReadPostsAutomaticallyTextView.setTextColor(primaryTextColor); + binding.markPostsAsReadTextViewPostHistoryFragment.setTextColor(primaryTextColor); + binding.markPostsAsReadAfterVotingTextViewPostHistoryFragment.setTextColor(primaryTextColor); + binding.markPostsAsReadOnScrollTextViewPostHistoryFragment.setTextColor(primaryTextColor); + binding.hideReadPostsAutomaticallyTextViewPostHistoryFragment.setTextColor(primaryTextColor); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/TranslationFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/TranslationFragment.java index 41db0168..4704a878 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/TranslationFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/TranslationFragment.java @@ -8,22 +8,17 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.RecyclerView; import javax.inject.Inject; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.adapters.TranslationFragmentRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.databinding.FragmentTranslationBinding; public class TranslationFragment extends Fragment { - @BindView(R.id.recycler_view_translation_fragment) - RecyclerView recyclerView; @Inject CustomThemeWrapper customThemeWrapper; private BaseActivity activity; @@ -33,21 +28,19 @@ public class TranslationFragment extends Fragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_translation, container, false); + FragmentTranslationBinding binding = FragmentTranslationBinding.inflate(inflater, container, false); ((Infinity) activity.getApplication()).getAppComponent().inject(this); - ButterKnife.bind(this, rootView); - TranslationFragmentRecyclerViewAdapter adapter = new TranslationFragmentRecyclerViewAdapter(activity, customThemeWrapper); - recyclerView.setAdapter(adapter); + binding.getRoot().setAdapter(adapter); - rootView.setBackgroundColor(customThemeWrapper.getBackgroundColor()); + binding.getRoot().setBackgroundColor(customThemeWrapper.getBackgroundColor()); - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/res/layout/fragment_acknowledgement.xml b/app/src/main/res/layout/fragment_acknowledgement.xml index d23fea19..afc63978 100644 --- a/app/src/main/res/layout/fragment_acknowledgement.xml +++ b/app/src/main/res/layout/fragment_acknowledgement.xml @@ -2,5 +2,4 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:id="@+id/recycler_view_acknowledgement_fragment" tools:context="ml.docilealligator.infinityforreddit.settings.AcknowledgementFragment" /> diff --git a/app/src/main/res/layout/fragment_translation.xml b/app/src/main/res/layout/fragment_translation.xml index 99e3580a..189df6f2 100644 --- a/app/src/main/res/layout/fragment_translation.xml +++ b/app/src/main/res/layout/fragment_translation.xml @@ -4,6 +4,5 @@ android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" - android:id="@+id/recycler_view_translation_fragment" app:layoutManager="ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed" tools:context=".settings.TranslationFragment" />
\ No newline at end of file |