summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt10
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt4
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt4
3 files changed, 15 insertions, 3 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
index 2b1551fa..1b9d3f9c 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
@@ -26,6 +26,7 @@ import com.google.android.material.snackbar.Snackbar
import com.zeapo.pwdstore.databinding.PasswordRecyclerViewBinding
import com.zeapo.pwdstore.git.BaseGitActivity
import com.zeapo.pwdstore.git.GitOperationActivity
+import com.zeapo.pwdstore.git.GitServerConfigActivity
import com.zeapo.pwdstore.ui.OnOffItemAnimator
import com.zeapo.pwdstore.ui.adapters.PasswordItemRecyclerAdapter
import com.zeapo.pwdstore.ui.dialogs.ItemCreationBottomSheet
@@ -69,8 +70,13 @@ class PasswordFragment : Fragment() {
swipeRefresher = binding.swipeRefresher
swipeRefresher.setOnRefreshListener {
if (!PasswordRepository.isGitRepo()) {
- Snackbar.make(binding.root, getString(R.string.clone_git_repo), Snackbar.LENGTH_SHORT)
- .show()
+ 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()
swipeRefresher.isRefreshing = false
} else {
val intent = Intent(context, GitOperationActivity::class.java)
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt
index ec73dae6..37f5e35c 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt
@@ -20,6 +20,10 @@ open class GitOperationActivity : BaseGitActivity() {
REQUEST_PULL -> syncRepository(REQUEST_PULL)
REQUEST_PUSH -> syncRepository(REQUEST_PUSH)
REQUEST_SYNC -> syncRepository(REQUEST_SYNC)
+ else -> {
+ setResult(RESULT_CANCELED)
+ finish()
+ }
}
}
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 bfe101a5..b2367431 100644
--- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt
@@ -80,7 +80,9 @@ open class PasswordRepository protected constructor() {
fun isGitRepo(): Boolean {
if (repository != null) {
// Check if remote exists
- return repository!!.config.getSubsections("remote").isNotEmpty()
+ return repository!!.config.getSubsections("remote").isNotEmpty() &&
+ repository!!.objectDatabase.exists() &&
+ repository!!.allRefs.isNotEmpty()
}
return false
}