diff options
Diffstat (limited to 'app/src')
4 files changed, 11 insertions, 7 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt index ac41246d..9b4a4023 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt @@ -30,6 +30,7 @@ import androidx.appcompat.widget.SearchView.OnQueryTextListener import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat import androidx.core.content.edit +import androidx.core.content.getSystemService import androidx.fragment.app.FragmentManager import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.observe @@ -102,7 +103,7 @@ class PasswordStore : AppCompatActivity() { activity = this settings = PreferenceManager.getDefaultSharedPreferences(this.applicationContext) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { - shortcutManager = getSystemService(ShortcutManager::class.java) + shortcutManager = getSystemService() } // If user opens app with permission granted then revokes and returns, diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt index 3e15ba4e..370c7983 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt @@ -578,7 +578,7 @@ class UserPreference : AppCompatActivity() { private val isAccessibilityServiceEnabled: Boolean get() { - val am = getSystemService(AccessibilityManager::class.java) ?: return false + val am = getSystemService<AccessibilityManager>() ?: return false val runningServices = am .getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC) return runningServices diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt index 612169a1..3d8ef1a7 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt @@ -33,6 +33,7 @@ import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.edit +import androidx.core.content.getSystemService import androidx.core.widget.doOnTextChanged import androidx.lifecycle.lifecycleScope import androidx.localbroadcastmanager.content.LocalBroadcastManager @@ -73,9 +74,7 @@ import org.openintents.openpgp.OpenPgpError import timber.log.Timber class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { - private val clipboard: ClipboardManager by lazy { - getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager - } + private val clipboard by lazy { getSystemService<ClipboardManager>() } private var passwordEntry: PasswordEntry? = null private var api: OpenPgpApi? = null @@ -140,6 +139,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { crypto_password_category_decrypt.text = relativeParentPath crypto_password_file.text = name crypto_password_file.setOnLongClickListener { + val clipboard = clipboard ?: return@setOnLongClickListener false val clip = ClipData.newPlainText("pgp_handler_result_pm", name) clipboard.setPrimaryClip(clip) showSnackbar(this.resources.getString(R.string.clipboard_username_toast_text)) @@ -808,6 +808,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { } private fun copyPasswordToClipBoard() { + val clipboard = clipboard ?: return var pass = passwordEntry?.password if (findViewById<TextView>(R.id.crypto_password_show) == null) { @@ -837,12 +838,14 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { } private fun copyUsernameToClipBoard(username: String) { + val clipboard = clipboard ?: return val clip = ClipData.newPlainText("pgp_handler_result_pm", username) clipboard.setPrimaryClip(clip) showSnackbar(resources.getString(R.string.clipboard_username_toast_text)) } private fun copyOtpToClipBoard(code: String) { + val clipboard = clipboard ?: return val clip = ClipData.newPlainText("pgp_handler_result_pm", code) clipboard.setPrimaryClip(clip) showSnackbar(resources.getString(R.string.clipboard_otp_toast_text)) diff --git a/app/src/main/java/com/zeapo/pwdstore/sshkeygen/ShowSshKeyFragment.kt b/app/src/main/java/com/zeapo/pwdstore/sshkeygen/ShowSshKeyFragment.kt index e3395d41..81fc7d7c 100644 --- a/app/src/main/java/com/zeapo/pwdstore/sshkeygen/ShowSshKeyFragment.kt +++ b/app/src/main/java/com/zeapo/pwdstore/sshkeygen/ShowSshKeyFragment.kt @@ -8,11 +8,11 @@ import android.annotation.SuppressLint import android.app.Dialog import android.content.ClipData import android.content.ClipboardManager -import android.content.Context import android.os.Bundle import android.view.View import android.widget.TextView import androidx.appcompat.app.AlertDialog +import androidx.core.content.getSystemService import androidx.fragment.app.DialogFragment import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.zeapo.pwdstore.R @@ -41,7 +41,7 @@ class ShowSshKeyFragment : DialogFragment() { ad.setOnShowListener { val b = ad.getButton(AlertDialog.BUTTON_NEUTRAL) b.setOnClickListener { - val clipboard = activity.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val clipboard = activity.getSystemService<ClipboardManager>() ?: return@setOnClickListener val clip = ClipData.newPlainText("public key", publicKey.text.toString()) clipboard.setPrimaryClip(clip) } |