update some functions related to pinning and hiding folders

This commit is contained in:
tibbi 2016-12-05 20:36:43 +01:00
parent b5b4e15990
commit 0857391189
3 changed files with 30 additions and 22 deletions

View File

@ -116,11 +116,11 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
true
}
R.id.hide_folder -> {
hideDirectory()
hideFolder()
true
}
R.id.unhide_folder -> {
unhideDirectory()
unhideFolder()
true
}
else -> super.onOptionsItemSelected(item)
@ -138,8 +138,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
}
}
private fun hideDirectory() {
mConfig.addHiddenDirectory(mPath)
private fun hideFolder() {
mConfig.addHiddenFolder(mPath)
if (!mConfig.showHiddenFolders)
finish()
@ -147,8 +147,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
invalidateOptionsMenu()
}
private fun unhideDirectory() {
mConfig.removeHiddenDirectory(mPath)
private fun unhideFolder() {
mConfig.removeHiddenFolder(mPath)
invalidateOptionsMenu()
}

View File

@ -78,12 +78,12 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
true
}
R.id.cab_hide -> {
hideDirs()
hideFolders()
mode.finish()
true
}
R.id.cab_unhide -> {
unhideDir()
unhideFolders()
mode.finish()
true
}
@ -163,13 +163,13 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
}
}
private fun hideDirs() {
config.addHiddenDirectories(getSelectedPaths())
private fun hideFolders() {
config.addHiddenFolders(getSelectedPaths())
listener?.refreshItems()
}
private fun unhideDir() {
config.removeHiddenDirectories(getSelectedPaths())
private fun unhideFolders() {
config.removeHiddenFolders(getSelectedPaths())
listener?.refreshItems()
}

View File

@ -43,25 +43,33 @@ class Config private constructor(context: Context) {
get() = mPrefs.getStringSet(PINNED_FOLDERS, HashSet<String>())
set(pinnedFolders) = mPrefs.edit().putStringSet(PINNED_FOLDERS, pinnedFolders).apply()
fun addHiddenDirectory(path: String) {
val currHiddenFolders = HashSet<String>(hiddenFolders)
currHiddenFolders.add(path)
hiddenFolders = currHiddenFolders
fun addPinnedFolders(paths: Set<String>) {
val currPinnedFolders = HashSet<String>(pinnedFolders)
currPinnedFolders.addAll(paths)
pinnedFolders = currPinnedFolders
}
fun addHiddenDirectories(paths: Set<String>) {
fun removePinnedFolders(paths: Set<String>) {
val currPinnedFolders = HashSet<String>(pinnedFolders)
currPinnedFolders.removeAll(paths)
pinnedFolders = currPinnedFolders
}
fun addHiddenFolder(path: String) {
addHiddenFolders(HashSet<String>(Arrays.asList(path)))
}
fun addHiddenFolders(paths: Set<String>) {
val currHiddenFolders = HashSet<String>(hiddenFolders)
currHiddenFolders.addAll(paths)
hiddenFolders = currHiddenFolders
}
fun removeHiddenDirectory(path: String) {
val currHiddenFolders = HashSet<String>(hiddenFolders)
currHiddenFolders.remove(path)
hiddenFolders = currHiddenFolders
fun removeHiddenFolder(path: String) {
removeHiddenFolders(HashSet<String>(Arrays.asList(path)))
}
fun removeHiddenDirectories(paths: Set<String>) {
fun removeHiddenFolders(paths: Set<String>) {
val currHiddenFolders = HashSet<String>(hiddenFolders)
currHiddenFolders.removeAll(paths)
hiddenFolders = currHiddenFolders