allow toggling numeric sorting at folders too
This commit is contained in:
parent
e05e12bcce
commit
d6c5b96722
|
@ -61,7 +61,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.12.15'
|
implementation 'com.simplemobiletools:commons:5.12.17'
|
||||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.view.View
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
|
import com.simplemobiletools.commons.extensions.isVisible
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
|
@ -12,7 +13,7 @@ import com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.helpers.SHOW_ALL
|
import com.simplemobiletools.gallery.pro.helpers.SHOW_ALL
|
||||||
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
||||||
|
|
||||||
class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorting: Boolean, showFolderCheckbox: Boolean,
|
class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorting: Boolean, val showFolderCheckbox: Boolean,
|
||||||
val path: String = "", val callback: () -> Unit) :
|
val path: String = "", val callback: () -> Unit) :
|
||||||
DialogInterface.OnClickListener {
|
DialogInterface.OnClickListener {
|
||||||
private var currSorting = 0
|
private var currSorting = 0
|
||||||
|
@ -23,7 +24,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
|
||||||
init {
|
init {
|
||||||
currSorting = if (isDirectorySorting) config.directorySorting else config.getFileSorting(pathToUse)
|
currSorting = if (isDirectorySorting) config.directorySorting else config.getFileSorting(pathToUse)
|
||||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null).apply {
|
view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null).apply {
|
||||||
use_for_this_folder_divider.beVisibleIf(showFolderCheckbox)
|
use_for_this_folder_divider.beVisibleIf(showFolderCheckbox || (currSorting and SORT_BY_NAME != 0 || currSorting and SORT_BY_PATH != 0))
|
||||||
|
|
||||||
sorting_dialog_numeric_sorting.beVisibleIf(showFolderCheckbox && (currSorting and SORT_BY_NAME != 0 || currSorting and SORT_BY_PATH != 0))
|
sorting_dialog_numeric_sorting.beVisibleIf(showFolderCheckbox && (currSorting and SORT_BY_NAME != 0 || currSorting and SORT_BY_PATH != 0))
|
||||||
sorting_dialog_numeric_sorting.isChecked = currSorting and SORT_USE_NUMERIC_VALUE != 0
|
sorting_dialog_numeric_sorting.isChecked = currSorting and SORT_USE_NUMERIC_VALUE != 0
|
||||||
|
@ -47,7 +48,9 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
|
||||||
private fun setupSortRadio() {
|
private fun setupSortRadio() {
|
||||||
val sortingRadio = view.sorting_dialog_radio_sorting
|
val sortingRadio = view.sorting_dialog_radio_sorting
|
||||||
sortingRadio.setOnCheckedChangeListener { group, checkedId ->
|
sortingRadio.setOnCheckedChangeListener { group, checkedId ->
|
||||||
view.sorting_dialog_numeric_sorting.beVisibleIf(checkedId == sortingRadio.sorting_dialog_radio_name.id || checkedId == sortingRadio.sorting_dialog_radio_path.id)
|
val isSortingByNameOrPath = checkedId == sortingRadio.sorting_dialog_radio_name.id || checkedId == sortingRadio.sorting_dialog_radio_path.id
|
||||||
|
view.sorting_dialog_numeric_sorting.beVisibleIf(isSortingByNameOrPath)
|
||||||
|
view.use_for_this_folder_divider.beVisibleIf(view.sorting_dialog_numeric_sorting.isVisible() || view.sorting_dialog_use_for_this_folder.isVisible())
|
||||||
}
|
}
|
||||||
|
|
||||||
val sortBtn = when {
|
val sortBtn = when {
|
||||||
|
|
|
@ -165,7 +165,20 @@ fun Context.getSortedDirectories(source: ArrayList<Directory>): ArrayList<Direct
|
||||||
o1 as Directory
|
o1 as Directory
|
||||||
o2 as Directory
|
o2 as Directory
|
||||||
var result = when {
|
var result = when {
|
||||||
sorting and SORT_BY_NAME != 0 -> AlphanumericComparator().compare(o1.name.toLowerCase(), o2.name.toLowerCase())
|
sorting and SORT_BY_NAME != 0 -> {
|
||||||
|
if (sorting and SORT_USE_NUMERIC_VALUE != 0) {
|
||||||
|
AlphanumericComparator().compare(o1.name.toLowerCase(), o2.name.toLowerCase())
|
||||||
|
} else {
|
||||||
|
o1.name.toLowerCase().compareTo(o2.name.toLowerCase())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sorting and SORT_BY_PATH != 0 -> {
|
||||||
|
if (sorting and SORT_USE_NUMERIC_VALUE != 0) {
|
||||||
|
AlphanumericComparator().compare(o1.path.toLowerCase(), o2.path.toLowerCase())
|
||||||
|
} else {
|
||||||
|
o1.path.toLowerCase().compareTo(o2.path.toLowerCase())
|
||||||
|
}
|
||||||
|
}
|
||||||
sorting and SORT_BY_PATH != 0 -> AlphanumericComparator().compare(o1.path.toLowerCase(), o2.path.toLowerCase())
|
sorting and SORT_BY_PATH != 0 -> AlphanumericComparator().compare(o1.path.toLowerCase(), o2.path.toLowerCase())
|
||||||
sorting and SORT_BY_SIZE != 0 -> o1.size.compareTo(o2.size)
|
sorting and SORT_BY_SIZE != 0 -> o1.size.compareTo(o2.size)
|
||||||
sorting and SORT_BY_DATE_MODIFIED != 0 -> o1.modified.compareTo(o2.modified)
|
sorting and SORT_BY_DATE_MODIFIED != 0 -> o1.modified.compareTo(o2.modified)
|
||||||
|
|
Loading…
Reference in New Issue