mirror of
				https://github.com/SimpleMobileTools/Simple-File-Manager.git
				synced 2025-06-05 22:09:15 +02:00 
			
		
		
		
	add password protection for showing hidden items
This commit is contained in:
		| @@ -32,7 +32,7 @@ android { | ||||
| } | ||||
|  | ||||
| dependencies { | ||||
|     compile 'com.simplemobiletools:commons:2.22.7' | ||||
|     compile 'com.simplemobiletools:commons:2.25.3' | ||||
|     compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' | ||||
|     compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||||
| } | ||||
|   | ||||
| @@ -184,8 +184,19 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br | ||||
|     } | ||||
|  | ||||
|     private fun temporarilyShowHidden() { | ||||
|         config.temporarilyShowHidden = true | ||||
|         if (config.temporarilyShowHidden) { | ||||
|             toggleTemporarilyShowHidden(false) | ||||
|         } else { | ||||
|             handleHiddenFolderPasswordProtection { | ||||
|                 toggleTemporarilyShowHidden(true) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private fun toggleTemporarilyShowHidden(show: Boolean) { | ||||
|         config.temporarilyShowHidden = show | ||||
|         openPath(currentPath) | ||||
|         invalidateOptionsMenu() | ||||
|     } | ||||
|  | ||||
|     private fun launchAbout() { | ||||
|   | ||||
| @@ -2,7 +2,10 @@ package com.simplemobiletools.filemanager.activities | ||||
|  | ||||
| import android.content.Intent | ||||
| import android.os.Bundle | ||||
| import com.simplemobiletools.commons.dialogs.SecurityDialog | ||||
| import com.simplemobiletools.commons.extensions.handleHiddenFolderPasswordProtection | ||||
| import com.simplemobiletools.commons.extensions.updateTextColors | ||||
| import com.simplemobiletools.commons.helpers.SHOW_ALL_TABS | ||||
| import com.simplemobiletools.filemanager.R | ||||
| import com.simplemobiletools.filemanager.extensions.config | ||||
| import kotlinx.android.synthetic.main.activity_settings.* | ||||
| @@ -19,6 +22,7 @@ class SettingsActivity : SimpleActivity() { | ||||
|         setupCustomizeColors() | ||||
|         setupManageFavorites() | ||||
|         setupShowHidden() | ||||
|         setupPasswordProtection() | ||||
|         updateTextColors(settings_holder) | ||||
|     } | ||||
|  | ||||
| @@ -37,8 +41,32 @@ class SettingsActivity : SimpleActivity() { | ||||
|     private fun setupShowHidden() { | ||||
|         settings_show_hidden.isChecked = config.showHidden | ||||
|         settings_show_hidden_holder.setOnClickListener { | ||||
|             if (config.showHidden) { | ||||
|                 toggleShowHidden() | ||||
|             } else { | ||||
|                 handleHiddenFolderPasswordProtection { | ||||
|                     toggleShowHidden() | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private fun toggleShowHidden() { | ||||
|         settings_show_hidden.toggle() | ||||
|         config.showHidden = settings_show_hidden.isChecked | ||||
|     } | ||||
|  | ||||
|     private fun setupPasswordProtection() { | ||||
|         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 -> | ||||
|                 val hasPasswordProtection = config.isPasswordProtectionOn | ||||
|                 settings_password_protection.isChecked = !hasPasswordProtection | ||||
|                 config.isPasswordProtectionOn = !hasPasswordProtection | ||||
|                 config.passwordHash = if (hasPasswordProtection) "" else hash | ||||
|                 config.protectionType = type | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -68,5 +68,25 @@ | ||||
|                 android:text="@string/show_hidden"/> | ||||
|  | ||||
|         </RelativeLayout> | ||||
|  | ||||
|         <RelativeLayout | ||||
|             android:id="@+id/settings_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_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_hidden_items"/> | ||||
|  | ||||
|         </RelativeLayout> | ||||
|     </LinearLayout> | ||||
| </ScrollView> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user