Clear password fields onStop()

This commit is contained in:
Matéo Duparc 2023-02-02 19:37:10 +01:00
parent 5e9656970a
commit 1e75e9a32f
Signed by: hardcoresushi
GPG Key ID: AFE384344A45E13A
6 changed files with 38 additions and 18 deletions

@ -1 +1 @@
Subproject commit a1c3f814d5c2597401918944094d16aa37b15bec
Subproject commit ba5df7390b68fba3dba53d2231e2fb38d1c7632c

View File

@ -207,4 +207,11 @@ class ChangePasswordActivity: BaseActivity() {
}
}
}
override fun onStop() {
super.onStop()
binding.editCurrentPassword.text.clear()
binding.editNewPassword.text.clear()
binding.editPasswordConfirm.text.clear()
}
}

View File

@ -475,6 +475,7 @@ class MainActivity : BaseActivity(), VolumeAdapter.Listener {
override fun onStop() {
super.onStop()
volumeOpener.wipeSensitive()
if (explorerRouter.pickMode && !usfKeepOpen && shouldCloseVolume) {
IntentUtils.getParcelableExtra<EncryptedVolume>(intent, "volume")?.close()
RestrictedFileProvider.wipeAll(this)

View File

@ -30,6 +30,7 @@ class VolumeOpener(
private val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(activity)
var themeValue = sharedPrefs.getString(ConstValues.THEME_VALUE_KEY, ConstValues.DEFAULT_THEME_VALUE)!!
var defaultVolumeName: String? = sharedPrefs.getString(DEFAULT_VOLUME_KEY, null)
private var dialogBinding: DialogOpenVolumeBinding? = null
init {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@ -90,10 +91,14 @@ class VolumeOpener(
}
}
private fun onPasswordSubmitted(volume: VolumeData, isVolumeSaved: Boolean, dialogBinding: DialogOpenVolumeBinding, callbacks: VolumeOpenerCallbacks) {
if (dialogBinding.checkboxDefaultOpen.isChecked xor (defaultVolumeName == volume.name)) {
fun wipeSensitive() {
dialogBinding?.editPassword?.text?.clear()
}
private fun onPasswordSubmitted(volume: VolumeData, isVolumeSaved: Boolean, callbacks: VolumeOpenerCallbacks) {
if (dialogBinding!!.checkboxDefaultOpen.isChecked xor (defaultVolumeName == volume.name)) {
with (sharedPrefs.edit()) {
defaultVolumeName = if (dialogBinding.checkboxDefaultOpen.isChecked) {
defaultVolumeName = if (dialogBinding!!.checkboxDefaultOpen.isChecked) {
putString(DEFAULT_VOLUME_KEY, volume.name)
volume.name
} else {
@ -103,41 +108,44 @@ class VolumeOpener(
apply()
}
}
val password = WidgetUtil.encodeEditTextContent(dialogBinding!!.editPassword)
val savePasswordHash = dialogBinding!!.checkboxSavePassword.isChecked
dialogBinding = null
// openVolumeWithPassword is responsible for wiping the password
openVolumeWithPassword(
volume,
WidgetUtil.encodeEditTextContent(dialogBinding.editPassword),
password,
isVolumeSaved,
dialogBinding.checkboxSavePassword.isChecked,
savePasswordHash,
callbacks,
)
}
private fun askForPassword(volume: VolumeData, isVolumeSaved: Boolean, callbacks: VolumeOpenerCallbacks, savePasswordHash: Boolean = false) {
val dialogBinding = DialogOpenVolumeBinding.inflate(activity.layoutInflater)
dialogBinding = DialogOpenVolumeBinding.inflate(activity.layoutInflater)
if (isVolumeSaved) {
if (!sharedPrefs.getBoolean("usf_fingerprint", false) || fingerprintProtector == null || volume.encryptedHash != null) {
dialogBinding.checkboxSavePassword.visibility = View.GONE
dialogBinding!!.checkboxSavePassword.visibility = View.GONE
} else {
dialogBinding.checkboxSavePassword.isChecked = savePasswordHash
dialogBinding!!.checkboxSavePassword.isChecked = savePasswordHash
}
dialogBinding.checkboxDefaultOpen.isChecked = defaultVolumeName == volume.name
dialogBinding!!.checkboxDefaultOpen.isChecked = defaultVolumeName == volume.name
} else {
dialogBinding.checkboxSavePassword.visibility = View.GONE
dialogBinding.checkboxDefaultOpen.visibility = View.GONE
dialogBinding!!.checkboxSavePassword.visibility = View.GONE
dialogBinding!!.checkboxDefaultOpen.visibility = View.GONE
}
val dialog = CustomAlertDialogBuilder(activity, themeValue)
.setTitle(activity.getString(R.string.open_dialog_title, volume.shortName))
.setView(dialogBinding.root)
.setView(dialogBinding!!.root)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.open) { _, _ ->
onPasswordSubmitted(volume, isVolumeSaved, dialogBinding, callbacks)
onPasswordSubmitted(volume, isVolumeSaved, callbacks)
}
.create()
dialogBinding.editPassword.apply {
dialogBinding!!.editPassword.apply {
setOnEditorActionListener { _, _, _ ->
dialog.dismiss()
onPasswordSubmitted(volume, isVolumeSaved, dialogBinding, callbacks)
onPasswordSubmitted(volume, isVolumeSaved, callbacks)
true
}
if (sharedPrefs.getBoolean(ConstValues.PIN_PASSWORDS_KEY, false)) {

View File

@ -263,4 +263,10 @@ class CreateVolumeFragment: Fragment() {
}
}
}
override fun onStop() {
super.onStop()
binding.editPassword.text.clear()
binding.editPasswordConfirm.text.clear()
}
}

View File

@ -15,8 +15,6 @@ org.gradle.jvmargs=-Xmx2048m
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official