fix #1400, allow toggling numeric sorting at numbers

This commit is contained in:
tibbi 2019-05-05 21:39:10 +02:00
parent 7f03b85e1b
commit 4812dff077
3 changed files with 32 additions and 4 deletions

View File

@ -21,11 +21,16 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
private var view: View
init {
currSorting = if (isDirectorySorting) config.directorySorting else config.getFileSorting(pathToUse)
view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null).apply {
use_for_this_folder_divider.beVisibleIf(showFolderCheckbox)
sorting_dialog_numeric_sorting.beVisibleIf(showFolderCheckbox)
sorting_dialog_numeric_sorting.isChecked = currSorting and SORT_USE_NUMERIC_VALUE != 0
sorting_dialog_use_for_this_folder.beVisibleIf(showFolderCheckbox)
sorting_dialog_bottom_note.beVisibleIf(!isDirectorySorting)
sorting_dialog_use_for_this_folder.isChecked = config.hasCustomSorting(pathToUse)
sorting_dialog_bottom_note.beVisibleIf(!isDirectorySorting)
}
AlertDialog.Builder(activity)
@ -35,7 +40,6 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
activity.setupDialogStuff(view, this, R.string.sort_by)
}
currSorting = if (isDirectorySorting) config.directorySorting else config.getFileSorting(pathToUse)
setupSortRadio()
setupOrderRadio()
}
@ -79,6 +83,10 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
sorting = sorting or SORT_DESCENDING
}
if (view.sorting_dialog_numeric_sorting.isChecked) {
sorting = sorting or SORT_USE_NUMERIC_VALUE
}
if (isDirectorySorting) {
config.directorySorting = sorting
} else {

View File

@ -287,8 +287,20 @@ class MediaFetcher(val context: Context) {
o1 as Medium
o2 as Medium
var result = when {
sorting and SORT_BY_NAME != 0 -> AlphanumericComparator().compare(o1.name.toLowerCase(), o2.name.toLowerCase())
sorting and SORT_BY_PATH != 0 -> AlphanumericComparator().compare(o1.path.toLowerCase(), o2.path.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_SIZE != 0 -> o1.size.compareTo(o2.size)
sorting and SORT_BY_DATE_MODIFIED != 0 -> o1.modified.compareTo(o2.modified)
else -> o1.taken.compareTo(o2.taken)

View File

@ -101,6 +101,14 @@
android:id="@+id/use_for_this_folder_divider"
layout="@layout/divider"/>
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/sorting_dialog_numeric_sorting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/sort_numeric_parts"/>
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/sorting_dialog_use_for_this_folder"
android:layout_width="match_parent"