Merge pull request #1025 from Pa3kSB/random-sorting
Added random sort option
This commit is contained in:
commit
9e9255af9a
|
@ -10,6 +10,7 @@ import com.simplemobiletools.commons.helpers.*
|
|||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.helpers.SHOW_ALL
|
||||
import com.simplemobiletools.gallery.helpers.SORT_BY_RANDOM
|
||||
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
||||
|
||||
class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorting: Boolean, showFolderCheckbox: Boolean,
|
||||
|
@ -47,6 +48,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
|
|||
currSorting and SORT_BY_SIZE != 0 -> sortingRadio.sorting_dialog_radio_size
|
||||
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
|
||||
else -> sortingRadio.sorting_dialog_radio_name
|
||||
}
|
||||
sortBtn.isChecked = true
|
||||
|
@ -69,6 +71,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
|
|||
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
|
||||
R.id.sorting_dialog_radio_random -> SORT_BY_RANDOM
|
||||
else -> SORT_BY_DATE_TAKEN
|
||||
}
|
||||
|
||||
|
|
|
@ -139,6 +139,11 @@ fun Context.getSortedDirectories(source: ArrayList<Directory>): ArrayList<Direct
|
|||
val sorting = config.directorySorting
|
||||
val dirs = source.clone() as ArrayList<Directory>
|
||||
|
||||
if (sorting and SORT_BY_RANDOM != 0) {
|
||||
dirs.shuffle()
|
||||
return movePinnedDirectoriesToFront(dirs)
|
||||
}
|
||||
|
||||
dirs.sortWith(Comparator { o1, o2 ->
|
||||
o1 as Directory
|
||||
o2 as Directory
|
||||
|
|
|
@ -157,3 +157,6 @@ const val BOTTOM_ACTION_RENAME = 1024
|
|||
const val BOTTOM_ACTION_SET_AS = 2048
|
||||
|
||||
const val DEFAULT_BOTTOM_ACTIONS = BOTTOM_ACTION_TOGGLE_FAVORITE or BOTTOM_ACTION_EDIT or BOTTOM_ACTION_SHARE or BOTTOM_ACTION_DELETE
|
||||
|
||||
// sorting
|
||||
const val SORT_BY_RANDOM = 16384
|
|
@ -343,7 +343,12 @@ class MediaFetcher(val context: Context) {
|
|||
return dateTakens
|
||||
}
|
||||
|
||||
fun sortMedia(media: ArrayList<Medium>, sorting: Int) {
|
||||
fun sortMedia (media: ArrayList<Medium>, sorting: Int) {
|
||||
if (sorting and SORT_BY_RANDOM != 0) {
|
||||
media.shuffle()
|
||||
return
|
||||
}
|
||||
|
||||
media.sortWith(Comparator { o1, o2 ->
|
||||
o1 as Medium
|
||||
o2 as Medium
|
||||
|
|
|
@ -60,6 +60,14 @@
|
|||
android:paddingTop="@dimen/medium_margin"
|
||||
android:text="@string/date_taken"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||
android:id="@+id/sorting_dialog_radio_random"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/medium_margin"
|
||||
android:paddingTop="@dimen/medium_margin"
|
||||
android:text="@string/random"/>
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<include
|
||||
|
|
|
@ -221,6 +221,7 @@
|
|||
|
||||
Táto aplikácia je iba jednou zo skupiny aplikácií. Ostatné viete nájsť na https://www.simplemobiletools.com
|
||||
</string>
|
||||
<string name="random">Náhodne</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
|
|
@ -221,6 +221,7 @@
|
|||
|
||||
This app is just one piece of a bigger series of apps. You can find the rest of them at https://www.simplemobiletools.com
|
||||
</string>
|
||||
<string name="random">Random</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
|
|
Loading…
Reference in New Issue