diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-05-02 00:38:20 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-05-02 00:38:20 +0300 |
commit | a30ab4cb25198ddae4aa0e57b761d5d92be46021 (patch) | |
tree | c217ec3b70b1251bd7d7042b04f069c97064466d /app/src/main/java/it/niedermann/owncloud/notes/android/fragment/PreferencesFragment.java | |
parent | e26a6b2f8bd459fc16a80f9ea38f9512dc37e855 (diff) |
#762 Branding
Make a setting
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/android/fragment/PreferencesFragment.java')
-rw-r--r-- | app/src/main/java/it/niedermann/owncloud/notes/android/fragment/PreferencesFragment.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/PreferencesFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/PreferencesFragment.java index ec1dda15..82cccba5 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/PreferencesFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/fragment/PreferencesFragment.java @@ -8,6 +8,7 @@ import android.util.Log; import androidx.annotation.ColorInt; import androidx.annotation.Nullable; import androidx.preference.ListPreference; +import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import it.niedermann.owncloud.notes.R; @@ -19,13 +20,14 @@ import it.niedermann.owncloud.notes.persistence.SyncWorker; import it.niedermann.owncloud.notes.util.DeviceCredentialUtil; import it.niedermann.owncloud.notes.util.Notes; -public class PreferencesFragment extends PreferenceFragmentCompat implements Branded{ +public class PreferencesFragment extends PreferenceFragmentCompat implements Branded { private static final String TAG = PreferencesFragment.class.getSimpleName(); private BrandedSwitchPreference fontPref; private BrandedSwitchPreference lockPref; private BrandedSwitchPreference wifiOnlyPref; + private BrandedSwitchPreference brandingPref; @Override public void onCreate(@Nullable Bundle savedInstanceState) { @@ -37,6 +39,20 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Bra addPreferencesFromResource(R.xml.preferences); fontPref = findPreference(getString(R.string.pref_key_font)); + + brandingPref = findPreference(getString(R.string.pref_key_branding)); + if (brandingPref != null) { + brandingPref.setOnPreferenceChangeListener((Preference preference, Object newValue) -> { + final Boolean branding = (Boolean) newValue; + Log.v(TAG, "branding: " + branding); + requireActivity().setResult(Activity.RESULT_OK); + requireActivity().recreate(); + return true; + }); + } else { + Log.e(TAG, "Could not find preference with key: \"" + getString(R.string.pref_key_branding) + "\""); + } + lockPref = findPreference(getString(R.string.pref_key_lock)); if (lockPref != null) { if (!DeviceCredentialUtil.areCredentialsAvailable(requireContext())) { @@ -93,5 +109,6 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Bra fontPref.applyBrand(mainColor, textColor); lockPref.applyBrand(mainColor, textColor); wifiOnlyPref.applyBrand(mainColor, textColor); + brandingPref.applyBrand(mainColor, textColor); } } |