diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2021-01-08 19:43:52 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-08 19:43:52 +0530 |
commit | 91e00d897f190ec6ab5330f7b3f43d6d7f3e57fb (patch) | |
tree | c86b302572afadd7aa0ab51f2f6f47bd4d0999c5 | |
parent | 534269c8fc8fbd9a72e64389564fb0c90365c0c0 (diff) |
app: cleanup how we handle menu item presses (#1275)
Fixes #1274
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
10 files changed, 22 insertions, 37 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e00a3e7..88686572 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file. - Git commits in the store would wrongly use the 'default' committer as opposed to the user's configured one - Connection attempts now use a reasonable 10 second timeout as opposed to the default of 30 seconds - A change to the remote host key for a server would prevent the user from being able to connect to it +- Pressing the back button in the navigation bar and the one in the toolbar behaved differently ### Changed diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 609b4c86..3e1d743e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -71,23 +71,19 @@ <activity android:name=".ui.settings.UserPreference" - android:label="@string/action_settings" - android:parentActivityName=".ui.passwords.PasswordStore" /> + android:label="@string/action_settings" /> <activity android:name=".ui.crypto.PasswordCreationActivity" android:label="@string/new_password_title" - android:parentActivityName=".ui.passwords.PasswordStore" android:windowSoftInputMode="adjustResize" /> <activity android:name=".ui.crypto.DecryptActivity" - android:parentActivityName=".ui.passwords.PasswordStore" android:windowSoftInputMode="adjustResize" /> <activity android:name=".ui.crypto.GetKeyIdsActivity" - android:parentActivityName=".ui.passwords.PasswordStore" android:theme="@style/NoBackgroundTheme" /> <service diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt index 8f36cd25..739d18a1 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt @@ -60,6 +60,7 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + supportActionBar?.setDisplayHomeAsUpEnabled(true) bindToOpenKeychain(this) title = name with(binding) { @@ -100,8 +101,9 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound { R.id.edit_password -> editPassword() R.id.share_password_as_plaintext -> shareAsPlaintext() R.id.copy_password -> copyPasswordToClipboard(passwordEntry?.password) + else -> return super.onOptionsItemSelected(item) } - return super.onOptionsItemSelected(item) + return true } override fun onBound(service: IOpenPgpService2) { diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt index 2ddcc8b8..a6385e7a 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt @@ -135,6 +135,7 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + supportActionBar?.setDisplayHomeAsUpEnabled(true) bindToOpenKeychain(this) title = if (editing) getString(R.string.edit_password) @@ -232,7 +233,7 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB when (item.itemId) { android.R.id.home -> { setResult(RESULT_CANCELED) - finish() + onBackPressed() } R.id.save_password -> { copy = false diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderActivity.kt index f2d655bb..d80e3572 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/folderselect/SelectFolderActivity.kt @@ -47,12 +47,12 @@ class SelectFolderActivity : AppCompatActivity(R.layout.select_folder_layout) { when (item.itemId) { android.R.id.home -> { setResult(RESULT_CANCELED) - finish() - return true + onBackPressed() } R.id.crypto_select -> selectFolder() + else -> return super.onOptionsItemSelected(item) } - return super.onOptionsItemSelected(item) + return true } private fun selectFolder() { diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt index 4067fda9..d354ce4e 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitConfigActivity.kt @@ -65,7 +65,7 @@ class GitConfigActivity : BaseGitActivity() { override fun onOptionsItemSelected(item: MenuItem): Boolean { return when (item.itemId) { android.R.id.home -> { - finish() + onBackPressed() true } else -> super.onOptionsItemSelected(item) diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt index 9826593c..db12e353 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/git/config/GitServerConfigActivity.kt @@ -172,7 +172,7 @@ class GitServerConfigActivity : BaseGitActivity() { override fun onOptionsItemSelected(item: MenuItem): Boolean { return when (item.itemId) { android.R.id.home -> { - finish() + onBackPressed() true } else -> super.onOptionsItemSelected(item) diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt b/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt index c7ed5ee9..49620ac8 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt @@ -292,9 +292,6 @@ class PasswordStore : BaseGitActivity() { return super.onPrepareOptionsMenu(menu) } - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. override fun onOptionsItemSelected(item: MenuItem): Boolean { val id = item.itemId val initBefore = MaterialAlertDialogBuilder(this) @@ -307,41 +304,33 @@ class PasswordStore : BaseGitActivity() { }.onFailure { e -> e.printStackTrace() } - return true } R.id.git_push -> { if (!PasswordRepository.isInitialized) { initBefore.show() - return false + } else { + runGitOperation(GitOp.PUSH) } - runGitOperation(GitOp.PUSH) - return true } R.id.git_pull -> { if (!PasswordRepository.isInitialized) { initBefore.show() - return false + } else { + runGitOperation(GitOp.PULL) } - runGitOperation(GitOp.PULL) - return true } R.id.git_sync -> { if (!PasswordRepository.isInitialized) { initBefore.show() - return false + } else { + runGitOperation(GitOp.SYNC) } - runGitOperation(GitOp.SYNC) - return true - } - R.id.refresh -> { - refreshPasswordList() - return true } + R.id.refresh -> refreshPasswordList() android.R.id.home -> onBackPressed() - else -> { - } + else -> return super.onOptionsItemSelected(item) } - return super.onOptionsItemSelected(item) + return true } override fun onBackPressed() { diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/settings/UserPreference.kt b/app/src/main/java/dev/msfjarvis/aps/ui/settings/UserPreference.kt index 7caf5fb2..315ebbda 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/settings/UserPreference.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/settings/UserPreference.kt @@ -581,13 +581,10 @@ class UserPreference : AppCompatActivity() { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. return when (item.itemId) { android.R.id.home -> { setResult(RESULT_OK) - finish() + onBackPressed() true } else -> super.onOptionsItemSelected(item) diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyGenActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyGenActivity.kt index 39819988..b260b77e 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyGenActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/sshkeygen/SshKeyGenActivity.kt @@ -95,7 +95,6 @@ class SshKeyGenActivity : AppCompatActivity() { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - // The back arrow in the action bar should act the same as the back button. return when (item.itemId) { android.R.id.home -> { onBackPressed() |