allow sorting items by path

This commit is contained in:
tibbi 2017-10-18 17:56:14 +02:00
parent f85fc7c20b
commit 3033f611a1
3 changed files with 16 additions and 6 deletions

View file

@ -42,12 +42,12 @@ class ChangeSortingDialog(val activity: SimpleActivity, val isDirectorySorting:
val sortingRadio = view.sorting_dialog_radio_sorting
var sortBtn = sortingRadio.sorting_dialog_radio_name
if (currSorting and SORT_BY_SIZE != 0) {
sortBtn = sortingRadio.sorting_dialog_radio_size
} else if (currSorting and SORT_BY_DATE_MODIFIED != 0) {
sortBtn = sortingRadio.sorting_dialog_radio_last_modified
} else if (currSorting and SORT_BY_DATE_TAKEN != 0)
sortBtn = sortingRadio.sorting_dialog_radio_date_taken
when {
currSorting and SORT_BY_PATH != 0 -> sortBtn = sortingRadio.sorting_dialog_radio_path
currSorting and SORT_BY_SIZE != 0 -> sortBtn = sortingRadio.sorting_dialog_radio_size
currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortBtn = sortingRadio.sorting_dialog_radio_last_modified
currSorting and SORT_BY_DATE_TAKEN != 0 -> sortBtn = sortingRadio.sorting_dialog_radio_date_taken
}
sortBtn.isChecked = true
}
@ -65,6 +65,7 @@ class ChangeSortingDialog(val activity: SimpleActivity, val isDirectorySorting:
val sortingRadio = view.sorting_dialog_radio_sorting
var sorting = when (sortingRadio.checkedRadioButtonId) {
R.id.sorting_dialog_radio_name -> SORT_BY_NAME
R.id.sorting_dialog_radio_path -> SORT_BY_PATH
R.id.sorting_dialog_radio_size -> SORT_BY_SIZE
R.id.sorting_dialog_radio_last_modified -> SORT_BY_DATE_MODIFIED
else -> SORT_BY_DATE_TAKEN

View file

@ -14,6 +14,7 @@ data class Directory(val path: String, val tmb: String, val name: String, var me
var result: Int
when {
sorting and SORT_BY_NAME != 0 -> result = AlphanumericComparator().compare(name.toLowerCase(), other.name.toLowerCase())
sorting and SORT_BY_PATH != 0 -> result = AlphanumericComparator().compare(path.toLowerCase(), other.path.toLowerCase())
sorting and SORT_BY_SIZE != 0 -> result = when {
size == other.size -> 0
size > other.size -> 1

View file

@ -28,6 +28,14 @@
android:paddingTop="@dimen/medium_margin"
android:text="@string/name"/>
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_path"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_margin"
android:paddingTop="@dimen/medium_margin"
android:text="@string/path"/>
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_size"
android:layout_width="match_parent"