Switch SettingsActivity to use Material3 Switch (#2006)
This commit is contained in:
parent
0695f42e07
commit
a15ff1b137
6 changed files with 28 additions and 14 deletions
|
@ -16,9 +16,9 @@ import app.passwordstore.util.auth.BiometricAuthenticator.Result
|
|||
import app.passwordstore.util.extensions.sharedPrefs
|
||||
import app.passwordstore.util.settings.PreferenceKeys
|
||||
import de.Maxr1998.modernpreferences.PreferenceScreen
|
||||
import de.Maxr1998.modernpreferences.helpers.checkBox
|
||||
import de.Maxr1998.modernpreferences.helpers.onClick
|
||||
import de.Maxr1998.modernpreferences.helpers.singleChoice
|
||||
import de.Maxr1998.modernpreferences.helpers.switch
|
||||
import de.Maxr1998.modernpreferences.preferences.choice.SelectionItem
|
||||
|
||||
class GeneralSettings(private val activity: FragmentActivity) : SettingsProvider {
|
||||
|
@ -42,32 +42,32 @@ class GeneralSettings(private val activity: FragmentActivity) : SettingsProvider
|
|||
titleRes = R.string.pref_sort_order_title
|
||||
}
|
||||
|
||||
checkBox(PreferenceKeys.DISABLE_SYNC_ACTION) {
|
||||
switch(PreferenceKeys.DISABLE_SYNC_ACTION) {
|
||||
titleRes = R.string.pref_disable_sync_on_pull_title
|
||||
summaryRes = R.string.pref_disable_sync_on_pull_summary
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
checkBox(PreferenceKeys.FILTER_RECURSIVELY) {
|
||||
switch(PreferenceKeys.FILTER_RECURSIVELY) {
|
||||
titleRes = R.string.pref_recursive_filter_title
|
||||
summaryRes = R.string.pref_recursive_filter_summary
|
||||
defaultValue = true
|
||||
}
|
||||
|
||||
checkBox(PreferenceKeys.SEARCH_ON_START) {
|
||||
switch(PreferenceKeys.SEARCH_ON_START) {
|
||||
titleRes = R.string.pref_search_on_start_title
|
||||
summaryRes = R.string.pref_search_on_start_summary
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
checkBox(PreferenceKeys.SHOW_HIDDEN_CONTENTS) {
|
||||
switch(PreferenceKeys.SHOW_HIDDEN_CONTENTS) {
|
||||
titleRes = R.string.pref_show_hidden_title
|
||||
summaryRes = R.string.pref_show_hidden_summary
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
val canAuthenticate = BiometricAuthenticator.canAuthenticate(activity)
|
||||
checkBox(PreferenceKeys.BIOMETRIC_AUTH) {
|
||||
switch(PreferenceKeys.BIOMETRIC_AUTH) {
|
||||
titleRes = R.string.pref_biometric_auth_title
|
||||
defaultValue = false
|
||||
enabled = canAuthenticate
|
||||
|
|
|
@ -17,9 +17,9 @@ import app.passwordstore.R
|
|||
import app.passwordstore.util.services.PasswordExportService
|
||||
import app.passwordstore.util.settings.PreferenceKeys
|
||||
import de.Maxr1998.modernpreferences.PreferenceScreen
|
||||
import de.Maxr1998.modernpreferences.helpers.checkBox
|
||||
import de.Maxr1998.modernpreferences.helpers.onClick
|
||||
import de.Maxr1998.modernpreferences.helpers.pref
|
||||
import de.Maxr1998.modernpreferences.helpers.switch
|
||||
|
||||
class MiscSettings(activity: FragmentActivity) : SettingsProvider {
|
||||
|
||||
|
@ -65,12 +65,12 @@ class MiscSettings(activity: FragmentActivity) : SettingsProvider {
|
|||
true
|
||||
}
|
||||
}
|
||||
checkBox(PreferenceKeys.CLEAR_CLIPBOARD_HISTORY) {
|
||||
switch(PreferenceKeys.CLEAR_CLIPBOARD_HISTORY) {
|
||||
defaultValue = false
|
||||
titleRes = R.string.pref_clear_clipboard_title
|
||||
summaryRes = R.string.pref_clear_clipboard_summary
|
||||
}
|
||||
checkBox(PreferenceKeys.ENABLE_DEBUG_LOGGING) {
|
||||
switch(PreferenceKeys.ENABLE_DEBUG_LOGGING) {
|
||||
defaultValue = false
|
||||
titleRes = R.string.pref_debug_logging_title
|
||||
summaryRes = R.string.pref_debug_logging_summary
|
||||
|
|
|
@ -10,10 +10,10 @@ import androidx.fragment.app.FragmentActivity
|
|||
import app.passwordstore.R
|
||||
import app.passwordstore.util.settings.PreferenceKeys
|
||||
import de.Maxr1998.modernpreferences.PreferenceScreen
|
||||
import de.Maxr1998.modernpreferences.helpers.checkBox
|
||||
import de.Maxr1998.modernpreferences.helpers.editText
|
||||
import de.Maxr1998.modernpreferences.helpers.onSelectionChange
|
||||
import de.Maxr1998.modernpreferences.helpers.singleChoice
|
||||
import de.Maxr1998.modernpreferences.helpers.switch
|
||||
import de.Maxr1998.modernpreferences.preferences.choice.SelectionItem
|
||||
|
||||
class PasswordSettings(private val activity: FragmentActivity) : SettingsProvider {
|
||||
|
@ -38,12 +38,12 @@ class PasswordSettings(private val activity: FragmentActivity) : SettingsProvide
|
|||
}
|
||||
textInputType = InputType.TYPE_CLASS_NUMBER
|
||||
}
|
||||
checkBox(PreferenceKeys.SHOW_PASSWORD) {
|
||||
switch(PreferenceKeys.SHOW_PASSWORD) {
|
||||
titleRes = R.string.show_password_pref_title
|
||||
summaryRes = R.string.show_password_pref_summary
|
||||
defaultValue = true
|
||||
}
|
||||
checkBox(PreferenceKeys.COPY_ON_DECRYPT) {
|
||||
switch(PreferenceKeys.COPY_ON_DECRYPT) {
|
||||
titleRes = R.string.pref_copy_title
|
||||
summaryRes = R.string.pref_copy_summary
|
||||
defaultValue = false
|
||||
|
|
|
@ -39,9 +39,9 @@ import dagger.hilt.android.EntryPointAccessors
|
|||
import dagger.hilt.components.SingletonComponent
|
||||
import de.Maxr1998.modernpreferences.Preference
|
||||
import de.Maxr1998.modernpreferences.PreferenceScreen
|
||||
import de.Maxr1998.modernpreferences.helpers.checkBox
|
||||
import de.Maxr1998.modernpreferences.helpers.onClick
|
||||
import de.Maxr1998.modernpreferences.helpers.pref
|
||||
import de.Maxr1998.modernpreferences.helpers.switch
|
||||
|
||||
class RepositorySettings(private val activity: FragmentActivity) : SettingsProvider {
|
||||
|
||||
|
@ -64,7 +64,7 @@ class RepositorySettings(private val activity: FragmentActivity) : SettingsProvi
|
|||
val gitSettings = hiltEntryPoint.gitSettings()
|
||||
|
||||
builder.apply {
|
||||
checkBox(PreferenceKeys.REBASE_ON_PULL) {
|
||||
switch(PreferenceKeys.REBASE_ON_PULL) {
|
||||
titleRes = R.string.pref_rebase_on_pull_title
|
||||
summaryRes = R.string.pref_rebase_on_pull_summary
|
||||
summaryOnRes = R.string.pref_rebase_on_pull_summary_on
|
||||
|
|
|
@ -37,31 +37,37 @@ class SettingsActivity : AppCompatActivity() {
|
|||
val screen =
|
||||
screen(this) {
|
||||
subScreen {
|
||||
collapseIcon = true
|
||||
titleRes = R.string.pref_category_general_title
|
||||
iconRes = R.drawable.app_settings_alt_24px
|
||||
generalSettings.provideSettings(this)
|
||||
}
|
||||
subScreen {
|
||||
collapseIcon = true
|
||||
titleRes = R.string.pref_category_autofill_title
|
||||
iconRes = R.drawable.ic_wysiwyg_24px
|
||||
autofillSettings.provideSettings(this)
|
||||
}
|
||||
subScreen {
|
||||
collapseIcon = true
|
||||
titleRes = R.string.pref_category_passwords_title
|
||||
iconRes = R.drawable.ic_password_24px
|
||||
passwordSettings.provideSettings(this)
|
||||
}
|
||||
subScreen {
|
||||
collapseIcon = true
|
||||
titleRes = R.string.pref_category_repository_title
|
||||
iconRes = R.drawable.ic_call_merge_24px
|
||||
repositorySettings.provideSettings(this)
|
||||
}
|
||||
subScreen {
|
||||
collapseIcon = true
|
||||
titleRes = R.string.pref_category_misc_title
|
||||
iconRes = R.drawable.ic_miscellaneous_services_24px
|
||||
miscSettings.provideSettings(this)
|
||||
}
|
||||
subScreen {
|
||||
collapseIcon = true
|
||||
titleRes = R.string.pref_category_pgp_title
|
||||
iconRes = R.drawable.ic_lock_open_24px
|
||||
pgpSettings.provideSettings(this)
|
||||
|
|
8
app/src/main/res/layout/map_preference_widget_switch.xml
Normal file
8
app/src/main/res/layout/map_preference_widget_switch.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.materialswitch.MaterialSwitch xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false" />
|
Loading…
Reference in a new issue