Skip to content

Commit f6332b0

Browse files
committed
fix: "shouldShowHidden" does not reflect changes on "showHidden || temporarilyShowHidden" due to its variable like definition on a singleton object
1 parent 8e67656 commit f6332b0

File tree

11 files changed

+28
-25
lines changed

11 files changed

+28
-25
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/FavoritesActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class FavoritesActivity : SimpleActivity(), RefreshRecyclerViewListener {
6565
}
6666

6767
private fun addFavorite() {
68-
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden, canAddShowHiddenButton = true) {
68+
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden(), canAddShowHiddenButton = true) {
6969
config.addFavorite(it)
7070
updateFavorites()
7171
}

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class MainActivity : SimpleActivity() {
188188
findItem(R.id.go_home).isVisible = currentFragment is ItemsFragment && currentFragment.currentPath != config.homeFolder
189189
findItem(R.id.set_as_home).isVisible = currentFragment is ItemsFragment && currentFragment.currentPath != config.homeFolder
190190

191-
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden && currentFragment !is StorageFragment
191+
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden() && currentFragment !is StorageFragment
192192
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden && currentFragment !is StorageFragment
193193

194194
findItem(R.id.column_count).isVisible = currentViewType == VIEW_TYPE_GRID && currentFragment !is StorageFragment

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MimeTypesActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import com.simplemobiletools.filemanager.pro.helpers.*
2929
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
3030
import com.simplemobiletools.filemanager.pro.models.ListItem
3131
import kotlinx.android.synthetic.main.activity_mimetypes.*
32-
import java.util.*
32+
import java.util.Locale
3333

3434
class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
3535
private var isSearchOpen = false
@@ -86,7 +86,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
8686
mimetypes_toolbar.menu.apply {
8787
findItem(R.id.toggle_filename).isVisible = currentViewType == VIEW_TYPE_GRID
8888

89-
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden
89+
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden()
9090
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden
9191

9292
findItem(R.id.column_count).isVisible = currentViewType == VIEW_TYPE_GRID
@@ -255,7 +255,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
255255

256256
private fun getProperFileDirItems(callback: (ArrayList<FileDirItem>) -> Unit) {
257257
val fileDirItems = ArrayList<FileDirItem>()
258-
val showHidden = config.shouldShowHidden
258+
val showHidden = config.shouldShowHidden()
259259
val uri = MediaStore.Files.getContentUri("external")
260260
val projection = arrayOf(
261261
MediaStore.Files.FileColumns.MIME_TYPE,

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/SaveAsActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import com.simplemobiletools.commons.helpers.NavigationIcon
99
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
1010
import com.simplemobiletools.filemanager.pro.R
1111
import com.simplemobiletools.filemanager.pro.extensions.config
12-
import kotlinx.android.synthetic.main.activity_save_as.*
12+
import kotlinx.android.synthetic.main.activity_save_as.activity_save_as_toolbar
1313
import java.io.File
1414

1515
class SaveAsActivity : SimpleActivity() {
@@ -18,7 +18,7 @@ class SaveAsActivity : SimpleActivity() {
1818
setContentView(R.layout.activity_save_as)
1919

2020
if (intent.action == Intent.ACTION_SEND && intent.extras?.containsKey(Intent.EXTRA_STREAM) == true) {
21-
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden, showFAB = true, showFavoritesButton = true) {
21+
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden(), showFAB = true, showFavoritesButton = true) {
2222
val destination = it
2323
handleSAFDialog(destination) {
2424
toast(R.string.saving)

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ItemsAdapter.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,10 @@ class ItemsAdapter(
249249

250250
private fun showProperties() {
251251
if (selectedKeys.size <= 1) {
252-
PropertiesDialog(activity, getFirstSelectedItemPath(), config.shouldShowHidden)
252+
PropertiesDialog(activity, getFirstSelectedItemPath(), config.shouldShowHidden())
253253
} else {
254254
val paths = getSelectedFileDirItems().map { it.path }
255-
PropertiesDialog(activity, paths, config.shouldShowHidden)
255+
PropertiesDialog(activity, paths, config.shouldShowHidden())
256256
}
257257
}
258258

@@ -340,7 +340,7 @@ class ItemsAdapter(
340340
@SuppressLint("NewApi")
341341
private fun addFileUris(path: String, paths: ArrayList<String>) {
342342
if (activity.getIsPathDirectory(path)) {
343-
val shouldShowHidden = config.shouldShowHidden
343+
val shouldShowHidden = config.shouldShowHidden()
344344
when {
345345
activity.isRestrictedSAFOnlyRoot(path) -> {
346346
activity.getAndroidSAFFileItems(path, shouldShowHidden, false) { files ->
@@ -407,9 +407,9 @@ class ItemsAdapter(
407407
val source = firstFile.getParentPath()
408408
FilePickerDialog(
409409
activity,
410-
activity.getDefaultCopyDestinationPath(config.shouldShowHidden, source),
410+
activity.getDefaultCopyDestinationPath(config.shouldShowHidden(), source),
411411
false,
412-
config.shouldShowHidden,
412+
config.shouldShowHidden(),
413413
true,
414414
true,
415415
showFavoritesButton = true
@@ -418,7 +418,7 @@ class ItemsAdapter(
418418
if (activity.isPathOnRoot(it) || activity.isPathOnRoot(firstFile.path)) {
419419
copyMoveRootItems(files, it, isCopyOperation)
420420
} else {
421-
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false, config.shouldShowHidden) {
421+
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false, config.shouldShowHidden()) {
422422
if (!isCopyOperation) {
423423
files.forEach { sourceFileDir ->
424424
val sourcePath = sourceFileDir.path

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/CompressAsDialog.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import com.simplemobiletools.commons.dialogs.FilePickerDialog
77
import com.simplemobiletools.commons.extensions.*
88
import com.simplemobiletools.filemanager.pro.R
99
import com.simplemobiletools.filemanager.pro.extensions.config
10-
import kotlinx.android.synthetic.main.dialog_compress_as.view.*
10+
import kotlinx.android.synthetic.main.dialog_compress_as.view.filename_value
11+
import kotlinx.android.synthetic.main.dialog_compress_as.view.folder
1112

1213
class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val callback: (destination: String) -> Unit) {
1314
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
2324

2425
folder.setText(activity.humanizePath(realPath))
2526
folder.setOnClickListener {
26-
FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden, true, true, showFavoritesButton = true) {
27+
FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden(), true, true, showFavoritesButton = true) {
2728
folder.setText(activity.humanizePath(it))
2829
realPath = it
2930
}

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
9999

100100
scrollStates[currentPath] = getScrollState()!!
101101
currentPath = realPath
102-
showHidden = context!!.config.shouldShowHidden
102+
showHidden = context!!.config.shouldShowHidden()
103103
showProgressBar()
104104
getItems(currentPath) { originalPath, listItems ->
105105
if (currentPath != originalPath) {
@@ -180,13 +180,13 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
180180
return@handleAndroidSAFDialog
181181
}
182182
val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST
183-
context.getAndroidSAFFileItems(path, context.config.shouldShowHidden, getProperChildCount) { fileItems ->
183+
context.getAndroidSAFFileItems(path, context.config.shouldShowHidden(), getProperChildCount) { fileItems ->
184184
callback(path, getListItemsFromFileDirItems(fileItems))
185185
}
186186
}
187187
} else if (context!!.isPathOnOTG(path) && config.OTGTreeUri.isNotEmpty()) {
188188
val getProperFileSize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
189-
context!!.getOTGItems(path, config.shouldShowHidden, getProperFileSize) {
189+
context!!.getOTGItems(path, config.shouldShowHidden(), getProperFileSize) {
190190
callback(path, getListItemsFromFileDirItems(it))
191191
}
192192
} else if (!config.enableRootAccess || !context!!.isPathOnRoot(path)) {

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/RecentsFragment.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ import com.simplemobiletools.filemanager.pro.extensions.config
2121
import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
2222
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
2323
import com.simplemobiletools.filemanager.pro.models.ListItem
24-
import kotlinx.android.synthetic.main.recents_fragment.view.*
24+
import kotlinx.android.synthetic.main.recents_fragment.view.recents_list
25+
import kotlinx.android.synthetic.main.recents_fragment.view.recents_placeholder
26+
import kotlinx.android.synthetic.main.recents_fragment.view.recents_swipe_refresh
2527
import java.io.File
2628

2729
class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener {
@@ -134,7 +136,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
134136
}
135137

136138
private fun getRecents(callback: (recents: ArrayList<ListItem>) -> Unit) {
137-
val showHidden = context?.config?.shouldShowHidden ?: return
139+
val showHidden = context?.config?.shouldShowHidden() ?: return
138140
val listItems = arrayListOf<ListItem>()
139141

140142
val uri = Files.getContentUri("external")

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/StorageFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
318318

319319
private fun getAllFiles(): ArrayList<FileDirItem> {
320320
val fileDirItems = ArrayList<FileDirItem>()
321-
val showHidden = context?.config?.shouldShowHidden ?: return fileDirItems
321+
val showHidden = context?.config?.shouldShowHidden() ?: return fileDirItems
322322
val uri = MediaStore.Files.getContentUri("external")
323323
val projection = arrayOf(
324324
MediaStore.Files.FileColumns.DATA,

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Config(context: Context) : BaseConfig(context) {
2020
get() = prefs.getBoolean(TEMPORARILY_SHOW_HIDDEN, false)
2121
set(temporarilyShowHidden) = prefs.edit().putBoolean(TEMPORARILY_SHOW_HIDDEN, temporarilyShowHidden).apply()
2222

23-
var shouldShowHidden = showHidden || temporarilyShowHidden
23+
fun shouldShowHidden() = showHidden || temporarilyShowHidden
2424

2525
var pressBackTwice: Boolean
2626
get() = prefs.getBoolean(PRESS_BACK_TWICE, true)

0 commit comments

Comments
 (0)