fix: address new IntentWithNullActionLaunch lint

This commit is contained in:
Harsh Shandilya 2023-07-26 16:22:06 +05:30
parent 5a12eff24e
commit fa50628719
No known key found for this signature in database
7 changed files with 15 additions and 17 deletions

View file

@ -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)

View file

@ -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() }

View file

@ -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)

View file

@ -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)
}
}
}

View file

@ -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)
}
}

View file

@ -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 */

View file

@ -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() } }
}