diff options
author | Harsh Shandilya <msfjarvis@gmail.com> | 2020-06-19 00:07:05 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-19 00:07:05 +0530 |
commit | 9751cde4061daf1a70d4e4cd11fa4fb01df55e2f (patch) | |
tree | 1f8480821424761412001741fbc534a3ebe3de7b /app/src/main/java | |
parent | 0a4bcc57f5d0f319f72f751c4406ca1877401b63 (diff) |
PasswordStore: refresh password list on swipe down in non-git mode (#862)
* PasswordStore: refresh password list on swipe down in non-git mode
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
* Address review comments
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Co-authored-by: Fabian Henneke <FabianHenneke@users.noreply.github.com>
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt index a47e6e70..d811f341 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt @@ -62,28 +62,29 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) { private fun initializePasswordList() { val gitDir = File(PasswordRepository.getRepositoryDirectory(requireContext()), ".git") val hasGitDir = gitDir.exists() && gitDir.isDirectory && (gitDir.listFiles()?.isNotEmpty() == true) - if (hasGitDir) { - binding.swipeRefresher.setOnRefreshListener { - if (!PasswordRepository.isGitRepo()) { - Snackbar.make(binding.root, getString(R.string.clone_git_repo), Snackbar.LENGTH_INDEFINITE) - .setAction(R.string.clone_button) { - val intent = Intent(context, GitServerConfigActivity::class.java) - intent.putExtra(BaseGitActivity.REQUEST_ARG_OP, BaseGitActivity.REQUEST_CLONE) - startActivityForResult(intent, BaseGitActivity.REQUEST_CLONE) - } - .show() - binding.swipeRefresher.isRefreshing = false - } else { - // When authentication is set to ConnectionMode.None then the only git operation we - // can run is a pull, so automatically fallback to that. - val operationId = when (ConnectionMode.fromString(settings.getString("git_remote_auth", null))) { - ConnectionMode.None -> BaseGitActivity.REQUEST_PULL - else -> BaseGitActivity.REQUEST_SYNC + binding.swipeRefresher.setOnRefreshListener { + if (!hasGitDir) { + requireStore().refreshPasswordList() + binding.swipeRefresher.isRefreshing = false + } else if (!PasswordRepository.isGitRepo()) { + Snackbar.make(binding.root, getString(R.string.clone_git_repo), Snackbar.LENGTH_INDEFINITE) + .setAction(R.string.clone_button) { + val intent = Intent(context, GitServerConfigActivity::class.java) + intent.putExtra(BaseGitActivity.REQUEST_ARG_OP, BaseGitActivity.REQUEST_CLONE) + startActivityForResult(intent, BaseGitActivity.REQUEST_CLONE) } - val intent = Intent(context, GitOperationActivity::class.java) - intent.putExtra(BaseGitActivity.REQUEST_ARG_OP, operationId) - startActivityForResult(intent, operationId) + .show() + binding.swipeRefresher.isRefreshing = false + } else { + // When authentication is set to ConnectionMode.None then the only git operation we + // can run is a pull, so automatically fallback to that. + val operationId = when (ConnectionMode.fromString(settings.getString("git_remote_auth", null))) { + ConnectionMode.None -> BaseGitActivity.REQUEST_PULL + else -> BaseGitActivity.REQUEST_SYNC } + val intent = Intent(context, GitOperationActivity::class.java) + intent.putExtra(BaseGitActivity.REQUEST_ARG_OP, operationId) + startActivityForResult(intent, operationId) } } |