diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2022-07-16 03:25:42 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-15 21:55:42 +0000 |
commit | a15ff1b137fa480120f9d0b670dd9d639294ed4d (patch) | |
tree | 4769a1b0019d41d0aab6b76a58b973285a06c57e /app/src | |
parent | 0695f42e07e2ce7c241c2ea2e954c843c324bd85 (diff) |
Switch SettingsActivity to use Material3 Switch (#2006)
Diffstat (limited to 'app/src')
6 files changed, 28 insertions, 14 deletions
diff --git a/app/src/main/java/app/passwordstore/ui/settings/GeneralSettings.kt b/app/src/main/java/app/passwordstore/ui/settings/GeneralSettings.kt index d6520ea3..b0c28455 100644 --- a/app/src/main/java/app/passwordstore/ui/settings/GeneralSettings.kt +++ b/app/src/main/java/app/passwordstore/ui/settings/GeneralSettings.kt @@ -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 diff --git a/app/src/main/java/app/passwordstore/ui/settings/MiscSettings.kt b/app/src/main/java/app/passwordstore/ui/settings/MiscSettings.kt index 7bd04eb5..250af493 100644 --- a/app/src/main/java/app/passwordstore/ui/settings/MiscSettings.kt +++ b/app/src/main/java/app/passwordstore/ui/settings/MiscSettings.kt @@ -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 diff --git a/app/src/main/java/app/passwordstore/ui/settings/PasswordSettings.kt b/app/src/main/java/app/passwordstore/ui/settings/PasswordSettings.kt index f90a8d95..b192bc67 100644 --- a/app/src/main/java/app/passwordstore/ui/settings/PasswordSettings.kt +++ b/app/src/main/java/app/passwordstore/ui/settings/PasswordSettings.kt @@ -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 diff --git a/app/src/main/java/app/passwordstore/ui/settings/RepositorySettings.kt b/app/src/main/java/app/passwordstore/ui/settings/RepositorySettings.kt index c9e28123..d57a1d36 100644 --- a/app/src/main/java/app/passwordstore/ui/settings/RepositorySettings.kt +++ b/app/src/main/java/app/passwordstore/ui/settings/RepositorySettings.kt @@ -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 diff --git a/app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt b/app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt index 8eae0520..7fc20d5d 100644 --- a/app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt +++ b/app/src/main/java/app/passwordstore/ui/settings/SettingsActivity.kt @@ -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) diff --git a/app/src/main/res/layout/map_preference_widget_switch.xml b/app/src/main/res/layout/map_preference_widget_switch.xml new file mode 100644 index 00000000..f06bd9bf --- /dev/null +++ b/app/src/main/res/layout/map_preference_widget_switch.xml @@ -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" /> |