mirror of
https://github.com/android-password-store/Android-Password-Store.git
synced 2025-09-05 15:45:42 +02:00
Better detect uninitialized repositories and offer to clone (#738)
* PasswordRepository: more comprehensive check for valid repository * PasswordFragment: Give 'repo uninitialized' Snackbar some purpose in life * GitOperationActivity: finish immediately when an unhandled request code is used * PasswordFragment: Make uninitialized repo Snackbar indefinite * spotless Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
a5437c480a
commit
bee20ac44a
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue