allow password protecting the whole app
This commit is contained in:
parent
43d49beca0
commit
c7bbeddae8
|
@ -45,7 +45,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.simplemobiletools:commons:2.37.6'
|
||||
compile 'com.simplemobiletools:commons:2.37.10'
|
||||
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.7.2'
|
||||
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
|
||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||
|
|
|
@ -60,6 +60,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
private var mStoredShowMediaCount = true
|
||||
private var mStoredTextColor = 0
|
||||
private var mLoadedInitialPhotos = false
|
||||
private var mIsPasswordProtectionPending = false
|
||||
private var mLatestMediaId = 0L
|
||||
private var mLastMediaHandler = Handler()
|
||||
private var mCurrAsyncTask: GetDirectoriesAsynctask? = null
|
||||
|
@ -88,6 +89,8 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
directories_empty_text.setOnClickListener {
|
||||
showFilterMediaDialog()
|
||||
}
|
||||
|
||||
mIsPasswordProtectionPending = config.appPasswordProtectionOn
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
@ -151,10 +154,22 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
getDirectoryAdapter()?.updateTextColor(config.textColor)
|
||||
}
|
||||
|
||||
tryloadGallery()
|
||||
invalidateOptionsMenu()
|
||||
directories_empty_text_label.setTextColor(config.textColor)
|
||||
directories_empty_text.setTextColor(config.primaryColor)
|
||||
|
||||
if (mIsPasswordProtectionPending) {
|
||||
handleAppPasswordProtection {
|
||||
if (it) {
|
||||
mIsPasswordProtectionPending = false
|
||||
tryloadGallery()
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tryloadGallery()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
|
|
@ -50,6 +50,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupHideSystemUI()
|
||||
setupReplaceShare()
|
||||
setupPasswordProtection()
|
||||
setupAppPasswordProtection()
|
||||
setupDeleteEmptyFolders()
|
||||
setupAllowVideoGestures()
|
||||
setupShowMediaCount()
|
||||
|
@ -181,7 +182,8 @@ class SettingsActivity : SimpleActivity() {
|
|||
settings_password_protection.isChecked = config.isPasswordProtectionOn
|
||||
settings_password_protection_holder.setOnClickListener {
|
||||
val tabToShow = if (config.isPasswordProtectionOn) config.protectionType else SHOW_ALL_TABS
|
||||
SecurityDialog(this, config.passwordHash, tabToShow) { hash, type ->
|
||||
SecurityDialog(this, config.passwordHash, tabToShow) { hash, type, success ->
|
||||
if (success) {
|
||||
val hasPasswordProtection = config.isPasswordProtectionOn
|
||||
settings_password_protection.isChecked = !hasPasswordProtection
|
||||
config.isPasswordProtectionOn = !hasPasswordProtection
|
||||
|
@ -196,6 +198,29 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupAppPasswordProtection() {
|
||||
settings_app_password_protection.isChecked = config.appPasswordProtectionOn
|
||||
settings_app_password_protection_holder.setOnClickListener {
|
||||
val tabToShow = if (config.appPasswordProtectionOn) config.appProtectionType else SHOW_ALL_TABS
|
||||
SecurityDialog(this, config.appPasswordHash, tabToShow) { hash, type, success ->
|
||||
if (success) {
|
||||
val hasPasswordProtection = config.appPasswordProtectionOn
|
||||
settings_app_password_protection.isChecked = !hasPasswordProtection
|
||||
config.appPasswordProtectionOn = !hasPasswordProtection
|
||||
config.appPasswordHash = if (hasPasswordProtection) "" else hash
|
||||
config.appProtectionType = type
|
||||
|
||||
if (config.appPasswordProtectionOn) {
|
||||
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) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupDeleteEmptyFolders() {
|
||||
settings_delete_empty_folders.isChecked = config.deleteEmptyFolders
|
||||
|
|
|
@ -308,6 +308,26 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_app_password_protection_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_app_password_protection"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/password_protect_whole_app"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_delete_empty_folders_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue