adding a checkbox for password protection file deletion

This commit is contained in:
tibbi 2018-10-30 22:53:19 +01:00
parent ca85e8a3df
commit 5c3d4f3e8d
5 changed files with 64 additions and 17 deletions

View file

@ -48,7 +48,7 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.2.15'
implementation 'com.simplemobiletools:commons:5.2.17'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'it.sephiroth.android.exif:library:1.0.1'

View file

@ -117,7 +117,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
showFilterMediaDialog()
}
mIsPasswordProtectionPending = config.appPasswordProtectionOn
mIsPasswordProtectionPending = config.isAppPasswordProtectionOn
setupLatestMediaId()
// notify some users about the Clock app

View file

@ -55,6 +55,7 @@ class SettingsActivity : SimpleActivity() {
setupHideSystemUI()
setupHiddenItemPasswordProtection()
setupAppPasswordProtection()
setupFileDeletionPasswordProtection()
setupDeleteEmptyFolders()
setupAllowPhotoGestures()
setupAllowVideoGestures()
@ -236,19 +237,19 @@ class SettingsActivity : SimpleActivity() {
}
private fun setupHiddenItemPasswordProtection() {
settings_hidden_item_password_protection.isChecked = config.isPasswordProtectionOn
settings_hidden_item_password_protection.isChecked = config.isHiddenPasswordProtectionOn
settings_hidden_item_password_protection_holder.setOnClickListener {
val tabToShow = if (config.isPasswordProtectionOn) config.protectionType else SHOW_ALL_TABS
SecurityDialog(this, config.passwordHash, tabToShow) { hash, type, success ->
val tabToShow = if (config.isHiddenPasswordProtectionOn) config.hiddenProtectionType else SHOW_ALL_TABS
SecurityDialog(this, config.hiddenPasswordHash, tabToShow) { hash, type, success ->
if (success) {
val hasPasswordProtection = config.isPasswordProtectionOn
val hasPasswordProtection = config.isHiddenPasswordProtectionOn
settings_hidden_item_password_protection.isChecked = !hasPasswordProtection
config.isPasswordProtectionOn = !hasPasswordProtection
config.passwordHash = if (hasPasswordProtection) "" else hash
config.protectionType = type
config.isHiddenPasswordProtectionOn = !hasPasswordProtection
config.hiddenPasswordHash = if (hasPasswordProtection) "" else hash
config.hiddenProtectionType = type
if (config.isPasswordProtectionOn) {
val confirmationTextId = if (config.protectionType == PROTECTION_FINGERPRINT)
if (config.isHiddenPasswordProtectionOn) {
val confirmationTextId = if (config.hiddenProtectionType == PROTECTION_FINGERPRINT)
R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully
ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { }
}
@ -258,18 +259,18 @@ class SettingsActivity : SimpleActivity() {
}
private fun setupAppPasswordProtection() {
settings_app_password_protection.isChecked = config.appPasswordProtectionOn
settings_app_password_protection.isChecked = config.isAppPasswordProtectionOn
settings_app_password_protection_holder.setOnClickListener {
val tabToShow = if (config.appPasswordProtectionOn) config.appProtectionType else SHOW_ALL_TABS
val tabToShow = if (config.isAppPasswordProtectionOn) config.appProtectionType else SHOW_ALL_TABS
SecurityDialog(this, config.appPasswordHash, tabToShow) { hash, type, success ->
if (success) {
val hasPasswordProtection = config.appPasswordProtectionOn
val hasPasswordProtection = config.isAppPasswordProtectionOn
settings_app_password_protection.isChecked = !hasPasswordProtection
config.appPasswordProtectionOn = !hasPasswordProtection
config.isAppPasswordProtectionOn = !hasPasswordProtection
config.appPasswordHash = if (hasPasswordProtection) "" else hash
config.appProtectionType = type
if (config.appPasswordProtectionOn) {
if (config.isAppPasswordProtectionOn) {
val confirmationTextId = if (config.appProtectionType == PROTECTION_FINGERPRINT)
R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully
ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { }
@ -279,6 +280,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 setupDeleteEmptyFolders() {
settings_delete_empty_folders.isChecked = config.deleteEmptyFolders
settings_delete_empty_folders_holder.setOnClickListener {

View file

@ -270,7 +270,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
if (intent.extras?.containsKey(IS_VIEW_INTENT) == true) {
if (isShowHiddenFlagNeeded()) {
if (!config.isPasswordProtectionOn) {
if (!config.isHiddenPasswordProtectionOn) {
config.temporarilyShowHidden = true
}
}

View file

@ -945,6 +945,30 @@
</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:paddingLeft="@dimen/medium_margin"
android:text="@string/password_protect_file_deletion"
app:switchPadding="@dimen/medium_margin"/>
</RelativeLayout>
<View
android:id="@+id/file_operations_divider"
android:layout_width="match_parent"