diff options
7 files changed, 112 insertions, 74 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 82cccba5..ccc046cf 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 @@ -57,6 +57,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Bra if (lockPref != null) { if (!DeviceCredentialUtil.areCredentialsAvailable(requireContext())) { lockPref.setVisible(false); + findPreference(getString(R.string.pref_category_security)).setVisible(false); } else { lockPref.setOnPreferenceChangeListener((preference, newValue) -> { Notes.setLockedPreference((Boolean) newValue); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java index b284d31f..606e7d77 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSwitchPreference.java @@ -74,11 +74,11 @@ public class BrandedSwitchPreference extends SwitchPreference implements Branded // int trackColor = Color.argb(77, Color.red(finalMainColor), Color.green(finalMainColor), Color.blue(finalMainColor)); DrawableCompat.setTintList(switchView.getThumbDrawable(), new ColorStateList( new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}}, - new int[]{finalMainColor, getContext().getResources().getColor(R.color.fg_default)} + new int[]{finalMainColor, getContext().getResources().getColor(R.color.fg_default_low)} )); DrawableCompat.setTintList(switchView.getTrackDrawable(), new ColorStateList( new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}}, - new int[]{finalMainColor, getContext().getResources().getColor(R.color.fg_default)} + new int[]{finalMainColor, getContext().getResources().getColor(R.color.fg_default_low)} )); } } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java index 37b58b9d..3ddbc68e 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java @@ -17,7 +17,6 @@ import it.niedermann.owncloud.notes.android.DarkModeSetting; import it.niedermann.owncloud.notes.util.Notes; import static it.niedermann.owncloud.notes.util.ColorUtil.contrastRatioIsSufficient; -import static it.niedermann.owncloud.notes.util.ColorUtil.isColorDark; public class BrandingUtil { @@ -58,20 +57,20 @@ public class BrandingUtil { } public static void saveBrandColors(@NonNull Context context, @ColorInt int mainColor, @ColorInt int textColor) { - if (isBrandingEnabled(context) && context instanceof BrandedActivity) { - final BrandedActivity activity = (BrandedActivity) context; - activity.applyBrand(mainColor, textColor); - BrandedActivity.applyBrandToStatusbar(activity.getWindow(), mainColor, textColor); - // TODO if colors changed, recreate activity - activity.setTheme(isColorDark(textColor) ? R.style.AppThemeLightBrand : R.style.AppTheme); - activity.invalidateOptionsMenu(); - } + final int previousMainColor = readBrandMainColor(context); + final int previousTextColor = readBrandTextColor(context); SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit(); Log.v(TAG, "--- Write: shared_preference_theme_main" + " | " + mainColor); Log.v(TAG, "--- Write: shared_preference_theme_text" + " | " + textColor); editor.putInt(pref_key_branding_main, mainColor); editor.putInt(pref_key_branding_text, textColor); editor.apply(); + if (isBrandingEnabled(context) && context instanceof BrandedActivity) { + if (mainColor != previousMainColor || textColor != previousTextColor) { + final BrandedActivity activity = (BrandedActivity) context; + activity.recreate(); + } + } } /** @@ -106,7 +105,7 @@ public class BrandingUtil { finalMainColor, finalMainColor, finalMainColor, - editText.getContext().getResources().getColor(R.color.fg_default) + editText.getContext().getResources().getColor(R.color.fg_default_low) } )); } diff --git a/app/src/main/res/layout/item_preference_category.xml b/app/src/main/res/layout/item_preference_category.xml new file mode 100644 index 00000000..4580a438 --- /dev/null +++ b/app/src/main/res/layout/item_preference_category.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:id="@android:id/title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingStart="56dp" + android:paddingLeft="56dp" + android:paddingTop="@dimen/spacer_3x" + android:paddingEnd="0dp" + android:paddingRight="0dp" + tools:text="@tools:sample/lorem" /> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index b615b358..24f9b81c 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -5,6 +5,7 @@ <dimen name="spacer_1hx">4dp</dimen> <dimen name="spacer_1x">8dp</dimen> <dimen name="spacer_2x">16dp</dimen> + <dimen name="spacer_3x">24dp</dimen> <!-- Buttons --> <dimen name="button_padding">@dimen/spacer_2x</dimen> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index abd1f614..ddcbdb2b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -116,6 +116,7 @@ <string name="pref_key_font_size" translatable="false">fontSize</string> <string name="pref_key_wifi_only" translatable="false">wifiOnly</string> <string name="pref_key_lock" translatable="false">lock</string> + <string name="pref_category_security" translatable="false">security</string> <string name="pref_key_last_note_mode" translatable="false">lastNoteMode</string> <string name="pref_key_background_sync" translatable="false">backgroundSync</string> <string name="pref_value_mode_edit" translatable="false">edit</string> @@ -181,6 +182,10 @@ <string name="error_dialog_contact_us">Please do not hesitate to contact us if the issues persist. You can find our contact information in the about section in the sidebar.</string> <string name="error_dialog_we_need_info">We need the following technical information to help you:</string> <string name="settings_branding">Branding</string> + <string name="simple_security">Security</string> + <string name="simple_appearance">Appearance</string> + <string name="simple_synchronization">Synchronization</string> + <string name="simple_behavior">Behavior</string> <!-- Array: note modes --> <string-array name="noteMode_entries"> diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 6611f0e9..3fc5b4f9 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -1,73 +1,93 @@ <?xml version="1.0" encoding="utf-8"?> -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + <it.niedermann.owncloud.notes.branding.BrandedPreferenceCategory - <it.niedermann.owncloud.notes.branding.BrandedSwitchPreference - android:defaultValue="@string/pref_value_lock" - android:icon="@drawable/ic_lock_grey600_24dp" - android:key="@string/pref_key_lock" - android:layout="@layout/item_pref" - android:summary="@string/simple_beta" - android:title="@string/settings_lock" /> + app:layout="@layout/item_preference_category" + app:title="@string/simple_synchronization"> - <ListPreference - android:defaultValue="@string/pref_value_mode_edit" - android:entries="@array/noteMode_entries" - android:entryValues="@array/noteMode_values" - android:icon="@drawable/ic_remove_red_eye_grey_24dp" - android:key="@string/pref_key_note_mode" - android:layout="@layout/item_pref" - android:summary="%s" - android:title="@string/settings_note_mode" /> + <it.niedermann.owncloud.notes.branding.BrandedSwitchPreference + android:defaultValue="@string/pref_value_wifi_and_mobile" + android:icon="@drawable/ic_network_wifi_grey600_24dp" + android:key="@string/pref_key_wifi_only" + android:layout="@layout/item_pref" + android:title="@string/settings_wifi_only" /> - <ListPreference - android:defaultValue="@string/pref_value_theme_system_default" - android:entries="@array/darkmode_entries" - android:entryValues="@array/darkMode_values" - android:icon="@drawable/ic_brightness_2_grey_24dp" - android:key="@string/pref_key_theme" - android:layout="@layout/item_pref" - android:summary="%s" - android:title="@string/settings_theme_title" /> + <ListPreference + android:defaultValue="@string/pref_value_sync_off" + android:entries="@array/sync_entries" + android:entryValues="@array/sync_values" + android:icon="@drawable/ic_sync_black_24dp" + android:key="@string/pref_key_background_sync" + android:layout="@layout/item_pref" + android:summary="%s" + android:title="@string/settings_background_sync" /> + </it.niedermann.owncloud.notes.branding.BrandedPreferenceCategory> - <it.niedermann.owncloud.notes.branding.BrandedSwitchPreference - android:defaultValue="true" - android:icon="@drawable/ic_color_lens_grey600_24dp" - android:key="@string/pref_key_branding" - android:layout="@layout/item_pref" - android:title="@string/settings_branding" /> + <it.niedermann.owncloud.notes.branding.BrandedPreferenceCategory - <it.niedermann.owncloud.notes.branding.BrandedSwitchPreference - android:defaultValue="@string/pref_value_font_normal" - android:icon="@drawable/ic_text_format_grey600_24dp" - android:key="@string/pref_key_font" - android:layout="@layout/item_pref" - android:title="@string/settings_font_title" /> + app:layout="@layout/item_preference_category" + app:title="@string/simple_appearance"> - <ListPreference - android:defaultValue="@string/pref_value_font_size_medium" - android:entries="@array/fontSize_entries" - android:entryValues="@array/fontSize_values" - android:icon="@drawable/ic_format_size_black_24dp" - android:key="@string/pref_key_font_size" - android:layout="@layout/item_pref" - android:summary="%s" - android:title="@string/settings_font_size" /> + <ListPreference + android:defaultValue="@string/pref_value_theme_system_default" + android:entries="@array/darkmode_entries" + android:entryValues="@array/darkMode_values" + android:icon="@drawable/ic_brightness_2_grey_24dp" + android:key="@string/pref_key_theme" + android:layout="@layout/item_pref" + android:summary="%s" + android:title="@string/settings_theme_title" /> - <it.niedermann.owncloud.notes.branding.BrandedSwitchPreference - android:defaultValue="@string/pref_value_wifi_and_mobile" - android:icon="@drawable/ic_network_wifi_grey600_24dp" - android:key="@string/pref_key_wifi_only" - android:layout="@layout/item_pref" - android:title="@string/settings_wifi_only" /> + <it.niedermann.owncloud.notes.branding.BrandedSwitchPreference + android:defaultValue="true" + android:icon="@drawable/ic_color_lens_grey600_24dp" + android:key="@string/pref_key_branding" + android:layout="@layout/item_pref" + android:title="@string/settings_branding" /> - <ListPreference - android:defaultValue="@string/pref_value_sync_off" - android:entries="@array/sync_entries" - android:entryValues="@array/sync_values" - android:icon="@drawable/ic_sync_black_24dp" - android:key="@string/pref_key_background_sync" - android:layout="@layout/item_pref" - android:summary="%s" - android:title="@string/settings_background_sync" /> + </it.niedermann.owncloud.notes.branding.BrandedPreferenceCategory> + <it.niedermann.owncloud.notes.branding.BrandedPreferenceCategory + android:key="@string/pref_category_security" + app:layout="@layout/item_preference_category" + app:title="@string/simple_security"> + <it.niedermann.owncloud.notes.branding.BrandedSwitchPreference + android:defaultValue="@string/pref_value_lock" + android:icon="@drawable/ic_lock_grey600_24dp" + android:key="@string/pref_key_lock" + android:layout="@layout/item_pref" + android:summary="@string/simple_beta" + android:title="@string/settings_lock" /> + </it.niedermann.owncloud.notes.branding.BrandedPreferenceCategory> + <it.niedermann.owncloud.notes.branding.BrandedPreferenceCategory + + app:layout="@layout/item_preference_category" + app:title="@string/simple_behavior"> + <it.niedermann.owncloud.notes.branding.BrandedSwitchPreference + android:defaultValue="@string/pref_value_font_normal" + android:icon="@drawable/ic_text_format_grey600_24dp" + android:key="@string/pref_key_font" + android:layout="@layout/item_pref" + android:title="@string/settings_font_title" /> + <ListPreference + android:defaultValue="@string/pref_value_mode_edit" + android:entries="@array/noteMode_entries" + android:entryValues="@array/noteMode_values" + android:icon="@drawable/ic_remove_red_eye_grey_24dp" + android:key="@string/pref_key_note_mode" + android:layout="@layout/item_pref" + android:summary="%s" + android:title="@string/settings_note_mode" /> + + <ListPreference + android:defaultValue="@string/pref_value_font_size_medium" + android:entries="@array/fontSize_entries" + android:entryValues="@array/fontSize_values" + android:icon="@drawable/ic_format_size_black_24dp" + android:key="@string/pref_key_font_size" + android:layout="@layout/item_pref" + android:summary="%s" + android:title="@string/settings_font_size" /> + </it.niedermann.owncloud.notes.branding.BrandedPreferenceCategory> </PreferenceScreen> |