aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-03-26 16:30:05 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-03-26 16:30:05 +0000
commit3dca261deaa2674b1faca52fec213f6cc960a61f (patch)
treea8dfbfe0c1503014ef66ee01d31d383073041a98 /app/src/main
parent0694c471c4ba39fa8235e1ecfcc4e8e40ad13ad2 (diff)
downloadinfinity-for-reddit-3dca261deaa2674b1faca52fec213f6cc960a61f.tar
infinity-for-reddit-3dca261deaa2674b1faca52fec213f6cc960a61f.tar.gz
infinity-for-reddit-3dca261deaa2674b1faca52fec213f6cc960a61f.tar.bz2
infinity-for-reddit-3dca261deaa2674b1faca52fec213f6cc960a61f.tar.lz
infinity-for-reddit-3dca261deaa2674b1faca52fec213f6cc960a61f.tar.xz
infinity-for-reddit-3dca261deaa2674b1faca52fec213f6cc960a61f.tar.zst
infinity-for-reddit-3dca261deaa2674b1faca52fec213f6cc960a61f.zip
Still implementing custom themes.
Diffstat (limited to '')
-rw-r--r--app/src/main/AndroidManifest.xml1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java57
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java39
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java35
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java46
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/ChangeThemeNameAsyncTask.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/DeleteThemeAsyncTask.java21
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeDao.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeRepository.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeViewModel.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java92
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SelectBaseThemeBottomSheetFragment.java78
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/ThemePreferenceFragment.java40
-rw-r--r--app/src/main/res/drawable-night/ic_amoled_theme_preference_24dp.xml9
-rw-r--r--app/src/main/res/drawable/ic_amoled_theme_preference_24dp.xml9
-rw-r--r--app/src/main/res/layout/activity_custom_theme_listing.xml10
-rw-r--r--app/src/main/res/layout/activity_customize_theme.xml1
-rw-r--r--app/src/main/res/layout/dialog_edit_theme_name.xml10
-rw-r--r--app/src/main/res/layout/fragment_custom_theme_options_bottom_sheet.xml97
-rw-r--r--app/src/main/res/layout/fragment_select_base_theme_bottom_sheet.xml81
-rw-r--r--app/src/main/res/layout/item_predefined_custom_theme.xml11
-rw-r--r--app/src/main/res/layout/item_user_custom_theme.xml4
-rw-r--r--app/src/main/res/values/strings.xml14
-rw-r--r--app/src/main/res/xml/theme_preferences.xml11
26 files changed, 700 insertions, 43 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index dafb5596..1091ef63 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -27,6 +27,7 @@
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".Activity.CustomizeThemeActivity"
+ android:label="@string/customize_theme_activity_label"
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
index 0e8376ec..6bc3a927 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
@@ -1,8 +1,12 @@
package ml.docilealligator.infinityforreddit.Activity;
+import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
@@ -11,6 +15,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
import javax.inject.Inject;
import javax.inject.Named;
@@ -18,13 +24,17 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Adapter.CustomThemeListingRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.AsyncTask.ChangeThemeNameAsyncTask;
+import ml.docilealligator.infinityforreddit.AsyncTask.DeleteThemeAsyncTask;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeViewModel;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.Fragment.CustomThemeOptionsBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.Fragment.SelectBaseThemeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
-public class CustomThemeListingActivity extends BaseActivity {
+public class CustomThemeListingActivity extends BaseActivity implements CustomThemeOptionsBottomSheetFragment.CustomThemeOptionsBottomSheetFragmentListener {
@BindView(R.id.appbar_layout_customize_theme_listing_activity)
AppBarLayout appBarLayout;
@@ -32,6 +42,8 @@ public class CustomThemeListingActivity extends BaseActivity {
Toolbar toolbar;
@BindView(R.id.recycler_view_customize_theme_listing_activity)
RecyclerView recyclerView;
+ @BindView(R.id.fab_custom_theme_listing_activity)
+ FloatingActionButton fab;
@Inject
@Named("default")
SharedPreferences sharedPreferences;
@@ -64,6 +76,11 @@ public class CustomThemeListingActivity extends BaseActivity {
new CustomThemeViewModel.Factory(redditDataRoomDatabase))
.get(CustomThemeViewModel.class);
customThemeViewModel.getAllCustomThemes().observe(this, adapter::setUserThemes);
+
+ fab.setOnClickListener(view -> {
+ SelectBaseThemeBottomSheetFragment selectBaseThemeBottomSheetFragment = new SelectBaseThemeBottomSheetFragment();
+ selectBaseThemeBottomSheetFragment.show(getSupportFragmentManager(), selectBaseThemeBottomSheetFragment.getTag());
+ });
}
@Override
@@ -89,4 +106,42 @@ public class CustomThemeListingActivity extends BaseActivity {
protected void applyCustomTheme() {
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
}
+
+ @Override
+ public void changeName(String oldName) {
+ View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_theme_name, null);
+ EditText themeNameEditText = dialogView.findViewById(R.id.theme_name_edit_text_edit_theme_name_dialog);
+ themeNameEditText.setText(oldName);
+ themeNameEditText.requestFocus();
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm != null) {
+ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+ }
+ new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.edit_theme_name)
+ .setView(dialogView)
+ .setPositiveButton(R.string.ok, (dialogInterface, i)
+ -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(themeNameEditText.getWindowToken(), 0);
+ }
+ new ChangeThemeNameAsyncTask(redditDataRoomDatabase, oldName, themeNameEditText.getText().toString());
+ })
+ .setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(themeNameEditText.getWindowToken(), 0);
+ }
+ })
+ .setOnDismissListener(dialogInterface -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(themeNameEditText.getWindowToken(), 0);
+ }
+ })
+ .show();
+ }
+
+ @Override
+ public void delete(String name) {
+ new DeleteThemeAsyncTask(redditDataRoomDatabase, name).execute();
+ }
}
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 7dde8fc6..e4847ac4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomizeThemeActivity.java
@@ -9,10 +9,12 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.snackbar.Snackbar;
import org.greenrobot.eventbus.EventBus;
@@ -43,9 +45,12 @@ public class CustomizeThemeActivity extends BaseActivity {
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";
+ public static final String EXTRA_CREATE_THEME = "ECT";
private static final String CUSTOM_THEME_SETTINGS_ITEMS_STATE = "CTSIS";
private static final String THEME_NAME_STATE = "TNS";
+ @BindView(R.id.coordinator_customize_theme_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_customize_theme_activity)
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_customize_theme_activity)
@@ -88,6 +93,10 @@ public class CustomizeThemeActivity extends BaseActivity {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ if (getIntent().getBooleanExtra(EXTRA_CREATE_THEME, false)) {
+ setTitle(R.string.customize_theme_activity_create_theme_label);
+ }
+
recyclerView.setLayoutManager(new LinearLayoutManager(this));
if (savedInstanceState != null) {
@@ -132,7 +141,6 @@ public class CustomizeThemeActivity extends BaseActivity {
themeName = customTheme.name;
}
- setTitle(themeName);
adapter = new CustomizeThemeRecyclerViewAdapter(this, themeName, isPredefinedTheme);
recyclerView.setAdapter(adapter);
adapter.setCustomThemeSettingsItem(customThemeSettingsItems);
@@ -142,14 +150,12 @@ public class CustomizeThemeActivity extends BaseActivity {
themeName = getIntent().getStringExtra(EXTRA_THEME_NAME);
adapter = new CustomizeThemeRecyclerViewAdapter(this, themeName, isPredefinedTheme);
recyclerView.setAdapter(adapter);
- setTitle(themeName);
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);
@@ -184,13 +190,20 @@ public class CustomizeThemeActivity extends BaseActivity {
finish();
return true;
case R.id.action_save_customize_theme_activity:
- CustomTheme customTheme = CustomTheme.convertSettingsItemsToCustomTheme(customThemeSettingsItems, themeName);
- 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();
+ if (adapter != null) {
+ themeName = adapter.getThemeName();
+ if (themeName.equals("")) {
+ Snackbar.make(coordinatorLayout, R.string.no_theme_name, Snackbar.LENGTH_SHORT).show();
+ return true;
+ }
+ CustomTheme customTheme = CustomTheme.convertSettingsItemsToCustomTheme(customThemeSettingsItems, themeName);
+ 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;
}
@@ -201,8 +214,10 @@ public class CustomizeThemeActivity extends BaseActivity {
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
- outState.putParcelableArrayList(CUSTOM_THEME_SETTINGS_ITEMS_STATE, customThemeSettingsItems);
- outState.putString(THEME_NAME_STATE, themeName);
+ if (adapter != null) {
+ outState.putParcelableArrayList(CUSTOM_THEME_SETTINGS_ITEMS_STATE, customThemeSettingsItems);
+ outState.putString(THEME_NAME_STATE, adapter.getThemeName());
+ }
}
@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 267c72cb..525564b8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomThemeListingRecyclerViewAdapter.java
@@ -1,8 +1,8 @@
package ml.docilealligator.infinityforreddit.Adapter;
-import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
+import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -10,6 +10,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
@@ -19,6 +20,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Activity.CustomizeThemeActivity;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme;
+import ml.docilealligator.infinityforreddit.Fragment.CustomThemeOptionsBottomSheetFragment;
import ml.docilealligator.infinityforreddit.R;
public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@@ -27,12 +29,12 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
private static final int VIEW_TYPE_PREDEFINED_THEME_DIVIDER = 2;
private static final int VIEW_TYPE_USER_THEME_DIVIDER = 3;
- private Context context;
+ private AppCompatActivity activity;
private ArrayList<CustomTheme> predefinedCustomThemes;
private ArrayList<CustomTheme> userCustomThemes;
- public CustomThemeListingRecyclerViewAdapter(Context context, ArrayList<CustomTheme> predefinedCustomThemes) {
- this.context = context;
+ public CustomThemeListingRecyclerViewAdapter(AppCompatActivity activity, ArrayList<CustomTheme> predefinedCustomThemes) {
+ this.activity = activity;
this.predefinedCustomThemes = predefinedCustomThemes;
userCustomThemes = new ArrayList<>();
}
@@ -72,25 +74,30 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
((PredefinedCustomThemeViewHolder) holder).colorPrimaryView.setBackgroundTintList(ColorStateList.valueOf(customTheme.colorPrimary));
((PredefinedCustomThemeViewHolder) holder).nameTextView.setText(customTheme.name);
((PredefinedCustomThemeViewHolder) holder).itemView.setOnClickListener(view -> {
- Intent intent = new Intent(context, CustomizeThemeActivity.class);
+ Intent intent = new Intent(activity, CustomizeThemeActivity.class);
intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, customTheme.name);
intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true);
- context.startActivity(intent);
+ activity.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).createThemeImageView.setOnClickListener(view -> {
+ Intent intent = new Intent(activity, CustomizeThemeActivity.class);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, customTheme.name);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true);
+ activity.startActivity(intent);
});
((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);
- context.startActivity(intent);
+ CustomThemeOptionsBottomSheetFragment customThemeOptionsBottomSheetFragment = new CustomThemeOptionsBottomSheetFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString(CustomThemeOptionsBottomSheetFragment.EXTRA_THEME_NAME, customTheme.name);
+ customThemeOptionsBottomSheetFragment.setArguments(bundle);
+ customThemeOptionsBottomSheetFragment.show(activity.getSupportFragmentManager(), customThemeOptionsBottomSheetFragment.getTag());
});
} else if (holder instanceof PreDefinedThemeDividerViewHolder) {
((TextView) ((PreDefinedThemeDividerViewHolder) holder).itemView).setText(R.string.predefined_themes);
@@ -115,6 +122,8 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
View colorPrimaryView;
@BindView(R.id.name_text_view_item_predefined_custom_theme)
TextView nameTextView;
+ @BindView(R.id.add_image_view_item_predefined_custom_theme)
+ ImageView createThemeImageView;
public PredefinedCustomThemeViewHolder(@NonNull View itemView) {
super(itemView);
@@ -128,8 +137,8 @@ public class CustomThemeListingRecyclerViewAdapter extends RecyclerView.Adapter<
View colorPrimaryView;
@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.add_image_view_item_user_custom_theme)
+ ImageView createThemeImageView;
@BindView(R.id.share_image_view_item_user_custom_theme)
ImageView shareImageView;
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 be2aae85..95833e72 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CustomizeThemeRecyclerViewAdapter.java
@@ -1,9 +1,12 @@
package ml.docilealligator.infinityforreddit.Adapter;
+import android.content.Context;
import android.content.res.ColorStateList;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
import android.widget.Switch;
import android.widget.TextView;
@@ -11,6 +14,8 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
+import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+
import java.util.ArrayList;
import butterknife.BindView;
@@ -40,7 +45,7 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
public int getItemViewType(int position) {
if (position == 0) {
return VIEW_TYPE_THEME_NAME;
- } else if (position > 3 && position < customThemeSettingsItems.size() - 3) {
+ } else if (position > 3 && position < customThemeSettingsItems.size() - 2) {
return VIEW_TYPE_COLOR;
}
@@ -82,7 +87,36 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
} else if (holder instanceof ThemeNameItemViewHolder) {
((ThemeNameItemViewHolder) holder).themeNameTextView.setText(themeName);
holder.itemView.setOnClickListener(view -> {
-
+ View dialogView = activity.getLayoutInflater().inflate(R.layout.dialog_edit_theme_name, null);
+ EditText themeNameEditText = dialogView.findViewById(R.id.theme_name_edit_text_edit_theme_name_dialog);
+ themeNameEditText.setText(themeName);
+ themeNameEditText.requestFocus();
+ InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (imm != null) {
+ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+ }
+ new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.edit_theme_name)
+ .setView(dialogView)
+ .setPositiveButton(R.string.ok, (dialogInterface, i)
+ -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(themeNameEditText.getWindowToken(), 0);
+ }
+ themeName = themeNameEditText.getText().toString();
+ ((ThemeNameItemViewHolder) holder).themeNameTextView.setText(themeName);
+ })
+ .setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(themeNameEditText.getWindowToken(), 0);
+ }
+ })
+ .setOnDismissListener(dialogInterface -> {
+ if (imm != null) {
+ imm.hideSoftInputFromWindow(themeNameEditText.getWindowToken(), 0);
+ }
+ })
+ .show();
});
}
}
@@ -99,6 +133,10 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
notifyDataSetChanged();
}
+ public String getThemeName() {
+ return themeName;
+ }
+
class ThemeColorItemViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.color_image_view_item_custom_theme_color_item)
View colorImageView;
@@ -135,10 +173,6 @@ public class CustomizeThemeRecyclerViewAdapter extends RecyclerView.Adapter<Recy
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/ChangeThemeNameAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/ChangeThemeNameAsyncTask.java
new file mode 100644
index 00000000..65fc3b8d
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/ChangeThemeNameAsyncTask.java
@@ -0,0 +1,23 @@
+package ml.docilealligator.infinityforreddit.AsyncTask;
+
+import android.os.AsyncTask;
+
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+
+public class ChangeThemeNameAsyncTask extends AsyncTask<Void, Void, Void> {
+ private RedditDataRoomDatabase redditDataRoomDatabase;
+ private String oldName;
+ private String newName;
+
+ public ChangeThemeNameAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, String oldName, String newName) {
+ this.redditDataRoomDatabase = redditDataRoomDatabase;
+ this.oldName = oldName;
+ this.newName = newName;
+ }
+
+ @Override
+ protected Void doInBackground(Void... voids) {
+ redditDataRoomDatabase.customThemeDao().updateName(oldName, newName);
+ return null;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/DeleteThemeAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/DeleteThemeAsyncTask.java
new file mode 100644
index 00000000..7b8caec2
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/DeleteThemeAsyncTask.java
@@ -0,0 +1,21 @@
+package ml.docilealligator.infinityforreddit.AsyncTask;
+
+import android.os.AsyncTask;
+
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+
+public class DeleteThemeAsyncTask extends AsyncTask<Void, Void, Void> {
+ private RedditDataRoomDatabase redditDataRoomDatabase;
+ private String themeName;
+
+ public DeleteThemeAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, String themeName) {
+ this.redditDataRoomDatabase = redditDataRoomDatabase;
+ this.themeName = themeName;
+ }
+
+ @Override
+ protected Void doInBackground(Void... voids) {
+ redditDataRoomDatabase.customThemeDao().deleteCustomTheme(themeName);
+ return null;
+ }
+}
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 48ec7122..8741f8e5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeDao.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeDao.java
@@ -25,6 +25,15 @@ public interface CustomThemeDao {
@Query("SELECT * FROM custom_themes WHERE is_amoled_theme = 1 LIMIT 1")
CustomTheme getAmoledCustomTheme();
+ @Query("SELECT * FROM custom_themes WHERE is_light_theme = 1 LIMIT 1")
+ LiveData<CustomTheme> getLightCustomThemeLiveData();
+
+ @Query("SELECT * FROM custom_themes WHERE is_dark_theme = 1 LIMIT 1")
+ LiveData<CustomTheme> getDarkCustomThemeLiveData();
+
+ @Query("SELECT * FROM custom_themes WHERE is_amoled_theme = 1 LIMIT 1")
+ LiveData<CustomTheme> getAmoledCustomThemeLiveData();
+
@Query("SELECT * FROM custom_themes WHERE name = :name COLLATE NOCASE LIMIT 1")
CustomTheme getCustomTheme(String name);
@@ -39,4 +48,7 @@ public interface CustomThemeDao {
@Query("DELETE FROM custom_themes WHERE name = :name")
void deleteCustomTheme(String name);
+
+ @Query("UPDATE custom_themes SET name = :newName WHERE name = :oldName")
+ void updateName(String oldName, String newName);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeRepository.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeRepository.java
index e2c0b692..2084bd5b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeRepository.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeRepository.java
@@ -8,12 +8,30 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
public class CustomThemeRepository {
private LiveData<List<CustomTheme>> mAllCustomThemes;
+ private LiveData<CustomTheme> mCurrentLightCustomTheme;
+ private LiveData<CustomTheme> mCurrentDarkCustomTheme;
+ private LiveData<CustomTheme> mCurrentAmoledCustomTheme;
CustomThemeRepository(RedditDataRoomDatabase redditDataRoomDatabase) {
mAllCustomThemes = redditDataRoomDatabase.customThemeDao().getAllCustomThemes();
+ mCurrentLightCustomTheme = redditDataRoomDatabase.customThemeDao().getLightCustomThemeLiveData();
+ mCurrentDarkCustomTheme = redditDataRoomDatabase.customThemeDao().getDarkCustomThemeLiveData();
+ mCurrentAmoledCustomTheme = redditDataRoomDatabase.customThemeDao().getAmoledCustomThemeLiveData();
}
LiveData<List<CustomTheme>> getAllCustomThemes() {
return mAllCustomThemes;
}
+
+ LiveData<CustomTheme> getCurrentLightCustomTheme() {
+ return mCurrentLightCustomTheme;
+ }
+
+ LiveData<CustomTheme> getCurrentDarkCustomTheme() {
+ return mCurrentDarkCustomTheme;
+ }
+
+ LiveData<CustomTheme> getCurrentAmoledCustomTheme() {
+ return mCurrentAmoledCustomTheme;
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeViewModel.java
index c9b1fde2..be8f044d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeViewModel.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeViewModel.java
@@ -11,16 +11,34 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
public class CustomThemeViewModel extends ViewModel {
private LiveData<List<CustomTheme>> mAllCustomThemes;
+ private LiveData<CustomTheme> mCurrentLightTheme;
+ private LiveData<CustomTheme> mCurrentDarkTheme;
+ private LiveData<CustomTheme> mCurrentAmoledTheme;
public CustomThemeViewModel(RedditDataRoomDatabase redditDataRoomDatabase) {
CustomThemeRepository customThemeRepository = new CustomThemeRepository(redditDataRoomDatabase);
mAllCustomThemes = customThemeRepository.getAllCustomThemes();
+ mCurrentLightTheme = customThemeRepository.getCurrentLightCustomTheme();
+ mCurrentDarkTheme = customThemeRepository.getCurrentDarkCustomTheme();
+ mCurrentAmoledTheme = customThemeRepository.getCurrentAmoledCustomTheme();
}
public LiveData<List<CustomTheme>> getAllCustomThemes() {
return mAllCustomThemes;
}
+ public LiveData<CustomTheme> getCurrentLightThemeLiveData() {
+ return mCurrentLightTheme;
+ }
+
+ public LiveData<CustomTheme> getCurrentDarkThemeLiveData() {
+ return mCurrentDarkTheme;
+ }
+
+ public LiveData<CustomTheme> getCurrentAmoledThemeLiveData() {
+ return mCurrentAmoledTheme;
+ }
+
public static class Factory extends ViewModelProvider.NewInstanceFactory {
private RedditDataRoomDatabase mRedditDataRoomDatabase;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java
index b53fbab8..3af6c99a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java
@@ -546,8 +546,8 @@ public class CustomThemeWrapper {
public static CustomTheme getIndigoAmoled(Context context) {
CustomTheme customTheme = new CustomTheme(context.getString(R.string.theme_name_indigo_amoled));
customTheme.isLightTheme = false;
- customTheme.isDarkTheme = true;
- customTheme.isAmoledTheme = false;
+ customTheme.isDarkTheme = false;
+ customTheme.isAmoledTheme = true;
customTheme.colorPrimary = Color.parseColor("#000000");
customTheme.colorPrimaryDark = Color.parseColor("#000000");
customTheme.colorAccent = Color.parseColor("#FF4081");
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java
new file mode 100644
index 00000000..7657bba9
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CustomThemeOptionsBottomSheetFragment.java
@@ -0,0 +1,92 @@
+package ml.docilealligator.infinityforreddit.Fragment;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.Fragment;
+
+import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment;
+import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Activity.CustomizeThemeActivity;
+import ml.docilealligator.infinityforreddit.R;
+
+/**
+ * A simple {@link Fragment} subclass.
+ */
+public class CustomThemeOptionsBottomSheetFragment extends RoundedBottomSheetDialogFragment {
+
+ public static final String EXTRA_THEME_NAME = "ETN";
+ @BindView(R.id.theme_name_text_view_custom_theme_options_bottom_sheet_fragment)
+ TextView themeNameTextView;
+ @BindView(R.id.edit_theme_text_view_custom_theme_options_bottom_sheet_fragment)
+ TextView editThemeTextView;
+ @BindView(R.id.share_theme_text_view_custom_theme_options_bottom_sheet_fragment)
+ TextView shareThemeTextView;
+ @BindView(R.id.change_theme_name_text_view_custom_theme_options_bottom_sheet_fragment)
+ TextView changeThemeNameTextView;
+ @BindView(R.id.delete_theme_text_view_custom_theme_options_bottom_sheet_fragment)
+ TextView deleteTextView;
+ private String themeName;
+ private Activity activity;
+
+ public CustomThemeOptionsBottomSheetFragment() {
+ // Required empty public constructor
+ }
+
+ public interface CustomThemeOptionsBottomSheetFragmentListener {
+ void changeName(String oldName);
+ void delete(String name);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_custom_theme_options_bottom_sheet, container, false);
+ ButterKnife.bind(this, rootView);
+
+ themeName = getArguments().getString(EXTRA_THEME_NAME);
+ themeNameTextView.setText(themeName);
+
+ editThemeTextView.setOnClickListener(view -> {
+ Intent intent = new Intent(activity, CustomizeThemeActivity.class);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, themeName);
+ startActivity(intent);
+ dismiss();
+ });
+
+ shareThemeTextView.setOnClickListener(view -> {
+ dismiss();
+ });
+
+ changeThemeNameTextView.setOnClickListener(view -> {
+ ((CustomThemeOptionsBottomSheetFragmentListener) activity).changeName(themeName);
+ dismiss();
+ });
+
+ deleteTextView.setOnClickListener(view -> {
+ ((CustomThemeOptionsBottomSheetFragmentListener) activity).delete(themeName);
+ dismiss();
+ });
+
+ return rootView;
+ }
+
+ @Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+ activity = (AppCompatActivity) context;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SelectBaseThemeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SelectBaseThemeBottomSheetFragment.java
new file mode 100644
index 00000000..81df06c5
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SelectBaseThemeBottomSheetFragment.java
@@ -0,0 +1,78 @@
+package ml.docilealligator.infinityforreddit.Fragment;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Activity.CustomizeThemeActivity;
+import ml.docilealligator.infinityforreddit.R;
+
+/**
+ * A simple {@link Fragment} subclass.
+ */
+public class SelectBaseThemeBottomSheetFragment extends RoundedBottomSheetDialogFragment {
+
+ @BindView(R.id.light_theme_text_view_select_base_theme_bottom_sheet_fragment)
+ TextView lightThemeTextView;
+ @BindView(R.id.dark_theme_text_view_select_base_theme_bottom_sheet_fragment)
+ TextView darkThemeTextView;
+ @BindView(R.id.amoled_theme_text_view_select_base_theme_bottom_sheet_fragment)
+ TextView amoledThemeTextView;
+ private Activity activity;
+ public SelectBaseThemeBottomSheetFragment() {
+ // Required empty public constructor
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_select_base_theme_bottom_sheet, container, false);
+ ButterKnife.bind(this, rootView);
+
+ lightThemeTextView.setOnClickListener(view -> {
+ Intent intent = new Intent(activity, CustomizeThemeActivity.class);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, getString(R.string.theme_name_indigo));
+ startActivity(intent);
+ dismiss();
+ });
+
+ darkThemeTextView.setOnClickListener(view -> {
+ Intent intent = new Intent(activity, CustomizeThemeActivity.class);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, getString(R.string.theme_name_indigo_dark));
+ startActivity(intent);
+ dismiss();
+ });
+
+ amoledThemeTextView.setOnClickListener(view -> {
+ Intent intent = new Intent(activity, CustomizeThemeActivity.class);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true);
+ intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, getString(R.string.theme_name_indigo_amoled));
+ startActivity(intent);
+ dismiss();
+ });
+ return rootView;
+ }
+
+ @Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+ activity = (Activity) context;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java
index 0447c7ba..d3c54782 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ShareLinkBottomSheetFragment.java
@@ -137,6 +137,6 @@ public class ShareLinkBottomSheetFragment extends RoundedBottomSheetDialogFragme
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
- this.activity = (AppCompatActivity) context;
+ activity = (AppCompatActivity) context;
}
}
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 aa41849c..01c55179 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/ThemePreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/ThemePreferenceFragment.java
@@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.Fragment;
+import androidx.lifecycle.ViewModelProvider;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
@@ -21,10 +22,12 @@ import javax.inject.Inject;
import ml.docilealligator.infinityforreddit.Activity.CustomThemeListingActivity;
import ml.docilealligator.infinityforreddit.Activity.CustomizeThemeActivity;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeViewModel;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
@@ -40,7 +43,10 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat {
private AppCompatActivity activity;
@Inject
+ RedditDataRoomDatabase redditDataRoomDatabase;
+ @Inject
CustomThemeWrapper customThemeWrapper;
+ public CustomThemeViewModel customThemeViewModel;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
@@ -143,6 +149,40 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat {
return true;
});
}
+
+ customThemeViewModel = new ViewModelProvider(this,
+ new CustomThemeViewModel.Factory(redditDataRoomDatabase))
+ .get(CustomThemeViewModel.class);
+ customThemeViewModel.getCurrentLightThemeLiveData().observe(this, customTheme -> {
+ if (customizeLightThemePreference != null) {
+ if (customTheme != null) {
+ customizeLightThemePreference.setVisible(true);
+ customizeLightThemePreference.setSummary(customTheme.name);
+ } else {
+ customizeLightThemePreference.setVisible(false);
+ }
+ }
+ });
+ customThemeViewModel.getCurrentDarkThemeLiveData().observe(this, customTheme -> {
+ if (customizeDarkThemePreference != null) {
+ if (customTheme != null) {
+ customizeDarkThemePreference.setVisible(true);
+ customizeDarkThemePreference.setSummary(customTheme.name);
+ } else {
+ customizeDarkThemePreference.setVisible(false);
+ }
+ }
+ });
+ customThemeViewModel.getCurrentAmoledThemeLiveData().observe(this, customTheme -> {
+ if (customizeAmoledThemePreference != null) {
+ if (customTheme != null) {
+ customizeAmoledThemePreference.setVisible(true);
+ customizeAmoledThemePreference.setSummary(customTheme.name);
+ } else {
+ customizeAmoledThemePreference.setVisible(false);
+ }
+ }
+ });
}
@Override
diff --git a/app/src/main/res/drawable-night/ic_amoled_theme_preference_24dp.xml b/app/src/main/res/drawable-night/ic_amoled_theme_preference_24dp.xml
new file mode 100644
index 00000000..3eb4a608
--- /dev/null
+++ b/app/src/main/res/drawable-night/ic_amoled_theme_preference_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M3,5A2,2 0,0 1,5 3H19A2,2 0,0 1,21 5V19A2,2 0,0 1,19 21H5C3.89,21 3,20.1 3,19V5M5,5V19H19V5H5M11,7H13A2,2 0,0 1,15 9V17H13V13H11V17H9V9A2,2 0,0 1,11 7M11,9V11H13V9H11Z"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_amoled_theme_preference_24dp.xml b/app/src/main/res/drawable/ic_amoled_theme_preference_24dp.xml
new file mode 100644
index 00000000..1389a13e
--- /dev/null
+++ b/app/src/main/res/drawable/ic_amoled_theme_preference_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M3,5A2,2 0,0 1,5 3H19A2,2 0,0 1,21 5V19A2,2 0,0 1,19 21H5C3.89,21 3,20.1 3,19V5M5,5V19H19V5H5M11,7H13A2,2 0,0 1,15 9V17H13V13H11V17H9V9A2,2 0,0 1,11 7M11,9V11H13V9H11Z"/>
+</vector>
diff --git a/app/src/main/res/layout/activity_custom_theme_listing.xml b/app/src/main/res/layout/activity_custom_theme_listing.xml
index f128c11c..260453e6 100644
--- a/app/src/main/res/layout/activity_custom_theme_listing.xml
+++ b/app/src/main/res/layout/activity_custom_theme_listing.xml
@@ -38,4 +38,14 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+ <com.google.android.material.floatingactionbutton.FloatingActionButton
+ android:id="@+id/fab_custom_theme_listing_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/fab_margin"
+ android:layout_gravity="bottom|end"
+ app:backgroundTint="?attr/colorPrimaryLightTheme"
+ app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp"
+ app:tint="@android:color/white" />
+
</androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/activity_customize_theme.xml b/app/src/main/res/layout/activity_customize_theme.xml
index 362772a1..90dfa2b8 100644
--- a/app/src/main/res/layout/activity_customize_theme.xml
+++ b/app/src/main/res/layout/activity_customize_theme.xml
@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:id="@+id/coordinator_customize_theme_activity"
tools:context=".Activity.CustomizeThemeActivity">
<com.google.android.material.appbar.AppBarLayout
diff --git a/app/src/main/res/layout/dialog_edit_theme_name.xml b/app/src/main/res/layout/dialog_edit_theme_name.xml
new file mode 100644
index 00000000..9a63f486
--- /dev/null
+++ b/app/src/main/res/layout/dialog_edit_theme_name.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<EditText xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/theme_name_edit_text_edit_theme_name_dialog"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="24dp"
+ android:background="#00000000"
+ android:hint="@string/theme_name_hint"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default" /> \ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_custom_theme_options_bottom_sheet.xml b/app/src/main/res/layout/fragment_custom_theme_options_bottom_sheet.xml
new file mode 100644
index 00000000..82962293
--- /dev/null
+++ b/app/src/main/res/layout/fragment_custom_theme_options_bottom_sheet.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="8dp"
+ android:overScrollMode="never">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/theme_name_text_view_custom_theme_options_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:textColor="?attr/primaryTextColor" />
+
+ <TextView
+ android:id="@+id/edit_theme_text_view_custom_theme_options_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:text="@string/edit_theme"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:drawableStart="@drawable/ic_edit_24dp"
+ android:drawablePadding="48dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/change_theme_name_text_view_custom_theme_options_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:text="@string/change_theme_name"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:drawableStart="@drawable/ic_edit_24dp"
+ android:drawablePadding="48dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/share_theme_text_view_custom_theme_options_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:text="@string/share_theme"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:drawableStart="@drawable/ic_share_24dp"
+ android:drawablePadding="48dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/delete_theme_text_view_custom_theme_options_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:text="@string/delete_theme"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:drawableStart="@drawable/ic_delete_24dp"
+ android:drawablePadding="48dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ </LinearLayout>
+
+</androidx.core.widget.NestedScrollView> \ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_select_base_theme_bottom_sheet.xml b/app/src/main/res/layout/fragment_select_base_theme_bottom_sheet.xml
new file mode 100644
index 00000000..d0adbd83
--- /dev/null
+++ b/app/src/main/res/layout/fragment_select_base_theme_bottom_sheet.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="8dp"
+ android:overScrollMode="never">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/light_theme_text_view_select_base_theme_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:text="@string/create_light_theme"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:drawableStart="@drawable/ic_light_theme_preference_24dp"
+ android:drawablePadding="48dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/dark_theme_text_view_select_base_theme_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:text="@string/create_dark_theme"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:drawableStart="@drawable/ic_dark_theme_preference_24dp"
+ android:drawablePadding="48dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/amoled_theme_text_view_select_base_theme_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:text="@string/create_amoled_theme"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:drawableStart="@drawable/ic_amoled_theme_preference_24dp"
+ android:drawablePadding="48dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:text="@string/create_theme_info"
+ android:textColor="?attr/secondaryTextColor"
+ android:textSize="?attr/font_default" />
+
+ </LinearLayout>
+
+</androidx.core.widget.NestedScrollView> \ No newline at end of file
diff --git a/app/src/main/res/layout/item_predefined_custom_theme.xml b/app/src/main/res/layout/item_predefined_custom_theme.xml
index 432628b1..cbc6bb20 100644
--- a/app/src/main/res/layout/item_predefined_custom_theme.xml
+++ b/app/src/main/res/layout/item_predefined_custom_theme.xml
@@ -16,10 +16,19 @@
<TextView
android:id="@+id/name_text_view_item_predefined_custom_theme"
- android:layout_width="wrap_content"
+ 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/add_image_view_item_predefined_custom_theme"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center_vertical"
+ android:layout_marginStart="32dp"
+ android:src="@drawable/ic_add_24dp" />
+
</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
index fe610557..e4ea128d 100644
--- a/app/src/main/res/layout/item_user_custom_theme.xml
+++ b/app/src/main/res/layout/item_user_custom_theme.xml
@@ -24,12 +24,12 @@
android:textColor="?attr/primaryTextColor" />
<ImageView
- android:id="@+id/delete_image_view_item_user_custom_theme"
+ android:id="@+id/add_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:src="@drawable/ic_add_24dp"
android:background="?attr/selectableItemBackgroundBorderless" />
<ImageView
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 56a0e264..57e85a64 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -20,6 +20,8 @@
<string name="create_multi_reddit_activity_label">Create Multireddit</string>
<string name="subreddit_multiselection_activity_label">Select Subreddits</string>
<string name="custom_theme_listing_activity_label">Custom Themes</string>
+ <string name="customize_theme_activity_label">Customize Theme</string>
+ <string name="customize_theme_activity_create_theme_label">Create Theme</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
@@ -468,7 +470,6 @@
<string name="save_gif_before_sharing">Saving the gif. Please wait.</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>
@@ -604,9 +605,20 @@
<string name="predefined_themes">Predefined Themes</string>
<string name="user_themes">Your Themes</string>
+ <string name="no_theme_name">What is the name of this theme?</string>
+ <string name="theme_name_hint">Theme Name</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>
+ <string name="create_light_theme">Create a Light Theme\nBase on Indigo Theme</string>
+ <string name="create_dark_theme">Create a Dark Theme\nBase on Indigo Dark Theme</string>
+ <string name="create_amoled_theme">Create an Amoled Theme\nBase on Indigo Amoled Theme</string>
+ <string name="create_theme_info">If you want to create a theme based on another theme, click the \"+\" button on a theme instead.</string>
+ <string name="edit_theme_name">Edit Theme Name</string>
+ <string name="edit_theme">Edit Theme</string>
+ <string name="delete_theme">Delete Theme</string>
+ <string name="share_theme">Share Theme</string>
+ <string name="change_theme_name">Change Name</string>
<string name="color_picker">Color Picker</string>
<string name="invalid_color">Invalid Color</string>
diff --git a/app/src/main/res/xml/theme_preferences.xml b/app/src/main/res/xml/theme_preferences.xml
index e6aec71f..f40ef592 100644
--- a/app/src/main/res/xml/theme_preferences.xml
+++ b/app/src/main/res/xml/theme_preferences.xml
@@ -21,17 +21,20 @@
<Preference
app:key="customize_light_theme"
app:icon="@drawable/ic_light_theme_preference_24dp"
- app:title="@string/settings_customize_light_theme_title" />
+ app:title="@string/settings_customize_light_theme_title"
+ app:isPreferenceVisible="false" />
<Preference
app:key="customize_dark_theme"
app:icon="@drawable/ic_dark_theme_preference_24dp"
- app:title="@string/settings_customize_dark_theme_title" />
+ app:title="@string/settings_customize_dark_theme_title"
+ app:isPreferenceVisible="false" />
<Preference
app:key="customize_amoled_theme"
- app:icon="@drawable/ic_dark_theme_preference_24dp"
- app:title="@string/settings_customize_amoled_theme_title" />
+ app:icon="@drawable/ic_amoled_theme_preference_24dp"
+ app:title="@string/settings_customize_amoled_theme_title"
+ app:isPreferenceVisible="false" />
<Preference
app:key="manage_themes"