aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java140
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java24
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java40
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java133
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeDao.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/ThemePreferenceFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java2
-rw-r--r--app/src/main/res/layout/item_predefined_custom_theme.xml (renamed from app/src/main/res/layout/item_custom_theme.xml)9
-rw-r--r--app/src/main/res/layout/item_theme_name.xml24
-rw-r--r--app/src/main/res/layout/item_user_custom_theme.xml44
-rw-r--r--app/src/main/res/values/strings.xml11
-rw-r--r--app/src/main/res/xml/theme_preferences.xml4
16 files changed, 323 insertions, 185 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
index 791cd336..0e8376ec 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
@@ -56,14 +56,14 @@ public class CustomThemeListingActivity extends BaseActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
CustomThemeListingRecyclerViewAdapter adapter = new CustomThemeListingRecyclerViewAdapter(this,
- CustomThemeWrapper.getPredifinedThemes(this));
+ CustomThemeWrapper.getPredefinedThemes(this));
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
customThemeViewModel = new ViewModelProvider(this,
new CustomThemeViewModel.Factory(redditDataRoomDatabase))
.get(CustomThemeViewModel.class);
- customThemeViewModel.getAllCustomThemes().observe(this, customThemes -> adapter.setUserThemes(customThemes));
+ customThemeViewModel.getAllCustomThemes().observe(this, adapter::setUserThemes);
}
@Override
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 468c55d9..7dde8fc6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java
@@ -28,7 +28,6 @@ import ml.docilealligator.infinityforreddit.AsyncTask.GetCustomThemeAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertCustomThemeAsyncTask;
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.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Infinity;
@@ -43,7 +42,9 @@ public class CustomizeThemeActivity extends BaseActivity {
public static final int EXTRA_DARK_THEME = CustomThemeSharedPreferencesUtils.DARK;
public static final int EXTRA_AMOLED_THEME = CustomThemeSharedPreferencesUtils.AMOLED;
public static final String EXTRA_THEME_NAME = "ETN";
+ public static final String EXTRA_IS_PREDEFIINED_THEME = "EIPT";
private static final String CUSTOM_THEME_SETTINGS_ITEMS_STATE = "CTSIS";
+ private static final String THEME_NAME_STATE = "TNS";
@BindView(R.id.appbar_layout_customize_theme_activity)
AppBarLayout appBarLayout;
@@ -68,10 +69,8 @@ public class CustomizeThemeActivity extends BaseActivity {
@Inject
CustomThemeWrapper customThemeWrapper;
- public CustomThemeViewModel customThemeViewModel;
-
- private int themeType;
private String themeName;
+ private boolean isPredefinedTheme;
private ArrayList<CustomThemeSettingsItem> customThemeSettingsItems;
private CustomizeThemeRecyclerViewAdapter adapter;
@@ -89,81 +88,84 @@ public class CustomizeThemeActivity extends BaseActivity {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- adapter = new CustomizeThemeRecyclerViewAdapter(this);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
- recyclerView.setAdapter(adapter);
if (savedInstanceState != null) {
customThemeSettingsItems = savedInstanceState.getParcelableArrayList(CUSTOM_THEME_SETTINGS_ITEMS_STATE);
+ themeName = savedInstanceState.getString(THEME_NAME_STATE);
}
int androidVersion = Build.VERSION.SDK_INT;
if (customThemeSettingsItems == null) {
if (getIntent().hasExtra(EXTRA_THEME_TYPE)) {
- themeType = getIntent().getIntExtra(EXTRA_THEME_TYPE, EXTRA_LIGHT_THEME);
+ int themeType = getIntent().getIntExtra(EXTRA_THEME_TYPE, EXTRA_LIGHT_THEME);
new GetCustomThemeAsyncTask(redditDataRoomDatabase, themeType, customTheme -> {
if (customTheme == null) {
+ isPredefinedTheme = true;
switch (themeType) {
case EXTRA_DARK_THEME:
customThemeSettingsItems = CustomThemeSettingsItem.convertCustomThemeToSettingsItem(
CustomizeThemeActivity.this,
- CustomThemeWrapper.getIndigoDark(CustomizeThemeActivity.this));
+ CustomThemeWrapper.getIndigoDark(CustomizeThemeActivity.this),
+ androidVersion);
+ themeName = getString(R.string.theme_name_indigo_dark);
break;
case EXTRA_AMOLED_THEME:
customThemeSettingsItems = CustomThemeSettingsItem.convertCustomThemeToSettingsItem(
CustomizeThemeActivity.this,
- CustomThemeWrapper.getIndigoAmoled(CustomizeThemeActivity.this));
+ CustomThemeWrapper.getIndigoAmoled(CustomizeThemeActivity.this),
+ androidVersion);
+ themeName = getString(R.string.theme_name_indigo_amoled);
break;
default:
customThemeSettingsItems = CustomThemeSettingsItem.convertCustomThemeToSettingsItem(
CustomizeThemeActivity.this,
- CustomThemeWrapper.getIndigo(CustomizeThemeActivity.this));
+ CustomThemeWrapper.getIndigo(CustomizeThemeActivity.this),
+ androidVersion);
+ themeName = getString(R.string.theme_name_indigo);
}
} 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);
- }
- if (androidVersion < Build.VERSION_CODES.M) {
- customThemeSettingsItems.get(customThemeSettingsItems.size() - 3).itemDetails = getString(R.string.theme_item_available_on_android_6);
+ customThemeSettingsItems = CustomThemeSettingsItem.convertCustomThemeToSettingsItem(
+ CustomizeThemeActivity.this, customTheme, androidVersion);
+ themeName = customTheme.name;
}
+ setTitle(themeName);
+ adapter = new CustomizeThemeRecyclerViewAdapter(this, themeName, isPredefinedTheme);
+ recyclerView.setAdapter(adapter);
adapter.setCustomThemeSettingsItem(customThemeSettingsItems);
}).execute();
-
- switch (themeType) {
- case EXTRA_DARK_THEME:
- setTitle(getString(R.string.customize_dark_theme_fragment_title));
- break;
- case EXTRA_AMOLED_THEME:
- setTitle(getString(R.string.customize_amoled_theme_fragment_title));
- break;
- default:
- setTitle(getString(R.string.customize_light_theme_fragment_title));
- break;
- }
} else {
+ isPredefinedTheme = getIntent().getBooleanExtra(EXTRA_IS_PREDEFIINED_THEME, false);
themeName = getIntent().getStringExtra(EXTRA_THEME_NAME);
+ adapter = new CustomizeThemeRecyclerViewAdapter(this, themeName, isPredefinedTheme);
+ recyclerView.setAdapter(adapter);
setTitle(themeName);
- new GetCustomThemeAsyncTask(redditDataRoomDatabase, themeName,
- customTheme -> {
- 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);
- }
- if (androidVersion < Build.VERSION_CODES.M) {
- customThemeSettingsItems.get(customThemeSettingsItems.size() - 3).itemDetails = getString(R.string.theme_item_available_on_android_6);
- }
-
- adapter.setCustomThemeSettingsItem(customThemeSettingsItems);
- }).execute();
+ if (isPredefinedTheme) {
+ customThemeSettingsItems = CustomThemeSettingsItem.convertCustomThemeToSettingsItem(
+ CustomizeThemeActivity.this,
+ CustomThemeWrapper.getPredefinedCustomTheme(this, themeName),
+ androidVersion);
+
+ setTitle(themeName);
+ adapter = new CustomizeThemeRecyclerViewAdapter(this, themeName, isPredefinedTheme);
+ recyclerView.setAdapter(adapter);
+ adapter.setCustomThemeSettingsItem(customThemeSettingsItems);
+ } else {
+ new GetCustomThemeAsyncTask(redditDataRoomDatabase, themeName,
+ customTheme -> {
+ customThemeSettingsItems = CustomThemeSettingsItem.convertCustomThemeToSettingsItem(
+ CustomizeThemeActivity.this, customTheme, androidVersion);
+
+ adapter.setCustomThemeSettingsItem(customThemeSettingsItems);
+ }).execute();
+ }
}
} else {
+ adapter = new CustomizeThemeRecyclerViewAdapter(this, themeName, isPredefinedTheme);
+ recyclerView.setAdapter(adapter);
adapter.setCustomThemeSettingsItem(customThemeSettingsItems);
}
}
@@ -182,52 +184,13 @@ public class CustomizeThemeActivity extends BaseActivity {
finish();
return true;
case R.id.action_save_customize_theme_activity:
- if (themeName == null) {
- switch (themeType) {
- case CustomThemeSharedPreferencesUtils.DARK:
- themeName = "Indigo Dark";
- break;
- case CustomThemeSharedPreferencesUtils.AMOLED:
- themeName = "Indigo Amoled";
- break;
- default:
- themeName = "Indigo";
- }
- }
-
CustomTheme customTheme = CustomTheme.convertSettingsItemsToCustomTheme(customThemeSettingsItems, themeName);
-
- switch (themeType) {
- case CustomThemeSharedPreferencesUtils.DARK:
- customTheme.isLightTheme = false;
- customTheme.isDarkTheme = true;
- customTheme.isAmoledTheme = false;
- new InsertCustomThemeAsyncTask(redditDataRoomDatabase, darkThemeSharedPreferences, customTheme, () -> {
- Toast.makeText(CustomizeThemeActivity.this, R.string.saved, Toast.LENGTH_SHORT).show();
- EventBus.getDefault().post(new RecreateActivityEvent());
- finish();
- }).execute();
- break;
- case CustomThemeSharedPreferencesUtils.AMOLED:
- customTheme.isLightTheme = false;
- customTheme.isDarkTheme = false;
- customTheme.isAmoledTheme = true;
- new InsertCustomThemeAsyncTask(redditDataRoomDatabase, amoledThemeSharedPreferences, customTheme, () -> {
- Toast.makeText(CustomizeThemeActivity.this, R.string.saved, Toast.LENGTH_SHORT).show();
- EventBus.getDefault().post(new RecreateActivityEvent());
- finish();
- }).execute();
- break;
- default:
- customTheme.isLightTheme = true;
- customTheme.isDarkTheme = false;
- customTheme.isAmoledTheme = false;
- new InsertCustomThemeAsyncTask(redditDataRoomDatabase, lightThemeSharedPreferences, customTheme, () -> {
- Toast.makeText(CustomizeThemeActivity.this, R.string.saved, Toast.LENGTH_SHORT).show();
- EventBus.getDefault().post(new RecreateActivityEvent());
- finish();
- }).execute();
- }
+ new InsertCustomThemeAsyncTask(redditDataRoomDatabase, lightThemeSharedPreferences,
+ darkThemeSharedPreferences, amoledThemeSharedPreferences, customTheme, () -> {
+ Toast.makeText(CustomizeThemeActivity.this, R.string.saved, Toast.LENGTH_SHORT).show();
+ EventBus.getDefault().post(new RecreateActivityEvent());
+ finish();
+ }).execute();
return true;
}
@@ -239,6 +202,7 @@ public class CustomizeThemeActivity extends BaseActivity {
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelableArrayList(CUSTOM_THEME_SETTINGS_ITEMS_STATE, customThemeSettingsItems);
+ outState.putString(THEME_NAME_STATE, themeName);
}
@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
index 81487a02..267c72cb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java
@@ -6,6 +6,7 @@ import android.content.res.ColorStateList;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -56,11 +57,11 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
case VIEW_TYPE_PREDEFINED_THEME_DIVIDER:
return new PreDefinedThemeDividerViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_theme_type_divider, parent, false));
case VIEW_TYPE_PREDEFINED_THEME:
- return new PredefinedCustomThemeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_custom_theme, parent, false));
+ return new PredefinedCustomThemeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_predefined_custom_theme, parent, false));
case VIEW_TYPE_USER_THEME_DIVIDER:
return new UserThemeDividerViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_theme_type_divider, parent, false));
default:
- return new UserCustomThemeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_custom_theme, parent, false));
+ return new UserCustomThemeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_user_custom_theme, parent, false));
}
}
@@ -73,12 +74,19 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
((PredefinedCustomThemeViewHolder) holder).itemView.setOnClickListener(view -> {
Intent intent = new Intent(context, CustomizeThemeActivity.class);
intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, customTheme.name);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true);
context.startActivity(intent);
});
} else if (holder instanceof UserCustomThemeViewHolder) {
CustomTheme customTheme = userCustomThemes.get(position - predefinedCustomThemes.size() - 2);
((UserCustomThemeViewHolder) holder).colorPrimaryView.setBackgroundTintList(ColorStateList.valueOf(customTheme.colorPrimary));
((UserCustomThemeViewHolder) holder).nameTextView.setText(customTheme.name);
+ ((UserCustomThemeViewHolder) holder).deleteImageView.setOnClickListener(view -> {
+
+ });
+ ((UserCustomThemeViewHolder) holder).shareImageView.setOnClickListener(view -> {
+
+ });
((UserCustomThemeViewHolder) holder).itemView.setOnClickListener(view -> {
Intent intent = new Intent(context, CustomizeThemeActivity.class);
intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, customTheme.name);
@@ -103,9 +111,9 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
class PredefinedCustomThemeViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.color_primary_item_custom_theme)
+ @BindView(R.id.color_primary_item_predefined_custom_theme)
View colorPrimaryView;
- @BindView(R.id.name_text_view_item_custom_theme)
+ @BindView(R.id.name_text_view_item_predefined_custom_theme)
TextView nameTextView;
public PredefinedCustomThemeViewHolder(@NonNull View itemView) {
@@ -116,10 +124,14 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
class UserCustomThemeViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.color_primary_item_custom_theme)
+ @BindView(R.id.color_primary_item_user_custom_theme)
View colorPrimaryView;
- @BindView(R.id.name_text_view_item_custom_theme)
+ @BindView(R.id.name_text_view_item_user_custom_theme)
TextView nameTextView;
+ @BindView(R.id.delete_image_view_item_user_custom_theme)
+ ImageView deleteImageView;
+ @BindView(R.id.share_image_view_item_user_custom_theme)
+ ImageView shareImageView;
public UserCustomThemeViewHolder(@NonNull View itemView) {
super(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 69fa7ee5..be2aae85 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java
@@ -22,17 +22,25 @@ 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 static final int VIEW_TYPE_THEME_NAME = 3;
private AppCompatActivity activity;
private ArrayList<CustomThemeSettingsItem> customThemeSettingsItems;
+ private String themeName;
+ private boolean isPredefinedTheme;
- public CustomizeThemeRecyclerViewAdapter(AppCompatActivity activity) {
+ public CustomizeThemeRecyclerViewAdapter(AppCompatActivity activity, String themeName,
+ boolean isPredefinedTheme) {
this.activity = activity;
customThemeSettingsItems = new ArrayList<>();
+ this.themeName = themeName;
+ this.isPredefinedTheme = isPredefinedTheme;
}
@Override
public int getItemViewType(int position) {
- if (position < customThemeSettingsItems.size() - 3) {
+ if (position == 0) {
+ return VIEW_TYPE_THEME_NAME;
+ } else if (position > 3 && position < customThemeSettingsItems.size() - 3) {
return VIEW_TYPE_COLOR;
}
@@ -44,6 +52,8 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
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_custom_theme_switch_item, parent, false));
+ } else if (viewType == VIEW_TYPE_THEME_NAME) {
+ return new ThemeNameItemViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_theme_name, parent, false));
}
return new ThemeColorItemViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_custom_theme_color_item, parent, false));
@@ -52,7 +62,7 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ThemeColorItemViewHolder) {
- CustomThemeSettingsItem customThemeSettingsItem = customThemeSettingsItems.get(position);
+ CustomThemeSettingsItem customThemeSettingsItem = customThemeSettingsItems.get(position - 1);
((ThemeColorItemViewHolder) holder).themeItemNameTextView.setText(customThemeSettingsItem.itemName);
((ThemeColorItemViewHolder) holder).themeItemInfoTextView.setText(customThemeSettingsItem.itemDetails);
((ThemeColorItemViewHolder) holder).colorImageView.setBackgroundTintList(ColorStateList.valueOf(customThemeSettingsItem.colorValue));
@@ -63,18 +73,23 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}).show();
});
} else if (holder instanceof ThemeSwitchItemViewHolder) {
- CustomThemeSettingsItem customThemeSettingsItem = customThemeSettingsItems.get(position);
+ CustomThemeSettingsItem customThemeSettingsItem = customThemeSettingsItems.get(position - 1);
((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());
+ } else if (holder instanceof ThemeNameItemViewHolder) {
+ ((ThemeNameItemViewHolder) holder).themeNameTextView.setText(themeName);
+ holder.itemView.setOnClickListener(view -> {
+
+ });
}
}
@Override
public int getItemCount() {
- return customThemeSettingsItems.size();
+ return customThemeSettingsItems.size() + 1;
}
public void setCustomThemeSettingsItem(ArrayList<CustomThemeSettingsItem> customThemeSettingsItems) {
@@ -111,4 +126,19 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
ButterKnife.bind(this, itemView);
}
}
+
+ class ThemeNameItemViewHolder extends RecyclerView.ViewHolder {
+ @BindView(R.id.theme_name_text_view_item_theme_name)
+ TextView themeNameTextView;
+ @BindView(R.id.description_text_view_item_theme_name)
+ TextView descriptionTextView;
+ public ThemeNameItemViewHolder(@NonNull View itemView) {
+ super(itemView);
+ ButterKnife.bind(this, itemView);
+ if (isPredefinedTheme) {
+ descriptionTextView.setText(activity.getString(R.string.theme_name_forbid_change_description));
+ itemView.setOnClickListener(view ->{});
+ }
+ }
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java
index c8c29a03..5477ecbe 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/InsertCustomThemeAsyncTask.java
@@ -9,7 +9,9 @@ import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUt
public class InsertCustomThemeAsyncTask extends AsyncTask<Void, Void, Void> {
private RedditDataRoomDatabase redditDataRoomDatabase;
- private SharedPreferences themeSharedPreferences;
+ private SharedPreferences lightThemeSharedPreferences;
+ private SharedPreferences darkThemeSharedPreferences;
+ private SharedPreferences amoledThemeSharedPreferences;
private CustomTheme customTheme;
private InsertCustomThemeAsyncTaskListener insertCustomThemeAsyncTaskListener;
@@ -18,18 +20,33 @@ public class InsertCustomThemeAsyncTask extends AsyncTask<Void, Void, Void> {
}
public InsertCustomThemeAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase,
- SharedPreferences themeSharedPreferences, CustomTheme customTheme,
+ SharedPreferences lightThemeSharedPreferences,
+ SharedPreferences darkThemeSharedPreferences,
+ SharedPreferences amoledThemeSharedPreferences, CustomTheme customTheme,
InsertCustomThemeAsyncTaskListener insertCustomThemeAsyncTaskListener) {
this.redditDataRoomDatabase = redditDataRoomDatabase;
- this.themeSharedPreferences = themeSharedPreferences;
+ this.lightThemeSharedPreferences = lightThemeSharedPreferences;
+ this.darkThemeSharedPreferences = darkThemeSharedPreferences;
+ this.amoledThemeSharedPreferences = amoledThemeSharedPreferences;
this.customTheme = customTheme;
this.insertCustomThemeAsyncTaskListener = insertCustomThemeAsyncTaskListener;
}
@Override
protected Void doInBackground(Void... voids) {
+ if (customTheme.isLightTheme) {
+ redditDataRoomDatabase.customThemeDao().unsetLightTheme();
+ CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, lightThemeSharedPreferences);
+ }
+ if (customTheme.isDarkTheme) {
+ redditDataRoomDatabase.customThemeDao().unsetDarkTheme();
+ CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, darkThemeSharedPreferences);
+ }
+ if (customTheme.isAmoledTheme) {
+ redditDataRoomDatabase.customThemeDao().unsetAmoledTheme();
+ CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, amoledThemeSharedPreferences);
+ }
redditDataRoomDatabase.customThemeDao().insert(customTheme);
- CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(customTheme, themeSharedPreferences);
return null;
}
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 374030ac..65409086 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java
@@ -161,71 +161,74 @@ public class CustomTheme {
return customTheme;
}
- customTheme.colorPrimary = customThemeSettingsItems.get(0).colorValue;
- customTheme.colorPrimaryDark = customThemeSettingsItems.get(1).colorValue;
- customTheme.colorAccent = customThemeSettingsItems.get(2).colorValue;
- customTheme.colorPrimaryLightTheme = customThemeSettingsItems.get(3).colorValue;
- customTheme.primaryTextColor = customThemeSettingsItems.get(4).colorValue;
- customTheme.secondaryTextColor = customThemeSettingsItems.get(5).colorValue;
- customTheme.postTitleColor = customThemeSettingsItems.get(6).colorValue;
- customTheme.postContentColor = customThemeSettingsItems.get(7).colorValue;
- customTheme.commentColor = customThemeSettingsItems.get(8).colorValue;
- customTheme.buttonTextColor = customThemeSettingsItems.get(9).colorValue;
- customTheme.chipTextColor = customThemeSettingsItems.get(10).colorValue;
- customTheme.backgroundColor = customThemeSettingsItems.get(11).colorValue;
- customTheme.cardViewBackgroundColor = customThemeSettingsItems.get(12).colorValue;
- customTheme.commentBackgroundColor = customThemeSettingsItems.get(13).colorValue;
- customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(14).colorValue;
- customTheme.primaryIconColor = customThemeSettingsItems.get(15).colorValue;
- customTheme.postIconAndInfoColor = customThemeSettingsItems.get(16).colorValue;
- customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(17).colorValue;
- customTheme.fabIconColor = customThemeSettingsItems.get(18).colorValue;
- customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(19).colorValue;
- customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(20).colorValue;
- customTheme.circularProgressBarBackground = customThemeSettingsItems.get(21).colorValue;
- customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(22).colorValue;
- customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(23).colorValue;
- customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(24).colorValue;
- customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(25).colorValue;
- customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(26).colorValue;
- customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(27).colorValue;
- customTheme.upvoted = customThemeSettingsItems.get(28).colorValue;
- customTheme.downvoted = customThemeSettingsItems.get(29).colorValue;
- customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(30).colorValue;
- customTheme.postTypeTextColor = customThemeSettingsItems.get(31).colorValue;
- customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(32).colorValue;
- customTheme.spoilerTextColor = customThemeSettingsItems.get(33).colorValue;
- customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(34).colorValue;
- customTheme.nsfwTextColor = customThemeSettingsItems.get(35).colorValue;
- customTheme.flairBackgroundColor = customThemeSettingsItems.get(36).colorValue;
- customTheme.flairTextColor = customThemeSettingsItems.get(37).colorValue;
- customTheme.archivedTint = customThemeSettingsItems.get(38).colorValue;
- customTheme.lockedIconTint = customThemeSettingsItems.get(39).colorValue;
- customTheme.crosspostIconTint = customThemeSettingsItems.get(40).colorValue;
- customTheme.stickiedPostIconTint = customThemeSettingsItems.get(41).colorValue;
- customTheme.subscribed = customThemeSettingsItems.get(42).colorValue;
- customTheme.unsubscribed = customThemeSettingsItems.get(43).colorValue;
- customTheme.username = customThemeSettingsItems.get(44).colorValue;
- customTheme.subreddit = customThemeSettingsItems.get(45).colorValue;
- customTheme.authorFlairTextColor = customThemeSettingsItems.get(46).colorValue;
- customTheme.submitter = customThemeSettingsItems.get(47).colorValue;
- customTheme.moderator = customThemeSettingsItems.get(48).colorValue;
- customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(49).colorValue;
- customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(50).colorValue;
- customTheme.dividerColor = customThemeSettingsItems.get(51).colorValue;
- customTheme.noPreviewLinkBackgroundColor = customThemeSettingsItems.get(52).colorValue;
- customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(53).colorValue;
- customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(54).colorValue;
- customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(55).colorValue;
- customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(56).colorValue;
- customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(57).colorValue;
- customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(58).colorValue;
- customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(59).colorValue;
- customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(60).colorValue;
- customTheme.navBarColor = customThemeSettingsItems.get(61).colorValue;
- customTheme.isLightStatusBar = customThemeSettingsItems.get(62).isEnabled;
- customTheme.isLightNavBar = customThemeSettingsItems.get(63).isEnabled;
- customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(64).isEnabled;
+ customTheme.isLightTheme = customThemeSettingsItems.get(0).isEnabled;
+ customTheme.isDarkTheme = customThemeSettingsItems.get(1).isEnabled;
+ customTheme.isAmoledTheme = customThemeSettingsItems.get(2).isEnabled;
+ customTheme.colorPrimary = customThemeSettingsItems.get(3).colorValue;
+ customTheme.colorPrimaryDark = customThemeSettingsItems.get(4).colorValue;
+ customTheme.colorAccent = customThemeSettingsItems.get(5).colorValue;
+ customTheme.colorPrimaryLightTheme = customThemeSettingsItems.get(6).colorValue;
+ customTheme.primaryTextColor = customThemeSettingsItems.get(7).colorValue;
+ customTheme.secondaryTextColor = customThemeSettingsItems.get(8).colorValue;
+ customTheme.postTitleColor = customThemeSettingsItems.get(9).colorValue;
+ customTheme.postContentColor = customThemeSettingsItems.get(10).colorValue;
+ customTheme.commentColor = customThemeSettingsItems.get(11).colorValue;
+ customTheme.buttonTextColor = customThemeSettingsItems.get(12).colorValue;
+ customTheme.chipTextColor = customThemeSettingsItems.get(13).colorValue;
+ customTheme.backgroundColor = customThemeSettingsItems.get(14).colorValue;
+ customTheme.cardViewBackgroundColor = customThemeSettingsItems.get(15).colorValue;
+ customTheme.commentBackgroundColor = customThemeSettingsItems.get(16).colorValue;
+ customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(17).colorValue;
+ customTheme.primaryIconColor = customThemeSettingsItems.get(18).colorValue;
+ customTheme.postIconAndInfoColor = customThemeSettingsItems.get(19).colorValue;
+ customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(20).colorValue;
+ customTheme.fabIconColor = customThemeSettingsItems.get(21).colorValue;
+ customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(22).colorValue;
+ customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(23).colorValue;
+ customTheme.circularProgressBarBackground = customThemeSettingsItems.get(24).colorValue;
+ customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(25).colorValue;
+ customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(26).colorValue;
+ customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(27).colorValue;
+ customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(28).colorValue;
+ customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(29).colorValue;
+ customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(30).colorValue;
+ customTheme.upvoted = customThemeSettingsItems.get(31).colorValue;
+ customTheme.downvoted = customThemeSettingsItems.get(32).colorValue;
+ customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(33).colorValue;
+ customTheme.postTypeTextColor = customThemeSettingsItems.get(34).colorValue;
+ customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(35).colorValue;
+ customTheme.spoilerTextColor = customThemeSettingsItems.get(36).colorValue;
+ customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(37).colorValue;
+ customTheme.nsfwTextColor = customThemeSettingsItems.get(38).colorValue;
+ customTheme.flairBackgroundColor = customThemeSettingsItems.get(39).colorValue;
+ customTheme.flairTextColor = customThemeSettingsItems.get(40).colorValue;
+ customTheme.archivedTint = customThemeSettingsItems.get(41).colorValue;
+ customTheme.lockedIconTint = customThemeSettingsItems.get(42).colorValue;
+ customTheme.crosspostIconTint = customThemeSettingsItems.get(43).colorValue;
+ customTheme.stickiedPostIconTint = customThemeSettingsItems.get(44).colorValue;
+ customTheme.subscribed = customThemeSettingsItems.get(45).colorValue;
+ customTheme.unsubscribed = customThemeSettingsItems.get(46).colorValue;
+ customTheme.username = customThemeSettingsItems.get(47).colorValue;
+ customTheme.subreddit = customThemeSettingsItems.get(48).colorValue;
+ customTheme.authorFlairTextColor = customThemeSettingsItems.get(49).colorValue;
+ customTheme.submitter = customThemeSettingsItems.get(50).colorValue;
+ customTheme.moderator = customThemeSettingsItems.get(51).colorValue;
+ customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(52).colorValue;
+ customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(53).colorValue;
+ customTheme.dividerColor = customThemeSettingsItems.get(54).colorValue;
+ customTheme.noPreviewLinkBackgroundColor = customThemeSettingsItems.get(55).colorValue;
+ customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(56).colorValue;
+ customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(57).colorValue;
+ customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(58).colorValue;
+ customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(59).colorValue;
+ customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(60).colorValue;
+ customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(61).colorValue;
+ customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(62).colorValue;
+ customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(63).colorValue;
+ customTheme.navBarColor = customThemeSettingsItems.get(64).colorValue;
+ customTheme.isLightStatusBar = customThemeSettingsItems.get(65).isEnabled;
+ customTheme.isLightNavBar = customThemeSettingsItems.get(66).isEnabled;
+ customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(67).isEnabled;
return 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 42102bcb..48ec7122 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeDao.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeDao.java
@@ -28,6 +28,15 @@ public interface CustomThemeDao {
@Query("SELECT * FROM custom_themes WHERE name = :name COLLATE NOCASE LIMIT 1")
CustomTheme getCustomTheme(String name);
+ @Query("UPDATE custom_themes SET is_light_theme = 0 WHERE is_light_theme = 1")
+ void unsetLightTheme();
+
+ @Query("UPDATE custom_themes SET is_dark_theme = 0 WHERE is_dark_theme = 1")
+ void unsetDarkTheme();
+
+ @Query("UPDATE custom_themes SET is_amoled_theme = 0 WHERE is_amoled_theme = 1")
+ void unsetAmoledTheme();
+
@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 97f5d10e..0dbf49de 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java
@@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit.CustomTheme;
import android.content.Context;
+import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
@@ -44,7 +45,9 @@ public class CustomThemeSettingsItem implements Parcelable {
}
};
- public static ArrayList<CustomThemeSettingsItem> convertCustomThemeToSettingsItem(Context context, CustomTheme customTheme) {
+ public static ArrayList<CustomThemeSettingsItem> convertCustomThemeToSettingsItem(Context context,
+ CustomTheme customTheme,
+ int androidVersion) {
ArrayList<CustomThemeSettingsItem> customThemeSettingsItems = new ArrayList<>();
if (customTheme == null) {
@@ -52,6 +55,18 @@ public class CustomThemeSettingsItem implements Parcelable {
}
customThemeSettingsItems.add(new CustomThemeSettingsItem(
+ context.getString(R.string.theme_item_is_light_theme),
+ customTheme.isLightTheme
+ ));
+ customThemeSettingsItems.add(new CustomThemeSettingsItem(
+ context.getString(R.string.theme_item_is_dark_theme),
+ customTheme.isDarkTheme
+ ));
+ customThemeSettingsItems.add(new CustomThemeSettingsItem(
+ context.getString(R.string.theme_item_is_amoled_theme),
+ customTheme.isAmoledTheme
+ ));
+ customThemeSettingsItems.add(new CustomThemeSettingsItem(
context.getString(R.string.theme_item_color_primary),
context.getString(R.string.theme_item_color_primary_detail),
customTheme.colorPrimary));
@@ -308,6 +323,12 @@ public class CustomThemeSettingsItem implements Parcelable {
customThemeSettingsItems.add(new CustomThemeSettingsItem(
context.getString(R.string.theme_item_change_status_bar_icon_color_after_toolbar_collapsed_in_immersive_interface),
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface));
+ if (androidVersion < Build.VERSION_CODES.O) {
+ customThemeSettingsItems.get(customThemeSettingsItems.size() - 2).itemDetails = context.getString(R.string.theme_item_available_on_android_8);
+ }
+ if (androidVersion < Build.VERSION_CODES.M) {
+ customThemeSettingsItems.get(customThemeSettingsItems.size() - 3).itemDetails = context.getString(R.string.theme_item_available_on_android_6);
+ }
return customThemeSettingsItems;
}
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 8244ce4f..b53fbab8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java
@@ -377,7 +377,17 @@ public class CustomThemeWrapper {
themeType == CustomThemeSharedPreferencesUtils.LIGHT);
}
- public static ArrayList<CustomTheme> getPredifinedThemes(Context context) {
+ public static CustomTheme getPredefinedCustomTheme(Context context, String name) {
+ if (name.equals(context.getString(R.string.theme_name_indigo_dark))) {
+ return getIndigoDark(context);
+ } else if (name.equals(context.getString(R.string.theme_name_indigo_amoled))) {
+ return getIndigoAmoled(context);
+ } else {
+ return getIndigo(context);
+ }
+ }
+
+ public static ArrayList<CustomTheme> getPredefinedThemes(Context context) {
ArrayList<CustomTheme> customThemes = new ArrayList<>();
customThemes.add(getIndigo(context));
customThemes.add(getIndigoDark(context));
@@ -534,7 +544,7 @@ public class CustomThemeWrapper {
}
public static CustomTheme getIndigoAmoled(Context context) {
- CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_indigo_dark));
+ CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_indigo_amoled));
customTheme.isLightTheme = false;
customTheme.isDarkTheme = true;
customTheme.isAmoledTheme = false;
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 f96f6f21..aa41849c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/ThemePreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/ThemePreferenceFragment.java
@@ -53,7 +53,7 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat {
Preference customizeLightThemePreference = findPreference(SharedPreferencesUtils.CUSTOMIZE_LIGHT_THEME);
Preference customizeDarkThemePreference = findPreference(SharedPreferencesUtils.CUSTOMIZE_DARK_THEME);
Preference customizeAmoledThemePreference = findPreference(SharedPreferencesUtils.CUSTOMIZE_AMOLED_THEME);
- Preference selectAndCustomizeThemePreference = findPreference(SharedPreferencesUtils.SELECT_AND_CUSTOMIZE_THEME);
+ Preference selectAndCustomizeThemePreference = findPreference(SharedPreferencesUtils.MANAGE_THEMES);
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
if (themePreference != null && amoledDarkSwitch != null) {
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 d9385249..08f55dfe 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -80,5 +80,5 @@ public class SharedPreferencesUtils {
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";
- public static final String SELECT_AND_CUSTOMIZE_THEME = "select_and_customize_theme";
+ public static final String MANAGE_THEMES = "manage_themes";
}
diff --git a/app/src/main/res/layout/item_custom_theme.xml b/app/src/main/res/layout/item_predefined_custom_theme.xml
index 1aba3472..432628b1 100644
--- a/app/src/main/res/layout/item_custom_theme.xml
+++ b/app/src/main/res/layout/item_predefined_custom_theme.xml
@@ -8,15 +8,18 @@
android:background="?attr/selectableItemBackground">
<View
- android:id="@+id/color_primary_item_custom_theme"
+ android:id="@+id/color_primary_item_predefined_custom_theme"
android:layout_width="24dp"
android:layout_height="24dp"
+ android:layout_gravity="center_vertical"
android:background="@drawable/circular_background" />
<TextView
- android:id="@+id/name_text_view_item_custom_theme"
+ android:id="@+id/name_text_view_item_predefined_custom_theme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="32dp" />
+ android:layout_marginStart="32dp"
+ android:layout_gravity="center_vertical"
+ android:textColor="?attr/primaryTextColor" />
</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/item_theme_name.xml b/app/src/main/res/layout/item_theme_name.xml
new file mode 100644
index 00000000..84c49d7c
--- /dev/null
+++ b/app/src/main/res/layout/item_theme_name.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground">
+
+ <TextView
+ android:id="@+id/theme_name_text_view_item_theme_name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textColor="?attr/primaryTextColor" />
+
+ <TextView
+ android:id="@+id/description_text_view_item_theme_name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="4dp"
+ android:text="@string/theme_name_description"
+ android:textColor="?attr/secondaryTextColor" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/item_user_custom_theme.xml b/app/src/main/res/layout/item_user_custom_theme.xml
new file mode 100644
index 00000000..fe610557
--- /dev/null
+++ b/app/src/main/res/layout/item_user_custom_theme.xml
@@ -0,0 +1,44 @@
+<?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_user_custom_theme"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center_vertical"
+ android:background="@drawable/circular_background" />
+
+ <TextView
+ android:id="@+id/name_text_view_item_user_custom_theme"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_marginStart="32dp"
+ android:layout_gravity="center_vertical"
+ android:textColor="?attr/primaryTextColor" />
+
+ <ImageView
+ android:id="@+id/delete_image_view_item_user_custom_theme"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center_vertical"
+ android:layout_marginStart="32dp"
+ android:src="@drawable/ic_delete_24dp"
+ android:background="?attr/selectableItemBackgroundBorderless" />
+
+ <ImageView
+ android:id="@+id/share_image_view_item_user_custom_theme"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center_vertical"
+ android:layout_marginStart="16dp"
+ android:src="@drawable/ic_share_24dp"
+ android:background="?attr/selectableItemBackgroundBorderless" />
+
+</LinearLayout> \ 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 b8d4e657..56a0e264 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -362,7 +362,7 @@
<string name="settings_customize_light_theme_title">Light Theme</string>
<string name="settings_customize_dark_theme_title">Dark Theme</string>
<string name="settings_customize_amoled_theme_title">Amoled Theme</string>
- <string name="settings_select_and_customize_theme_title">Select and Customize Themes</string>
+ <string name="settings_manage_themes_title">Manage Themes</string>
<string name="settings_custom_theme_cannot_apply_to_settings_page_title">Custom themes cannot be applied to settings page.</string>
<string name="no_link_available">Cannot get the link</string>
@@ -467,10 +467,11 @@
<string name="save_image_before_sharing">Saving the image. Please wait.</string>
<string name="save_gif_before_sharing">Saving the gif. Please wait.</string>
- <string name="customize_light_theme_fragment_title">Customize Light Theme</string>
- <string name="customize_dark_theme_fragment_title">Customize Dark Theme</string>
- <string name="customize_amoled_theme_fragment_title">Customize Amoled Theme</string>
-
+ <string name="theme_name_description">Tap to change the name of this theme.</string>
+ <string name="theme_name_forbid_change_description">You cannot change the name of this predefined theme.</string>
+ <string name="theme_item_is_light_theme">Set as Light Theme</string>
+ <string name="theme_item_is_dark_theme">Set as Dark Theme</string>
+ <string name="theme_item_is_amoled_theme">Set as Amoled Theme</string>
<string name="theme_item_color_primary">Color Primary</string>
<string name="theme_item_color_primary_detail">Applied to: Toolbar</string>
<string name="theme_item_color_primary_dark">Color Primary Dark</string>
diff --git a/app/src/main/res/xml/theme_preferences.xml b/app/src/main/res/xml/theme_preferences.xml
index 5bcc5ef3..e6aec71f 100644
--- a/app/src/main/res/xml/theme_preferences.xml
+++ b/app/src/main/res/xml/theme_preferences.xml
@@ -34,9 +34,9 @@
app:title="@string/settings_customize_amoled_theme_title" />
<Preference
- app:key="select_and_customize_theme"
+ app:key="manage_themes"
app:icon="@drawable/ic_edit_24dp"
- app:title="@string/settings_select_and_customize_theme_title" />
+ app:title="@string/settings_manage_themes_title" />
<Preference
app:summary="@string/settings_custom_theme_cannot_apply_to_settings_page_title"