Commit ae80a27d authored by Thomas's avatar Thomas
Browse files

Allow to reset customizations

parent d9ed0984
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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"
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ public class SpannableHelper {
                linkColor = link_color;
            }
        } else {
            linkColor = linkColor;
            linkColor = ThemeHelper.getAttColor(context, R.attr.linkColor);
        }

        SpannableString initialContent;
+35 −0
Original line number Diff line number Diff line
@@ -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;
            });
        }
    }

}
+2 −0
Original line number Diff line number Diff line
@@ -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>

+7 −43
Original line number Diff line number Diff line
@@ -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" />

Loading