aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java51
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/DeleteThemeAsyncTask.java27
-rw-r--r--app/src/main/res/drawable-night/ic_add_day_night_24dp.xml (renamed from app/src/main/res/drawable-night/ic_add_bottom_app_bar_24dp.xml)0
-rw-r--r--app/src/main/res/drawable/ic_add_day_night_24dp.xml (renamed from app/src/main/res/drawable/ic_add_bottom_app_bar_24dp.xml)0
-rw-r--r--app/src/main/res/layout/activity_custom_theme_listing.xml2
-rw-r--r--app/src/main/res/layout/activity_multi_reddit_listing.xml2
-rw-r--r--app/src/main/res/layout/activity_view_subreddit_detail.xml2
-rw-r--r--app/src/main/res/layout/app_bar_main.xml2
-rw-r--r--app/src/main/res/layout/item_predefined_custom_theme.xml2
-rw-r--r--app/src/main/res/layout/item_user_custom_theme.xml2
-rw-r--r--app/src/main/res/values/strings.xml3
14 files changed, 85 insertions, 14 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 6bc3a927..eb918960 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CustomThemeListingActivity.java
@@ -18,6 +18,9 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+
import javax.inject.Inject;
import javax.inject.Named;
@@ -28,11 +31,13 @@ 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.Event.RecreateActivityEvent;
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;
+import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils;
public class CustomThemeListingActivity extends BaseActivity implements CustomThemeOptionsBottomSheetFragment.CustomThemeOptionsBottomSheetFragmentListener {
@@ -51,6 +56,15 @@ public class CustomThemeListingActivity extends BaseActivity implements CustomTh
RedditDataRoomDatabase redditDataRoomDatabase;
@Inject
CustomThemeWrapper customThemeWrapper;
+ @Inject
+ @Named("light_theme")
+ SharedPreferences lightThemeSharedPreferences;
+ @Inject
+ @Named("dark_theme")
+ SharedPreferences darkThemeSharedPreferences;
+ @Inject
+ @Named("amoled_theme")
+ SharedPreferences amoledThemeSharedPreferences;
public CustomThemeViewModel customThemeViewModel;
@Override
@@ -62,6 +76,8 @@ public class CustomThemeListingActivity extends BaseActivity implements CustomTh
ButterKnife.bind(this);
+ EventBus.getDefault().register(this);
+
applyCustomTheme();
setSupportActionBar(toolbar);
@@ -125,7 +141,7 @@ public class CustomThemeListingActivity extends BaseActivity implements CustomTh
if (imm != null) {
imm.hideSoftInputFromWindow(themeNameEditText.getWindowToken(), 0);
}
- new ChangeThemeNameAsyncTask(redditDataRoomDatabase, oldName, themeNameEditText.getText().toString());
+ new ChangeThemeNameAsyncTask(redditDataRoomDatabase, oldName, themeNameEditText.getText().toString()).execute();
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
if (imm != null) {
@@ -142,6 +158,37 @@ public class CustomThemeListingActivity extends BaseActivity implements CustomTh
@Override
public void delete(String name) {
- new DeleteThemeAsyncTask(redditDataRoomDatabase, name).execute();
+ new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
+ .setTitle(R.string.delete_theme)
+ .setMessage(getString(R.string.delete_theme_dialog_message, name))
+ .setPositiveButton(R.string.yes, (dialogInterface, i)
+ -> new DeleteThemeAsyncTask(redditDataRoomDatabase, name, (isLightTheme, isDarkTheme, isAmoledTheme) -> {
+ if (isLightTheme) {
+ CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(
+ CustomThemeWrapper.getIndigo(CustomThemeListingActivity.this), lightThemeSharedPreferences);
+ }
+ if (isDarkTheme) {
+ CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(
+ CustomThemeWrapper.getIndigo(CustomThemeListingActivity.this), darkThemeSharedPreferences);
+ }
+ if (isAmoledTheme) {
+ CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(
+ CustomThemeWrapper.getIndigo(CustomThemeListingActivity.this), amoledThemeSharedPreferences);
+ }
+ EventBus.getDefault().post(new RecreateActivityEvent());
+ }).execute())
+ .setNegativeButton(R.string.no, null)
+ .show();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ EventBus.getDefault().unregister(this);
+ }
+
+ @Subscribe
+ public void onRecreateActivityEvent(RecreateActivityEvent recreateActivityEvent) {
+ recreate();
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
index b65fc134..1a38677a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
@@ -305,7 +305,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
applyTabLayoutTheme(tabLayout);
bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
- applyFABTheme(fab, R.drawable.ic_add_bottom_app_bar_24dp);
+ applyFABTheme(fab, R.drawable.ic_add_day_night_24dp);
}
private void getCurrentAccountAndBindView() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java
index e5069e16..a4ccc4b7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java
@@ -258,6 +258,6 @@ public class MultiRedditListingActivity extends BaseActivity {
mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground());
mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
- applyFABTheme(fab, R.drawable.ic_add_bottom_app_bar_24dp);
+ applyFABTheme(fab, R.drawable.ic_add_day_night_24dp);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
index d34b133b..13aca8a1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
@@ -360,7 +360,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
multiRedditBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
messageBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
profileBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- applyFABTheme(fab, R.drawable.ic_add_bottom_app_bar_24dp);
+ applyFABTheme(fab, R.drawable.ic_add_day_night_24dp);
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
subscribedColor = mCustomThemeWrapper.getSubscribed();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/DeleteThemeAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/DeleteThemeAsyncTask.java
index 7b8caec2..c166087c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/DeleteThemeAsyncTask.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AsyncTask/DeleteThemeAsyncTask.java
@@ -2,20 +2,43 @@ package ml.docilealligator.infinityforreddit.AsyncTask;
import android.os.AsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomTheme;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
public class DeleteThemeAsyncTask extends AsyncTask<Void, Void, Void> {
private RedditDataRoomDatabase redditDataRoomDatabase;
private String themeName;
+ private DeleteThemeAsyncTaskListener deleteThemeAsyncTaskListener;
+ private boolean isLightTheme = false;
+ private boolean isDarkTheme = false;
+ private boolean isAmoledTheme = false;
- public DeleteThemeAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, String themeName) {
+ public interface DeleteThemeAsyncTaskListener {
+ void success(boolean isLightTheme, boolean isDarkTheme, boolean isAmoledTheme);
+ }
+
+ public DeleteThemeAsyncTask(RedditDataRoomDatabase redditDataRoomDatabase, String themeName,
+ DeleteThemeAsyncTaskListener deleteThemeAsyncTaskListener) {
this.redditDataRoomDatabase = redditDataRoomDatabase;
this.themeName = themeName;
+ this.deleteThemeAsyncTaskListener = deleteThemeAsyncTaskListener;
}
@Override
protected Void doInBackground(Void... voids) {
- redditDataRoomDatabase.customThemeDao().deleteCustomTheme(themeName);
+ CustomTheme customTheme = redditDataRoomDatabase.customThemeDao().getCustomTheme(themeName);
+ if (customTheme != null) {
+ isLightTheme = customTheme.isLightTheme;
+ isDarkTheme = customTheme.isDarkTheme;
+ isAmoledTheme = customTheme.isAmoledTheme;
+ redditDataRoomDatabase.customThemeDao().deleteCustomTheme(themeName);
+ }
return null;
}
+
+ @Override
+ protected void onPostExecute(Void aVoid) {
+ super.onPostExecute(aVoid);
+ deleteThemeAsyncTaskListener.success(isLightTheme, isDarkTheme, isAmoledTheme);
+ }
}
diff --git a/app/src/main/res/drawable-night/ic_add_bottom_app_bar_24dp.xml b/app/src/main/res/drawable-night/ic_add_day_night_24dp.xml
index b6814bc2..b6814bc2 100644
--- a/app/src/main/res/drawable-night/ic_add_bottom_app_bar_24dp.xml
+++ b/app/src/main/res/drawable-night/ic_add_day_night_24dp.xml
diff --git a/app/src/main/res/drawable/ic_add_bottom_app_bar_24dp.xml b/app/src/main/res/drawable/ic_add_day_night_24dp.xml
index ed95d188..ed95d188 100644
--- a/app/src/main/res/drawable/ic_add_bottom_app_bar_24dp.xml
+++ b/app/src/main/res/drawable/ic_add_day_night_24dp.xml
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 260453e6..37b8f878 100644
--- a/app/src/main/res/layout/activity_custom_theme_listing.xml
+++ b/app/src/main/res/layout/activity_custom_theme_listing.xml
@@ -45,7 +45,7 @@
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:srcCompat="@drawable/ic_add_day_night_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_multi_reddit_listing.xml b/app/src/main/res/layout/activity_multi_reddit_listing.xml
index ea101e05..65285189 100644
--- a/app/src/main/res/layout/activity_multi_reddit_listing.xml
+++ b/app/src/main/res/layout/activity_multi_reddit_listing.xml
@@ -78,7 +78,7 @@
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:srcCompat="@drawable/ic_add_day_night_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_view_subreddit_detail.xml b/app/src/main/res/layout/activity_view_subreddit_detail.xml
index 5f2c2294..3337fc67 100644
--- a/app/src/main/res/layout/activity_view_subreddit_detail.xml
+++ b/app/src/main/res/layout/activity_view_subreddit_detail.xml
@@ -201,7 +201,7 @@
android:layout_margin="@dimen/fab_margin"
android:visibility="gone"
app:backgroundTint="?attr/colorPrimaryLightTheme"
- app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp"
+ app:srcCompat="@drawable/ic_add_day_night_24dp"
app:tint="@android:color/white"
app:layout_anchor="@id/bottom_navigation_view_subreddit_detail_activity" />
diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml
index cc63287c..b1d9b330 100644
--- a/app/src/main/res/layout/app_bar_main.xml
+++ b/app/src/main/res/layout/app_bar_main.xml
@@ -132,7 +132,7 @@
android:layout_margin="@dimen/fab_margin"
android:visibility="gone"
app:backgroundTint="?attr/colorPrimaryLightTheme"
- app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp"
+ app:srcCompat="@drawable/ic_add_day_night_24dp"
app:tint="@android:color/white"
app:layout_anchor="@id/bottom_navigation_main_activity" />
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 cbc6bb20..37dcdb0c 100644
--- a/app/src/main/res/layout/item_predefined_custom_theme.xml
+++ b/app/src/main/res/layout/item_predefined_custom_theme.xml
@@ -29,6 +29,6 @@
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="32dp"
- android:src="@drawable/ic_add_24dp" />
+ android:src="@drawable/ic_add_day_night_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 e4ea128d..55891961 100644
--- a/app/src/main/res/layout/item_user_custom_theme.xml
+++ b/app/src/main/res/layout/item_user_custom_theme.xml
@@ -29,7 +29,7 @@
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="32dp"
- android:src="@drawable/ic_add_24dp"
+ android:src="@drawable/ic_add_day_night_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 57e85a64..22b971ff 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -365,7 +365,7 @@
<string name="settings_customize_dark_theme_title">Dark Theme</string>
<string name="settings_customize_amoled_theme_title">Amoled Theme</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="settings_custom_theme_cannot_apply_to_settings_page_title">Custom themes cannot be applied to settings page (except toolbar, status bar and navigation bar).</string>
<string name="no_link_available">Cannot get the link</string>
@@ -617,6 +617,7 @@
<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="delete_theme_dialog_message">Are you sure to delete %1$s?</string>
<string name="share_theme">Share Theme</string>
<string name="change_theme_name">Change Name</string>