mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-09-01 14:55:19 +00:00
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>
This commit is contained in:
@@ -62,28 +62,29 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
|
|||||||
private fun initializePasswordList() {
|
private fun initializePasswordList() {
|
||||||
val gitDir = File(PasswordRepository.getRepositoryDirectory(requireContext()), ".git")
|
val gitDir = File(PasswordRepository.getRepositoryDirectory(requireContext()), ".git")
|
||||||
val hasGitDir = gitDir.exists() && gitDir.isDirectory && (gitDir.listFiles()?.isNotEmpty() == true)
|
val hasGitDir = gitDir.exists() && gitDir.isDirectory && (gitDir.listFiles()?.isNotEmpty() == true)
|
||||||
if (hasGitDir) {
|
binding.swipeRefresher.setOnRefreshListener {
|
||||||
binding.swipeRefresher.setOnRefreshListener {
|
if (!hasGitDir) {
|
||||||
if (!PasswordRepository.isGitRepo()) {
|
requireStore().refreshPasswordList()
|
||||||
Snackbar.make(binding.root, getString(R.string.clone_git_repo), Snackbar.LENGTH_INDEFINITE)
|
binding.swipeRefresher.isRefreshing = false
|
||||||
.setAction(R.string.clone_button) {
|
} else if (!PasswordRepository.isGitRepo()) {
|
||||||
val intent = Intent(context, GitServerConfigActivity::class.java)
|
Snackbar.make(binding.root, getString(R.string.clone_git_repo), Snackbar.LENGTH_INDEFINITE)
|
||||||
intent.putExtra(BaseGitActivity.REQUEST_ARG_OP, BaseGitActivity.REQUEST_CLONE)
|
.setAction(R.string.clone_button) {
|
||||||
startActivityForResult(intent, BaseGitActivity.REQUEST_CLONE)
|
val intent = Intent(context, GitServerConfigActivity::class.java)
|
||||||
}
|
intent.putExtra(BaseGitActivity.REQUEST_ARG_OP, BaseGitActivity.REQUEST_CLONE)
|
||||||
.show()
|
startActivityForResult(intent, BaseGitActivity.REQUEST_CLONE)
|
||||||
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)
|
.show()
|
||||||
intent.putExtra(BaseGitActivity.REQUEST_ARG_OP, operationId)
|
binding.swipeRefresher.isRefreshing = false
|
||||||
startActivityForResult(intent, operationId)
|
} 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user