From 1ce3ef4ea3c55d4a6c4a79f8a6cca58387b240df Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 27 Aug 2020 14:27:55 +0530 Subject: Expand show hidden folders to also cover files (#1059) * PasswordItem: only strip .gpg suffixes Signed-off-by: Harsh Shandilya * Add preference key and migration for showing all hidden contents Signed-off-by: Harsh Shandilya * Allow showing both hidden files and directories Signed-off-by: Harsh Shandilya * Add tests for hidden folder setting migration Signed-off-by: Harsh Shandilya * Add changelog entry Signed-off-by: Harsh Shandilya * Slightly improve migration logic Skip migration if old key is not found and always delete the previous key even if its set to false. Signed-off-by: Harsh Shandilya * Tweak wording Suggested-by: Fabian Henneke Signed-off-by: Harsh Shandilya * Assert previous key's removal in tests Signed-off-by: Harsh Shandilya --- app/src/main/java/com/zeapo/pwdstore/Migrations.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/src/main/java/com/zeapo/pwdstore/Migrations.kt') diff --git a/app/src/main/java/com/zeapo/pwdstore/Migrations.kt b/app/src/main/java/com/zeapo/pwdstore/Migrations.kt index 7148ad7e..f7cce784 100644 --- a/app/src/main/java/com/zeapo/pwdstore/Migrations.kt +++ b/app/src/main/java/com/zeapo/pwdstore/Migrations.kt @@ -19,6 +19,7 @@ import java.net.URI fun runMigrations(context: Context) { migrateToGitUrlBasedConfig(context) + migrateToHideAll(context) } private fun migrateToGitUrlBasedConfig(context: Context) { @@ -84,3 +85,12 @@ private fun migrateToGitUrlBasedConfig(context: Context) { e { "Failed to migrate to URL-based Git config, generated URL is invalid" } } } + +private fun migrateToHideAll(context: Context) { + context.sharedPrefs.all[PreferenceKeys.SHOW_HIDDEN_FOLDERS] ?: return + val isHidden = context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, false) + context.sharedPrefs.edit { + remove(PreferenceKeys.SHOW_HIDDEN_FOLDERS) + putBoolean(PreferenceKeys.SHOW_HIDDEN_CONTENTS, isHidden) + } +} -- cgit v1.2.3