diff options
Diffstat (limited to 'app/src')
7 files changed, 15 insertions, 17 deletions
diff --git a/app/src/main/java/app/passwordstore/ui/crypto/DecryptActivity.kt b/app/src/main/java/app/passwordstore/ui/crypto/DecryptActivity.kt index 95a0bbdf..d9472d5d 100644 --- a/app/src/main/java/app/passwordstore/ui/crypto/DecryptActivity.kt +++ b/app/src/main/java/app/passwordstore/ui/crypto/DecryptActivity.kt @@ -127,6 +127,7 @@ class DecryptActivity : BasePGPActivity() { */ private fun editPassword() { val intent = Intent(this, PasswordCreationActivity::class.java) + intent.action = Intent.ACTION_VIEW intent.putExtra("FILE_PATH", relativeParentPath) intent.putExtra("REPO_PATH", repoPath) intent.putExtra(PasswordCreationActivity.EXTRA_FILE_NAME, name) 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 a783273d..1411389f 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 @@ -4,7 +4,6 @@ */ package app.passwordstore.ui.git.config -import android.content.Intent import android.os.Bundle import android.os.Handler import android.os.Looper @@ -20,6 +19,7 @@ import app.passwordstore.ui.dialogs.TextInputDialog import app.passwordstore.ui.git.base.BaseGitActivity import app.passwordstore.ui.git.log.GitLogActivity import app.passwordstore.util.extensions.asLog +import app.passwordstore.util.extensions.launchActivity import app.passwordstore.util.extensions.viewBinding import com.github.michaelbull.result.fold import com.github.michaelbull.result.getOrElse @@ -91,7 +91,7 @@ class GitConfigActivity : BaseGitActivity() { binding.gitAbortRebase.alpha = if (needsAbort) 1.0f else 0.5f } binding.gitLog.setOnClickListener { - runCatching { startActivity(Intent(this, GitLogActivity::class.java)) } + runCatching { launchActivity(GitLogActivity::class.java) } .onFailure { ex -> logcat(ERROR) { ex.asLog("Failed to start GitLogActivity") } } } binding.gitAbortRebase.setOnClickListener { abortRebase() } diff --git a/app/src/main/java/app/passwordstore/ui/main/LaunchActivity.kt b/app/src/main/java/app/passwordstore/ui/main/LaunchActivity.kt index 15cd77ad..d61515fd 100644 --- a/app/src/main/java/app/passwordstore/ui/main/LaunchActivity.kt +++ b/app/src/main/java/app/passwordstore/ui/main/LaunchActivity.kt @@ -64,7 +64,7 @@ class LaunchActivity : AppCompatActivity() { intent.getStringExtra(BasePGPActivity.EXTRA_REPO_PATH) ) } - else Intent(this, PasswordStore::class.java) + else Intent(this, PasswordStore::class.java).setAction(Intent.ACTION_VIEW) startActivity(intentToStart) Handler(Looper.getMainLooper()).postDelayed({ finish() }, if (noAuth) 0L else 500L) diff --git a/app/src/main/java/app/passwordstore/ui/onboarding/fragments/WelcomeFragment.kt b/app/src/main/java/app/passwordstore/ui/onboarding/fragments/WelcomeFragment.kt index 4d320ff7..b90e5b47 100644 --- a/app/src/main/java/app/passwordstore/ui/onboarding/fragments/WelcomeFragment.kt +++ b/app/src/main/java/app/passwordstore/ui/onboarding/fragments/WelcomeFragment.kt @@ -5,7 +5,6 @@ package app.passwordstore.ui.onboarding.fragments -import android.content.Intent import android.os.Bundle import android.view.View import androidx.annotation.Keep @@ -13,6 +12,7 @@ import androidx.fragment.app.Fragment import app.passwordstore.R import app.passwordstore.databinding.FragmentWelcomeBinding import app.passwordstore.ui.settings.SettingsActivity +import app.passwordstore.util.extensions.launchActivity import app.passwordstore.util.extensions.performTransactionWithBackStack import app.passwordstore.util.extensions.viewBinding @@ -27,7 +27,7 @@ class WelcomeFragment : Fragment(R.layout.fragment_welcome) { parentFragmentManager.performTransactionWithBackStack(CloneFragment.newInstance()) } binding.settingsButton.setOnClickListener { - startActivity(Intent(requireContext(), SettingsActivity::class.java)) + requireActivity().launchActivity(SettingsActivity::class.java) } } } diff --git a/app/src/main/java/app/passwordstore/ui/passwords/PasswordStore.kt b/app/src/main/java/app/passwordstore/ui/passwords/PasswordStore.kt index b8bbd232..8aeee609 100644 --- a/app/src/main/java/app/passwordstore/ui/passwords/PasswordStore.kt +++ b/app/src/main/java/app/passwordstore/ui/passwords/PasswordStore.kt @@ -40,6 +40,7 @@ import app.passwordstore.util.extensions.commitChange import app.passwordstore.util.extensions.contains import app.passwordstore.util.extensions.getString import app.passwordstore.util.extensions.isInsideRepository +import app.passwordstore.util.extensions.launchActivity import app.passwordstore.util.extensions.listFilesRecursively import app.passwordstore.util.extensions.sharedPrefs import app.passwordstore.util.settings.AuthMode @@ -272,7 +273,7 @@ class PasswordStore : BaseGitActivity() { .setPositiveButton(resources.getString(R.string.dialog_ok), null) when (id) { R.id.user_pref -> { - runCatching { startActivity(Intent(this, SettingsActivity::class.java)) } + runCatching { launchActivity(SettingsActivity::class.java) } .onFailure { e -> e.printStackTrace() } } R.id.git_push -> { @@ -356,7 +357,7 @@ class PasswordStore : BaseGitActivity() { } } } else { - startActivity(Intent(this, OnboardingActivity::class.java)) + launchActivity(OnboardingActivity::class.java) } } diff --git a/app/src/main/java/app/passwordstore/util/extensions/AndroidExtensions.kt b/app/src/main/java/app/passwordstore/util/extensions/AndroidExtensions.kt index 70dfaac1..565ecaf4 100644 --- a/app/src/main/java/app/passwordstore/util/extensions/AndroidExtensions.kt +++ b/app/src/main/java/app/passwordstore/util/extensions/AndroidExtensions.kt @@ -127,7 +127,7 @@ fun FragmentActivity.snackbar( /** Launch an activity denoted by [clazz]. */ fun <T : ComponentActivity> ComponentActivity.launchActivity(clazz: Class<T>) { - startActivity(Intent(this, clazz)) + startActivity(Intent(this, clazz).setAction(Intent.ACTION_VIEW)) } /** Simplifies the common `getString(key, null) ?: defaultValue` case slightly */ diff --git a/app/src/main/java/app/passwordstore/util/git/operation/GitOperation.kt b/app/src/main/java/app/passwordstore/util/git/operation/GitOperation.kt index 298ae4b1..1cc42633 100644 --- a/app/src/main/java/app/passwordstore/util/git/operation/GitOperation.kt +++ b/app/src/main/java/app/passwordstore/util/git/operation/GitOperation.kt @@ -4,7 +4,6 @@ */ package app.passwordstore.util.git.operation -import android.content.Intent import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.FragmentActivity @@ -18,6 +17,7 @@ import app.passwordstore.util.auth.BiometricAuthenticator.Result.Failure import app.passwordstore.util.auth.BiometricAuthenticator.Result.Retry import app.passwordstore.util.auth.BiometricAuthenticator.Result.Success import app.passwordstore.util.coroutines.DispatcherProvider +import app.passwordstore.util.extensions.launchActivity import app.passwordstore.util.git.GitCommandExecutor import app.passwordstore.util.git.sshj.SshAuthMethod import app.passwordstore.util.git.sshj.SshjSessionFactory @@ -108,15 +108,11 @@ abstract class GitOperation(protected val callingActivity: FragmentActivity) { } } - private fun getSshKey(make: Boolean) { + private fun getSshKey(generateKey: Boolean) { runCatching { - val intent = - if (make) { - Intent(callingActivity.applicationContext, SshKeyGenActivity::class.java) - } else { - Intent(callingActivity.applicationContext, SshKeyImportActivity::class.java) - } - callingActivity.startActivity(intent) + callingActivity.launchActivity( + if (generateKey) SshKeyGenActivity::class.java else SshKeyImportActivity::class.java + ) } .onFailure { e -> logcat(ERROR) { e.asLog() } } } |