diff options
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt | 14 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 2 | ||||
-rw-r--r-- | app/src/main/res/xml/preference.xml | 6 |
3 files changed, 17 insertions, 5 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt index 22d9046f..d10a5d59 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt @@ -47,6 +47,7 @@ open class PasswordRepository protected constructor() { companion object { private var repository: Repository? = null + private lateinit var settings: SharedPreferences /** * Returns the git repository @@ -139,7 +140,6 @@ open class PasswordRepository protected constructor() { @JvmStatic fun getRepositoryDirectory(context: Context): File { - val settings = PreferenceManager.getDefaultSharedPreferences(context.applicationContext) return if (settings.getBoolean("git_external", false)) { val externalRepo = settings.getString("git_external_repo", null) File(requireNotNull(externalRepo)) @@ -150,9 +150,8 @@ open class PasswordRepository protected constructor() { @JvmStatic fun initialize(context: Context): Repository? { + settings = PreferenceManager.getDefaultSharedPreferences(context.applicationContext) val dir = getRepositoryDirectory(context) - val settings = PreferenceManager.getDefaultSharedPreferences(context.applicationContext) - // uninitialize the repo if the dir does not exist or is absolutely empty if (!dir.exists() || !dir.isDirectory || dir.listFiles()!!.isEmpty()) { settings.edit().putBoolean("repository_initialized", false).apply() @@ -207,10 +206,15 @@ open class PasswordRepository protected constructor() { // We need to recover the passwords then parse the files val passList = getFilesList(path).also { it.sortBy { f -> f.name } } val passwordList = ArrayList<PasswordItem>() + val showHiddenDirs = settings.getBoolean("show_hidden_folders", false) if (passList.size == 0) return passwordList - - passList.filter { !it.isHidden }.forEach { file -> + if (showHiddenDirs) { + passList.filter { !(it.isFile && it.isHidden) }.toCollection(passList.apply { clear() }) + } else { + passList.filter { !it.isHidden }.toCollection(passList.apply { clear() }) + } + passList.forEach { file -> passwordList.add(if (file.isFile) { PasswordItem.newPassword(file.name, file, rootDir) } else { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9ac5a850..c0c4c3fd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -274,4 +274,6 @@ <string name="access_sdcard_text">The store is on the sdcard but the app does not have permission to access it. Please give permission.</string> <string name="your_public_key">Your public key</string> <string name="error_generate_ssh_key">Error while trying to generate the ssh-key</string> + <string name="pref_show_hidden_title">Show hidden folders</string> + <string name="pref_show_hidden_summary">Include hidden directories in the password list</string> </resources> diff --git a/app/src/main/res/xml/preference.xml b/app/src/main/res/xml/preference.xml index 3f05af08..b03bfa5b 100644 --- a/app/src/main/res/xml/preference.xml +++ b/app/src/main/res/xml/preference.xml @@ -90,6 +90,12 @@ android:entryValues="@array/sort_order_values" android:persistent="true" /> <androidx.preference.SwitchPreferenceCompat + android:title="@string/pref_show_hidden_title" + android:summary="@string/pref_show_hidden_summary" + android:key="show_hidden_folders" + android:defaultValue="false" + android:persistent="true" /> + <androidx.preference.SwitchPreferenceCompat android:key="biometric_auth" android:title="@string/biometric_auth_title" android:summary="@string/biometric_auth_summary" /> |