summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2019-11-13 11:34:57 +0530
committerGitHub <noreply@github.com>2019-11-13 11:34:57 +0530
commit1f158c5ca6f5b88df0ff0a6234299bf839581c04 (patch)
treeeaa76473c3c8fe046e441edcb5e8016ae82cf9e8 /app/src/main/java
parent4c751a175f9a267e7bfb37b50ebb954fb9e552ee (diff)
Add option to show hidden folders (#571)
* Add option to show hidden folders Fixes #446 * Simplify filtering Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt14
1 files changed, 9 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 {