diff options
author | Harsh Shandilya <msfjarvis@gmail.com> | 2020-09-07 20:13:04 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-07 16:43:04 +0200 |
commit | c65f3c7099895f75a9babdcbacefb2290a52d758 (patch) | |
tree | dfef584a23f9be033aa900f9b99a5eb4c27a3fab /app/src/main/java | |
parent | 2687763bdaa36709667d38919b7cba1a7e26206f (diff) |
UX fixups and improvements (#1086)
* git: re-add back button handling
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
* Hide unsupported authentication methods
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
* GitCommandExecutor: cleanup and address build warning
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
* Address review comments
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
* DecryptActivity: hide menu items until decrypt finishes
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
* GitServerConfigActivity: don't finish on failure
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java')
5 files changed, 63 insertions, 6 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt index e0e82cd7..3685cb17 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt @@ -82,6 +82,15 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound { override fun onCreateOptionsMenu(menu: Menu?): Boolean { menuInflater.inflate(R.menu.pgp_handler, menu) + passwordEntry?.let { entry -> + if (menu != null) { + menu.findItem(R.id.edit_password).isVisible = true + if (entry.password.isNotEmpty()) { + menu.findItem(R.id.share_password_as_plaintext).isVisible = true + menu.findItem(R.id.copy_password).isVisible = true + } + } + } return true } @@ -153,6 +162,7 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound { val entry = PasswordEntry(outputStream) passwordEntry = entry + invalidateOptionsMenu() with(binding) { if (entry.password.isEmpty()) { diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitCommandExecutor.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitCommandExecutor.kt index 6ef09537..ed5411ac 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitCommandExecutor.kt +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitCommandExecutor.kt @@ -8,6 +8,7 @@ package com.zeapo.pwdstore.git import android.widget.Toast import androidx.fragment.app.FragmentActivity import com.github.michaelbull.result.Result +import com.github.michaelbull.result.runCatching import com.google.android.material.snackbar.Snackbar import com.zeapo.pwdstore.R import com.zeapo.pwdstore.git.GitException.PullException @@ -37,7 +38,7 @@ class GitCommandExecutor( ) // Count the number of uncommitted files var nbChanges = 0 - return com.github.michaelbull.result.runCatching { + return runCatching { for (command in operation.commands) { when (command) { is StatusCommand -> { @@ -95,6 +96,8 @@ class GitCommandExecutor( ).show() } } + else -> { + } } } } diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitConfigActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitConfigActivity.kt index b3217395..49abc92d 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitConfigActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitConfigActivity.kt @@ -8,6 +8,7 @@ import android.content.Intent import android.os.Bundle import android.os.Handler import android.util.Patterns +import android.view.MenuItem import androidx.core.os.postDelayed import androidx.lifecycle.lifecycleScope import com.github.ajalt.timberkt.e @@ -59,6 +60,16 @@ class GitConfigActivity : BaseGitActivity() { } } + override fun onOptionsItemSelected(item: MenuItem): Boolean { + return when (item.itemId) { + android.R.id.home -> { + finish() + true + } + else -> super.onOptionsItemSelected(item) + } + } + /** * Sets up the UI components of the tools section. */ diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt index 97010c23..4bbc5965 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt @@ -6,8 +6,11 @@ package com.zeapo.pwdstore.git import android.os.Bundle import android.os.Handler +import android.view.MenuItem import android.view.View import androidx.core.os.postDelayed +import androidx.core.view.isVisible +import androidx.core.widget.doOnTextChanged import androidx.lifecycle.lifecycleScope import com.github.ajalt.timberkt.e import com.github.michaelbull.result.fold @@ -68,6 +71,19 @@ class GitServerConfigActivity : BaseGitActivity() { binding.serverUrl.setText(GitSettings.url) binding.serverBranch.setText(GitSettings.branch) + binding.serverUrl.doOnTextChanged { text, _, _, _ -> + if (text.isNullOrEmpty()) return@doOnTextChanged + if (text.startsWith("http://") || text.startsWith("https://")) { + binding.authModeSshKey.isVisible = false + binding.authModeOpenKeychain.isVisible = false + binding.authModePassword.isVisible = true + } else { + binding.authModeSshKey.isVisible = true + binding.authModeOpenKeychain.isVisible = true + binding.authModePassword.isVisible = true + } + } + binding.saveButton.setOnClickListener { when (val updateResult = GitSettings.updateConnectionSettingsIfValid( newAuthMode = newAuthMode, @@ -104,6 +120,16 @@ class GitServerConfigActivity : BaseGitActivity() { } } + override fun onOptionsItemSelected(item: MenuItem): Boolean { + return when (item.itemId) { + android.R.id.home -> { + finish() + true + } + else -> super.onOptionsItemSelected(item) + } + } + /** * Clones the repository, the directory exists, deletes it */ @@ -164,11 +190,7 @@ class GitServerConfigActivity : BaseGitActivity() { setResult(RESULT_OK) finish() }, - failure = { err -> - promptOnErrorHandler(err) { - finish() - } - }, + failure = ::promptOnErrorHandler, ) } } diff --git a/app/src/main/java/com/zeapo/pwdstore/git/log/GitLogActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/log/GitLogActivity.kt index 8c1c0f09..1e616bae 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/log/GitLogActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/git/log/GitLogActivity.kt @@ -6,6 +6,7 @@ package com.zeapo.pwdstore.git.log import android.os.Bundle +import android.view.MenuItem import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import com.zeapo.pwdstore.databinding.ActivityGitLogBinding @@ -28,6 +29,16 @@ class GitLogActivity : BaseGitActivity() { createRecyclerView() } + override fun onOptionsItemSelected(item: MenuItem): Boolean { + return when (item.itemId) { + android.R.id.home -> { + finish() + true + } + else -> super.onOptionsItemSelected(item) + } + } + private fun createRecyclerView() { binding.gitLogRecyclerView.apply { setHasFixedSize(true) |