aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-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
-rw-r--r--app/src/main/res/values/strings.xml4
4 files changed, 17 insertions, 5 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
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index bc7f0a6f..33c0b103 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -100,7 +100,7 @@
<string name="git_user_email">Email</string>
<string name="git_user_email_hint">email</string>
<string name="invalid_email_dialog_text">Please enter a valid email address</string>
- <string name="clone_button">Clone!</string>
+ <string name="clone_button">Clone</string>
<!-- PGP Handler -->
<string name="crypto_name_hint">Name</string>
@@ -344,7 +344,7 @@
<string name="pref_search_on_start_hint">Open search bar when app is launched</string>
<string name="password_generator_category_title">Password Generator</string>
<string name="tap_clear_clipboard">Tap here to clear clipboard</string>
- <string name="clone_git_repo">Clone a git repository to sync changes</string>
+ <string name="clone_git_repo">The repository must be cloned before syncing changes.</string>
<string name="theme_title">App theme</string>
<string name="theme_light">Light</string>
<string name="theme_dark">Dark</string>