mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
fix: Better preference implementation and fix colors
This commit is contained in:
@@ -24,6 +24,7 @@ import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceCategory
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.viewmodels.DatabaseViewModel
|
||||
@@ -60,6 +61,9 @@ class MainPreferenceFragment : PreferenceFragmentCompat() {
|
||||
private fun checkDatabaseLoaded() {
|
||||
findPreference<Preference>(getString(R.string.settings_database_key))
|
||||
?.isEnabled = mDatabaseLoaded
|
||||
|
||||
findPreference<PreferenceCategory>(getString(R.string.settings_database_category_key))
|
||||
?.isVisible = mDatabaseLoaded
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
|
||||
6
app/src/main/res/color/on_surface_selector.xml
Normal file
6
app/src/main/res/color/on_surface_selector.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:alpha="0.46" android:color="?attr/colorOnSurface" android:state_hovered="true"/>
|
||||
<item android:alpha="0.38" android:color="?attr/colorOnSurface" android:state_enabled="false"/>
|
||||
<item android:alpha="1.00" android:color="?attr/colorOnSurface"/>
|
||||
</selector>
|
||||
76
app/src/main/res/layout/preference_material.xml
Normal file
76
app/src/main/res/layout/preference_material.xml
Normal file
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2015 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingHorizontal="32dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clipToPadding="false"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<include
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
layout="@layout/image_frame"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
style="@style/KeepassDXStyle.TextAppearance.LargeTitle"
|
||||
android:textColor="@color/on_surface_selector"
|
||||
android:ellipsize="marquee"/>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
android:layout_alignStart="@android:id/title"
|
||||
android:layout_gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:maxLines="10"
|
||||
style="@style/PreferenceSummaryTextStyle"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<!-- Preference should place its actual preference widget here. -->
|
||||
<LinearLayout
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="end|center_vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingRight="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -24,12 +24,12 @@
|
||||
<item name="android:navigationBarColor">@color/grey_dark</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.Light.v21" parent="KeepassDXStyle.Light.v14" >
|
||||
<item name="preferenceTheme">@style/KeepassDXStyle.Preference.v21</item>
|
||||
<item name="android:statusBarColor">?attr/colorSurface</item>
|
||||
<item name="android:navigationBarColor">?attr/colorSurface</item>
|
||||
<item name="preferenceTheme">@style/KeepassDXStyle.Preference.Theme</item>
|
||||
<item name="android:statusBarColor">@color/grey_dark</item>
|
||||
<item name="android:navigationBarColor">@color/grey_dark</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.Night.v21" parent="KeepassDXStyle.Night.v14" >
|
||||
<item name="preferenceTheme">@style/KeepassDXStyle.Preference.v21</item>
|
||||
<item name="preferenceTheme">@style/KeepassDXStyle.Preference.Theme</item>
|
||||
<item name="android:statusBarColor">?attr/colorSurface</item>
|
||||
<item name="android:navigationBarColor">?attr/colorSurface</item>
|
||||
</style>
|
||||
@@ -40,8 +40,8 @@
|
||||
</style>
|
||||
|
||||
<!-- Preference Theme -->
|
||||
<style name="KeepassDXStyle.Preference.v21" parent="@style/PreferenceThemeOverlay.v14.Material">
|
||||
<item name="android:tint">?attr/iconPreferenceColor</item>
|
||||
<style name="KeepassDXStyle.Preference.Theme" parent="@style/PreferenceThemeOverlay">
|
||||
<item name="android:tint">?attr/colorOnSurface</item>
|
||||
</style>
|
||||
|
||||
<!-- Button Style -->
|
||||
|
||||
@@ -20,10 +20,12 @@
|
||||
<resources>
|
||||
<style name="KeepassDXStyle.Light.v23" parent="KeepassDXStyle.Light.v21" >
|
||||
<item name="android:statusBarColor">?attr/colorSurface</item>
|
||||
<item name="android:navigationBarColor">?attr/colorSurface</item>
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.Night.v23" parent="KeepassDXStyle.Night.v21" >
|
||||
<item name="android:statusBarColor">?attr/colorSurface</item>
|
||||
<item name="android:navigationBarColor">?attr/colorSurface</item>
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
<attr name="toolbarActionStyle" format="reference" />
|
||||
|
||||
<attr name="dialogBackgroundColor" format="reference|color" />
|
||||
<attr name="iconPreferenceColor" format="reference|color" />
|
||||
|
||||
<declare-styleable name="explanationDialog">
|
||||
<attr name="explanations" format="string" />
|
||||
|
||||
@@ -540,8 +540,6 @@
|
||||
|
||||
<!-- Reply -->
|
||||
|
||||
<color name="reply_black_transparent">#E0232F34</color>
|
||||
|
||||
<color name="reply_theme_light_primary">#F9AA33</color>
|
||||
<color name="reply_theme_light_primaryDark">#D1DADF</color>
|
||||
<color name="reply_theme_light_onPrimary">#232F34</color>
|
||||
|
||||
@@ -260,6 +260,7 @@
|
||||
<bool name="search_option_templates_default" translatable="false">false</bool>
|
||||
|
||||
<!-- Database Settings -->
|
||||
<string name="settings_database_category_key" translatable="false">settings_database_category_key</string>
|
||||
<string name="settings_database_key" translatable="false">settings_database_key</string>
|
||||
<string name="settings_database_security_key" translatable="false">settings_database_security_key</string>
|
||||
<string name="settings_database_credentials_key" translatable="false">settings_database_credentials_key</string>
|
||||
|
||||
@@ -252,11 +252,17 @@
|
||||
<string name="copy_field">Copy of %1$s</string>
|
||||
<string name="settings">Settings</string>
|
||||
<string name="menu_app_settings">App settings</string>
|
||||
<string name="menu_app_settings_summary">Search, lock, history, properties</string>
|
||||
<string name="menu_form_filling_settings">Form filling</string>
|
||||
<string name="menu_form_filling_settings_summary">Keyboard, autofill, clipboard</string>
|
||||
<string name="menu_advanced_unlock_settings">Advanced unlocking</string>
|
||||
<string name="menu_advanced_unlock_settings_summary">Biometry, device credential</string>
|
||||
<string name="menu_database_settings">Database settings</string>
|
||||
<string name="menu_database_settings_summary">Metadata, recycle bin, templates, history</string>
|
||||
<string name="menu_security_settings">Security settings</string>
|
||||
<string name="menu_security_settings_summary">Encryption, key derivation function</string>
|
||||
<string name="menu_master_key_settings">Master key settings</string>
|
||||
<string name="master_key_settings_summary">Change main credential, renewal</string>
|
||||
<string name="menu_donate">Donate</string>
|
||||
<string name="menu_edit">Edit</string>
|
||||
<string name="menu_copy">Copy</string>
|
||||
@@ -400,6 +406,7 @@
|
||||
<string name="database_history">History</string>
|
||||
<string name="properties">Properties</string>
|
||||
<string name="menu_appearance_settings">Appearance</string>
|
||||
<string name="menu_appearance_settings_summary">Themes, colors, attributes</string>
|
||||
<string name="biometric">Biometric</string>
|
||||
<string name="device_credential">Device credential</string>
|
||||
<string name="general">General</string>
|
||||
|
||||
@@ -84,8 +84,6 @@
|
||||
<item name="android:textColor">?attr/colorOnSurface</item>
|
||||
<item name="android:textColorPrimary">@color/green_light</item>
|
||||
|
||||
<item name="iconPreferenceColor">?attr/colorOnSurface</item>
|
||||
|
||||
<!-- Dialog -->
|
||||
<item name="android:alertDialogTheme">@style/KeepassDXStyle.Light.Dialog</item>
|
||||
<item name="alertDialogTheme">@style/KeepassDXStyle.Light.Dialog</item>
|
||||
@@ -104,6 +102,11 @@
|
||||
<!-- Tab -->
|
||||
<item name="tabStyle">@style/KeepassDXStyle.TabLayout</item>
|
||||
|
||||
<!-- Preference -->
|
||||
<item name="preferenceStyle">@style/KeepassDXStyle.Preference.Style</item>
|
||||
<item name="dialogPreferenceStyle">@style/KeepassDXStyle.Preference.Dialog.Style</item>
|
||||
<item name="preferenceCategoryStyle">@style/KeepassDXStyle.Preference.Category.Style</item>
|
||||
|
||||
<!-- Switch -->
|
||||
<item name="android:switchPreferenceStyle">@style/KeepassDXStyle.SwitchPreference</item>
|
||||
<item name="switchPreferenceStyle">@style/KeepassDXStyle.SwitchPreference</item>
|
||||
@@ -173,8 +176,6 @@
|
||||
<item name="android:textColor">?attr/colorOnSurface</item>
|
||||
<item name="android:textColorPrimary">@color/green_light</item>
|
||||
|
||||
<item name="iconPreferenceColor">?attr/colorOnSurface</item>
|
||||
|
||||
<!-- Dialog -->
|
||||
<item name="android:alertDialogTheme">@style/KeepassDXStyle.Night.Dialog</item>
|
||||
<item name="alertDialogTheme">@style/KeepassDXStyle.Night.Dialog</item>
|
||||
@@ -193,6 +194,11 @@
|
||||
<!-- Tab -->
|
||||
<item name="tabStyle">@style/KeepassDXStyle.TabLayout</item>
|
||||
|
||||
<!-- Preference -->
|
||||
<item name="preferenceStyle">@style/KeepassDXStyle.Preference.Style</item>
|
||||
<item name="dialogPreferenceStyle">@style/KeepassDXStyle.Preference.Dialog.Style</item>
|
||||
<item name="preferenceCategoryStyle">@style/KeepassDXStyle.Preference.Category.Style</item>
|
||||
|
||||
<!-- Switch -->
|
||||
<item name="android:switchPreferenceStyle">@style/KeepassDXStyle.SwitchPreference</item>
|
||||
<item name="switchPreferenceStyle">@style/KeepassDXStyle.SwitchPreference</item>
|
||||
@@ -242,9 +248,30 @@
|
||||
<!-- Tab -->
|
||||
<style name="KeepassDXStyle.TabLayout" parent="@style/Widget.Material3.TabLayout" />
|
||||
|
||||
<!-- Preference -->
|
||||
<style name="KeepassDXStyle.Preference.Style" parent="@style/Preference.Material">
|
||||
<item name="android:layout">@layout/preference_material</item>
|
||||
<item name="allowDividerAbove">false</item>
|
||||
<item name="allowDividerBelow">false</item>
|
||||
<item name="iconSpaceReserved">false</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.Preference.Dialog.Style" parent="@style/Preference.DialogPreference.Material">
|
||||
<item name="allowDividerAbove">false</item>
|
||||
<item name="allowDividerBelow">false</item>
|
||||
<item name="iconSpaceReserved">false</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.Preference.Category.Style" parent="@style/Preference.Category.Material">
|
||||
<item name="allowDividerAbove">false</item>
|
||||
<item name="allowDividerBelow">false</item>
|
||||
<item name="iconSpaceReserved">false</item>
|
||||
</style>
|
||||
|
||||
<!-- Switch -->
|
||||
<style name="KeepassDXStyle.SwitchPreference" parent="@style/Preference.SwitchPreferenceCompat.Material">
|
||||
<item name="widgetLayout">@layout/preference_material_switch</item>
|
||||
<item name="allowDividerAbove">false</item>
|
||||
<item name="allowDividerBelow">false</item>
|
||||
<item name="iconSpaceReserved">false</item>
|
||||
</style>
|
||||
|
||||
<!-- Chip -->
|
||||
|
||||
@@ -20,47 +20,55 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/application">
|
||||
<Preference
|
||||
android:key="@string/settings_app_key"
|
||||
android:title="@string/menu_app_settings"
|
||||
android:icon="@drawable/prefs_phone_android_24dp"
|
||||
android:persistent="false" />
|
||||
<Preference
|
||||
android:key="@string/settings_form_filling_key"
|
||||
android:title="@string/menu_form_filling_settings"
|
||||
android:icon="@drawable/prefs_content_paste_24dp"
|
||||
android:persistent="false" />
|
||||
<Preference
|
||||
android:key="@string/settings_advanced_unlock_key"
|
||||
android:title="@string/menu_advanced_unlock_settings"
|
||||
android:icon="@drawable/prefs_bolt_24dp"
|
||||
android:persistent="false" />
|
||||
<Preference
|
||||
android:key="@string/settings_appearance_key"
|
||||
android:title="@string/menu_appearance_settings"
|
||||
android:icon="@drawable/prefs_color_lens_24dp"
|
||||
android:persistent="false" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="@string/settings_database_category_key"
|
||||
android:title="@string/database">
|
||||
<Preference
|
||||
android:key="@string/settings_database_key"
|
||||
android:title="@string/menu_database_settings"
|
||||
android:icon="@drawable/prefs_data_usage_24dp"
|
||||
android:summary="@string/menu_database_settings_summary"
|
||||
android:persistent="false" />
|
||||
<Preference
|
||||
android:key="@string/settings_database_security_key"
|
||||
android:title="@string/security"
|
||||
android:icon="@drawable/prefs_security_24dp"
|
||||
android:dependency="@string/settings_database_key"
|
||||
android:summary="@string/menu_security_settings_summary"
|
||||
android:persistent="false" />
|
||||
<Preference
|
||||
android:key="@string/settings_database_credentials_key"
|
||||
android:title="@string/master_key"
|
||||
android:icon="@drawable/prefs_key_24dp"
|
||||
android:dependency="@string/settings_database_key"
|
||||
android:summary="@string/master_key_settings_summary"
|
||||
android:persistent="false" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/application">
|
||||
<Preference
|
||||
android:key="@string/settings_app_key"
|
||||
android:title="@string/menu_app_settings"
|
||||
android:icon="@drawable/prefs_phone_android_24dp"
|
||||
android:summary="@string/menu_app_settings_summary"
|
||||
android:persistent="false" />
|
||||
<Preference
|
||||
android:key="@string/settings_form_filling_key"
|
||||
android:title="@string/menu_form_filling_settings"
|
||||
android:icon="@drawable/prefs_content_paste_24dp"
|
||||
android:summary="@string/menu_form_filling_settings_summary"
|
||||
android:persistent="false" />
|
||||
<Preference
|
||||
android:key="@string/settings_advanced_unlock_key"
|
||||
android:title="@string/menu_advanced_unlock_settings"
|
||||
android:icon="@drawable/prefs_bolt_24dp"
|
||||
android:summary="@string/menu_advanced_unlock_settings_summary"
|
||||
android:persistent="false" />
|
||||
<Preference
|
||||
android:key="@string/settings_appearance_key"
|
||||
android:title="@string/menu_appearance_settings"
|
||||
android:icon="@drawable/prefs_color_lens_24dp"
|
||||
android:summary="@string/menu_appearance_settings_summary"
|
||||
android:persistent="false" />
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user