diff options
Diffstat (limited to 'app/src/main/java/ml')
17 files changed, 646 insertions, 38 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java index 3849e5f0..e1f87b21 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java @@ -230,7 +230,7 @@ public abstract class BaseActivity extends AppCompatActivity { } protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) { - appBarLayout.setBackgroundColor(customThemeWrapper.getToolbarAndTabBackgroundColor()); + appBarLayout.setBackgroundColor(customThemeWrapper.getColorPrimary()); toolbar.setTitleTextColor(customThemeWrapper.getToolbarPrimaryTextAndIconColor()); if (toolbar.getNavigationIcon() != null) { toolbar.getNavigationIcon().setColorFilter(customThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN); @@ -259,7 +259,7 @@ public abstract class BaseActivity extends AppCompatActivity { } protected void applyTabLayoutTheme(TabLayout tabLayout) { - int toolbarAndTabBackgroundColor = customThemeWrapper.getToolbarAndTabBackgroundColor(); + int toolbarAndTabBackgroundColor = customThemeWrapper.getColorPrimary(); tabLayout.setBackgroundColor(toolbarAndTabBackgroundColor); tabLayout.setSelectedTabIndicatorColor(customThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabIndicator()); tabLayout.setTabTextColors(customThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor(), diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java new file mode 100644 index 00000000..530d947a --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java @@ -0,0 +1,125 @@ +package ml.docilealligator.infinityforreddit.Activity; + +import android.content.SharedPreferences; +import android.os.Build; +import android.os.Bundle; + +import androidx.appcompat.widget.Toolbar; +import androidx.lifecycle.LiveData; +import androidx.lifecycle.Observer; +import androidx.lifecycle.ViewModelProvider; +import androidx.recyclerview.widget.RecyclerView; + +import com.google.android.material.appbar.AppBarLayout; + +import java.util.ArrayList; + +import javax.inject.Inject; +import javax.inject.Named; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.Adapter.CustomizeThemeRecyclerViewAdapter; +import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme; +import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeSettingsItem; +import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeViewModel; +import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.Infinity; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; + +public class CustomizeThemeActivity extends BaseActivity { + + public static final String EXTRA_THEME_TYPE = "ETT"; + public static final int EXTRA_LIGHT_THEME = 0; + public static final int EXTRA_DARK_THEME = 1; + public static final int EXTRA_AMOLED_THEME = 2; + + @BindView(R.id.appbar_layout_customize_theme_activity) + AppBarLayout appBarLayout; + @BindView(R.id.toolbar_customize_theme_activity) + Toolbar toolbar; + @BindView(R.id.recycler_view_customize_theme_activity) + RecyclerView recyclerView; + @Inject + @Named("default") + SharedPreferences sharedPreferences; + @Inject + RedditDataRoomDatabase redditDataRoomDatabase; + @Inject + CustomThemeWrapper customThemeWrapper; + + public CustomThemeViewModel customThemeViewModel; + private CustomizeThemeRecyclerViewAdapter adapter; + private int themeType; + + @Override + protected void onCreate(Bundle savedInstanceState) { + ((Infinity) getApplication()).getAppComponent().inject(this); + + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_customize_theme); + + ButterKnife.bind(this); + + applyCustomTheme(); + + themeType = getIntent().getIntExtra(EXTRA_THEME_TYPE, EXTRA_LIGHT_THEME); + + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + adapter = new CustomizeThemeRecyclerViewAdapter(); + + customThemeViewModel = new ViewModelProvider(this, new CustomThemeViewModel.Factory(redditDataRoomDatabase)) + .get(CustomThemeViewModel.class); + + LiveData<CustomTheme> customThemeLiveData; + switch (themeType) { + case EXTRA_DARK_THEME: + toolbar.setTitle(getString(R.string.customize_dark_theme_fragment_title)); + customThemeLiveData = customThemeViewModel.getDarkCustomTheme(); + break; + case EXTRA_AMOLED_THEME: + toolbar.setTitle(getString(R.string.customize_amoled_theme_fragment_title)); + customThemeLiveData = customThemeViewModel.getAmoledCustomTheme(); + break; + default: + toolbar.setTitle(getString(R.string.customize_light_theme_fragment_title)); + customThemeLiveData = customThemeViewModel.getLightCustomTheme(); + break; + } + + int androidVersion = Build.VERSION.SDK_INT; + customThemeLiveData.observe(this, new Observer<CustomTheme>() { + @Override + public void onChanged(CustomTheme customTheme) { + ArrayList<CustomThemeSettingsItem> customThemeSettingsItems = + CustomThemeSettingsItem.convertCustomTheme(CustomizeThemeActivity.this, customTheme); + if (androidVersion < Build.VERSION_CODES.O) { + customThemeSettingsItems.get(customThemeSettingsItems.size() - 2).itemDetails = getString(R.string.theme_item_available_on_android_8); + } + if (androidVersion < Build.VERSION_CODES.M) { + customThemeSettingsItems.get(customThemeSettingsItems.size() - 3).itemDetails = getString(R.string.theme_item_available_on_android_6); + } + + adapter.setCustomThemeSettingsItem(customThemeSettingsItems); + } + }); + } + + @Override + protected SharedPreferences getSharedPreferences() { + return sharedPreferences; + } + + @Override + protected CustomThemeWrapper getCustomThemeWrapper() { + return customThemeWrapper; + } + + @Override + protected void applyCustomTheme() { + applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); + } +} 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 1a678afe..c8ad39c5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java @@ -7,7 +7,6 @@ import android.view.MenuItem; import androidx.annotation.NonNull; import androidx.appcompat.widget.Toolbar; -import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.fragment.app.Fragment; import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; @@ -31,8 +30,6 @@ public class SettingsActivity extends BaseActivity implements private static final String TITLE_STATE = "TS"; - @BindView(R.id.coordinator_layout_settings_activity) - CoordinatorLayout coordinatorLayout; @BindView(R.id.appbar_layout_settings_activity) AppBarLayout appBarLayout; @BindView(R.id.toolbar_settings_activity) @@ -96,7 +93,6 @@ public class SettingsActivity extends BaseActivity implements @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index 75564f05..7b89c940 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -303,7 +303,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mSpoilerTextColor = customThemeWrapper.getSpoilerTextColor(); mNSFWBackgroundColor = customThemeWrapper.getNsfwBackgroundColor(); mNSFWTextColor = customThemeWrapper.getNsfwTextColor(); - mArchivedTintColor = customThemeWrapper.getArchivedTint(); + mArchivedTintColor = customThemeWrapper.getArchivedIconTint(); mLockedTintColor = customThemeWrapper.getLockedIconTint(); mCrosspostTintColor = customThemeWrapper.getCrosspostIconTint(); mNoPreviewLinkBackgroundColor = customThemeWrapper.getNoPreviewLinkBackgroundColor(); @@ -321,7 +321,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mCommentVerticalBarColor6 = customThemeWrapper.getCommentVerticalBarColor6(); mCommentVerticalBarColor7 = customThemeWrapper.getCommentVerticalBarColor7(); mSingleCommentThreadBackgroundColor = customThemeWrapper.getSingleCommentThreadBackgroundColor(); - mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableVoteButtonColor(); + mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor(); mButtonTextColor = customThemeWrapper.getButtonTextColor(); mPostIconAndInfoColor = customThemeWrapper.getPostIconAndInfoColor(); mCommentIconAndInfoColor = customThemeWrapper.getCommentIconAndInfoColor(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java new file mode 100644 index 00000000..5bb55eea --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java @@ -0,0 +1,107 @@ +package ml.docilealligator.infinityforreddit.Adapter; + +import android.content.res.ColorStateList; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Switch; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeSettingsItem; +import ml.docilealligator.infinityforreddit.R; + +public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { + private static final int VIEW_TYPE_COLOR = 1; + private static final int VIEW_TYPE_SWITCH = 2; + private ArrayList<CustomThemeSettingsItem> customThemeSettingsItems; + + public CustomizeThemeRecyclerViewAdapter() { + customThemeSettingsItems = new ArrayList<>(); + } + + @Override + public int getItemViewType(int position) { + if (position < customThemeSettingsItems.size() - 3) { + return VIEW_TYPE_COLOR; + } + + return VIEW_TYPE_SWITCH; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + if (viewType == VIEW_TYPE_SWITCH) { + return new ThemeSwitchItemViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_theme_color_item, parent, false)); + } + + return new ThemeColorItemViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_theme_color_item, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + if (holder instanceof ThemeColorItemViewHolder) { + CustomThemeSettingsItem customThemeSettingsItem = customThemeSettingsItems.get(position); + ((ThemeColorItemViewHolder) holder).themeItemNameTextView.setText(customThemeSettingsItem.itemName); + ((ThemeColorItemViewHolder) holder).themeItemInfoTextView.setText(customThemeSettingsItem.itemDetails); + ((ThemeColorItemViewHolder) holder).colorImageView.setBackgroundTintList(ColorStateList.valueOf(customThemeSettingsItem.colorValue)); + holder.itemView.setOnClickListener(view -> { + + }); + } else if (holder instanceof ThemeSwitchItemViewHolder) { + CustomThemeSettingsItem customThemeSettingsItem = customThemeSettingsItems.get(position); + ((ThemeSwitchItemViewHolder) holder).themeItemNameTextView.setText(customThemeSettingsItem.itemName); + ((ThemeSwitchItemViewHolder) holder).themeItemInfoTextView.setText(customThemeSettingsItem.itemName); + ((ThemeSwitchItemViewHolder) holder).themeItemSwitch.setChecked(customThemeSettingsItem.isEnabled); + ((ThemeSwitchItemViewHolder) holder).themeItemSwitch.setOnClickListener(view -> customThemeSettingsItem.isEnabled = ((ThemeSwitchItemViewHolder) holder).themeItemSwitch.isChecked()); + holder.itemView.setOnClickListener(view -> ((ThemeSwitchItemViewHolder) holder).themeItemSwitch.performClick()); + } + } + + @Override + public int getItemCount() { + return customThemeSettingsItems.size(); + } + + public void setCustomThemeSettingsItem(ArrayList<CustomThemeSettingsItem> customThemeSettingsItems) { + this.customThemeSettingsItems.clear(); + notifyDataSetChanged(); + this.customThemeSettingsItems.addAll(customThemeSettingsItems); + notifyDataSetChanged(); + } + + class ThemeColorItemViewHolder extends RecyclerView.ViewHolder { + @BindView(R.id.color_image_view_item_theme_color_item) + View colorImageView; + @BindView(R.id.theme_item_name_text_view_item_theme_color_item) + TextView themeItemNameTextView; + @BindView(R.id.theme_item_info_text_view_item_theme_color_item) + TextView themeItemInfoTextView; + + ThemeColorItemViewHolder(@NonNull View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + } + } + + class ThemeSwitchItemViewHolder extends RecyclerView.ViewHolder { + @BindView(R.id.theme_item_name_text_view_item_theme_switch_item) + TextView themeItemNameTextView; + @BindView(R.id.theme_item_info_text_view_item_theme_switch_item) + TextView themeItemInfoTextView; + @BindView(R.id.theme_item_switch_item_theme_switch_item) + Switch themeItemSwitch; + + ThemeSwitchItemViewHolder(@NonNull View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + } + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java index c374282d..a5504f4a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -180,13 +180,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView mFlairTextColor = customThemeWrapper.getFlairTextColor(); mNSFWBackgroundColor = customThemeWrapper.getNsfwBackgroundColor(); mNSFWTextColor = customThemeWrapper.getNsfwTextColor(); - mArchivedIconTint = customThemeWrapper.getArchivedTint(); + mArchivedIconTint = customThemeWrapper.getArchivedIconTint(); mLockedIconTint = customThemeWrapper.getLockedIconTint(); mCrosspostIconTint = customThemeWrapper.getCrosspostIconTint(); mNoPreviewLinkBackgroundColor = customThemeWrapper.getNoPreviewLinkBackgroundColor(); mUpvotedColor = customThemeWrapper.getUpvoted(); mDownvotedColor = customThemeWrapper.getDownvoted(); - mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableVoteButtonColor(); + mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor(); mButtonTextColor = customThemeWrapper.getButtonTextColor(); mPostIconAndInfoColor = customThemeWrapper.getPostIconAndInfoColor(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java index c5c68959..80c6c6c7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java @@ -7,6 +7,7 @@ import ml.docilealligator.infinityforreddit.Activity.AccountPostsActivity; import ml.docilealligator.infinityforreddit.Activity.AccountSavedThingActivity; import ml.docilealligator.infinityforreddit.Activity.CommentActivity; import ml.docilealligator.infinityforreddit.Activity.CreateMultiRedditActivity; +import ml.docilealligator.infinityforreddit.Activity.CustomizeThemeActivity; import ml.docilealligator.infinityforreddit.Activity.EditCommentActivity; import ml.docilealligator.infinityforreddit.Activity.EditPostActivity; import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity; @@ -140,4 +141,6 @@ public interface AppComponent { void inject(SubredditMultiselectionActivity subredditMultiselectionActivity); void inject(ThemePreferenceFragment themePreferenceFragment); + + void inject(CustomizeThemeActivity customizeThemeActivity); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java index 94f4bac9..bb7da9db 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java @@ -47,12 +47,14 @@ public class CustomTheme { public int bottomAppBarBackgroundColor; @ColumnInfo(name = "primary_icon_color") public int primaryIconColor; + @ColumnInfo(name = "post_icon_and_info_color") + public int postIconAndInfoColor; @ColumnInfo(name = "comment_icon_and_info_color") public int commentIconAndInfoColor; @ColumnInfo(name = "toolbar_primary_text_and_icon_color") public int toolbarPrimaryTextAndIconColor; - @ColumnInfo(name = "toolbar_and_tab_background_color") - public int toolbarAndTabBackgroundColor; + @ColumnInfo(name = "toolbar_secondary_text_color") + public int toolbarSecondaryTextColor; @ColumnInfo(name = "circular_progress_bar_background") public int circularProgressBarBackground; @ColumnInfo(name = "tab_layout_with_expanded_collapsing_toolbar_tab_background") @@ -119,8 +121,8 @@ public class CustomTheme { public int dividerColor; @ColumnInfo(name = "no_preview_link_background_color") public int noPreviewLinkBackgroundColor; - @ColumnInfo(name = "vote_and_reply_unavailable_vote_button_color") - public int voteAndReplyUnavailableVoteButtonColor; + @ColumnInfo(name = "vote_and_reply_unavailable_button_color") + public int voteAndReplyUnavailableButtonColor; @ColumnInfo(name = "comment_vertical_bar_color_1") public int commentVerticalBarColor1; @ColumnInfo(name = "comment_vertical_bar_color_2") @@ -140,11 +142,11 @@ public class CustomTheme { @ColumnInfo(name = "chip_text_color") public int chipTextColor; @ColumnInfo(name = "is_light_status_bar") - public int isLightStatusBar; + public boolean isLightStatusBar; @ColumnInfo(name = "is_light_nav_bar") - public int isLightNavBar; + public boolean isLightNavBar; @ColumnInfo(name = "is_change_status_bar_icon_color_after_toolbar_collapsed_in_immersive_interface") - public int isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface; + public boolean isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface; public CustomTheme(@NonNull String name) { this.name = name; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeDao.java index f1afb3c4..4525cf81 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeDao.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeDao.java @@ -16,6 +16,15 @@ public interface CustomThemeDao { @Query("SELECT * FROM custom_themes") LiveData<List<CustomTheme>> getAllCustomThemes(); + @Query("SELECT * FROM custom_themes WHERE is_light_theme = 1 LIMIT 1") + LiveData<CustomTheme> getLightCustomTheme(); + + @Query("SELECT * FROM custom_themes WHERE is_dark_theme = 1 LIMIT 1") + LiveData<CustomTheme> getDarkCustomTheme(); + + @Query("SELECT * FROM custom_themes WHERE is_amoled_theme = 1 LIMIT 1") + LiveData<CustomTheme> getAmoledCustomTheme(); + @Query("SELECT * FROM custom_themes WHERE name = :name AND username = :username COLLATE NOCASE LIMIT 1") CustomTheme getCustomTheme(String name, String username); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeRepository.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeRepository.java index e2c0b692..cedc4513 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeRepository.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeRepository.java @@ -8,12 +8,30 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; public class CustomThemeRepository { private LiveData<List<CustomTheme>> mAllCustomThemes; + private LiveData<CustomTheme> mLightCustomTheme; + private LiveData<CustomTheme> mDarkCustomTheme; + private LiveData<CustomTheme> mAmoledCustomTheme; CustomThemeRepository(RedditDataRoomDatabase redditDataRoomDatabase) { mAllCustomThemes = redditDataRoomDatabase.customThemeDao().getAllCustomThemes(); + mLightCustomTheme = redditDataRoomDatabase.customThemeDao().getLightCustomTheme(); + mDarkCustomTheme = redditDataRoomDatabase.customThemeDao().getDarkCustomTheme(); + mAmoledCustomTheme = redditDataRoomDatabase.customThemeDao().getAmoledCustomTheme(); } LiveData<List<CustomTheme>> getAllCustomThemes() { return mAllCustomThemes; } + + public LiveData<CustomTheme> getLightCustomTheme() { + return mLightCustomTheme; + } + + public LiveData<CustomTheme> getDarkCustomTheme() { + return mDarkCustomTheme; + } + + public LiveData<CustomTheme> getAmoledCustomTheme() { + return mAmoledCustomTheme; + } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java new file mode 100644 index 00000000..1dfd7f59 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java @@ -0,0 +1,292 @@ +package ml.docilealligator.infinityforreddit.CustomTheme; + +import android.content.Context; + +import java.util.ArrayList; + +import ml.docilealligator.infinityforreddit.R; + +public class CustomThemeSettingsItem { + public String itemName; + public String itemDetails; + public int colorValue; + public boolean isEnabled; + + private CustomThemeSettingsItem(String itemName, String itemDetails, int colorValue) { + this.itemName = itemName; + this.itemDetails = itemDetails; + this.colorValue = colorValue; + } + + private CustomThemeSettingsItem(String itemName, boolean isEnabled) { + this.itemName = itemName; + this.isEnabled = isEnabled; + } + + public static ArrayList<CustomThemeSettingsItem> convertCustomTheme(Context context, CustomTheme customTheme) { + ArrayList<CustomThemeSettingsItem> customThemeSettingsItems = new ArrayList<>(); + + if (customTheme == null) { + return customThemeSettingsItems; + } + + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_color_primary), + context.getString(R.string.theme_item_color_primary_detail), + customTheme.colorPrimary)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_color_primary_dark), + context.getString(R.string.theme_item_color_primary_dark_detail), + customTheme.colorPrimaryDark)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_color_accent), + context.getString(R.string.theme_item_color_accent_detail), + customTheme.colorAccent)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_color_primary_light_theme), + context.getString(R.string.theme_item_color_primary_light_theme_detail), + customTheme.colorPrimaryLightTheme)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_primary_text_color), + context.getString(R.string.theme_item_primary_text_color_detail), + customTheme.primaryTextColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_secondary_text_color), + context.getString(R.string.theme_item_secondary_text_color_detail), + customTheme.secondaryTextColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_post_title_color), + context.getString(R.string.theme_item_post_title_color_detail), + customTheme.postTitleColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_post_content_color), + context.getString(R.string.theme_item_post_content_color_detail), + customTheme.postContentColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_comment_color), + context.getString(R.string.theme_item_comment_color_detail), + customTheme.commentColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_button_text_color), + context.getString(R.string.theme_item_button_text_color_detail), + customTheme.buttonTextColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_chip_text_color), + context.getString(R.string.theme_item_chip_text_color_detail), + customTheme.chipTextColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_background_color), + context.getString(R.string.theme_item_background_color_detail), + customTheme.backgroundColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_card_view_background_color), + context.getString(R.string.theme_item_card_view_background_color_detail), + customTheme.cardViewBackgroundColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_comment_background_color), + context.getString(R.string.theme_item_comment_background_color_detail), + customTheme.commentBackgroundColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_bottom_app_bar_background_color), + context.getString(R.string.theme_item_bottom_app_bar_background_color_detail), + customTheme.bottomAppBarBackgroundColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_primary_icon_color), + context.getString(R.string.theme_item_primary_icon_color_detail), + customTheme.primaryIconColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_post_icon_and_info_color), + context.getString(R.string.theme_item_post_icon_and_info_color_detail), + customTheme.postIconAndInfoColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_comment_icon_and_info_color), + context.getString(R.string.theme_item_comment_icon_and_info_color_detail), + customTheme.commentIconAndInfoColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_fab_icon_color), + context.getString(R.string.theme_item_fab_icon_color_detail), + customTheme.fabIconColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_toolbar_primary_text_and_icon_color), + context.getString(R.string.theme_item_toolbar_primary_text_and_icon_color_detail), + customTheme.toolbarPrimaryTextAndIconColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_toolbar_secondary_text_color), + context.getString(R.string.theme_item_toolbar_secondary_text_color_detail), + customTheme.toolbarSecondaryTextColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_circular_progress_bar_background_color), + context.getString(R.string.theme_item_circular_progress_bar_background_color_detail), + customTheme.circularProgressBarBackground)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_tab_layout_with_expanded_collapsing_toolbar_tab_background), + context.getString(R.string.theme_item_tab_layout_with_expanded_collapsing_toolbar_tab_background_detail), + customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_tab_layout_with_expanded_collapsing_toolbar_text_color), + context.getString(R.string.theme_item_tab_layout_with_expanded_collapsing_toolbar_text_color_detail), + customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_tab_layout_with_expanded_collapsing_toolbar_tab_indicator), + context.getString(R.string.theme_item_tab_layout_with_expanded_collapsing_toolbar_tab_indicator_detail), + customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_tab_layout_with_collapsed_collapsing_toolbar_tab_background), + context.getString(R.string.theme_item_tab_layout_with_collapsed_collapsing_toolbar_tab_background_detail), + customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_tab_layout_with_collapsed_collapsing_toolbar_text_color), + context.getString(R.string.theme_item_tab_layout_with_collapsed_collapsing_toolbar_text_color_detail), + customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_tab_layout_with_collapsed_collapsing_toolbar_tab_indicator), + context.getString(R.string.theme_item_tab_layout_with_collapsed_collapsing_toolbar_tab_indicator_detail), + customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_upvoted_color), + context.getString(R.string.theme_item_upvoted_color_detail), + customTheme.upvoted)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_downvoted_color), + context.getString(R.string.theme_item_downvoted_color_detail), + customTheme.downvoted)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_post_type_background_color), + context.getString(R.string.theme_item_post_type_background_color_detail), + customTheme.postTypeBackgroundColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_post_type_text_color), + context.getString(R.string.theme_item_post_type_text_color_detail), + customTheme.postTypeTextColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_spoiler_background_color), + context.getString(R.string.theme_item_spoiler_background_color_detail), + customTheme.spoilerBackgroundColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_spoiler_text_color), + context.getString(R.string.theme_item_spoiler_text_color_detail), + customTheme.spoilerTextColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_nsfw_background_color), + context.getString(R.string.theme_item_nsfw_background_color_detail), + customTheme.nsfwBackgroundColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_nsfw_text_color), + context.getString(R.string.theme_item_nsfw_text_color_detail), + customTheme.nsfwTextColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_flair_background_color), + context.getString(R.string.theme_item_flair_background_color_detail), + customTheme.flairBackgroundColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_flair_text_color), + context.getString(R.string.theme_item_flair_text_color_detail), + customTheme.flairTextColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_archived_tint), + context.getString(R.string.theme_item_archived_tint_detail), + customTheme.archivedTint)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_locked_icon_tint), + context.getString(R.string.theme_item_locked_icon_tint_detail), + customTheme.lockedIconTint)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_crosspost_icon_tint), + context.getString(R.string.theme_item_crosspost_icon_tint_detail), + customTheme.crosspostIconTint)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_stickied_post_icon_tint), + context.getString(R.string.theme_item_stickied_post_icon_tint_detail), + customTheme.stickiedPostIconTint)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_subscribed_color), + context.getString(R.string.theme_item_subscribed_color_detail), + customTheme.subscribed)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_unsubscribed_color), + context.getString(R.string.theme_item_unsubscribed_color_detail), + customTheme.unsubscribed)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_username_color), + context.getString(R.string.theme_item_username_color_detail), + customTheme.username)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_subreddit_color), + context.getString(R.string.theme_item_subreddit_color_detail), + customTheme.subreddit)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_author_flair_text_color), + context.getString(R.string.theme_item_author_flair_text_color_detail), + customTheme.authorFlairTextColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_submitter_color), + context.getString(R.string.theme_item_submitter_color_detail), + customTheme.submitter)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_moderator_color), + context.getString(R.string.theme_item_moderator_color_detail), + customTheme.moderator)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_single_comment_thread_background_color), + context.getString(R.string.theme_item_single_comment_thread_background_color_detail), + customTheme.singleCommentThreadBackgroundColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_unread_message_background_color), + context.getString(R.string.theme_item_unread_message_background_color_detail), + customTheme.unreadMessageBackgroundColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_divider_color), + context.getString(R.string.theme_item_divider_color_detail), + customTheme.dividerColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_no_preview_link_background_color), + context.getString(R.string.theme_item_no_preview_link_background_color_detail), + customTheme.noPreviewLinkBackgroundColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_vote_and_reply_unavailable_button_color), + context.getString(R.string.theme_item_vote_and_reply_unavailable_button_color_detail), + customTheme.voteAndReplyUnavailableButtonColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_comment_vertical_bar_color_1), + context.getString(R.string.theme_item_comment_vertical_bar_color_1_detail), + customTheme.commentVerticalBarColor1)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_comment_vertical_bar_color_2), + context.getString(R.string.theme_item_comment_vertical_bar_color_2_detail), + customTheme.commentVerticalBarColor2)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_comment_vertical_bar_color_3), + context.getString(R.string.theme_item_comment_vertical_bar_color_3_detail), + customTheme.commentVerticalBarColor3)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_comment_vertical_bar_color_4), + context.getString(R.string.theme_item_comment_vertical_bar_color_4_detail), + customTheme.commentVerticalBarColor4)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_comment_vertical_bar_color_5), + context.getString(R.string.theme_item_comment_vertical_bar_color_5_detail), + customTheme.commentVerticalBarColor5)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_comment_vertical_bar_color_6), + context.getString(R.string.theme_item_comment_vertical_bar_color_6_detail), + customTheme.commentVerticalBarColor6)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_comment_vertical_bar_color_7), + context.getString(R.string.theme_item_comment_vertical_bar_color_7_detail), + customTheme.commentVerticalBarColor7)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_nav_bar_color), + context.getString(R.string.theme_item_nav_bar_color_detail), + customTheme.navBarColor)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_light_status_bar), + customTheme.isLightStatusBar)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_light_nav_bar), + customTheme.isLightNavBar)); + customThemeSettingsItems.add(new CustomThemeSettingsItem( + context.getString(R.string.theme_item_change_status_bar_icon_color_after_toolbar_collapsed_in_immersive_interface), + customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface)); + return customThemeSettingsItems; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeViewModel.java index 44a43f23..227e641e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeViewModel.java @@ -11,15 +11,34 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; public class CustomThemeViewModel extends ViewModel { private LiveData<List<CustomTheme>> mAllCustomThemes; + private LiveData<CustomTheme> mLightCustomTheme; + private LiveData<CustomTheme> mDarkCustomTheme; + private LiveData<CustomTheme> mAmoledCustomTheme; public CustomThemeViewModel(RedditDataRoomDatabase redditDataRoomDatabase) { - mAllCustomThemes = new CustomThemeRepository(redditDataRoomDatabase).getAllCustomThemes(); + CustomThemeRepository customThemeRepository = new CustomThemeRepository(redditDataRoomDatabase); + mAllCustomThemes = customThemeRepository.getAllCustomThemes(); + mLightCustomTheme = customThemeRepository.getLightCustomTheme(); + mDarkCustomTheme = customThemeRepository.getDarkCustomTheme(); + mAmoledCustomTheme = customThemeRepository.getAmoledCustomTheme(); } public LiveData<List<CustomTheme>> getAllCustomThemes() { return mAllCustomThemes; } + public LiveData<CustomTheme> getLightCustomTheme() { + return mLightCustomTheme; + } + + public LiveData<CustomTheme> getDarkCustomTheme() { + return mDarkCustomTheme; + } + + public LiveData<CustomTheme> getAmoledCustomTheme() { + return mAmoledCustomTheme; + } + public static class Factory extends ViewModelProvider.NewInstanceFactory { private RedditDataRoomDatabase mRedditDataRoomDatabase; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java index bcb46f7e..2546c9f2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java @@ -138,9 +138,9 @@ public class CustomThemeWrapper { getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF")); } - public int getToolbarAndTabBackgroundColor() { - return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.TOOLBAR_AND_TAB_BACKGROUND_COLOR, - getDefaultColor("#1565C0", "#282828", "#000000")); + public int getToolbarSecondaryTextColor() { + return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.TOOLBAR_SECONDARY_TEXT_COLOR, + getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF")); } public int getCircularProgressBarBackground() { @@ -178,11 +178,6 @@ public class CustomThemeWrapper { getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF")); } - public int getNavBarColor() { - return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.NAV_BAR_COLOR, - getDefaultColor("#FFFFFF", "#121212", "#000000")); - } - public int getUpvoted() { return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.UPVOTED, getDefaultColor("#E91E63", "#E91E63", "#E91E63")); @@ -233,8 +228,8 @@ public class CustomThemeWrapper { getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF")); } - public int getArchivedTint() { - return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.ARCHIVED_TINT, + public int getArchivedIconTint() { + return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.ARCHIVED_ICON_TINT, getDefaultColor("#B4009F", "#B4009F", "#B4009F")); } @@ -308,8 +303,8 @@ public class CustomThemeWrapper { getDefaultColor("#E0E0E0", "#424242", "#424242")); } - public int getVoteAndReplyUnavailableVoteButtonColor() { - return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.VOTE_AND_REPLY_UNAVAILABLE_VOTE_BUTTON_COLOR, + public int getVoteAndReplyUnavailableButtonColor() { + return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.VOTE_AND_REPLY_UNAVAILABLE_BUTTON_COLOR, getDefaultColor("#F0F0F0", "#3C3C3C", "#3C3C3C")); } @@ -358,6 +353,11 @@ public class CustomThemeWrapper { getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF")); } + public int getNavBarColor() { + return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.NAV_BAR_COLOR, + getDefaultColor("#FFFFFF", "#121212", "#000000")); + } + public boolean isLightStatusBar() { return getThemeSharedPreferences().getBoolean(CustomThemeSharedPreferencesUtils.LIGHT_STATUS_BAR, false); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java index e6d31728..0225d14a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java @@ -125,8 +125,9 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase { "button_text_color INTEGER NOT NULL, background_color INTEGER NOT NULL," + "card_view_background_color INTEGER NOT NULL, comment_background_color INTEGER NOT NULL," + "bottom_app_bar_background_color INTEGER NOT NULL, primary_icon_color INTEGER NOT NULL," + + "post_icon_and_info_color INTEGER NOT NULL," + "comment_icon_and_info_color INTEGER NOT NULL, toolbar_primary_text_and_icon_color INTEGER NOT NULL," + - "toolbar_and_tab_background_color INTEGER NOT NULL, circular_progress_bar_background INTEGER NOT NULL," + + "toolbar_secondary_text_color INTEGER NOT NULL, circular_progress_bar_background INTEGER NOT NULL," + "tab_layout_with_expanded_collapsing_toolbar_tab_background INTEGER NOT NULL," + "tab_layout_with_expanded_collapsing_toolbar_text_color INTEGER NOT NULL," + "tab_layout_with_expanded_collapsing_toolbar_tab_indicator INTEGER NOT NULL," + @@ -146,7 +147,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase { "single_comment_thread_background_color INTEGER NOT NULL," + "unread_message_background_color INTEGER NOT NULL, divider_color INTEGER NOT NULL," + "no_preview_link_background_color INTEGER NOT NULL," + - "vote_and_reply_unavailable_vote_button_color INTEGER NOT NULL," + + "vote_and_reply_unavailable_button_color INTEGER NOT NULL," + "comment_vertical_bar_color_1 INTEGER NOT NULL, comment_vertical_bar_color_2 INTEGER NOT NULL," + "comment_vertical_bar_color_3 INTEGER NOT NULL, comment_vertical_bar_color_4 INTEGER NOT NULL," + "comment_vertical_bar_color_5 INTEGER NOT NULL, comment_vertical_bar_color_6 INTEGER NOT NULL," + diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/ThemePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/ThemePreferenceFragment.java index 516e3c93..58dbf619 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/ThemePreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/ThemePreferenceFragment.java @@ -1,15 +1,17 @@ package ml.docilealligator.infinityforreddit.Settings; -import android.app.Activity; import android.content.Context; +import android.content.Intent; import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; import androidx.fragment.app.Fragment; import androidx.preference.ListPreference; +import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import androidx.preference.SwitchPreference; @@ -17,6 +19,7 @@ import org.greenrobot.eventbus.EventBus; import javax.inject.Inject; +import ml.docilealligator.infinityforreddit.Activity.CustomizeThemeActivity; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.Infinity; @@ -34,7 +37,7 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES; */ public class ThemePreferenceFragment extends PreferenceFragmentCompat { - private Activity activity; + private AppCompatActivity activity; @Inject CustomThemeWrapper customThemeWrapper; @@ -46,6 +49,9 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat { ListPreference themePreference = findPreference(SharedPreferencesUtils.THEME_KEY); SwitchPreference amoledDarkSwitch = findPreference(SharedPreferencesUtils.AMOLED_DARK_KEY); + Preference customizeLightThemePreference = findPreference(SharedPreferencesUtils.CUSTOMIZE_LIGHT_THEME); + Preference customizeDarkThemePreference = findPreference(SharedPreferencesUtils.CUSTOMIZE_DARK_THEME); + Preference customizeAmoledThemePreference = findPreference(SharedPreferencesUtils.CUSTOMIZE_AMOLED_THEME); boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; if (themePreference != null && amoledDarkSwitch != null) { @@ -100,11 +106,38 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat { return true; }); } + + if (customizeLightThemePreference != null) { + customizeLightThemePreference.setOnPreferenceClickListener(preference -> { + Intent intent = new Intent(activity, CustomizeThemeActivity.class); + intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_TYPE, CustomizeThemeActivity.EXTRA_LIGHT_THEME); + startActivity(intent); + return false; + }); + } + + if (customizeDarkThemePreference != null) { + customizeDarkThemePreference.setOnPreferenceClickListener(preference -> { + Intent intent = new Intent(activity, CustomizeThemeActivity.class); + intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_TYPE, CustomizeThemeActivity.EXTRA_DARK_THEME); + startActivity(intent); + return false; + }); + } + + if (customizeAmoledThemePreference != null) { + customizeAmoledThemePreference.setOnPreferenceClickListener(preference -> { + Intent intent = new Intent(activity, CustomizeThemeActivity.class); + intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_TYPE, CustomizeThemeActivity.EXTRA_AMOLED_THEME); + startActivity(intent); + return false; + }); + } } @Override public void onAttach(@NonNull Context context) { super.onAttach(context); - activity = (Activity) context; + activity = (AppCompatActivity) context; } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java index 44559721..a4631521 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java @@ -28,7 +28,7 @@ public class CustomThemeSharedPreferencesUtils { public static final String POST_ICON_AND_INFO_COLOR = "postIconAndInfoColor"; public static final String COMMENT_ICON_AND_INFO_COLOR = "commentIconAndInfoColor"; public static final String TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR = "toolbarPrimaryTextAndIconColor"; - public static final String TOOLBAR_AND_TAB_BACKGROUND_COLOR = "toolbarAndTabBackgroundColor"; + public static final String TOOLBAR_SECONDARY_TEXT_COLOR = "toolbarSecondaryTextColor"; public static final String CIRCULAR_PROGRESS_BAR_BACKGROUND = "circularProgressBarBackground"; public static final String TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_BACKGROUND = "tabLayoutWithExpandedCollapsingToolbarTabBackground"; public static final String TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TEXT_COLOR = "tabLayoutWithExpandedCollapsingToolbarTextColor"; @@ -47,7 +47,7 @@ public class CustomThemeSharedPreferencesUtils { public static final String NSFW_TEXT_COLOR = "nsfwTextColor"; public static final String FLAIR_BACKGROUND_COLOR = "flairBackgroundColor"; public static final String FLAIR_TEXT_COLOR = "flairTextColor"; - public static final String ARCHIVED_TINT = "archivedTint"; + public static final String ARCHIVED_ICON_TINT = "archivedIconTint"; public static final String LOCKED_ICON_TINT = "lockedIconTint"; public static final String CROSSPOST_ICON_TINT = "crosspostIconTint"; public static final String STICKIED_POST_ICON_TINT = "stickiedPost"; @@ -62,7 +62,7 @@ public class CustomThemeSharedPreferencesUtils { public static final String UNREAD_MESSAGE_BACKGROUND_COLOR = "unreadMessageBackgroundColor"; public static final String DIVIDER_COLOR = "dividerColor"; public static final String NO_PREVIEW_LINK_BACKGROUND_COLOR = "noPreviewLinkBackgroundColor"; - public static final String VOTE_AND_REPLY_UNAVAILABLE_VOTE_BUTTON_COLOR = "voteAndReplyUnavailableVoteButtonColor"; + public static final String VOTE_AND_REPLY_UNAVAILABLE_BUTTON_COLOR = "voteAndReplyUnavailableButtonColor"; public static final String COMMENT_VERTICAL_BAR_COLOR_1 = "commentVerticalBarColor1"; public static final String COMMENT_VERTICAL_BAR_COLOR_2 = "commentVerticalBarColor2"; public static final String COMMENT_VERTICAL_BAR_COLOR_3 = "commentVerticalBarColor3"; 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 0ff474bd..ef15d5e6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -77,4 +77,7 @@ public class SharedPreferencesUtils { public static final String LOCK_BOTTOM_APP_BAR = "lock_bottom_app_bar"; public static final String SHOW_COMMENT_DIVIDER = "show_comment_divider"; public static final String SHOW_ABSOLUTE_NUMBER_OF_VOTES = "show_absolute_number_of_votes"; + public static final String CUSTOMIZE_LIGHT_THEME = "customize_light_theme"; + public static final String CUSTOMIZE_DARK_THEME = "customize_dark_theme"; + public static final String CUSTOMIZE_AMOLED_THEME = "customize_amoled_theme"; } |