add a menu button for temporarily showing hidden items
This commit is contained in:
parent
362fa75b10
commit
419c1f501b
|
@ -32,7 +32,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.simplemobiletools:commons:2.21.10'
|
||||
compile 'com.simplemobiletools:commons:2.21.11'
|
||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
|
|
|
@ -16,6 +16,12 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getBoolean(SHOW_HIDDEN, false)
|
||||
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
|
||||
get(): String {
|
||||
var home = prefs.getString(HOME_FOLDER, "")
|
||||
|
|
|
@ -9,3 +9,4 @@ val HOME_FOLDER = "home_folder"
|
|||
val FAVORITES = "favorites"
|
||||
val SORT_ORDER = "sort_order"
|
||||
val SORT_FOLDER_PREFIX = "sort_folder_"
|
||||
val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden"
|
||||
|
|
|
@ -56,7 +56,7 @@ class FavoritesActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun addFavorite() {
|
||||
FilePickerDialog(this, pickFile = false, showHidden = config.showHidden) {
|
||||
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden) {
|
||||
config.addFavorite(it)
|
||||
updateFavorites()
|
||||
}
|
||||
|
|
|
@ -66,6 +66,11 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
|
|||
mStoredTextColor = config.textColor
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
config.temporarilyShowHidden = false
|
||||
}
|
||||
|
||||
private fun tryInitFileManager() {
|
||||
if (hasWriteStoragePermission()) {
|
||||
initRootFileManager()
|
||||
|
@ -109,6 +114,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
|
|||
findItem(R.id.add_favorite).isVisible = !favorites.contains(currentPath)
|
||||
findItem(R.id.remove_favorite).isVisible = favorites.contains(currentPath)
|
||||
findItem(R.id.go_to_favorite).isVisible = favorites.isNotEmpty()
|
||||
menu.findItem(R.id.temporarily_show_hidden).isVisible = !config.showHidden
|
||||
}
|
||||
|
||||
return true
|
||||
|
@ -122,6 +128,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
|
|||
R.id.remove_favorite -> removeFavorite()
|
||||
R.id.go_to_favorite -> goToFavorite()
|
||||
R.id.set_as_home -> setAsHome()
|
||||
R.id.temporarily_show_hidden -> temporarilyShowHidden()
|
||||
R.id.settings -> startActivity(Intent(this, SettingsActivity::class.java))
|
||||
R.id.about -> launchAbout()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
|
@ -176,6 +183,11 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
|
|||
toast(R.string.home_folder_updated)
|
||||
}
|
||||
|
||||
private fun temporarilyShowHidden() {
|
||||
config.temporarilyShowHidden = true
|
||||
openPath(currentPath)
|
||||
}
|
||||
|
||||
private fun launchAbout() {
|
||||
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() {
|
||||
if (selectedPositions.size <= 1) {
|
||||
PropertiesDialog(activity, mItems[selectedPositions.first()].path, config.showHidden)
|
||||
PropertiesDialog(activity, mItems[selectedPositions.first()].path, config.shouldShowHidden)
|
||||
} else {
|
||||
val paths = ArrayList<String>()
|
||||
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>) {
|
||||
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)
|
||||
}
|
||||
} else {
|
||||
|
@ -183,7 +183,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
|||
selectedPositions.forEach { files.add(File(mItems[it].path)) }
|
||||
|
||||
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) {
|
||||
if (!isCopyOperation) {
|
||||
listener?.refreshItems()
|
||||
|
|
|
@ -44,7 +44,7 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener {
|
|||
|
||||
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mShowHidden = context.config.showHidden
|
||||
mShowHidden = context.config.shouldShowHidden
|
||||
fillItems()
|
||||
|
||||
items_swipe_refresh.setOnRefreshListener({ fillItems() })
|
||||
|
@ -54,7 +54,7 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener {
|
|||
override fun onResume() {
|
||||
super.onResume()
|
||||
val config = context.config
|
||||
if (mShowHidden != config.showHidden) {
|
||||
if (mShowHidden != config.shouldShowHidden) {
|
||||
mShowHidden = !mShowHidden
|
||||
fillItems()
|
||||
}
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
android:id="@+id/set_as_home"
|
||||
android:title="@string/set_as_home_folder"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/temporarily_show_hidden"
|
||||
android:title="@string/temporarily_show_hidden"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/settings"
|
||||
android:title="@string/settings"
|
||||
|
|
Loading…
Reference in New Issue