diff options
Diffstat (limited to 'app/src/main')
16 files changed, 616 insertions, 109 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b13132c7..233d5efc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,7 +21,9 @@ android:theme="@style/AppTheme" android:usesCleartextTraffic="true" tools:replace="android:label"> - <activity android:name=".Activity.CustomizeThemeActivity" + <activity android:name=".Activity.CustomThemeListingActivity"></activity> + <activity + android:name=".Activity.CustomizeThemeActivity" android:parentActivityName=".Activity.MainActivity" android:theme="@style/AppTheme.NoActionBar" /> <activity diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java new file mode 100644 index 00000000..8ba9a885 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java @@ -0,0 +1,55 @@ +package ml.docilealligator.infinityforreddit.Activity; + +import android.content.SharedPreferences; +import android.os.Bundle; + +import androidx.appcompat.widget.Toolbar; +import androidx.recyclerview.widget.RecyclerView; + +import com.google.android.material.appbar.AppBarLayout; + +import javax.inject.Inject; +import javax.inject.Named; + +import butterknife.BindView; +import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; + +public class CustomThemeListingActivity extends BaseActivity { + + @BindView(R.id.appbar_layout_customize_theme_listing_activity) + AppBarLayout appBarLayout; + @BindView(R.id.toolbar_customize_theme_listing_activity) + Toolbar toolbar; + @BindView(R.id.recycler_view_customize_theme_listing_activity) + RecyclerView recyclerView; + @Inject + @Named("default") + SharedPreferences sharedPreferences; + @Inject + RedditDataRoomDatabase redditDataRoomDatabase; + @Inject + CustomThemeWrapper customThemeWrapper; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_custom_theme_listing); + } + + @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/CustomizeThemeActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java index 530d947a..b6e45b8a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java @@ -6,8 +6,8 @@ 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.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.appbar.AppBarLayout; @@ -20,6 +20,7 @@ import javax.inject.Named; import butterknife.BindView; import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.Adapter.CustomizeThemeRecyclerViewAdapter; +import ml.docilealligator.infinityforreddit.AsyncTask.GetCustomThemeAsyncTask; import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeSettingsItem; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeViewModel; @@ -34,6 +35,7 @@ public class CustomizeThemeActivity extends BaseActivity { public static final int EXTRA_LIGHT_THEME = 0; public static final int EXTRA_DARK_THEME = 1; public static final int EXTRA_AMOLED_THEME = 2; + public static final String EXTRA_THEME_NAME = "ETN"; @BindView(R.id.appbar_layout_customize_theme_activity) AppBarLayout appBarLayout; @@ -51,7 +53,6 @@ public class CustomizeThemeActivity extends BaseActivity { public CustomThemeViewModel customThemeViewModel; private CustomizeThemeRecyclerViewAdapter adapter; - private int themeType; @Override protected void onCreate(Bundle savedInstanceState) { @@ -64,38 +65,59 @@ public class CustomizeThemeActivity extends BaseActivity { applyCustomTheme(); - themeType = getIntent().getIntExtra(EXTRA_THEME_TYPE, EXTRA_LIGHT_THEME); - + setTitle(getIntent().getStringExtra(EXTRA_THEME_NAME)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); adapter = new CustomizeThemeRecyclerViewAdapter(); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + recyclerView.setAdapter(adapter); 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 (getIntent().hasExtra(EXTRA_THEME_TYPE)) { + LiveData<CustomTheme> customThemeLiveData; + int themeType = getIntent().getIntExtra(EXTRA_THEME_TYPE, EXTRA_LIGHT_THEME); + switch (themeType) { + case EXTRA_DARK_THEME: + setTitle(getString(R.string.customize_dark_theme_fragment_title)); + customThemeLiveData = customThemeViewModel.getDarkCustomTheme(); + break; + case EXTRA_AMOLED_THEME: + setTitle(getString(R.string.customize_amoled_theme_fragment_title)); + customThemeLiveData = customThemeViewModel.getAmoledCustomTheme(); + break; + default: + setTitle(getString(R.string.customize_light_theme_fragment_title)); + customThemeLiveData = customThemeViewModel.getLightCustomTheme(); + break; + } + + customThemeLiveData.observe(this, customTheme -> { + ArrayList<CustomThemeSettingsItem> customThemeSettingsItems; + if (customTheme == null) { + switch (themeType) { + case EXTRA_DARK_THEME: + customThemeSettingsItems = CustomThemeSettingsItem.convertCustomThemeToSettingsItem( + CustomizeThemeActivity.this, + CustomThemeWrapper.getIndigoDark(CustomizeThemeActivity.this)); + break; + case EXTRA_AMOLED_THEME: + customThemeSettingsItems = CustomThemeSettingsItem.convertCustomThemeToSettingsItem( + CustomizeThemeActivity.this, + CustomThemeWrapper.getIndigoAmoled(CustomizeThemeActivity.this)); + break; + default: + customThemeSettingsItems = CustomThemeSettingsItem.convertCustomThemeToSettingsItem( + CustomizeThemeActivity.this, + CustomThemeWrapper.getIndigo(CustomizeThemeActivity.this)); + } + } else { + customThemeSettingsItems = CustomThemeSettingsItem.convertCustomThemeToSettingsItem(CustomizeThemeActivity.this, customTheme); + } + if (androidVersion < Build.VERSION_CODES.O) { customThemeSettingsItems.get(customThemeSettingsItems.size() - 2).itemDetails = getString(R.string.theme_item_available_on_android_8); } @@ -104,8 +126,12 @@ public class CustomizeThemeActivity extends BaseActivity { } adapter.setCustomThemeSettingsItem(customThemeSettingsItems); - } - }); + }); + } else { + new GetCustomThemeAsyncTask(redditDataRoomDatabase, getIntent().getStringExtra(EXTRA_THEME_NAME), + customTheme -> adapter.setCustomThemeSettingsItem( + CustomThemeSettingsItem.convertCustomThemeToSettingsItem(CustomizeThemeActivity.this, customTheme))).execute(); + } } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java new file mode 100644 index 00000000..9504317d --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java @@ -0,0 +1,68 @@ +package ml.docilealligator.infinityforreddit.Adapter; + +import android.content.Context; +import android.content.Intent; +import android.content.res.ColorStateList; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +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.Activity.CustomizeThemeActivity; +import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme; +import ml.docilealligator.infinityforreddit.R; + +public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { + private Context context; + private ArrayList<CustomTheme> customThemes; + + public CustomThemeListingRecyclerViewAdapter(Context context) { + this.context = context; + customThemes = new ArrayList<>(); + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new CustomThemeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_custom_theme, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + if (holder instanceof CustomThemeViewHolder) { + CustomTheme customTheme = customThemes.get(position); + ((CustomThemeViewHolder) holder).colorPrimaryView.setBackgroundTintList(ColorStateList.valueOf(customTheme.colorPrimary)); + ((CustomThemeViewHolder) holder).nameTextView.setText(customTheme.name); + ((CustomThemeViewHolder) holder).itemView.setOnClickListener(view -> { + Intent intent = new Intent(context, CustomizeThemeActivity.class); + intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, customTheme.name); + context.startActivity(intent); + }); + } + } + + @Override + public int getItemCount() { + return 0; + } + + class CustomThemeViewHolder extends RecyclerView.ViewHolder { + + @BindView(R.id.color_primary_item_custom_theme) + View colorPrimaryView; + @BindView(R.id.name_text_view_item_custom_theme) + TextView nameTextView; + + public CustomThemeViewHolder(@NonNull View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + } + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java index 5bb55eea..398042de 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java @@ -39,10 +39,10 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy @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 ThemeSwitchItemViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_custom_theme_switch_item, parent, false)); } - return new ThemeColorItemViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_theme_color_item, parent, false)); + return new ThemeColorItemViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_custom_theme_color_item, parent, false)); } @Override @@ -78,11 +78,11 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy } class ThemeColorItemViewHolder extends RecyclerView.ViewHolder { - @BindView(R.id.color_image_view_item_theme_color_item) + @BindView(R.id.color_image_view_item_custom_theme_color_item) View colorImageView; - @BindView(R.id.theme_item_name_text_view_item_theme_color_item) + @BindView(R.id.theme_item_name_text_view_item_custom_theme_color_item) TextView themeItemNameTextView; - @BindView(R.id.theme_item_info_text_view_item_theme_color_item) + @BindView(R.id.theme_item_info_text_view_item_custom_theme_color_item) TextView themeItemInfoTextView; ThemeColorItemViewHolder(@NonNull View itemView) { @@ -92,11 +92,11 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy } class ThemeSwitchItemViewHolder extends RecyclerView.ViewHolder { - @BindView(R.id.theme_item_name_text_view_item_theme_switch_item) + @BindView(R.id.theme_item_name_text_view_item_custom_theme_switch_item) TextView themeItemNameTextView; - @BindView(R.id.theme_item_info_text_view_item_theme_switch_item) + @BindView(R.id.theme_item_info_text_view_item_custom_theme_switch_item) TextView themeItemInfoTextView; - @BindView(R.id.theme_item_switch_item_theme_switch_item) + @BindView(R.id.theme_item_switch_item_custom_theme_switch_item) Switch themeItemSwitch; ThemeSwitchItemViewHolder(@NonNull View itemView) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/GetCustomThemeAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/GetCustomThemeAsyncTask.java new file mode 100644 index 00000000..9a8469f5 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/GetCustomThemeAsyncTask.java @@ -0,0 +1,37 @@ +package ml.docilealligator.infinityforreddit.AsyncTask; + +import android.os.AsyncTask; + +import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme; +import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; + +public class GetCustomThemeAsyncTask extends AsyncTask<Void, Void, Void> { + private RedditDataRoomDatabase redditDataRoomDatabase; + private String customThemeName; + private GetCustomThemeAsyncTaskListener getCustomThemeAsyncTaskListener; + private CustomTheme customTheme; + + public interface GetCustomThemeAsyncTaskListener { + void success(CustomTheme customTheme); + } + + public GetCustomThemeAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, + String customThemeName, + GetCustomThemeAsyncTaskListener getCustomThemeAsyncTaskListener) { + this.redditDataRoomDatabase = redditDataRoomDatabase; + this.customThemeName = customThemeName; + this.getCustomThemeAsyncTaskListener = getCustomThemeAsyncTaskListener; + } + + @Override + protected Void doInBackground(Void... voids) { + customTheme = redditDataRoomDatabase.customThemeDao().getCustomTheme(customThemeName); + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + super.onPostExecute(aVoid); + getCustomThemeAsyncTaskListener.success(customTheme); + } +} 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 4525cf81..552cc8a7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeDao.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeDao.java @@ -25,9 +25,9 @@ public interface CustomThemeDao { @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); + @Query("SELECT * FROM custom_themes WHERE name = :name COLLATE NOCASE LIMIT 1") + CustomTheme getCustomTheme(String name); - @Query("DELETE FROM custom_themes WHERE name = :name AND username = :username") - void deleteCustomTheme(String name, String username); + @Query("DELETE FROM custom_themes WHERE name = :name") + void deleteCustomTheme(String name); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java index 1dfd7f59..5741d1f1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java @@ -23,7 +23,7 @@ public class CustomThemeSettingsItem { this.isEnabled = isEnabled; } - public static ArrayList<CustomThemeSettingsItem> convertCustomTheme(Context context, CustomTheme customTheme) { + public static ArrayList<CustomThemeSettingsItem> convertCustomThemeToSettingsItem(Context context, CustomTheme customTheme) { ArrayList<CustomThemeSettingsItem> customThemeSettingsItems = new ArrayList<>(); if (customTheme == null) { 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 2546c9f2..b6416f53 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java @@ -1,8 +1,12 @@ package ml.docilealligator.infinityforreddit.CustomTheme; +import android.content.Context; import android.content.SharedPreferences; import android.graphics.Color; +import java.util.ArrayList; + +import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils; import static ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils.AMOLED; @@ -345,7 +349,7 @@ public class CustomThemeWrapper { public int getFABIconColor() { return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.FAB_ICON_COLOR, - getDefaultColor("#1565C0", "#1565C0", "#1565C0")); + getDefaultColor("#FFFFFF", "#FFFFFF", "#FFFFFF")); } public int getChipTextColor() { @@ -363,11 +367,243 @@ public class CustomThemeWrapper { } public boolean isLightNavBar() { - return getThemeSharedPreferences().getBoolean(CustomThemeSharedPreferencesUtils.LIGHT_NAV_BAR, true); + return getThemeSharedPreferences().getBoolean(CustomThemeSharedPreferencesUtils.LIGHT_NAV_BAR, + themeType == CustomThemeSharedPreferencesUtils.LIGHT); } public boolean isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface() { return getThemeSharedPreferences().getBoolean( - CustomThemeSharedPreferencesUtils.CHANGE_STATUS_BAR_ICON_COLOR_AFTER_TOOLBAR_COLLAPSED_IN_IMMERSIVE_INTERFACE, true); + CustomThemeSharedPreferencesUtils.CHANGE_STATUS_BAR_ICON_COLOR_AFTER_TOOLBAR_COLLAPSED_IN_IMMERSIVE_INTERFACE, + themeType == CustomThemeSharedPreferencesUtils.LIGHT); + } + + public static ArrayList<CustomTheme> getPredifinedThemes(Context context) { + ArrayList<CustomTheme> customThemes = new ArrayList<>(); + customThemes.add(getIndigo(context)); + customThemes.add(getIndigoDark(context)); + customThemes.add(getIndigoAmoled(context)); + return customThemes; + } + + public static CustomTheme getIndigo(Context context) { + CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_indigo)); + customTheme.isLightTheme = true; + customTheme.isDarkTheme = false; + customTheme.isAmoledTheme = false; + customTheme.colorPrimary = Color.parseColor("#1565C0"); + customTheme.colorPrimaryDark = Color.parseColor("#0D47A1"); + customTheme.colorAccent = Color.parseColor("#FF4081"); + customTheme.colorPrimaryLightTheme = Color.parseColor("#1565C0"); + customTheme.primaryTextColor = Color.parseColor("#000000"); + customTheme.secondaryTextColor = Color.parseColor("#8A000000"); + customTheme.postTitleColor = Color.parseColor("#000000"); + customTheme.postContentColor = Color.parseColor("#8A000000"); + customTheme.commentColor = Color.parseColor("#000000"); + customTheme.buttonTextColor = Color.parseColor("#FFFFFF"); + customTheme.backgroundColor = Color.parseColor("#FFFFFF"); + customTheme.cardViewBackgroundColor = Color.parseColor("#FFFFFF"); + customTheme.commentBackgroundColor = Color.parseColor("#FFFFFF"); + customTheme.bottomAppBarBackgroundColor = Color.parseColor("#FFFFFF"); + customTheme.primaryIconColor = Color.parseColor("#000000"); + customTheme.postIconAndInfoColor = Color.parseColor("#8A000000"); + customTheme.commentIconAndInfoColor = Color.parseColor("#8A000000"); + customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#FFFFFF"); + customTheme.toolbarSecondaryTextColor = Color.parseColor("#FFFFFF"); + customTheme.circularProgressBarBackground = Color.parseColor("#FFFFFF"); + customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = Color.parseColor("#FFFFFF"); + customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = Color.parseColor("#1565C0"); + customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = Color.parseColor("#1565C0"); + customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = Color.parseColor("#1565C0"); + customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = Color.parseColor("#FFFFFF"); + customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = Color.parseColor("#FFFFFF"); + customTheme.upvoted = Color.parseColor("#E91E63"); + customTheme.downvoted = Color.parseColor("#007DDE"); + customTheme.postTypeBackgroundColor = Color.parseColor("#0D47A1"); + customTheme.postTypeTextColor = Color.parseColor("#FFFFFF"); + customTheme.spoilerBackgroundColor = Color.parseColor("#EE02EB"); + customTheme.spoilerTextColor = Color.parseColor("#FFFFFF"); + customTheme.nsfwBackgroundColor = Color.parseColor("#FF4081"); + customTheme.nsfwTextColor = Color.parseColor("#FFFFFF"); + customTheme.flairBackgroundColor = Color.parseColor("#00AA8C"); + customTheme.flairTextColor = Color.parseColor("#FFFFFF"); + customTheme.archivedTint = Color.parseColor("#B4009F"); + customTheme.lockedIconTint = Color.parseColor("#EE7302"); + customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.stickiedPostIconTint = Color.parseColor("#0D47A1"); + customTheme.subscribed = Color.parseColor("#FF4081"); + customTheme.unsubscribed = Color.parseColor("#0D47A1"); + customTheme.username = Color.parseColor("#0D47A1"); + customTheme.subreddit = Color.parseColor("#E91E63"); + customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); + customTheme.submitter = Color.parseColor("#EE8A02"); + customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#B3E5F9"); + customTheme.unreadMessageBackgroundColor = Color.parseColor("#B3E5F9"); + customTheme.dividerColor = Color.parseColor("#E0E0E0"); + customTheme.noPreviewLinkBackgroundColor = Color.parseColor("#E0E0E0"); + customTheme.voteAndReplyUnavailableButtonColor = Color.parseColor("#F0F0F0"); + customTheme.commentVerticalBarColor1 = Color.parseColor("#1565C0"); + customTheme.commentVerticalBarColor2 = Color.parseColor("#EE02BE"); + customTheme.commentVerticalBarColor3 = Color.parseColor("#02DFEE"); + customTheme.commentVerticalBarColor4 = Color.parseColor("#EED502"); + customTheme.commentVerticalBarColor5 = Color.parseColor("#EE0220"); + customTheme.commentVerticalBarColor6 = Color.parseColor("#02EE6E"); + customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); + customTheme.fabIconColor = Color.parseColor("#FFFFFF"); + customTheme.chipTextColor = Color.parseColor("#FFFFFF"); + customTheme.navBarColor = Color.parseColor("#FFFFFF"); + customTheme.isLightStatusBar = false; + customTheme.isLightNavBar = true; + customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = true; + + return customTheme; + } + + public static CustomTheme getIndigoDark(Context context) { + CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_indigo_dark)); + customTheme.isLightTheme = false; + customTheme.isDarkTheme = true; + customTheme.isAmoledTheme = false; + customTheme.colorPrimary = Color.parseColor("#242424"); + customTheme.colorPrimaryDark = Color.parseColor("#121212"); + customTheme.colorAccent = Color.parseColor("#FF4081"); + customTheme.colorPrimaryLightTheme = Color.parseColor("#1565C0"); + customTheme.primaryTextColor = Color.parseColor("#FFFFFF"); + customTheme.secondaryTextColor = Color.parseColor("#B3FFFFFF"); + customTheme.postTitleColor = Color.parseColor("#FFFFFF"); + customTheme.postContentColor = Color.parseColor("#B3FFFFFF"); + customTheme.commentColor = Color.parseColor("#FFFFFF"); + customTheme.buttonTextColor = Color.parseColor("#FFFFFF"); + customTheme.backgroundColor = Color.parseColor("#121212"); + customTheme.cardViewBackgroundColor = Color.parseColor("#242424"); + customTheme.commentBackgroundColor = Color.parseColor("#242424"); + customTheme.bottomAppBarBackgroundColor = Color.parseColor("#121212"); + customTheme.primaryIconColor = Color.parseColor("#FFFFFF"); + customTheme.postIconAndInfoColor = Color.parseColor("#B3FFFFFF"); + customTheme.commentIconAndInfoColor = Color.parseColor("#B3FFFFFF"); + customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#FFFFFF"); + customTheme.toolbarSecondaryTextColor = Color.parseColor("#FFFFFF"); + customTheme.circularProgressBarBackground = Color.parseColor("#242424"); + customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = Color.parseColor("#242424"); + customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = Color.parseColor("#FFFFFF"); + customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = Color.parseColor("#FFFFFF"); + customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = Color.parseColor("#242424"); + customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = Color.parseColor("#FFFFFF"); + customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = Color.parseColor("#FFFFFF"); + customTheme.upvoted = Color.parseColor("#E91E63"); + customTheme.downvoted = Color.parseColor("#007DDE"); + customTheme.postTypeBackgroundColor = Color.parseColor("#1565C0"); + customTheme.postTypeTextColor = Color.parseColor("#FFFFFF"); + customTheme.spoilerBackgroundColor = Color.parseColor("#EE02EB"); + customTheme.spoilerTextColor = Color.parseColor("#FFFFFF"); + customTheme.nsfwBackgroundColor = Color.parseColor("#FF4081"); + customTheme.nsfwTextColor = Color.parseColor("#FFFFFF"); + customTheme.flairBackgroundColor = Color.parseColor("#00AA8C"); + customTheme.flairTextColor = Color.parseColor("#FFFFFF"); + customTheme.archivedTint = Color.parseColor("#B4009F"); + customTheme.lockedIconTint = Color.parseColor("#EE7302"); + customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.stickiedPostIconTint = Color.parseColor("#1565C0"); + customTheme.subscribed = Color.parseColor("#FF4081"); + customTheme.unsubscribed = Color.parseColor("#1565C0"); + customTheme.username = Color.parseColor("#1E88E5"); + customTheme.subreddit = Color.parseColor("#E91E63"); + customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); + customTheme.submitter = Color.parseColor("#EE8A02"); + customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#123E77"); + customTheme.unreadMessageBackgroundColor = Color.parseColor("#123E77"); + customTheme.dividerColor = Color.parseColor("#69666C"); + customTheme.noPreviewLinkBackgroundColor = Color.parseColor("#424242"); + customTheme.voteAndReplyUnavailableButtonColor = Color.parseColor("#3C3C3C"); + customTheme.commentVerticalBarColor1 = Color.parseColor("#1565C0"); + customTheme.commentVerticalBarColor2 = Color.parseColor("#C300B3"); + customTheme.commentVerticalBarColor3 = Color.parseColor("#00B8DA"); + customTheme.commentVerticalBarColor4 = Color.parseColor("#EDCA00"); + customTheme.commentVerticalBarColor5 = Color.parseColor("#EE0219"); + customTheme.commentVerticalBarColor6 = Color.parseColor("#00B925"); + customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); + customTheme.fabIconColor = Color.parseColor("#FFFFFF"); + customTheme.chipTextColor = Color.parseColor("#FFFFFF"); + customTheme.navBarColor = Color.parseColor("#121212"); + customTheme.isLightStatusBar = false; + customTheme.isLightNavBar = false; + customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = false; + + return customTheme; + } + + public static CustomTheme getIndigoAmoled(Context context) { + CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_indigo_dark)); + customTheme.isLightTheme = false; + customTheme.isDarkTheme = true; + customTheme.isAmoledTheme = false; + customTheme.colorPrimary = Color.parseColor("#000000"); + customTheme.colorPrimaryDark = Color.parseColor("#000000"); + customTheme.colorAccent = Color.parseColor("#FF4081"); + customTheme.colorPrimaryLightTheme = Color.parseColor("#1565C0"); + customTheme.primaryTextColor = Color.parseColor("#FFFFFF"); + customTheme.secondaryTextColor = Color.parseColor("#B3FFFFFF"); + customTheme.postTitleColor = Color.parseColor("#FFFFFF"); + customTheme.postContentColor = Color.parseColor("#B3FFFFFF"); + customTheme.commentColor = Color.parseColor("#FFFFFF"); + customTheme.buttonTextColor = Color.parseColor("#FFFFFF"); + customTheme.backgroundColor = Color.parseColor("#000000"); + customTheme.cardViewBackgroundColor = Color.parseColor("#000000"); + customTheme.commentBackgroundColor = Color.parseColor("#000000"); + customTheme.bottomAppBarBackgroundColor = Color.parseColor("#000000"); + customTheme.primaryIconColor = Color.parseColor("#FFFFFF"); + customTheme.postIconAndInfoColor = Color.parseColor("#B3FFFFFF"); + customTheme.commentIconAndInfoColor = Color.parseColor("#B3FFFFFF"); + customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#FFFFFF"); + customTheme.toolbarSecondaryTextColor = Color.parseColor("#FFFFFF"); + customTheme.circularProgressBarBackground = Color.parseColor("#000000"); + customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = Color.parseColor("#000000"); + customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = Color.parseColor("#FFFFFF"); + customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = Color.parseColor("#FFFFFF"); + customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = Color.parseColor("#000000"); + customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = Color.parseColor("#FFFFFF"); + customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = Color.parseColor("#FFFFFF"); + customTheme.upvoted = Color.parseColor("#E91E63"); + customTheme.downvoted = Color.parseColor("#007DDE"); + customTheme.postTypeBackgroundColor = Color.parseColor("#1565C0"); + customTheme.postTypeTextColor = Color.parseColor("#FFFFFF"); + customTheme.spoilerBackgroundColor = Color.parseColor("#EE02EB"); + customTheme.spoilerTextColor = Color.parseColor("#FFFFFF"); + customTheme.nsfwBackgroundColor = Color.parseColor("#FF4081"); + customTheme.nsfwTextColor = Color.parseColor("#FFFFFF"); + customTheme.flairBackgroundColor = Color.parseColor("#00AA8C"); + customTheme.flairTextColor = Color.parseColor("#FFFFFF"); + customTheme.archivedTint = Color.parseColor("#B4009F"); + customTheme.lockedIconTint = Color.parseColor("#EE7302"); + customTheme.crosspostIconTint = Color.parseColor("#FF4081"); + customTheme.stickiedPostIconTint = Color.parseColor("#1565C0"); + customTheme.subscribed = Color.parseColor("#FF4081"); + customTheme.unsubscribed = Color.parseColor("#1565C0"); + customTheme.username = Color.parseColor("#1E88E5"); + customTheme.subreddit = Color.parseColor("#E91E63"); + customTheme.authorFlairTextColor = Color.parseColor("#EE02C4"); + customTheme.submitter = Color.parseColor("#EE8A02"); + customTheme.moderator = Color.parseColor("#00BA81"); + customTheme.singleCommentThreadBackgroundColor = Color.parseColor("#123E77"); + customTheme.unreadMessageBackgroundColor = Color.parseColor("#123E77"); + customTheme.dividerColor = Color.parseColor("#69666C"); + customTheme.noPreviewLinkBackgroundColor = Color.parseColor("#424242"); + customTheme.voteAndReplyUnavailableButtonColor = Color.parseColor("#3C3C3C"); + customTheme.commentVerticalBarColor1 = Color.parseColor("#1565C0"); + customTheme.commentVerticalBarColor2 = Color.parseColor("#C300B3"); + customTheme.commentVerticalBarColor3 = Color.parseColor("#00B8DA"); + customTheme.commentVerticalBarColor4 = Color.parseColor("#EDCA00"); + customTheme.commentVerticalBarColor5 = Color.parseColor("#EE0219"); + customTheme.commentVerticalBarColor6 = Color.parseColor("#00B925"); + customTheme.commentVerticalBarColor7 = Color.parseColor("#EE4602"); + customTheme.fabIconColor = Color.parseColor("#FFFFFF"); + customTheme.chipTextColor = Color.parseColor("#FFFFFF"); + customTheme.navBarColor = Color.parseColor("#000000"); + customTheme.isLightStatusBar = false; + customTheme.isLightNavBar = false; + customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = false; + + return customTheme; } } diff --git a/app/src/main/res/layout/activity_custom_theme_listing.xml b/app/src/main/res/layout/activity_custom_theme_listing.xml new file mode 100644 index 00000000..f128c11c --- /dev/null +++ b/app/src/main/res/layout/activity_custom_theme_listing.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.coordinatorlayout.widget.CoordinatorLayout 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=".Activity.CustomThemeListingActivity"> + + <com.google.android.material.appbar.AppBarLayout + android:id="@+id/appbar_layout_customize_theme_listing_activity" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="?attr/toolbarAndTabBackgroundColor" + android:theme="@style/AppTheme.AppBarOverlay"> + + <com.google.android.material.appbar.CollapsingToolbarLayout + android:id="@+id/collapsing_toolbar_layout_customize_theme_listing_activity" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:layout_scrollFlags="scroll|enterAlways" + app:titleEnabled="false" + app:toolbarId="@+id/toolbar_customize_theme_listing_activity"> + + <androidx.appcompat.widget.Toolbar + android:id="@+id/toolbar_customize_theme_listing_activity" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + app:popupTheme="@style/AppTheme.PopupOverlay" + app:navigationIcon="?attr/homeAsUpIndicator" /> + + </com.google.android.material.appbar.CollapsingToolbarLayout> + + </com.google.android.material.appbar.AppBarLayout> + + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/recycler_view_customize_theme_listing_activity" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:layout_behavior="@string/appbar_scrolling_view_behavior" /> + +</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/item_custom_theme.xml b/app/src/main/res/layout/item_custom_theme.xml new file mode 100644 index 00000000..1aba3472 --- /dev/null +++ b/app/src/main/res/layout/item_custom_theme.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <View + android:id="@+id/color_primary_item_custom_theme" + android:layout_width="24dp" + android:layout_height="24dp" + android:background="@drawable/circular_background" /> + + <TextView + android:id="@+id/name_text_view_item_custom_theme" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="32dp" /> + +</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/item_custom_theme_color_item.xml b/app/src/main/res/layout/item_custom_theme_color_item.xml new file mode 100644 index 00000000..9a56b98b --- /dev/null +++ b/app/src/main/res/layout/item_custom_theme_color_item.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <View + android:id="@+id/color_image_view_item_custom_theme_color_item" + android:layout_width="24dp" + android:layout_height="24dp" + android:background="@drawable/circular_background" + android:layout_gravity="center_vertical" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:layout_marginStart="32dp"> + + <TextView + android:id="@+id/theme_item_name_text_view_item_custom_theme_color_item" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_16" /> + + <TextView + android:id="@+id/theme_item_info_text_view_item_custom_theme_color_item" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="4dp" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" /> + + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/item_custom_theme_switch_item.xml b/app/src/main/res/layout/item_custom_theme_switch_item.xml new file mode 100644 index 00000000..18e3aed2 --- /dev/null +++ b/app/src/main/res/layout/item_custom_theme_switch_item.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <LinearLayout + android:layout_width="0dp" + android:layout_height="wrap_content" + android:orientation="vertical" + android:layout_weight="1" + android:layout_marginStart="56dp" + android:layout_marginEnd="16dp"> + + <TextView + android:id="@+id/theme_item_name_text_view_item_custom_theme_switch_item" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textColor="?attr/primaryTextColor" + android:textSize="?attr/font_16" /> + + <TextView + android:id="@+id/theme_item_info_text_view_item_custom_theme_switch_item" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="4dp" + android:textColor="?attr/secondaryTextColor" + android:textSize="?attr/font_default" /> + + </LinearLayout> + + <Switch + android:id="@+id/theme_item_switch_item_custom_theme_switch_item" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" /> + +</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/item_theme_color_item.xml b/app/src/main/res/layout/item_theme_color_item.xml deleted file mode 100644 index 6adc2d29..00000000 --- a/app/src/main/res/layout/item_theme_color_item.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <View - android:id="@+id/color_image_view_item_theme_color_item" - android:layout_width="24dp" - android:layout_height="24dp" - android:background="@drawable/circular_background" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> - - <TextView - android:id="@+id/theme_item_name_text_view_item_theme_color_item" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintStart_toEndOf="@id/color_image_view_item_theme_color_item" - app:layout_constraintEnd_toEndOf="parent" /> - - <TextView - android:id="@+id/theme_item_info_text_view_item_theme_color_item" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - app:layout_constraintTop_toBottomOf="@id/theme_item_name_text_view_item_theme_color_item" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toEndOf="@id/color_image_view_item_theme_color_item" - app:layout_constraintEnd_toEndOf="parent" /> - -</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/item_theme_switch_item.xml b/app/src/main/res/layout/item_theme_switch_item.xml deleted file mode 100644 index 4b337fc8..00000000 --- a/app/src/main/res/layout/item_theme_switch_item.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - xmlns:app="http://schemas.android.com/apk/res-auto"> - - <TextView - android:id="@+id/theme_item_name_text_view_item_theme_switch_item" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toEndOf="parent" /> - - <TextView - android:id="@+id/theme_item_info_text_view_item_theme_switch_item" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - app:layout_constraintTop_toBottomOf="@id/theme_item_name_text_view_item_theme_switch_item" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toStartOf="@id/theme_item_switch_item_theme_switch_item" /> - - <Switch - android:id="@+id/theme_item_switch_item_theme_switch_item" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" /> - -</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 158495c7..c32eac17 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -598,4 +598,8 @@ <string name="theme_item_available_on_android_8">Only available for Android 8.0 or above.</string> <string name="theme_item_available_on_android_6">Only available for Android 6.0 or above.</string> + <string name="theme_name_indigo">Indigo</string> + <string name="theme_name_indigo_dark">Indigo Dark</string> + <string name="theme_name_indigo_amoled">Indigo Amoled</string> + </resources> |