add Custom sorting at the sorting dialog

This commit is contained in:
tibbi 2021-05-13 19:10:31 +02:00
parent 5dcad025bb
commit 552c98c270
3 changed files with 31 additions and 15 deletions

View file

@ -178,6 +178,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
val reorderedFoldersList = dirs.map { it.path }
config.customFoldersOrder = TextUtils.join("|||", reorderedFoldersList)
config.directorySorting = SORT_BY_CUSTOM
}
isChangingOrder = false

View file

@ -32,6 +32,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
sorting_dialog_use_for_this_folder.beVisibleIf(showFolderCheckbox)
sorting_dialog_use_for_this_folder.isChecked = config.hasCustomSorting(pathToUse)
sorting_dialog_bottom_note.beVisibleIf(!isDirectorySorting)
sorting_dialog_radio_custom.beVisibleIf(isDirectorySorting)
}
AlertDialog.Builder(activity)
@ -51,6 +52,10 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
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 isCustomSorting = checkedId == sortingRadio.sorting_dialog_radio_custom.id
view.sorting_dialog_radio_order.beVisibleIf(!isCustomSorting)
view.sorting_dialog_order_divider.beVisibleIf(!isCustomSorting)
}
val sortBtn = when {
@ -59,6 +64,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortingRadio.sorting_dialog_radio_last_modified
currSorting and SORT_BY_DATE_TAKEN != 0 -> sortingRadio.sorting_dialog_radio_date_taken
currSorting and SORT_BY_RANDOM != 0 -> sortingRadio.sorting_dialog_radio_random
currSorting and SORT_BY_CUSTOM != 0 -> sortingRadio.sorting_dialog_radio_custom
else -> sortingRadio.sorting_dialog_radio_name
}
sortBtn.isChecked = true
@ -82,6 +88,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
R.id.sorting_dialog_radio_size -> SORT_BY_SIZE
R.id.sorting_dialog_radio_last_modified -> SORT_BY_DATE_MODIFIED
R.id.sorting_dialog_radio_random -> SORT_BY_RANDOM
R.id.sorting_dialog_radio_custom -> SORT_BY_CUSTOM
else -> SORT_BY_DATE_TAKEN
}

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sorting_dialog_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -68,9 +67,18 @@
android:paddingBottom="@dimen/medium_margin"
android:text="@string/random" />
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_custom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/custom" />
</RadioGroup>
<include
android:id="@+id/sorting_dialog_order_divider"
layout="@layout/divider" />
<RadioGroup