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">
@ -26,7 +25,7 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/name"/>
android:text="@string/name" />
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_path"
@ -34,7 +33,7 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/path"/>
android:text="@string/path" />
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_size"
@ -42,7 +41,7 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/size"/>
android:text="@string/size" />
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_last_modified"
@ -50,7 +49,7 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/last_modified"/>
android:text="@string/last_modified" />
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_date_taken"
@ -58,7 +57,7 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/date_taken"/>
android:text="@string/date_taken" />
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_random"
@ -66,12 +65,21 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/random"/>
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
layout="@layout/divider"/>
android:id="@+id/sorting_dialog_order_divider"
layout="@layout/divider" />
<RadioGroup
android:id="@+id/sorting_dialog_radio_order"
@ -86,7 +94,7 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/ascending"/>
android:text="@string/ascending" />
<com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_descending"
@ -94,12 +102,12 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/descending"/>
android:text="@string/descending" />
</RadioGroup>
<include
android:id="@+id/use_for_this_folder_divider"
layout="@layout/divider"/>
layout="@layout/divider" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/sorting_dialog_numeric_sorting"
@ -107,7 +115,7 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/sort_numeric_parts"/>
android:text="@string/sort_numeric_parts" />
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/sorting_dialog_use_for_this_folder"
@ -115,7 +123,7 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/use_for_this_folder"/>
android:text="@string/use_for_this_folder" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/sorting_dialog_bottom_note"
@ -124,7 +132,7 @@
android:paddingStart="@dimen/small_margin"
android:paddingEnd="@dimen/medium_margin"
android:text="@string/grouping_and_sorting"
android:textSize="@dimen/smaller_text_size"/>
android:textSize="@dimen/smaller_text_size" />
</LinearLayout>
</ScrollView>