mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-16 20:00:36 +01:00
added password protection to deleting and moving files
This commit is contained in:
parent
82f2a9fe0d
commit
028877ed90
@ -31,6 +31,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupShowHidden()
|
||||
setupHiddenItemPasswordProtection()
|
||||
setupAppPasswordProtection()
|
||||
setupFileDeletionPasswordProtection()
|
||||
setupKeepLastModified()
|
||||
setupShowInfoBubble()
|
||||
setupEnableRootAccess()
|
||||
@ -129,6 +130,28 @@ class SettingsActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupFileDeletionPasswordProtection() {
|
||||
settings_file_deletion_password_protection.isChecked = config.isDeletePasswordProtectionOn
|
||||
settings_file_deletion_password_protection_holder.setOnClickListener {
|
||||
val tabToShow = if (config.isDeletePasswordProtectionOn) config.deleteProtectionType else SHOW_ALL_TABS
|
||||
SecurityDialog(this, config.deletePasswordHash, tabToShow) { hash, type, success ->
|
||||
if (success) {
|
||||
val hasPasswordProtection = config.isDeletePasswordProtectionOn
|
||||
settings_file_deletion_password_protection.isChecked = !hasPasswordProtection
|
||||
config.isDeletePasswordProtectionOn = !hasPasswordProtection
|
||||
config.deletePasswordHash = if (hasPasswordProtection) "" else hash
|
||||
config.deleteProtectionType = type
|
||||
|
||||
if (config.isDeletePasswordProtectionOn) {
|
||||
val confirmationTextId = if (config.deleteProtectionType == PROTECTION_FINGERPRINT)
|
||||
R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully
|
||||
ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupKeepLastModified() {
|
||||
settings_keep_last_modified.isChecked = config.keepLastModified
|
||||
settings_keep_last_modified_holder.setOnClickListener {
|
||||
|
@ -85,7 +85,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||
R.id.cab_open_with -> openWith()
|
||||
R.id.cab_open_as -> openAs()
|
||||
R.id.cab_copy_to -> copyMoveTo(true)
|
||||
R.id.cab_move_to -> copyMoveTo(false)
|
||||
R.id.cab_move_to -> tryMoveFiles()
|
||||
R.id.cab_compress -> compressSelection()
|
||||
R.id.cab_decompress -> decompressSelection()
|
||||
R.id.cab_select_all -> selectAll()
|
||||
@ -247,6 +247,12 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||
}
|
||||
}
|
||||
|
||||
private fun tryMoveFiles() {
|
||||
activity.handleDeletePasswordProtection {
|
||||
copyMoveTo(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||
val files = getSelectedFileDirItems()
|
||||
val firstFile = files[0]
|
||||
@ -479,11 +485,13 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
||||
}
|
||||
|
||||
private fun askConfirmDelete() {
|
||||
val selectionSize = selectedKeys.size
|
||||
val items = resources.getQuantityString(R.plurals.delete_items, selectionSize, selectionSize)
|
||||
val question = String.format(resources.getString(R.string.deletion_confirmation), items)
|
||||
ConfirmationDialog(activity, question) {
|
||||
deleteFiles()
|
||||
activity.handleDeletePasswordProtection {
|
||||
val selectionSize = selectedKeys.size
|
||||
val items = resources.getQuantityString(R.plurals.delete_items, selectionSize, selectionSize)
|
||||
val question = String.format(resources.getString(R.string.deletion_confirmation), items)
|
||||
ConfirmationDialog(activity, question) {
|
||||
deleteFiles()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,6 +262,29 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_file_deletion_password_protection_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_file_deletion_password_protection"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/password_protect_file_deletion"
|
||||
app:switchPadding="@dimen/medium_margin"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_enable_root_access_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
x
Reference in New Issue
Block a user