diff --git a/app/build.gradle b/app/build.gradle index bd927d8d..e50aed0b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/ChangeSortingDialog.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/ChangeSortingDialog.kt index ef1452a9..9ab985d6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/ChangeSortingDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/dialogs/ChangeSortingDialog.kt @@ -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 { diff --git a/app/src/main/res/layout/dialog_change_sorting.xml b/app/src/main/res/layout/dialog_change_sorting.xml index cf08d0ac..475e7a96 100644 --- a/app/src/main/res/layout/dialog_change_sorting.xml +++ b/app/src/main/res/layout/dialog_change_sorting.xml @@ -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> diff --git a/app/src/main/res/values/integers.xml b/app/src/main/res/values/integers.xml new file mode 100644 index 00000000..1ea0ea21 --- /dev/null +++ b/app/src/main/res/values/integers.xml @@ -0,0 +1,3 @@ +<resources> + <integer name="default_sorting">32769</integer> +</resources>