From a42cbf8afc3fdf4354f7f5a8787ca868fa425682 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 19 Sep 2025 08:21:35 +0200 Subject: [PATCH] Manage custom colors --- .../mastodon/ui/drawer/ComposeAdapter.java | 48 +++++++------------ ...ragmentCustomVisibilityColorsSettings.java | 25 ++++++++++ app/src/main/res/values/strings.xml | 9 ++-- .../res/xml/pref_custom_visibility_colors.xml | 11 +++++ 4 files changed, 57 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java index 16c7bf11..2c030949 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java @@ -205,44 +205,28 @@ public class ComposeAdapter extends RecyclerView.Adapter { + AlertDialog.Builder resetConfirm = new MaterialAlertDialogBuilder(requireActivity()); + resetConfirm.setMessage(getString(R.string.reset_color)); + resetConfirm.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss()); + resetConfirm.setPositiveButton(R.string.reset, (dialog, which) -> { + SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences(); + if (sharedPreferences != null) { + sharedPreferences.edit().remove(getString(R.string.SET_COLOR_VISIBILITY_PUBLIC)).apply(); + sharedPreferences.edit().remove(getString(R.string.SET_COLOR_VISIBILITY_UNLISTED)).apply(); + sharedPreferences.edit().remove(getString(R.string.SET_COLOR_VISIBILITY_PRIVATE)).apply(); + sharedPreferences.edit().remove(getString(R.string.SET_COLOR_VISIBILITY_DIRECT)).apply(); + } + + dialog.dismiss(); + }); + resetConfirm.show(); + return true; + }); + } } @Override diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 336eb37a..85817149 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1220,10 +1220,11 @@ SET_LIGHT_LINK SET_LIGHT_ICON - SET_COLOR_VISIBILITY_PUBLIC - SET_COLOR_VISIBILITY_UNLISTED - SET_COLOR_VISIBILITY_PRIVATE - SET_COLOR_VISIBILITY_DIRECT + SET_COLOR_VISIBILITY_PUBLIC + SET_COLOR_VISIBILITY_UNLISTED + SET_COLOR_VISIBILITY_PRIVATE + SET_COLOR_VISIBILITY_DIRECT + SET_RESET_CUSTOM_COLOR_VISIBILITY SYSTEM SET_AUTO_PLAY_GIG_MEDIA diff --git a/app/src/main/res/xml/pref_custom_visibility_colors.xml b/app/src/main/res/xml/pref_custom_visibility_colors.xml index 005d2d26..222dd69a 100644 --- a/app/src/main/res/xml/pref_custom_visibility_colors.xml +++ b/app/src/main/res/xml/pref_custom_visibility_colors.xml @@ -5,27 +5,38 @@ android:layout_height="match_parent"> + + \ No newline at end of file