summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2022-12-09 10:01:57 +0100
committerThomas <tschneider.ac@gmail.com>2022-12-09 10:01:57 +0100
commitae80a27db95b0701a8621bfb158ece2c95720823 (patch)
treeb3757510927c506eb560451c4e437c543707be11
parentd9ed0984648900b5f2c2fe793729a3f5075803fe (diff)
Allow to reset customizations
-rw-r--r--app/build.gradle2
-rw-r--r--app/src/main/java/app/fedilab/android/helper/SpannableHelper.java2
-rw-r--r--app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentThemingSettings.java35
-rw-r--r--app/src/main/res/values/strings.xml2
-rw-r--r--app/src/main/res/xml/pref_custom_dark.xml50
-rw-r--r--app/src/main/res/xml/pref_custom_light.xml49
-rw-r--r--app/src/main/res/xml/pref_theming.xml6
7 files changed, 59 insertions, 87 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 3e592ea7c..50d97fa2b 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -82,7 +82,7 @@ dependencies {
implementation 'com.google.android.material:material:1.7.0'
- implementation "com.github.skydoves:colorpickerpreference:2.0.6"
+ implementation 'com.jaredrummler:colorpicker:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "com.google.code.gson:gson:2.9.1"
diff --git a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java
index 1eb8492e5..8db48cc46 100644
--- a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java
+++ b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java
@@ -121,7 +121,7 @@ public class SpannableHelper {
linkColor = link_color;
}
} else {
- linkColor = linkColor;
+ linkColor = ThemeHelper.getAttColor(context, R.attr.linkColor);
}
SpannableString initialContent;
diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentThemingSettings.java b/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentThemingSettings.java
index 7141514a8..b6b407e5d 100644
--- a/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentThemingSettings.java
+++ b/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentThemingSettings.java
@@ -18,6 +18,7 @@ package app.fedilab.android.ui.fragment.settings;
import android.content.SharedPreferences;
import android.os.Bundle;
+import androidx.appcompat.app.AlertDialog;
import androidx.navigation.NavOptions;
import androidx.navigation.Navigation;
import androidx.preference.ListPreference;
@@ -113,6 +114,40 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements
return true;
});
}
+
+ Preference SET_RESET_CUSTOM_COLOR = findPreference(getString(R.string.SET_RESET_CUSTOM_COLOR));
+ if (SET_RESET_CUSTOM_COLOR != null) {
+ SET_RESET_CUSTOM_COLOR.getContext().setTheme(Helper.dialogStyle());
+ SET_RESET_CUSTOM_COLOR.setOnPreferenceClickListener(preference -> {
+ AlertDialog.Builder resetConfirm = new AlertDialog.Builder(requireActivity(), Helper.dialogStyle());
+ 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_LIGHT_BACKGROUND)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_LIGHT_BOOST_HEADER)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_LIGHT_DISPLAY_NAME)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_LIGHT_USERNAME)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_LIGHT_TEXT)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_LIGHT_LINK)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_LIGHT_ICON)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_DARK_BACKGROUND)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_DARK_BOOST_HEADER)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_DARK_DISPLAY_NAME)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_DARK_USERNAME)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_DARK_TEXT)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_DARK_LINK)).apply();
+ sharedPreferences.edit().remove(getString(R.string.SET_DARK_ICON)).apply();
+
+ }
+
+ dialog.dismiss();
+ });
+ resetConfirm.show();
+ return true;
+ });
+ }
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e6a907bfb..20d9ede7e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1302,6 +1302,8 @@
<string name="SET_CUSTOMIZE_LIGHT_COLORS_ACTION" translatable="false">SET_CUSTOMIZE_LIGHT_COLORS_ACTION</string>
<string name="SET_CUSTOMIZE_DARK_COLORS" translatable="false">SET_CUSTOMIZE_DARK_COLORS</string>
<string name="SET_CUSTOMIZE_DARK_COLORS_ACTION" translatable="false">SET_CUSTOMIZE_DARK_COLORS_ACTION</string>
+ <string name="SET_RESET_CUSTOM_COLOR" translatable="false">SET_RESET_CUSTOM_COLOR</string>
+
<string name="SET_THEME_DEFAULT_LIGHT" translatable="false">SET_THEME_DEFAULT_LIGHT</string>
<string name="SET_THEME_DEFAULT_DARK" translatable="false">SET_THEME_DEFAULT_DARK</string>
diff --git a/app/src/main/res/xml/pref_custom_dark.xml b/app/src/main/res/xml/pref_custom_dark.xml
index f9135bf9d..2d1c82f84 100644
--- a/app/src/main/res/xml/pref_custom_dark.xml
+++ b/app/src/main/res/xml/pref_custom_dark.xml
@@ -4,82 +4,46 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_DARK_BACKGROUND"
- app:default_color="?android:colorBackground"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/background_status"
app:title="@string/background_status_title" />
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_DARK_BOOST_HEADER"
- app:default_color="?android:colorBackground"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/boost_header_color"
app:title="@string/boost_header_color_title" />
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_DARK_DISPLAY_NAME"
- app:default_color="?colorOnBackground"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/displayname_title"
app:title="@string/display_name" />
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_DARK_USERNAME"
- app:default_color="?colorOnBackground"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/username_title"
app:title="@string/username" />
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_DARK_TEXT"
- app:default_color="?colorOnBackground"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/text_color"
app:title="@string/text_color_title" />
-
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_DARK_LINK"
- app:default_color="?linkColor"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/link_color"
app:title="@string/link_color_title" />
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_DARK_ICON"
- app:default_color="?colorControlNormal"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/icons_color"
app:title="@string/icons_color_title" />
diff --git a/app/src/main/res/xml/pref_custom_light.xml b/app/src/main/res/xml/pref_custom_light.xml
index 70d33cc64..f33def956 100644
--- a/app/src/main/res/xml/pref_custom_light.xml
+++ b/app/src/main/res/xml/pref_custom_light.xml
@@ -4,82 +4,47 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_LIGHT_BACKGROUND"
- app:default_color="?android:colorBackground"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/background_status"
app:title="@string/background_status_title" />
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_LIGHT_BOOST_HEADER"
- app:default_color="?android:colorBackground"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/boost_header_color"
app:title="@string/boost_header_color_title" />
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_LIGHT_DISPLAY_NAME"
- app:default_color="?colorOnBackground"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/displayname_title"
app:title="@string/display_name" />
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_LIGHT_USERNAME"
- app:default_color="?colorOnBackground"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/username_title"
app:title="@string/username" />
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_LIGHT_TEXT"
- app:default_color="?colorOnBackground"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/text_color"
app:title="@string/text_color_title" />
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_LIGHT_LINK"
- app:default_color="?linkColor"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/link_color"
app:title="@string/link_color_title" />
- <com.skydoves.colorpickerpreference.ColorPickerPreference
+ <com.jaredrummler.android.colorpicker.ColorPreferenceCompat
android:key="@string/SET_LIGHT_ICON"
- app:default_color="?colorControlNormal"
app:iconSpaceReserved="false"
- app:preference_attachAlphaSlideBar="false"
- app:preference_attachBrightnessSlideBar="false"
- app:preference_dialog_negative="@string/cancel"
- app:preference_dialog_positive="@string/save"
app:summary="@string/icons_color"
app:title="@string/icons_color_title" />
diff --git a/app/src/main/res/xml/pref_theming.xml b/app/src/main/res/xml/pref_theming.xml
index f8ba554ff..3751a4552 100644
--- a/app/src/main/res/xml/pref_theming.xml
+++ b/app/src/main/res/xml/pref_theming.xml
@@ -86,4 +86,10 @@
app:iconSpaceReserved="false"
app:key="@string/SET_CUSTOMIZE_DARK_COLORS_ACTION" />
+ <Preference
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:title="@string/reset_color"
+ app:iconSpaceReserved="false"
+ app:key="@string/SET_RESET_CUSTOM_COLOR" />
</androidx.preference.PreferenceScreen>