aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/app/passwordstore/ui/git/config/GitConfigActivity.kt86
1 files changed, 45 insertions, 41 deletions
diff --git a/app/src/main/java/app/passwordstore/ui/git/config/GitConfigActivity.kt b/app/src/main/java/app/passwordstore/ui/git/config/GitConfigActivity.kt
index 96a9d191..a783273d 100644
--- a/app/src/main/java/app/passwordstore/ui/git/config/GitConfigActivity.kt
+++ b/app/src/main/java/app/passwordstore/ui/git/config/GitConfigActivity.kt
@@ -94,56 +94,60 @@ class GitConfigActivity : BaseGitActivity() {
runCatching { startActivity(Intent(this, GitLogActivity::class.java)) }
.onFailure { ex -> logcat(ERROR) { ex.asLog("Failed to start GitLogActivity") } }
}
- binding.gitAbortRebase.setOnClickListener {
+ binding.gitAbortRebase.setOnClickListener { abortRebase() }
+ binding.gitResetToRemote.setOnClickListener { resetToRemote() }
+ binding.gitGc.setOnClickListener {
lifecycleScope.launch {
- launchGitOperation(GitOp.BREAK_OUT_OF_DETACHED)
+ launchGitOperation(GitOp.GC)
.fold(
- success = {
- val branch = PasswordRepository.getCurrentBranch()
- MaterialAlertDialogBuilder(this@GitConfigActivity).run {
- setTitle(resources.getString(R.string.git_abort_and_push_title))
- setMessage(
- resources.getString(
- R.string.git_break_out_of_detached_success,
- branch,
- "conflicting-$branch-...",
- )
- )
- setOnDismissListener { finish() }
- setPositiveButton(resources.getString(R.string.dialog_ok)) { _, _ -> }
- show()
- }
- },
+ success = ::finishOnSuccessHandler,
failure = { err -> promptOnErrorHandler(err) { finish() } },
)
}
}
- binding.gitResetToRemote.setOnClickListener {
- val dialog =
- TextInputDialog.newInstance(getString(R.string.git_utils_reset_remote_branch_title))
- dialog.show(supportFragmentManager, "BRANCH_INPUT_DIALOG")
- dialog.setFragmentResultListener(TextInputDialog.REQUEST_KEY) { _, bundle ->
- val result = bundle.getString(TextInputDialog.BUNDLE_KEY_TEXT)
- if (!result.isNullOrEmpty()) {
- remoteBranch = result
- lifecycleScope.launch {
- launchGitOperation(GitOp.RESET)
- .fold(
- success = ::finishOnSuccessHandler,
- failure = { err -> promptOnErrorHandler(err) { finish() } },
- )
- }
+ }
+
+ private fun resetToRemote() {
+ val dialog =
+ TextInputDialog.newInstance(getString(R.string.git_utils_reset_remote_branch_title))
+ dialog.show(supportFragmentManager, "BRANCH_INPUT_DIALOG")
+ dialog.setFragmentResultListener(TextInputDialog.REQUEST_KEY) { _, bundle ->
+ val result = bundle.getString(TextInputDialog.BUNDLE_KEY_TEXT)
+ if (!result.isNullOrEmpty()) {
+ remoteBranch = result
+ lifecycleScope.launch {
+ launchGitOperation(GitOp.RESET)
+ .fold(
+ success = ::finishOnSuccessHandler,
+ failure = { err -> promptOnErrorHandler(err) { finish() } },
+ )
}
}
}
- binding.gitGc.setOnClickListener {
- lifecycleScope.launch {
- launchGitOperation(GitOp.GC)
- .fold(
- success = ::finishOnSuccessHandler,
- failure = { err -> promptOnErrorHandler(err) { finish() } },
- )
- }
+ }
+
+ private fun abortRebase() {
+ lifecycleScope.launch {
+ launchGitOperation(GitOp.BREAK_OUT_OF_DETACHED)
+ .fold(
+ success = {
+ val branch = PasswordRepository.getCurrentBranch()
+ MaterialAlertDialogBuilder(this@GitConfigActivity).run {
+ setTitle(resources.getString(R.string.git_abort_and_push_title))
+ setMessage(
+ resources.getString(
+ R.string.git_break_out_of_detached_success,
+ branch,
+ "conflicting-$branch-...",
+ )
+ )
+ setOnDismissListener { finish() }
+ setPositiveButton(resources.getString(R.string.dialog_ok)) { _, _ -> }
+ show()
+ }
+ },
+ failure = { err -> promptOnErrorHandler(err) { finish() } },
+ )
}
}