forked from hardcoresushi/DroidFS
Clear password fields onStop()
This commit is contained in:
parent
5e9656970a
commit
1e75e9a32f
@ -1 +1 @@
|
|||||||
Subproject commit a1c3f814d5c2597401918944094d16aa37b15bec
|
Subproject commit ba5df7390b68fba3dba53d2231e2fb38d1c7632c
|
@ -207,4 +207,11 @@ class ChangePasswordActivity: BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStop() {
|
||||||
|
super.onStop()
|
||||||
|
binding.editCurrentPassword.text.clear()
|
||||||
|
binding.editNewPassword.text.clear()
|
||||||
|
binding.editPasswordConfirm.text.clear()
|
||||||
|
}
|
||||||
}
|
}
|
@ -475,6 +475,7 @@ class MainActivity : BaseActivity(), VolumeAdapter.Listener {
|
|||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
super.onStop()
|
super.onStop()
|
||||||
|
volumeOpener.wipeSensitive()
|
||||||
if (explorerRouter.pickMode && !usfKeepOpen && shouldCloseVolume) {
|
if (explorerRouter.pickMode && !usfKeepOpen && shouldCloseVolume) {
|
||||||
IntentUtils.getParcelableExtra<EncryptedVolume>(intent, "volume")?.close()
|
IntentUtils.getParcelableExtra<EncryptedVolume>(intent, "volume")?.close()
|
||||||
RestrictedFileProvider.wipeAll(this)
|
RestrictedFileProvider.wipeAll(this)
|
||||||
|
@ -30,6 +30,7 @@ class VolumeOpener(
|
|||||||
private val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(activity)
|
private val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||||
var themeValue = sharedPrefs.getString(ConstValues.THEME_VALUE_KEY, ConstValues.DEFAULT_THEME_VALUE)!!
|
var themeValue = sharedPrefs.getString(ConstValues.THEME_VALUE_KEY, ConstValues.DEFAULT_THEME_VALUE)!!
|
||||||
var defaultVolumeName: String? = sharedPrefs.getString(DEFAULT_VOLUME_KEY, null)
|
var defaultVolumeName: String? = sharedPrefs.getString(DEFAULT_VOLUME_KEY, null)
|
||||||
|
private var dialogBinding: DialogOpenVolumeBinding? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
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) {
|
fun wipeSensitive() {
|
||||||
if (dialogBinding.checkboxDefaultOpen.isChecked xor (defaultVolumeName == volume.name)) {
|
dialogBinding?.editPassword?.text?.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onPasswordSubmitted(volume: VolumeData, isVolumeSaved: Boolean, callbacks: VolumeOpenerCallbacks) {
|
||||||
|
if (dialogBinding!!.checkboxDefaultOpen.isChecked xor (defaultVolumeName == volume.name)) {
|
||||||
with (sharedPrefs.edit()) {
|
with (sharedPrefs.edit()) {
|
||||||
defaultVolumeName = if (dialogBinding.checkboxDefaultOpen.isChecked) {
|
defaultVolumeName = if (dialogBinding!!.checkboxDefaultOpen.isChecked) {
|
||||||
putString(DEFAULT_VOLUME_KEY, volume.name)
|
putString(DEFAULT_VOLUME_KEY, volume.name)
|
||||||
volume.name
|
volume.name
|
||||||
} else {
|
} else {
|
||||||
@ -103,41 +108,44 @@ class VolumeOpener(
|
|||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val password = WidgetUtil.encodeEditTextContent(dialogBinding!!.editPassword)
|
||||||
|
val savePasswordHash = dialogBinding!!.checkboxSavePassword.isChecked
|
||||||
|
dialogBinding = null
|
||||||
// openVolumeWithPassword is responsible for wiping the password
|
// openVolumeWithPassword is responsible for wiping the password
|
||||||
openVolumeWithPassword(
|
openVolumeWithPassword(
|
||||||
volume,
|
volume,
|
||||||
WidgetUtil.encodeEditTextContent(dialogBinding.editPassword),
|
password,
|
||||||
isVolumeSaved,
|
isVolumeSaved,
|
||||||
dialogBinding.checkboxSavePassword.isChecked,
|
savePasswordHash,
|
||||||
callbacks,
|
callbacks,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun askForPassword(volume: VolumeData, isVolumeSaved: Boolean, callbacks: VolumeOpenerCallbacks, savePasswordHash: Boolean = false) {
|
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 (isVolumeSaved) {
|
||||||
if (!sharedPrefs.getBoolean("usf_fingerprint", false) || fingerprintProtector == null || volume.encryptedHash != null) {
|
if (!sharedPrefs.getBoolean("usf_fingerprint", false) || fingerprintProtector == null || volume.encryptedHash != null) {
|
||||||
dialogBinding.checkboxSavePassword.visibility = View.GONE
|
dialogBinding!!.checkboxSavePassword.visibility = View.GONE
|
||||||
} else {
|
} else {
|
||||||
dialogBinding.checkboxSavePassword.isChecked = savePasswordHash
|
dialogBinding!!.checkboxSavePassword.isChecked = savePasswordHash
|
||||||
}
|
}
|
||||||
dialogBinding.checkboxDefaultOpen.isChecked = defaultVolumeName == volume.name
|
dialogBinding!!.checkboxDefaultOpen.isChecked = defaultVolumeName == volume.name
|
||||||
} else {
|
} else {
|
||||||
dialogBinding.checkboxSavePassword.visibility = View.GONE
|
dialogBinding!!.checkboxSavePassword.visibility = View.GONE
|
||||||
dialogBinding.checkboxDefaultOpen.visibility = View.GONE
|
dialogBinding!!.checkboxDefaultOpen.visibility = View.GONE
|
||||||
}
|
}
|
||||||
val dialog = CustomAlertDialogBuilder(activity, themeValue)
|
val dialog = CustomAlertDialogBuilder(activity, themeValue)
|
||||||
.setTitle(activity.getString(R.string.open_dialog_title, volume.shortName))
|
.setTitle(activity.getString(R.string.open_dialog_title, volume.shortName))
|
||||||
.setView(dialogBinding.root)
|
.setView(dialogBinding!!.root)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.setPositiveButton(R.string.open) { _, _ ->
|
.setPositiveButton(R.string.open) { _, _ ->
|
||||||
onPasswordSubmitted(volume, isVolumeSaved, dialogBinding, callbacks)
|
onPasswordSubmitted(volume, isVolumeSaved, callbacks)
|
||||||
}
|
}
|
||||||
.create()
|
.create()
|
||||||
dialogBinding.editPassword.apply {
|
dialogBinding!!.editPassword.apply {
|
||||||
setOnEditorActionListener { _, _, _ ->
|
setOnEditorActionListener { _, _, _ ->
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
onPasswordSubmitted(volume, isVolumeSaved, dialogBinding, callbacks)
|
onPasswordSubmitted(volume, isVolumeSaved, callbacks)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
if (sharedPrefs.getBoolean(ConstValues.PIN_PASSWORDS_KEY, false)) {
|
if (sharedPrefs.getBoolean(ConstValues.PIN_PASSWORDS_KEY, false)) {
|
||||||
|
@ -263,4 +263,10 @@ class CreateVolumeFragment: Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStop() {
|
||||||
|
super.onStop()
|
||||||
|
binding.editPassword.text.clear()
|
||||||
|
binding.editPasswordConfirm.text.clear()
|
||||||
|
}
|
||||||
}
|
}
|
@ -15,8 +15,6 @@ org.gradle.jvmargs=-Xmx2048m
|
|||||||
# Android operating system, and which are packaged with your app"s APK
|
# Android operating system, and which are packaged with your app"s APK
|
||||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
android.useAndroidX=true
|
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 for this project: "official" or "obsolete":
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user