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