mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
adding the Filter Media dialog
This commit is contained in:
parent
272d45b3f4
commit
d954dc0d5a
4 changed files with 90 additions and 2 deletions
|
@ -25,6 +25,7 @@ import com.simplemobiletools.gallery.R
|
|||
import com.simplemobiletools.gallery.adapters.DirectoryAdapter
|
||||
import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask
|
||||
import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog
|
||||
import com.simplemobiletools.gallery.dialogs.FilterMediaDialog
|
||||
import com.simplemobiletools.gallery.extensions.*
|
||||
import com.simplemobiletools.gallery.helpers.*
|
||||
import com.simplemobiletools.gallery.models.Directory
|
||||
|
@ -203,7 +204,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
}
|
||||
|
||||
private fun showFilterMediaDialog() {
|
||||
|
||||
FilterMediaDialog(this) {
|
||||
getDirectories()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showAllMedia() {
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.simplemobiletools.gallery.adapters.MediaAdapter
|
|||
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
|
||||
import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog
|
||||
import com.simplemobiletools.gallery.dialogs.ExcludeFolderDialog
|
||||
import com.simplemobiletools.gallery.dialogs.FilterMediaDialog
|
||||
import com.simplemobiletools.gallery.extensions.*
|
||||
import com.simplemobiletools.gallery.helpers.*
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
|
@ -235,7 +236,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
}
|
||||
|
||||
private fun showFilterMediaDialog() {
|
||||
|
||||
FilterMediaDialog(this) {
|
||||
getMedia()
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleFilenameVisibility() {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.simplemobiletools.gallery.dialogs
|
||||
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.helpers.GIFS
|
||||
import com.simplemobiletools.gallery.helpers.IMAGES
|
||||
import com.simplemobiletools.gallery.helpers.VIDEOS
|
||||
import kotlinx.android.synthetic.main.dialog_filter_media.view.*
|
||||
|
||||
class FilterMediaDialog(val activity: SimpleActivity, val callback: (result: Int) -> Unit) {
|
||||
private var view: View = LayoutInflater.from(activity).inflate(R.layout.dialog_filter_media, null)
|
||||
|
||||
init {
|
||||
val filterMedia = activity.config.filterMedia
|
||||
view.apply {
|
||||
filter_media_images.isChecked = filterMedia and IMAGES != 0
|
||||
filter_media_videos.isChecked = filterMedia and VIDEOS != 0
|
||||
filter_media_gifs.isChecked = filterMedia and GIFS != 0
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, { dialog, which -> dialogConfirmed() })
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.filter_media)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dialogConfirmed() {
|
||||
var result = 0
|
||||
if (view.filter_media_images.isChecked)
|
||||
result += IMAGES
|
||||
if (view.filter_media_videos.isChecked)
|
||||
result += VIDEOS
|
||||
if (view.filter_media_gifs.isChecked)
|
||||
result += GIFS
|
||||
|
||||
activity.config.filterMedia = result
|
||||
callback(result)
|
||||
}
|
||||
}
|
36
app/src/main/res/layout/dialog_filter_media.xml
Normal file
36
app/src/main/res/layout/dialog_filter_media.xml
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/filter_media_dialog_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/filter_media_images"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/images"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/filter_media_videos"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/videos"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/filter_media_gifs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/gifs"/>
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in a new issue