mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-18 12:50:35 +01:00
add a menu button for temporarily showing hidden items
This commit is contained in:
parent
362fa75b10
commit
419c1f501b
@ -32,7 +32,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.simplemobiletools:commons:2.21.10'
|
compile 'com.simplemobiletools:commons:2.21.11'
|
||||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,12 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
get() = prefs.getBoolean(SHOW_HIDDEN, false)
|
get() = prefs.getBoolean(SHOW_HIDDEN, false)
|
||||||
set(show) = prefs.edit().putBoolean(SHOW_HIDDEN, show).apply()
|
set(show) = prefs.edit().putBoolean(SHOW_HIDDEN, show).apply()
|
||||||
|
|
||||||
|
var temporarilyShowHidden: Boolean
|
||||||
|
get() = prefs.getBoolean(TEMPORARILY_SHOW_HIDDEN, false)
|
||||||
|
set(temporarilyShowHidden) = prefs.edit().putBoolean(TEMPORARILY_SHOW_HIDDEN, temporarilyShowHidden).apply()
|
||||||
|
|
||||||
|
var shouldShowHidden = showHidden || temporarilyShowHidden
|
||||||
|
|
||||||
var homeFolder: String
|
var homeFolder: String
|
||||||
get(): String {
|
get(): String {
|
||||||
var home = prefs.getString(HOME_FOLDER, "")
|
var home = prefs.getString(HOME_FOLDER, "")
|
||||||
|
@ -9,3 +9,4 @@ val HOME_FOLDER = "home_folder"
|
|||||||
val FAVORITES = "favorites"
|
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"
|
||||||
|
@ -56,7 +56,7 @@ class FavoritesActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addFavorite() {
|
private fun addFavorite() {
|
||||||
FilePickerDialog(this, pickFile = false, showHidden = config.showHidden) {
|
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden) {
|
||||||
config.addFavorite(it)
|
config.addFavorite(it)
|
||||||
updateFavorites()
|
updateFavorites()
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,11 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
|
|||||||
mStoredTextColor = config.textColor
|
mStoredTextColor = config.textColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
config.temporarilyShowHidden = false
|
||||||
|
}
|
||||||
|
|
||||||
private fun tryInitFileManager() {
|
private fun tryInitFileManager() {
|
||||||
if (hasWriteStoragePermission()) {
|
if (hasWriteStoragePermission()) {
|
||||||
initRootFileManager()
|
initRootFileManager()
|
||||||
@ -109,6 +114,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
|
|||||||
findItem(R.id.add_favorite).isVisible = !favorites.contains(currentPath)
|
findItem(R.id.add_favorite).isVisible = !favorites.contains(currentPath)
|
||||||
findItem(R.id.remove_favorite).isVisible = favorites.contains(currentPath)
|
findItem(R.id.remove_favorite).isVisible = favorites.contains(currentPath)
|
||||||
findItem(R.id.go_to_favorite).isVisible = favorites.isNotEmpty()
|
findItem(R.id.go_to_favorite).isVisible = favorites.isNotEmpty()
|
||||||
|
menu.findItem(R.id.temporarily_show_hidden).isVisible = !config.showHidden
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
@ -122,6 +128,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
|
|||||||
R.id.remove_favorite -> removeFavorite()
|
R.id.remove_favorite -> removeFavorite()
|
||||||
R.id.go_to_favorite -> goToFavorite()
|
R.id.go_to_favorite -> goToFavorite()
|
||||||
R.id.set_as_home -> setAsHome()
|
R.id.set_as_home -> setAsHome()
|
||||||
|
R.id.temporarily_show_hidden -> temporarilyShowHidden()
|
||||||
R.id.settings -> startActivity(Intent(this, SettingsActivity::class.java))
|
R.id.settings -> startActivity(Intent(this, SettingsActivity::class.java))
|
||||||
R.id.about -> launchAbout()
|
R.id.about -> launchAbout()
|
||||||
else -> return super.onOptionsItemSelected(item)
|
else -> return super.onOptionsItemSelected(item)
|
||||||
@ -176,6 +183,11 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
|
|||||||
toast(R.string.home_folder_updated)
|
toast(R.string.home_folder_updated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun temporarilyShowHidden() {
|
||||||
|
config.temporarilyShowHidden = true
|
||||||
|
openPath(currentPath)
|
||||||
|
}
|
||||||
|
|
||||||
private fun launchAbout() {
|
private fun launchAbout() {
|
||||||
startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_MULTISELECT, BuildConfig.VERSION_NAME)
|
startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_MULTISELECT, BuildConfig.VERSION_NAME)
|
||||||
}
|
}
|
||||||
|
@ -125,11 +125,11 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
|||||||
|
|
||||||
private fun showProperties() {
|
private fun showProperties() {
|
||||||
if (selectedPositions.size <= 1) {
|
if (selectedPositions.size <= 1) {
|
||||||
PropertiesDialog(activity, mItems[selectedPositions.first()].path, config.showHidden)
|
PropertiesDialog(activity, mItems[selectedPositions.first()].path, config.shouldShowHidden)
|
||||||
} else {
|
} else {
|
||||||
val paths = ArrayList<String>()
|
val paths = ArrayList<String>()
|
||||||
selectedPositions.forEach { paths.add(mItems[it].path) }
|
selectedPositions.forEach { paths.add(mItems[it].path) }
|
||||||
PropertiesDialog(activity, paths, config.showHidden)
|
PropertiesDialog(activity, paths, config.shouldShowHidden)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
|||||||
|
|
||||||
private fun addFileUris(file: File, uris: ArrayList<Uri>) {
|
private fun addFileUris(file: File, uris: ArrayList<Uri>) {
|
||||||
if (file.isDirectory) {
|
if (file.isDirectory) {
|
||||||
file.listFiles()?.filter { if (config.showHidden) true else !it.isHidden }?.forEach {
|
file.listFiles()?.filter { if (config.shouldShowHidden) true else !it.isHidden }?.forEach {
|
||||||
addFileUris(it, uris)
|
addFileUris(it, uris)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -183,7 +183,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
|||||||
selectedPositions.forEach { files.add(File(mItems[it].path)) }
|
selectedPositions.forEach { files.add(File(mItems[it].path)) }
|
||||||
|
|
||||||
val source = if (files[0].isFile) files[0].parent else files[0].absolutePath
|
val source = if (files[0].isFile) files[0].parent else files[0].absolutePath
|
||||||
FilePickerDialog(activity, source, false, config.showHidden, true) {
|
FilePickerDialog(activity, source, false, config.shouldShowHidden, true) {
|
||||||
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false) {
|
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false) {
|
||||||
if (!isCopyOperation) {
|
if (!isCopyOperation) {
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
|
@ -44,7 +44,7 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener {
|
|||||||
|
|
||||||
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
mShowHidden = context.config.showHidden
|
mShowHidden = context.config.shouldShowHidden
|
||||||
fillItems()
|
fillItems()
|
||||||
|
|
||||||
items_swipe_refresh.setOnRefreshListener({ fillItems() })
|
items_swipe_refresh.setOnRefreshListener({ fillItems() })
|
||||||
@ -54,7 +54,7 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener {
|
|||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
val config = context.config
|
val config = context.config
|
||||||
if (mShowHidden != config.showHidden) {
|
if (mShowHidden != config.shouldShowHidden) {
|
||||||
mShowHidden = !mShowHidden
|
mShowHidden = !mShowHidden
|
||||||
fillItems()
|
fillItems()
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,10 @@
|
|||||||
android:id="@+id/set_as_home"
|
android:id="@+id/set_as_home"
|
||||||
android:title="@string/set_as_home_folder"
|
android:title="@string/set_as_home_folder"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/temporarily_show_hidden"
|
||||||
|
android:title="@string/temporarily_show_hidden"
|
||||||
|
app:showAsAction="never"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/settings"
|
android:id="@+id/settings"
|
||||||
android:title="@string/settings"
|
android:title="@string/settings"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user