mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
fix #983, add an option for showing the Recycle Bin as the last folder
This commit is contained in:
parent
66cd5dad3e
commit
af8133b8b2
6 changed files with 59 additions and 6 deletions
|
@ -768,7 +768,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
|
||||
val foldersToScan = mediaFetcher.getFoldersToScan()
|
||||
foldersToScan.add(FAVORITES)
|
||||
if (config.showRecycleBinAtFolders) {
|
||||
if (config.useRecycleBin && config.showRecycleBinAtFolders) {
|
||||
foldersToScan.add(RECYCLE_BIN)
|
||||
} else {
|
||||
foldersToScan.remove(RECYCLE_BIN)
|
||||
|
|
|
@ -18,10 +18,7 @@ import com.simplemobiletools.gallery.extensions.config
|
|||
import com.simplemobiletools.gallery.extensions.emptyTheRecycleBin
|
||||
import com.simplemobiletools.gallery.extensions.galleryDB
|
||||
import com.simplemobiletools.gallery.extensions.showRecycleBinEmptyingDialog
|
||||
import com.simplemobiletools.gallery.helpers.DEFAULT_BOTTOM_ACTIONS
|
||||
import com.simplemobiletools.gallery.helpers.ROTATE_BY_ASPECT_RATIO
|
||||
import com.simplemobiletools.gallery.helpers.ROTATE_BY_DEVICE_ROTATION
|
||||
import com.simplemobiletools.gallery.helpers.ROTATE_BY_SYSTEM_SETTING
|
||||
import com.simplemobiletools.gallery.helpers.*
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import java.util.*
|
||||
|
||||
|
@ -77,6 +74,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupManageBottomActions()
|
||||
setupUseRecycleBin()
|
||||
setupShowRecycleBin()
|
||||
setupShowRecycleBinLast()
|
||||
setupEmptyRecycleBin()
|
||||
updateTextColors(settings_holder)
|
||||
setupSectionColors()
|
||||
|
@ -459,11 +457,14 @@ class SettingsActivity : SimpleActivity() {
|
|||
private fun setupUseRecycleBin() {
|
||||
settings_empty_recycle_bin_holder.beVisibleIf(config.useRecycleBin)
|
||||
settings_show_recycle_bin_holder.beVisibleIf(config.useRecycleBin)
|
||||
settings_show_recycle_bin_last_holder.beVisibleIf(config.useRecycleBin && config.showRecycleBinAtFolders)
|
||||
settings_use_recycle_bin.isChecked = config.useRecycleBin
|
||||
settings_use_recycle_bin_holder.setOnClickListener {
|
||||
settings_use_recycle_bin.toggle()
|
||||
config.useRecycleBin = settings_use_recycle_bin.isChecked
|
||||
settings_empty_recycle_bin_holder.beVisibleIf(config.useRecycleBin)
|
||||
settings_show_recycle_bin_holder.beVisibleIf(config.useRecycleBin)
|
||||
settings_show_recycle_bin_last_holder.beVisibleIf(config.useRecycleBin && config.showRecycleBinAtFolders)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -472,6 +473,18 @@ class SettingsActivity : SimpleActivity() {
|
|||
settings_show_recycle_bin_holder.setOnClickListener {
|
||||
settings_show_recycle_bin.toggle()
|
||||
config.showRecycleBinAtFolders = settings_show_recycle_bin.isChecked
|
||||
settings_show_recycle_bin_last_holder.beVisibleIf(config.useRecycleBin && config.showRecycleBinAtFolders)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowRecycleBinLast() {
|
||||
settings_show_recycle_bin_last.isChecked = config.showRecycleBinLast
|
||||
settings_show_recycle_bin_last_holder.setOnClickListener {
|
||||
settings_show_recycle_bin_last.toggle()
|
||||
config.showRecycleBinLast = settings_show_recycle_bin_last.isChecked
|
||||
if (config.showRecycleBinLast) {
|
||||
config.removePinnedFolders(setOf(RECYCLE_BIN))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,6 +123,14 @@ fun Context.movePinnedDirectoriesToFront(dirs: ArrayList<Directory>): ArrayList<
|
|||
dirs.add(0, newFolder)
|
||||
}
|
||||
}
|
||||
|
||||
if (config.useRecycleBin && config.showRecycleBinAtFolders && config.showRecycleBinLast) {
|
||||
val binIndex = dirs.indexOfFirst { it.isRecycleBin() }
|
||||
if (binIndex != -1) {
|
||||
val bin = dirs.removeAt(binIndex)
|
||||
dirs.add(bin)
|
||||
}
|
||||
}
|
||||
return dirs
|
||||
}
|
||||
|
||||
|
@ -334,7 +342,7 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly:
|
|||
ArrayList<Directory>()
|
||||
}
|
||||
|
||||
if (!config.showRecycleBinAtFolders) {
|
||||
if (!config.showRecycleBinAtFolders || !config.useRecycleBin) {
|
||||
directories.removeAll { it.isRecycleBin() }
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,9 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
val currPinnedFolders = HashSet<String>(pinnedFolders)
|
||||
currPinnedFolders.addAll(paths)
|
||||
pinnedFolders = currPinnedFolders
|
||||
if (paths.contains(RECYCLE_BIN)) {
|
||||
showRecycleBinLast = false
|
||||
}
|
||||
}
|
||||
|
||||
fun removePinnedFolders(paths: Set<String>) {
|
||||
|
@ -392,4 +395,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
var showHighestQuality: Boolean
|
||||
get() = prefs.getBoolean(SHOW_HIGHEST_QUALITY, false)
|
||||
set(showHighestQuality) = prefs.edit().putBoolean(SHOW_HIGHEST_QUALITY, showHighestQuality).apply()
|
||||
|
||||
var showRecycleBinLast: Boolean
|
||||
get() = prefs.getBoolean(SHOW_RECYCLE_BIN_LAST, false)
|
||||
set(showRecycleBinLast) = prefs.edit().putBoolean(SHOW_RECYCLE_BIN_LAST, showRecycleBinLast).apply()
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ const val USE_RECYCLE_BIN = "use_recycle_bin"
|
|||
const val GROUP_BY = "group_by"
|
||||
const val EVER_SHOWN_FOLDERS = "ever_shown_folders"
|
||||
const val SHOW_RECYCLE_BIN_AT_FOLDERS = "show_recycle_bin_at_folders"
|
||||
const val SHOW_RECYCLE_BIN_LAST = "show_recycle_bin_last"
|
||||
const val ALLOW_ZOOMING_IMAGES = "allow_zooming_images"
|
||||
const val WAS_SVG_SHOWING_HANDLED = "was_svg_showing_handled"
|
||||
const val LAST_BIN_CHECK = "last_bin_check"
|
||||
|
|
|
@ -1141,6 +1141,30 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_show_recycle_bin_last_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_show_recycle_bin_last"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:text="@string/show_recycle_bin_last"
|
||||
app:switchPadding="@dimen/medium_margin"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_empty_recycle_bin_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in a new issue