mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-11 09:20:51 +01:00
fix: "shouldShowHidden" does not reflect changes on "showHidden || temporarilyShowHidden" due to its variable like definition on a singleton object
This commit is contained in:
parent
8e67656719
commit
f6332b09c2
@ -65,7 +65,7 @@ class FavoritesActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
}
|
||||
|
||||
private fun addFavorite() {
|
||||
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden, canAddShowHiddenButton = true) {
|
||||
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden(), canAddShowHiddenButton = true) {
|
||||
config.addFavorite(it)
|
||||
updateFavorites()
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ class MainActivity : SimpleActivity() {
|
||||
findItem(R.id.go_home).isVisible = currentFragment is ItemsFragment && currentFragment.currentPath != config.homeFolder
|
||||
findItem(R.id.set_as_home).isVisible = currentFragment is ItemsFragment && currentFragment.currentPath != config.homeFolder
|
||||
|
||||
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden && currentFragment !is StorageFragment
|
||||
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden() && currentFragment !is StorageFragment
|
||||
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden && currentFragment !is StorageFragment
|
||||
|
||||
findItem(R.id.column_count).isVisible = currentViewType == VIEW_TYPE_GRID && currentFragment !is StorageFragment
|
||||
|
@ -29,7 +29,7 @@ import com.simplemobiletools.filemanager.pro.helpers.*
|
||||
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
||||
import com.simplemobiletools.filemanager.pro.models.ListItem
|
||||
import kotlinx.android.synthetic.main.activity_mimetypes.*
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
|
||||
class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
||||
private var isSearchOpen = false
|
||||
@ -86,7 +86,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
||||
mimetypes_toolbar.menu.apply {
|
||||
findItem(R.id.toggle_filename).isVisible = currentViewType == VIEW_TYPE_GRID
|
||||
|
||||
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden
|
||||
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden()
|
||||
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden
|
||||
|
||||
findItem(R.id.column_count).isVisible = currentViewType == VIEW_TYPE_GRID
|
||||
@ -255,7 +255,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
||||
|
||||
private fun getProperFileDirItems(callback: (ArrayList<FileDirItem>) -> Unit) {
|
||||
val fileDirItems = ArrayList<FileDirItem>()
|
||||
val showHidden = config.shouldShowHidden
|
||||
val showHidden = config.shouldShowHidden()
|
||||
val uri = MediaStore.Files.getContentUri("external")
|
||||
val projection = arrayOf(
|
||||
MediaStore.Files.FileColumns.MIME_TYPE,
|
||||
|
@ -9,7 +9,7 @@ import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.filemanager.pro.R
|
||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||
import kotlinx.android.synthetic.main.activity_save_as.*
|
||||
import kotlinx.android.synthetic.main.activity_save_as.activity_save_as_toolbar
|
||||
import java.io.File
|
||||
|
||||
class SaveAsActivity : SimpleActivity() {
|
||||
@ -18,7 +18,7 @@ class SaveAsActivity : SimpleActivity() {
|
||||
setContentView(R.layout.activity_save_as)
|
||||
|
||||
if (intent.action == Intent.ACTION_SEND && intent.extras?.containsKey(Intent.EXTRA_STREAM) == true) {
|
||||
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden, showFAB = true, showFavoritesButton = true) {
|
||||
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden(), showFAB = true, showFavoritesButton = true) {
|
||||
val destination = it
|
||||
handleSAFDialog(destination) {
|
||||
toast(R.string.saving)
|
||||
|
@ -249,10 +249,10 @@ class ItemsAdapter(
|
||||
|
||||
private fun showProperties() {
|
||||
if (selectedKeys.size <= 1) {
|
||||
PropertiesDialog(activity, getFirstSelectedItemPath(), config.shouldShowHidden)
|
||||
PropertiesDialog(activity, getFirstSelectedItemPath(), config.shouldShowHidden())
|
||||
} else {
|
||||
val paths = getSelectedFileDirItems().map { it.path }
|
||||
PropertiesDialog(activity, paths, config.shouldShowHidden)
|
||||
PropertiesDialog(activity, paths, config.shouldShowHidden())
|
||||
}
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ class ItemsAdapter(
|
||||
@SuppressLint("NewApi")
|
||||
private fun addFileUris(path: String, paths: ArrayList<String>) {
|
||||
if (activity.getIsPathDirectory(path)) {
|
||||
val shouldShowHidden = config.shouldShowHidden
|
||||
val shouldShowHidden = config.shouldShowHidden()
|
||||
when {
|
||||
activity.isRestrictedSAFOnlyRoot(path) -> {
|
||||
activity.getAndroidSAFFileItems(path, shouldShowHidden, false) { files ->
|
||||
@ -407,9 +407,9 @@ class ItemsAdapter(
|
||||
val source = firstFile.getParentPath()
|
||||
FilePickerDialog(
|
||||
activity,
|
||||
activity.getDefaultCopyDestinationPath(config.shouldShowHidden, source),
|
||||
activity.getDefaultCopyDestinationPath(config.shouldShowHidden(), source),
|
||||
false,
|
||||
config.shouldShowHidden,
|
||||
config.shouldShowHidden(),
|
||||
true,
|
||||
true,
|
||||
showFavoritesButton = true
|
||||
@ -418,7 +418,7 @@ class ItemsAdapter(
|
||||
if (activity.isPathOnRoot(it) || activity.isPathOnRoot(firstFile.path)) {
|
||||
copyMoveRootItems(files, it, isCopyOperation)
|
||||
} else {
|
||||
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false, config.shouldShowHidden) {
|
||||
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false, config.shouldShowHidden()) {
|
||||
if (!isCopyOperation) {
|
||||
files.forEach { sourceFileDir ->
|
||||
val sourcePath = sourceFileDir.path
|
||||
|
@ -7,7 +7,8 @@ import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.filemanager.pro.R
|
||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||
import kotlinx.android.synthetic.main.dialog_compress_as.view.*
|
||||
import kotlinx.android.synthetic.main.dialog_compress_as.view.filename_value
|
||||
import kotlinx.android.synthetic.main.dialog_compress_as.view.folder
|
||||
|
||||
class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val callback: (destination: String) -> Unit) {
|
||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_compress_as, null)
|
||||
@ -23,7 +24,7 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
|
||||
|
||||
folder.setText(activity.humanizePath(realPath))
|
||||
folder.setOnClickListener {
|
||||
FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden, true, true, showFavoritesButton = true) {
|
||||
FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden(), true, true, showFavoritesButton = true) {
|
||||
folder.setText(activity.humanizePath(it))
|
||||
realPath = it
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
||||
|
||||
scrollStates[currentPath] = getScrollState()!!
|
||||
currentPath = realPath
|
||||
showHidden = context!!.config.shouldShowHidden
|
||||
showHidden = context!!.config.shouldShowHidden()
|
||||
showProgressBar()
|
||||
getItems(currentPath) { originalPath, listItems ->
|
||||
if (currentPath != originalPath) {
|
||||
@ -180,13 +180,13 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
||||
return@handleAndroidSAFDialog
|
||||
}
|
||||
val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST
|
||||
context.getAndroidSAFFileItems(path, context.config.shouldShowHidden, getProperChildCount) { fileItems ->
|
||||
context.getAndroidSAFFileItems(path, context.config.shouldShowHidden(), getProperChildCount) { fileItems ->
|
||||
callback(path, getListItemsFromFileDirItems(fileItems))
|
||||
}
|
||||
}
|
||||
} else if (context!!.isPathOnOTG(path) && config.OTGTreeUri.isNotEmpty()) {
|
||||
val getProperFileSize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
|
||||
context!!.getOTGItems(path, config.shouldShowHidden, getProperFileSize) {
|
||||
context!!.getOTGItems(path, config.shouldShowHidden(), getProperFileSize) {
|
||||
callback(path, getListItemsFromFileDirItems(it))
|
||||
}
|
||||
} else if (!config.enableRootAccess || !context!!.isPathOnRoot(path)) {
|
||||
|
@ -21,7 +21,9 @@ import com.simplemobiletools.filemanager.pro.extensions.config
|
||||
import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
|
||||
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
||||
import com.simplemobiletools.filemanager.pro.models.ListItem
|
||||
import kotlinx.android.synthetic.main.recents_fragment.view.*
|
||||
import kotlinx.android.synthetic.main.recents_fragment.view.recents_list
|
||||
import kotlinx.android.synthetic.main.recents_fragment.view.recents_placeholder
|
||||
import kotlinx.android.synthetic.main.recents_fragment.view.recents_swipe_refresh
|
||||
import java.io.File
|
||||
|
||||
class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener {
|
||||
@ -134,7 +136,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
||||
}
|
||||
|
||||
private fun getRecents(callback: (recents: ArrayList<ListItem>) -> Unit) {
|
||||
val showHidden = context?.config?.shouldShowHidden ?: return
|
||||
val showHidden = context?.config?.shouldShowHidden() ?: return
|
||||
val listItems = arrayListOf<ListItem>()
|
||||
|
||||
val uri = Files.getContentUri("external")
|
||||
|
@ -318,7 +318,7 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
||||
|
||||
private fun getAllFiles(): ArrayList<FileDirItem> {
|
||||
val fileDirItems = ArrayList<FileDirItem>()
|
||||
val showHidden = context?.config?.shouldShowHidden ?: return fileDirItems
|
||||
val showHidden = context?.config?.shouldShowHidden() ?: return fileDirItems
|
||||
val uri = MediaStore.Files.getContentUri("external")
|
||||
val projection = arrayOf(
|
||||
MediaStore.Files.FileColumns.DATA,
|
||||
|
@ -20,7 +20,7 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
get() = prefs.getBoolean(TEMPORARILY_SHOW_HIDDEN, false)
|
||||
set(temporarilyShowHidden) = prefs.edit().putBoolean(TEMPORARILY_SHOW_HIDDEN, temporarilyShowHidden).apply()
|
||||
|
||||
var shouldShowHidden = showHidden || temporarilyShowHidden
|
||||
fun shouldShowHidden() = showHidden || temporarilyShowHidden
|
||||
|
||||
var pressBackTwice: Boolean
|
||||
get() = prefs.getBoolean(PRESS_BACK_TWICE, true)
|
||||
|
@ -36,7 +36,7 @@ class RootHelpers(val activity: Activity) {
|
||||
val fullLines = it
|
||||
|
||||
val files = ArrayList<ListItem>()
|
||||
val hiddenArgument = if (activity.config.shouldShowHidden) "-A " else ""
|
||||
val hiddenArgument = if (activity.config.shouldShowHidden()) "-A " else ""
|
||||
val cmd = "ls $hiddenArgument$path"
|
||||
|
||||
val command = object : Command(0, cmd) {
|
||||
@ -66,7 +66,7 @@ class RootHelpers(val activity: Activity) {
|
||||
|
||||
private fun getFullLines(path: String, callback: (ArrayList<String>) -> Unit) {
|
||||
val fullLines = ArrayList<String>()
|
||||
val hiddenArgument = if (activity.config.shouldShowHidden) "-Al " else "-l "
|
||||
val hiddenArgument = if (activity.config.shouldShowHidden()) "-Al " else "-l "
|
||||
val cmd = "ls $hiddenArgument$path"
|
||||
|
||||
val command = object : Command(0, cmd) {
|
||||
@ -85,7 +85,7 @@ class RootHelpers(val activity: Activity) {
|
||||
}
|
||||
|
||||
private fun getChildrenCount(files: ArrayList<ListItem>, path: String, callback: (originalPath: String, listItems: ArrayList<ListItem>) -> Unit) {
|
||||
val hiddenArgument = if (activity.config.shouldShowHidden) "-A " else ""
|
||||
val hiddenArgument = if (activity.config.shouldShowHidden()) "-A " else ""
|
||||
var cmd = ""
|
||||
files.filter { it.isDirectory }.forEach {
|
||||
cmd += "ls $hiddenArgument${it.path} |wc -l;"
|
||||
|
Loading…
x
Reference in New Issue
Block a user