allow sorting items by proper numeric values in their names
This commit is contained in:
parent
809984c89e
commit
e665c38f05
4 changed files with 40 additions and 11 deletions
|
@ -58,7 +58,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.28.24'
|
||||
implementation 'com.simplemobiletools:commons:5.29.1'
|
||||
implementation 'com.github.Stericson:RootTools:df729dcb13'
|
||||
implementation 'com.github.Stericson:RootShell:1.6'
|
||||
implementation 'com.alexvasilkov:gesture-views:2.5.2'
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.simplemobiletools.filemanager.pro.dialogs
|
||||
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.filemanager.pro.R
|
||||
|
@ -11,25 +13,36 @@ import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
|||
class ChangeSortingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) {
|
||||
private var currSorting = 0
|
||||
private var config = activity.config
|
||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null)
|
||||
private var view: View
|
||||
|
||||
init {
|
||||
view.sorting_dialog_use_for_this_folder.isChecked = config.hasCustomSorting(path)
|
||||
currSorting = config.getFolderSorting(path)
|
||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null).apply {
|
||||
sorting_dialog_use_for_this_folder.isChecked = config.hasCustomSorting(path)
|
||||
|
||||
sorting_dialog_numeric_sorting.beVisibleIf(currSorting and SORT_BY_NAME != 0)
|
||||
sorting_dialog_numeric_sorting.isChecked = currSorting and SORT_USE_NUMERIC_VALUE != 0
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.sort_by)
|
||||
}
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.sort_by)
|
||||
}
|
||||
|
||||
currSorting = config.getFolderSorting(path)
|
||||
setupSortRadio()
|
||||
setupOrderRadio()
|
||||
}
|
||||
|
||||
private fun setupSortRadio() {
|
||||
val sortingRadio = view.sorting_dialog_radio_sorting
|
||||
|
||||
sortingRadio.setOnCheckedChangeListener { group, checkedId ->
|
||||
val isSortingByName = checkedId == sortingRadio.sorting_dialog_radio_name.id
|
||||
view.sorting_dialog_numeric_sorting.beVisibleIf(isSortingByName)
|
||||
}
|
||||
|
||||
val sortBtn = when {
|
||||
currSorting and SORT_BY_SIZE != 0 -> sortingRadio.sorting_dialog_radio_size
|
||||
currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortingRadio.sorting_dialog_radio_last_modified
|
||||
|
@ -62,6 +75,10 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val path: String = "
|
|||
sorting = sorting or SORT_DESCENDING
|
||||
}
|
||||
|
||||
if (view.sorting_dialog_numeric_sorting.isChecked) {
|
||||
sorting = sorting or SORT_USE_NUMERIC_VALUE
|
||||
}
|
||||
|
||||
if (view.sorting_dialog_use_for_this_folder.isChecked) {
|
||||
config.saveCustomSorting(path, sorting)
|
||||
} else {
|
||||
|
|
|
@ -83,12 +83,21 @@
|
|||
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:layout_marginTop="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/normal_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"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/normal_margin"
|
||||
android:text="@string/use_for_this_folder" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
3
app/src/main/res/values/integers.xml
Normal file
3
app/src/main/res/values/integers.xml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<integer name="default_sorting">32769</integer>
|
||||
</resources>
|
Loading…
Reference in a new issue