diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-08-20 03:02:00 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-08-20 03:02:00 +0000 |
commit | 24348b256fd1db6c395fc22304fe425b13b82edc (patch) | |
tree | 01f2c4a7af8c516288eec6e8dbe9ed242e3016a4 /app/src/main | |
parent | aad5a6200b053b18646f72fd842b7c4ae4e82a84 (diff) | |
download | infinity-for-reddit-24348b256fd1db6c395fc22304fe425b13b82edc.tar infinity-for-reddit-24348b256fd1db6c395fc22304fe425b13b82edc.tar.gz infinity-for-reddit-24348b256fd1db6c395fc22304fe425b13b82edc.tar.bz2 infinity-for-reddit-24348b256fd1db6c395fc22304fe425b13b82edc.tar.lz infinity-for-reddit-24348b256fd1db6c395fc22304fe425b13b82edc.tar.xz infinity-for-reddit-24348b256fd1db6c395fc22304fe425b13b82edc.tar.zst infinity-for-reddit-24348b256fd1db6c395fc22304fe425b13b82edc.zip |
Set different main tabs for different users.
Diffstat (limited to 'app/src/main')
12 files changed, 965 insertions, 46 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java index 5daee793..d86168ee 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -169,6 +169,9 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb @Named("post_layout") SharedPreferences mPostLayoutSharedPreferences; @Inject + @Named("main_activity_tabs") + SharedPreferences mMainActivityTabsSharedPreferences; + @Inject CustomThemeWrapper mCustomThemeWrapper; private SectionsPagerAdapter sectionsPagerAdapter; private AppBarLayout.LayoutParams params; @@ -955,22 +958,23 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } if (position == 0) { - String postType = mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME); - String name = mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, ""); + int postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME); + String name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, ""); return generatePostFragment(postType, name); } else if (position == 1) { - String postType = mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR); - String name = mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, ""); + int postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR); + String name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, ""); return generatePostFragment(postType, name); } else { - String postType = mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL); - String name = mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, ""); + int postType = mMainActivityTabsSharedPreferences.getInt((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL); + String name = mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, ""); return generatePostFragment(postType, name); } } - private Fragment generatePostFragment(String postType, String name) { - if (postType.equals(SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME)) { + private Fragment generatePostFragment(int postType, String name) { + + if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME) { PostFragment fragment = new PostFragment(); Bundle bundle = new Bundle(); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE); @@ -979,7 +983,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); return fragment; - } else if (postType.equals(SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL)) { + } else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL) { PostFragment fragment = new PostFragment(); Bundle bundle = new Bundle(); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT); @@ -989,7 +993,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); return fragment; - } else if (postType.equals(SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT)) { + } else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT) { PostFragment fragment = new PostFragment(); Bundle bundle = new Bundle(); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT); @@ -999,7 +1003,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); return fragment; - } else if (postType.equals(SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT)) { + } else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT) { PostFragment fragment = new PostFragment(); Bundle bundle = new Bundle(); bundle.putString(PostFragment.EXTRA_NAME, name); @@ -1009,7 +1013,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName); fragment.setArguments(bundle); return fragment; - } else if (postType.equals(SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_USER)) { + } else if (postType == SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_USER) { PostFragment fragment = new PostFragment(); Bundle bundle = new Bundle(); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_USER); @@ -1053,11 +1057,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } else { switch (position) { case 0: - return mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)); + return mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)); case 1: - return mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular)); + return mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular)); case 2: - return mSharedPreferences.getString(SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)); + return mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)); } } return null; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java index 4e59c42b..d93374c4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java @@ -21,11 +21,14 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.Settings.AboutPreferenceFragment; +import ml.docilealligator.infinityforreddit.Settings.CustomizeMainPageTabsTestFragment; import ml.docilealligator.infinityforreddit.Settings.FontPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.InterfacePreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment; @@ -39,11 +42,15 @@ public class SettingsActivity extends BaseActivity implements AppBarLayout appBarLayout; @BindView(R.id.toolbar_settings_activity) Toolbar toolbar; + private boolean mNullAccountName; + private String mAccountName; @Inject @Named("default") SharedPreferences mSharedPreferences; @Inject + RedditDataRoomDatabase mRedditDataRoomDatabase; + @Inject CustomThemeWrapper mCustomThemeWrapper; @Override @@ -68,14 +75,7 @@ public class SettingsActivity extends BaseActivity implements setSupportActionBar(toolbar); - if (savedInstanceState == null) { - getSupportFragmentManager() - .beginTransaction() - .replace(R.id.frame_layout_settings_activity, new MainPreferenceFragment()) - .commit(); - } else { - setTitle(savedInstanceState.getCharSequence(TITLE_STATE)); - } + getCurrentAccountAndBindView(savedInstanceState); getSupportFragmentManager().addOnBackStackChangedListener(() -> { if (getSupportFragmentManager().getBackStackEntryCount() == 0) { @@ -90,6 +90,25 @@ public class SettingsActivity extends BaseActivity implements }); } + private void getCurrentAccountAndBindView(Bundle savedInstanceState) { + new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> { + if (account == null) { + mNullAccountName = true; + } else { + mAccountName = account.getUsername(); + } + + if (savedInstanceState == null) { + getSupportFragmentManager() + .beginTransaction() + .replace(R.id.frame_layout_settings_activity, new MainPreferenceFragment()) + .commit(); + } else { + setTitle(savedInstanceState.getCharSequence(TITLE_STATE)); + } + }).execute(); + } + @Override public SharedPreferences getDefaultSharedPreferences() { return mSharedPreferences; @@ -135,6 +154,9 @@ public class SettingsActivity extends BaseActivity implements final Fragment fragment = getSupportFragmentManager().getFragmentFactory().instantiate( getClassLoader(), pref.getFragment()); + if (fragment instanceof CustomizeMainPageTabsTestFragment) { + args.putString(CustomizeMainPageTabsTestFragment.EXTRA_ACCOUNT_NAME, mAccountName); + } fragment.setArguments(args); fragment.setTargetFragment(caller, 0); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java index 2952e741..5e9dcd45 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java @@ -58,6 +58,7 @@ import ml.docilealligator.infinityforreddit.Service.DownloadVideoService; import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import ml.docilealligator.infinityforreddit.Settings.AdvancedPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.CustomizeMainPageTabsFragment; +import ml.docilealligator.infinityforreddit.Settings.CustomizeMainPageTabsTestFragment; import ml.docilealligator.infinityforreddit.Settings.GesturesAndButtonsPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment; import ml.docilealligator.infinityforreddit.Settings.NotificationPreferenceFragment; @@ -188,4 +189,6 @@ public interface AppComponent { void inject(ViewRedditGalleryActivity viewRedditGalleryActivity); void inject(ViewRedditGalleryVideoFragment viewRedditGalleryVideoFragment); + + void inject(CustomizeMainPageTabsTestFragment customizeMainPageTabsTestFragment); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java index d5e7dfad..44c86977 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java @@ -206,6 +206,12 @@ class AppModule { } @Provides + @Named("main_activity_tabs") + SharedPreferences provideMainActivityTabsSharedPreferences() { + return mApplication.getSharedPreferences(SharedPreferencesUtils.MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE); + } + + @Provides @Singleton CustomThemeWrapper provideCustomThemeWrapper(@Named("light_theme") SharedPreferences lightThemeSharedPreferences, @Named("dark_theme") SharedPreferences darkThemeSharedPreferences, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeMainPageTabsFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeMainPageTabsFragment.java index 33ad2ea9..96226448 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeMainPageTabsFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeMainPageTabsFragment.java @@ -6,8 +6,6 @@ import android.os.Bundle; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import androidx.preference.EditTextPreference; -import androidx.preference.ListPreference; import androidx.preference.PreferenceFragmentCompat; import javax.inject.Inject; @@ -15,9 +13,6 @@ import javax.inject.Named; import ml.docilealligator.infinityforreddit.Activity.SettingsActivity; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; -import ml.docilealligator.infinityforreddit.Infinity; -import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; /** * A simple {@link Fragment} subclass. @@ -33,7 +28,7 @@ public class CustomizeMainPageTabsFragment extends PreferenceFragmentCompat { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { - setPreferencesFromResource(R.xml.customize_main_page_tabs_preferences, rootKey); + /*setPreferencesFromResource(R.xml.customize_main_page_tabs_preferences, rootKey); ((Infinity) activity.getApplication()).getAppComponent().inject(this); @@ -156,7 +151,7 @@ public class CustomizeMainPageTabsFragment extends PreferenceFragmentCompat { } return true; }); - } + }*/ } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeMainPageTabsTestFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeMainPageTabsTestFragment.java new file mode 100644 index 00000000..88baf556 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CustomizeMainPageTabsTestFragment.java @@ -0,0 +1,501 @@ +package ml.docilealligator.infinityforreddit.Settings; + +import android.app.Activity; +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + +import javax.inject.Inject; +import javax.inject.Named; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.Infinity; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; + +public class CustomizeMainPageTabsTestFragment extends Fragment { + + public static final String EXTRA_ACCOUNT_NAME = "EAN"; + + @BindView(R.id.info_text_view_customize_main_page_tabs_fragment) + TextView infoTextView; + @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_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_summary_text_view_customize_main_page_tabs_fragment) + TextView tab1TypeSummaryTextView; + @BindView(R.id.tab_1_name_linear_layout_customize_main_page_tabs_fragment) + LinearLayout tab1NameLinearLayout; + @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.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_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_summary_text_view_customize_main_page_tabs_fragment) + TextView tab2TypeSummaryTextView; + @BindView(R.id.tab_2_name_linear_layout_customize_main_page_tabs_fragment) + LinearLayout tab2NameLinearLayout; + @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.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_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_summary_text_view_customize_main_page_tabs_fragment) + TextView tab3TypeSummaryTextView; + @BindView(R.id.tab_3_name_linear_layout_customize_main_page_tabs_fragment) + LinearLayout tab3NameLinearLayout; + @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; + @Inject + @Named("main_activity_tabs") + SharedPreferences sharedPreferences; + private Activity activity; + private String tab1CurrentTitle; + private int tab1CurrentPostType; + private String tab1CurrentName; + private String tab2CurrentTitle; + private int tab2CurrentPostType; + private String tab2CurrentName; + private String tab3CurrentTitle; + private int tab3CurrentPostType; + private String tab3CurrentName; + + public CustomizeMainPageTabsTestFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View rootView = inflater.inflate(R.layout.fragment_customize_main_page_tabs_test, container, false); + + ((Infinity) activity.getApplication()).getAppComponent().inject(this); + + ButterKnife.bind(this, rootView); + + String accountName = getArguments().getString(EXTRA_ACCOUNT_NAME); + + if (accountName == null) { + infoTextView.setText(R.string.settings_customize_tabs_in_main_page_summary); + divider1.setVisibility(View.GONE); + tab1GroupSummaryTextView.setVisibility(View.GONE); + tab1TitleLinearLayout.setVisibility(View.GONE); + tab1TypeLinearLayout.setVisibility(View.GONE); + divider2.setVisibility(View.GONE); + tab2GroupSummaryTextView.setVisibility(View.GONE); + tab2TitleLinearLayout.setVisibility(View.GONE); + tab2TypeLinearLayout.setVisibility(View.GONE); + divider3.setVisibility(View.GONE); + tab3GroupSummaryTextView.setVisibility(View.GONE); + tab3TitleLinearLayout.setVisibility(View.GONE); + tab3TypeLinearLayout.setVisibility(View.GONE); + + return rootView; + } + + String[] typeValues = activity.getResources().getStringArray(R.array.settings_tab_post_type); + + tab1CurrentTitle = sharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)); + tab1CurrentPostType = sharedPreferences.getInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_HOME); + tab1CurrentName = sharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, ""); + tab1TypeSummaryTextView.setText(typeValues[tab1CurrentPostType]); + tab1TitleSummaryTextView.setText(tab1CurrentTitle); + tab1NameSummaryTextView.setText(tab1CurrentName); + applyTab1NameView(tab1NameLinearLayout, tab1NameTitleTextView, 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 -> { + editText.setHint(R.string.settings_tab_title); + editText.setText(tab1CurrentTitle); + editText.requestFocus(); + InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); + if (imm != null) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + } + if (dialogView.getParent() != null) { + ((ViewGroup) dialogView.getParent()).removeView(dialogView); + } + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_tab_title) + .setView(dialogView) + .setPositiveButton(R.string.ok, (dialogInterface, i) + -> { + tab1CurrentTitle = editText.getText().toString(); + sharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, tab1CurrentTitle).apply(); + tab1TitleSummaryTextView.setText(tab1CurrentTitle); + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + }) + .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + }) + .show(); + }); + + tab1TypeLinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_tab_title) + .setSingleChoiceItems(typeValues, tab1CurrentPostType, (dialogInterface, i) -> { + tab1CurrentPostType = i; + sharedPreferences.edit().putInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_POST_TYPE, i).apply(); + tab1TypeSummaryTextView.setText(typeValues[i]); + applyTab1NameView(tab1NameLinearLayout, tab1NameTitleTextView, i); + dialogInterface.dismiss(); + }) + .setNegativeButton(R.string.cancel, null) + .show(); + }); + + tab1NameLinearLayout.setOnClickListener(view -> { + int titleId; + switch (tab1CurrentPostType) { + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: + titleId = R.string.settings_tab_subreddit_name; + break; + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT: + titleId = R.string.settings_tab_multi_reddit_name; + break; + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_USER: + titleId = R.string.settings_tab_username; + break; + default: + return; + } + editText.setText(tab1CurrentName); + editText.setHint(titleId); + editText.requestFocus(); + InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); + if (imm != null) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + } + if (dialogView.getParent() != null) { + ((ViewGroup) dialogView.getParent()).removeView(dialogView); + } + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(titleId) + .setView(dialogView) + .setPositiveButton(R.string.ok, (dialogInterface, i) + -> { + tab1CurrentName = editText.getText().toString(); + sharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply(); + tab1NameSummaryTextView.setText(tab1CurrentName); + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + }) + .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + }) + .show(); + }); + + tab2CurrentTitle = sharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.popular)); + tab2CurrentPostType = sharedPreferences.getInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_POPULAR); + tab2CurrentName = sharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, ""); + tab2TypeSummaryTextView.setText(typeValues[tab2CurrentPostType]); + tab2TitleSummaryTextView.setText(tab2CurrentTitle); + tab2NameSummaryTextView.setText(tab2CurrentName); + applyTab2NameView(tab2NameLinearLayout, tab2NameTitleTextView, tab2CurrentPostType); + + tab2TitleLinearLayout.setOnClickListener(view -> { + editText.setHint(R.string.settings_tab_title); + editText.setText(tab2CurrentTitle); + editText.requestFocus(); + InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); + if (imm != null) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + } + if (dialogView.getParent() != null) { + ((ViewGroup) dialogView.getParent()).removeView(dialogView); + } + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_tab_title) + .setView(dialogView) + .setPositiveButton(R.string.ok, (dialogInterface, i) + -> { + tab2CurrentTitle = editText.getText().toString(); + sharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, tab2CurrentTitle).apply(); + tab2TitleSummaryTextView.setText(tab2CurrentTitle); + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + }) + .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + }) + .show(); + }); + + tab2TypeLinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_tab_title) + .setSingleChoiceItems(typeValues, tab2CurrentPostType, (dialogInterface, i) -> { + tab2CurrentPostType = i; + sharedPreferences.edit().putInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_POST_TYPE, i).apply(); + tab2TypeSummaryTextView.setText(typeValues[i]); + applyTab2NameView(tab2NameLinearLayout, tab2NameTitleTextView, i); + dialogInterface.dismiss(); + }) + .setNegativeButton(R.string.cancel, null) + .show(); + }); + + tab2NameLinearLayout.setOnClickListener(view -> { + int titleId; + switch (tab2CurrentPostType) { + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: + titleId = R.string.settings_tab_subreddit_name; + break; + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT: + titleId = R.string.settings_tab_multi_reddit_name; + break; + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_USER: + titleId = R.string.settings_tab_username; + break; + default: + return; + } + editText.setText(tab2CurrentName); + editText.setHint(titleId); + editText.requestFocus(); + InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); + if (imm != null) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + } + if (dialogView.getParent() != null) { + ((ViewGroup) dialogView.getParent()).removeView(dialogView); + } + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(titleId) + .setView(dialogView) + .setPositiveButton(R.string.ok, (dialogInterface, i) + -> { + tab2CurrentName = editText.getText().toString(); + sharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply(); + tab2NameSummaryTextView.setText(tab2CurrentName); + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + }) + .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + }) + .show(); + }); + + tab3CurrentTitle = sharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, getString(R.string.all)); + tab3CurrentPostType = sharedPreferences.getInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_ALL); + tab3CurrentName = sharedPreferences.getString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, ""); + tab3TypeSummaryTextView.setText(typeValues[tab3CurrentPostType]); + tab3TitleSummaryTextView.setText(tab3CurrentTitle); + tab3NameSummaryTextView.setText(tab3CurrentName); + applyTab3NameView(tab3NameLinearLayout, tab3NameTitleTextView, tab3CurrentPostType); + + tab3TitleLinearLayout.setOnClickListener(view -> { + editText.setHint(R.string.settings_tab_title); + editText.setText(tab3CurrentTitle); + editText.requestFocus(); + InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); + if (imm != null) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + } + if (dialogView.getParent() != null) { + ((ViewGroup) dialogView.getParent()).removeView(dialogView); + } + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_tab_title) + .setView(dialogView) + .setPositiveButton(R.string.ok, (dialogInterface, i) + -> { + tab3CurrentTitle = editText.getText().toString(); + sharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_TITLE, tab3CurrentTitle).apply(); + tab3TitleSummaryTextView.setText(tab3CurrentTitle); + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + }) + .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + }) + .show(); + }); + + tab3TypeLinearLayout.setOnClickListener(view -> { + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(R.string.settings_tab_title) + .setSingleChoiceItems(typeValues, tab3CurrentPostType, (dialogInterface, i) -> { + tab3CurrentPostType = i; + sharedPreferences.edit().putInt((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_POST_TYPE, i).apply(); + tab3TypeSummaryTextView.setText(typeValues[i]); + applyTab3NameView(tab3NameLinearLayout, tab3NameTitleTextView, i); + dialogInterface.dismiss(); + }) + .setNegativeButton(R.string.cancel, null) + .show(); + }); + + tab3NameLinearLayout.setOnClickListener(view -> { + int titleId; + switch (tab3CurrentPostType) { + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: + titleId = R.string.settings_tab_subreddit_name; + break; + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT: + titleId = R.string.settings_tab_multi_reddit_name; + break; + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_USER: + titleId = R.string.settings_tab_username; + break; + default: + return; + } + editText.setText(tab3CurrentName); + editText.setHint(titleId); + editText.requestFocus(); + InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); + if (imm != null) { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + } + if (dialogView.getParent() != null) { + ((ViewGroup) dialogView.getParent()).removeView(dialogView); + } + new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme) + .setTitle(titleId) + .setView(dialogView) + .setPositiveButton(R.string.ok, (dialogInterface, i) + -> { + tab3CurrentName = editText.getText().toString(); + sharedPreferences.edit().putString((accountName == null ? "" : accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply(); + tab3NameSummaryTextView.setText(tab3CurrentName); + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + }) + .setNegativeButton(R.string.cancel, (dialogInterface, i) -> { + if (imm != null) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + } + }) + .show(); + }); + + return rootView; + } + + private void applyTab1NameView(LinearLayout linearLayout, TextView titleTextView, int postType) { + switch (postType) { + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: + linearLayout.setVisibility(View.VISIBLE); + titleTextView.setText(R.string.settings_tab_subreddit_name); + break; + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT: + linearLayout.setVisibility(View.VISIBLE); + titleTextView.setText(R.string.settings_tab_multi_reddit_name); + break; + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_USER: + linearLayout.setVisibility(View.VISIBLE); + titleTextView.setText(R.string.settings_tab_username); + break; + default: + linearLayout.setVisibility(View.GONE); + } + } + + private void applyTab2NameView(LinearLayout linearLayout, TextView titleTextView, int postType) { + switch (postType) { + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: + linearLayout.setVisibility(View.VISIBLE); + titleTextView.setText(R.string.settings_tab_subreddit_name); + break; + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT: + linearLayout.setVisibility(View.VISIBLE); + titleTextView.setText(R.string.settings_tab_multi_reddit_name); + break; + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_USER: + linearLayout.setVisibility(View.VISIBLE); + titleTextView.setText(R.string.settings_tab_username); + break; + default: + linearLayout.setVisibility(View.GONE); + } + } + + private void applyTab3NameView(LinearLayout linearLayout, TextView titleTextView, int postType) { + switch (postType) { + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT: + linearLayout.setVisibility(View.VISIBLE); + titleTextView.setText(R.string.settings_tab_subreddit_name); + break; + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT: + linearLayout.setVisibility(View.VISIBLE); + titleTextView.setText(R.string.settings_tab_multi_reddit_name); + break; + case SharedPreferencesUtils.MAIN_PAGE_TAB_POST_TYPE_USER: + linearLayout.setVisibility(View.VISIBLE); + titleTextView.setText(R.string.settings_tab_username); + break; + default: + linearLayout.setVisibility(View.GONE); + } + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + activity = (Activity) context; + } +}
\ No newline at end of file diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java index b6b5cd7f..617981bc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -115,21 +115,24 @@ public class SharedPreferencesUtils { public static final String DELETE_FRONT_PAGE_SCROLLED_POSITIONS_IN_DATABASE = "delete_front_page_scrolled_positions_in_database"; public static final String DELETE_ALL_LEGACY_SETTINGS = "delete_all_legacy_settings"; public static final String RESET_ALL_SETTINGS = "reset_all_settings"; - public static final String MAIN_PAGE_TAB_1_TITLE = "main_page_tab_1_title"; - public static final String MAIN_PAGE_TAB_2_TITLE = "main_page_tab_2_title"; - public static final String MAIN_PAGE_TAB_3_TITLE = "main_page_tab_3_title"; - public static final String MAIN_PAGE_TAB_1_POST_TYPE = "main_page_tab_1_post_type"; - public static final String MAIN_PAGE_TAB_2_POST_TYPE = "main_page_tab_2_post_type"; - public static final String MAIN_PAGE_TAB_3_POST_TYPE = "main_page_tab_3_post_type"; - public static final String MAIN_PAGE_TAB_1_NAME = "main_page_tab_1_name"; - public static final String MAIN_PAGE_TAB_2_NAME = "main_page_tab_2_name"; - public static final String MAIN_PAGE_TAB_3_NAME = "main_page_tab_3_name"; - public static final String MAIN_PAGE_TAB_POST_TYPE_HOME = "0"; - public static final String MAIN_PAGE_TAB_POST_TYPE_POPULAR = "1"; - public static final String MAIN_PAGE_TAB_POST_TYPE_ALL = "2"; - public static final String MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT = "3"; - public static final String MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT = "4"; - public static final String MAIN_PAGE_TAB_POST_TYPE_USER = "5"; + + public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; + public static final String MAIN_PAGE_TAB_1_TITLE = "_main_page_tab_1_title"; + public static final String MAIN_PAGE_TAB_2_TITLE = "_main_page_tab_2_title"; + public static final String MAIN_PAGE_TAB_3_TITLE = "_main_page_tab_3_title"; + public static final String MAIN_PAGE_TAB_1_POST_TYPE = "_main_page_tab_1_post_type"; + public static final String MAIN_PAGE_TAB_2_POST_TYPE = "_main_page_tab_2_post_type"; + public static final String MAIN_PAGE_TAB_3_POST_TYPE = "_main_page_tab_3_post_type"; + public static final String MAIN_PAGE_TAB_1_NAME = "_main_page_tab_1_name"; + public static final String MAIN_PAGE_TAB_2_NAME = "_main_page_tab_2_name"; + public static final String MAIN_PAGE_TAB_3_NAME = "_main_page_tab_3_name"; + public static final int MAIN_PAGE_TAB_POST_TYPE_HOME = 0; + public static final int MAIN_PAGE_TAB_POST_TYPE_POPULAR = 1; + public static final int MAIN_PAGE_TAB_POST_TYPE_ALL = 2; + public static final int MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT = 3; + public static final int MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT = 4; + public static final int MAIN_PAGE_TAB_POST_TYPE_USER = 5; + public static final String START_AUTOPLAY_VISIBLE_AREA_OFFSET_PORTRAIT = "start_autoplay_visible_area_offset_portrait"; public static final String START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE = "start_autoplay_visible_area_offset_landscape"; public static final String MUTE_NSFW_VIDEO = "mute_nsfw_video"; diff --git a/app/src/main/res/layout/dialog_edit_text.xml b/app/src/main/res/layout/dialog_edit_text.xml new file mode 100644 index 00000000..158ff59d --- /dev/null +++ b/app/src/main/res/layout/dialog_edit_text.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" android:layout_width="match_parent" + android:layout_height="match_parent"> + + <EditText + android:id="@+id/edit_text_edit_text_dialog" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_margin="24dp" + android:background="#00000000" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + +</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/fragment_customize_main_page_tabs_test.xml b/app/src/main/res/layout/fragment_customize_main_page_tabs_test.xml new file mode 100644 index 00000000..a9b10c8c --- /dev/null +++ b/app/src/main/res/layout/fragment_customize_main_page_tabs_test.xml @@ -0,0 +1,365 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".Settings.CustomizeMainPageTabsTestFragment"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:id="@+id/info_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + android:drawablePadding="32dp" + android:text="@string/settings_tab_info" + android:textColor="@color/settingsSubtitleColor" + android:gravity="center_vertical" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" + app:drawableStartCompat="@drawable/ic_info_preference_24dp" /> + + <View + android:id="@+id/divider_1_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="1dp" + android:background="@color/dividerColor" /> + + <TextView + android:id="@+id/tab_1_group_summary_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:text="@string/settings_tab_1_summary" + android:textColor="@color/colorAccent" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + <LinearLayout + android:id="@+id/tab_1_title_linear_layout_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/settings_tab_title" + android:textColor="@color/primaryTextColor" + android:textSize="?attr/font_18" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/tab_1_title_summary_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/tab_1_type_linear_layout_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/settings_tab_post_type" + android:textColor="@color/primaryTextColor" + android:textSize="?attr/font_18" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/tab_1_type_summary_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/tab_1_name_linear_layout_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" + android:visibility="gone"> + + <TextView + android:id="@+id/tab_1_name_title_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="@color/primaryTextColor" + android:textSize="?attr/font_18" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/tab_1_name_summary_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <View + android:id="@+id/divider_2_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="1dp" + android:background="@color/dividerColor" /> + + <TextView + android:id="@+id/tab_2_group_summary_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:text="@string/settings_tab_2_summary" + android:textColor="@color/colorAccent" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + <LinearLayout + android:id="@+id/tab_2_title_linear_layout_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/settings_tab_title" + android:textColor="@color/primaryTextColor" + android:textSize="?attr/font_18" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/tab_2_title_summary_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/tab_2_type_linear_layout_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/settings_tab_post_type" + android:textColor="@color/primaryTextColor" + android:textSize="?attr/font_18" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/tab_2_type_summary_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/tab_2_name_linear_layout_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" + android:visibility="gone"> + + <TextView + android:id="@+id/tab_2_name_title_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="@color/primaryTextColor" + android:textSize="?attr/font_18" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/tab_2_name_summary_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <View + android:id="@+id/divider_3_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="1dp" + android:background="@color/dividerColor" /> + + <TextView + android:id="@+id/tab_3_group_summary_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:text="@string/settings_tab_3_summary" + android:textColor="@color/colorAccent" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + <LinearLayout + android:id="@+id/tab_3_title_linear_layout_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/settings_tab_title" + android:textColor="@color/primaryTextColor" + android:textSize="?attr/font_18" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/tab_3_title_summary_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/tab_3_type_linear_layout_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/settings_tab_post_type" + android:textColor="@color/primaryTextColor" + android:textSize="?attr/font_18" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/tab_3_type_summary_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + <LinearLayout + android:id="@+id/tab_3_name_linear_layout_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="72dp" + android:paddingEnd="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" + android:visibility="gone"> + + <TextView + android:id="@+id/tab_3_name_title_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="@color/primaryTextColor" + android:textSize="?attr/font_18" + android:fontFamily="?attr/font_family" /> + + <TextView + android:id="@+id/tab_3_name_summary_text_view_customize_main_page_tabs_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" + android:fontFamily="?attr/font_family" /> + + </LinearLayout> + + </LinearLayout> + +</androidx.core.widget.NestedScrollView>
\ No newline at end of file diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 4ab1f8bd..e4d0fdcd 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -9,4 +9,6 @@ <color name="playButtonBackgroundColor">#FFFFFF</color> <color name="roundedBottomSheetPrimaryBackground">#242424</color> <color name="primaryTextColor">#FFFFFF</color> + <color name="settingsSubtitleColor">#4DFFFFFF</color> + <color name="dividerColor">#69666c</color> </resources> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c940e5fa..03423272 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -10,4 +10,6 @@ <color name="roundedBottomSheetPrimaryBackground">#FFFFFF</color> <color name="roundedBottomSheetPrimaryNavigationBarColor">#000000</color> <color name="primaryTextColor">#000000</color> + <color name="settingsSubtitleColor">#42000000</color> + <color name="dividerColor">#E0E0E0</color> </resources> diff --git a/app/src/main/res/xml/interface_preference.xml b/app/src/main/res/xml/interface_preference.xml index 2e5c71e3..10efc01f 100644 --- a/app/src/main/res/xml/interface_preference.xml +++ b/app/src/main/res/xml/interface_preference.xml @@ -16,7 +16,7 @@ <Preference app:title="@string/settings_customize_tabs_in_main_page_title" app:summary="@string/settings_customize_tabs_in_main_page_summary" - app:fragment="ml.docilealligator.infinityforreddit.Settings.CustomizeMainPageTabsFragment" /> + app:fragment="ml.docilealligator.infinityforreddit.Settings.CustomizeMainPageTabsTestFragment" /> <SwitchPreference app:defaultValue="false" |