diff --git a/app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt
index ceed968..e7a430e 100644
--- a/app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt
+++ b/app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt
@@ -3,6 +3,7 @@ package sushi.hardcore.droidfs
import android.annotation.SuppressLint
import android.os.Build
import android.os.Bundle
+import android.text.InputType
import android.view.MenuItem
import android.view.View
import android.widget.Toast
@@ -39,6 +40,11 @@ class ChangePasswordActivity: BaseActivity() {
if (!usfFingerprint || fingerprintProtector == null) {
binding.checkboxSavePassword.visibility = View.GONE
}
+ if (sharedPrefs.getBoolean(ConstValues.PIN_PASSWORDS_KEY, false)) {
+ arrayOf(binding.editCurrentPassword, binding.editNewPassword, binding.editPasswordConfirm).forEach {
+ it.inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
+ }
+ }
binding.editPasswordConfirm.setOnEditorActionListener { _, _, _ ->
changeVolumePassword()
true
diff --git a/app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt b/app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt
index e4ba822..fb15ceb 100644
--- a/app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt
+++ b/app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt
@@ -16,6 +16,7 @@ object ConstValues {
const val DEFAULT_THEME_VALUE = "dark_green"
const val THUMBNAIL_MAX_SIZE_KEY = "thumbnail_max_size"
const val DEFAULT_THUMBNAIL_MAX_SIZE = 10_000L
+ const val PIN_PASSWORDS_KEY = "pin_passwords"
private val FILE_EXTENSIONS = mapOf(
Pair("image", listOf("png", "jpg", "jpeg", "gif", "webp", "bmp", "heic")),
Pair("video", listOf("mp4", "webm", "mkv", "mov")),
diff --git a/app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt
index ffa7d90..6d1b592 100644
--- a/app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt
+++ b/app/src/main/java/sushi/hardcore/droidfs/MainActivity.kt
@@ -9,6 +9,7 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.IBinder
+import android.text.InputType
import android.view.Menu
import android.view.MenuItem
import android.view.View
@@ -524,10 +525,15 @@ class MainActivity : BaseActivity(), VolumeAdapter.Listener {
onPasswordSubmitted(volume, position, dialogBinding)
}
.create()
- dialogBinding.editPassword.setOnEditorActionListener { _, _, _ ->
- dialog.dismiss()
- onPasswordSubmitted(volume, position, dialogBinding)
- true
+ dialogBinding.editPassword.apply {
+ setOnEditorActionListener { _, _, _ ->
+ dialog.dismiss()
+ onPasswordSubmitted(volume, position, dialogBinding)
+ true
+ }
+ if (sharedPrefs.getBoolean(ConstValues.PIN_PASSWORDS_KEY, false)) {
+ inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
+ }
}
dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
dialog.show()
diff --git a/app/src/main/java/sushi/hardcore/droidfs/add_volume/AddVolumeActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/add_volume/AddVolumeActivity.kt
index e8bf3ff..4765b28 100644
--- a/app/src/main/java/sushi/hardcore/droidfs/add_volume/AddVolumeActivity.kt
+++ b/app/src/main/java/sushi/hardcore/droidfs/add_volume/AddVolumeActivity.kt
@@ -3,6 +3,7 @@ package sushi.hardcore.droidfs.add_volume
import android.os.Bundle
import android.view.MenuItem
import sushi.hardcore.droidfs.BaseActivity
+import sushi.hardcore.droidfs.ConstValues
import sushi.hardcore.droidfs.R
import sushi.hardcore.droidfs.databinding.ActivityAddVolumeBinding
@@ -68,6 +69,7 @@ class AddVolumeActivity: BaseActivity() {
themeValue,
volumePath,
isHidden,
+ sharedPrefs.getBoolean(ConstValues.PIN_PASSWORDS_KEY, false),
sharedPrefs.getBoolean("usf_fingerprint", false),
)
)
diff --git a/app/src/main/java/sushi/hardcore/droidfs/add_volume/CreateVolumeFragment.kt b/app/src/main/java/sushi/hardcore/droidfs/add_volume/CreateVolumeFragment.kt
index 6c5ce50..0c02524 100644
--- a/app/src/main/java/sushi/hardcore/droidfs/add_volume/CreateVolumeFragment.kt
+++ b/app/src/main/java/sushi/hardcore/droidfs/add_volume/CreateVolumeFragment.kt
@@ -3,6 +3,7 @@ package sushi.hardcore.droidfs.add_volume
import android.annotation.SuppressLint
import android.os.Build
import android.os.Bundle
+import android.text.InputType
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -22,12 +23,14 @@ class CreateVolumeFragment: Fragment() {
private const val KEY_THEME_VALUE = "theme"
private const val KEY_VOLUME_PATH = "path"
private const val KEY_IS_HIDDEN = "hidden"
+ private const val KEY_PIN_PASSWORDS = ConstValues.PIN_PASSWORDS_KEY
private const val KEY_USF_FINGERPRINT = "fingerprint"
fun newInstance(
themeValue: String,
volumePath: String,
isHidden: Boolean,
+ pinPasswords: Boolean,
usfFingerprint: Boolean,
): CreateVolumeFragment {
return CreateVolumeFragment().apply {
@@ -35,6 +38,7 @@ class CreateVolumeFragment: Fragment() {
putString(KEY_THEME_VALUE, themeValue)
putString(KEY_VOLUME_PATH, volumePath)
putBoolean(KEY_IS_HIDDEN, isHidden)
+ putBoolean(KEY_PIN_PASSWORDS, pinPasswords)
putBoolean(KEY_USF_FINGERPRINT, usfFingerprint)
}
}
@@ -60,11 +64,12 @@ class CreateVolumeFragment: Fragment() {
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- requireArguments().let { arguments ->
+ val pinPasswords = requireArguments().let { arguments ->
arguments.getString(KEY_THEME_VALUE)?.let { themeValue = it }
volumePath = arguments.getString(KEY_VOLUME_PATH)!!
isHiddenVolume = arguments.getBoolean(KEY_IS_HIDDEN)
usfFingerprint = arguments.getBoolean(KEY_USF_FINGERPRINT)
+ arguments.getBoolean(KEY_PIN_PASSWORDS)
}
volumeDatabase = VolumeDatabase(requireContext())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@@ -73,6 +78,11 @@ class CreateVolumeFragment: Fragment() {
if (!usfFingerprint || fingerprintProtector == null) {
binding.checkboxSavePassword.visibility = View.GONE
}
+ if (pinPasswords) {
+ arrayOf(binding.editPassword, binding.editPasswordConfirm).forEach {
+ it.inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
+ }
+ }
binding.editPasswordConfirm.setOnEditorActionListener { _, _, _ ->
createVolume()
true
diff --git a/app/src/main/res/drawable/icon_num_pad.xml b/app/src/main/res/drawable/icon_num_pad.xml
new file mode 100644
index 0000000..bc97444
--- /dev/null
+++ b/app/src/main/res/drawable/icon_num_pad.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c475ea7..f75ddd7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -240,4 +240,6 @@
Open this volume when launching the application
Don\'t open by default
%d/%d selected
+ Numeric keypad layout
+ Use a numeric keypad layout when entering volume passwords
diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml
index d1601fa..3643dfe 100644
--- a/app/src/main/res/xml/root_preferences.xml
+++ b/app/src/main/res/xml/root_preferences.xml
@@ -26,6 +26,13 @@
android:defaultValue="false"
android:icon="@drawable/icon_mod"/>
+
+