mirror of
				https://github.com/SimpleMobileTools/Simple-File-Manager.git
				synced 2025-06-05 22:09:15 +02:00 
			
		
		
		
	show the root access toggle only if root is available
This commit is contained in:
		| @@ -68,6 +68,10 @@ class Config(context: Context) : BaseConfig(context) { | ||||
|  | ||||
|     fun hasCustomSorting(path: String) = prefs.contains(SORT_FOLDER_PREFIX + path) | ||||
|  | ||||
|     var isRootAvailable: Boolean | ||||
|         get() = prefs.getBoolean(IS_ROOT_AVAILABLE, false) | ||||
|         set(isRootAvailable) = prefs.edit().putBoolean(IS_ROOT_AVAILABLE, isRootAvailable).apply() | ||||
|  | ||||
|     var enableRootAccess: Boolean | ||||
|         get() = prefs.getBoolean(ENABLE_ROOT_ACCESS, false) | ||||
|         set(enableRootAccess) = prefs.edit().putBoolean(ENABLE_ROOT_ACCESS, enableRootAccess).apply() | ||||
|   | ||||
| @@ -10,4 +10,5 @@ val FAVORITES = "favorites" | ||||
| val SORT_ORDER = "sort_order" | ||||
| val SORT_FOLDER_PREFIX = "sort_folder_" | ||||
| val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden" | ||||
| val IS_ROOT_AVAILABLE = "is_root_available" | ||||
| val ENABLE_ROOT_ACCESS = "enable_root_access" | ||||
|   | ||||
| @@ -25,6 +25,7 @@ import com.simplemobiletools.filemanager.SCROLL_STATE | ||||
| import com.simplemobiletools.filemanager.dialogs.ChangeSortingDialog | ||||
| import com.simplemobiletools.filemanager.extensions.config | ||||
| import com.simplemobiletools.filemanager.fragments.ItemsFragment | ||||
| import com.stericson.RootTools.RootTools | ||||
| import kotlinx.android.synthetic.main.activity_main.* | ||||
| import java.util.* | ||||
|  | ||||
| @@ -45,6 +46,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br | ||||
|         tryInitFileManager() | ||||
|         storeStoragePaths() | ||||
|         checkWhatsNewDialog() | ||||
|         checkIfRootAvailable() | ||||
|     } | ||||
|  | ||||
|     override fun onResume() { | ||||
| @@ -246,6 +248,12 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private fun checkIfRootAvailable() { | ||||
|         Thread({ | ||||
|             config.isRootAvailable = RootTools.isRootAvailable() | ||||
|         }).start() | ||||
|     } | ||||
|  | ||||
|     private fun checkWhatsNewDialog() { | ||||
|         arrayListOf<Release>().apply { | ||||
|             add(Release(26, R.string.release_26)) | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package com.simplemobiletools.filemanager.activities | ||||
| import android.content.Intent | ||||
| import android.os.Bundle | ||||
| import com.simplemobiletools.commons.dialogs.SecurityDialog | ||||
| import com.simplemobiletools.commons.extensions.beVisibleIf | ||||
| import com.simplemobiletools.commons.extensions.handleHiddenFolderPasswordProtection | ||||
| import com.simplemobiletools.commons.extensions.updateTextColors | ||||
| import com.simplemobiletools.commons.helpers.SHOW_ALL_TABS | ||||
| @@ -73,6 +74,7 @@ class SettingsActivity : SimpleActivity() { | ||||
|     } | ||||
|  | ||||
|     private fun setupEnableRootAccess() { | ||||
|         settings_enable_root_access_holder.beVisibleIf(config.isRootAvailable) | ||||
|         settings_enable_root_access.isChecked = config.enableRootAccess | ||||
|         settings_enable_root_access_holder.setOnClickListener { | ||||
|             if (!config.enableRootAccess) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user