mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
use the new radio group dialog for Show Media picking
This commit is contained in:
parent
739e1c01a8
commit
ee32c1ab3a
4 changed files with 14 additions and 82 deletions
|
@ -32,7 +32,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.simplemobiletools:commons:2.9.4'
|
||||
compile 'com.simplemobiletools:commons:2.9.8'
|
||||
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
|
||||
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
|
||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||
|
|
|
@ -1,20 +1,26 @@
|
|||
package com.simplemobiletools.gallery.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.res.Resources
|
||||
import android.os.Bundle
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.dialogs.ShowMediaDialog
|
||||
import com.simplemobiletools.gallery.extensions.beVisibleIf
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.helpers.IMAGES
|
||||
import com.simplemobiletools.gallery.helpers.IMAGES_AND_VIDEOS
|
||||
import com.simplemobiletools.gallery.helpers.VIDEOS
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
lateinit var res: Resources
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings)
|
||||
res = resources
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -80,7 +86,12 @@ class SettingsActivity : SimpleActivity() {
|
|||
private fun setupShowMedia() {
|
||||
settings_show_media.text = getShowMediaText()
|
||||
settings_show_media_holder.setOnClickListener {
|
||||
ShowMediaDialog(this) {
|
||||
val items = arrayListOf(
|
||||
RadioItem(IMAGES_AND_VIDEOS, res.getString(R.string.images_and_videos)),
|
||||
RadioItem(IMAGES, res.getString(R.string.images)),
|
||||
RadioItem(VIDEOS, res.getString(R.string.videos)))
|
||||
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.showMedia) {
|
||||
config.showMedia = it
|
||||
settings_show_media.text = getShowMediaText()
|
||||
}
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
package com.simplemobiletools.gallery.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.RadioGroup
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.helpers.IMAGES
|
||||
import com.simplemobiletools.gallery.helpers.IMAGES_AND_VIDEOS
|
||||
import com.simplemobiletools.gallery.helpers.VIDEOS
|
||||
import kotlinx.android.synthetic.main.dialog_show_media.view.*
|
||||
|
||||
class ShowMediaDialog(val activity: Activity, val callback: (newValue: Int) -> Unit) : AlertDialog.Builder(activity), RadioGroup.OnCheckedChangeListener {
|
||||
val dialog: AlertDialog?
|
||||
|
||||
init {
|
||||
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_show_media, null).dialog_radio_view.apply {
|
||||
check(getSavedItem())
|
||||
setOnCheckedChangeListener(this@ShowMediaDialog)
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCheckedChanged(group: RadioGroup?, checkedId: Int) {
|
||||
callback.invoke(getNewValue(checkedId))
|
||||
dialog?.dismiss()
|
||||
}
|
||||
|
||||
fun getNewValue(id: Int) = when (id) {
|
||||
R.id.dialog_radio_images -> IMAGES
|
||||
R.id.dialog_radio_videos -> VIDEOS
|
||||
else -> IMAGES_AND_VIDEOS
|
||||
}
|
||||
|
||||
fun getSavedItem() = when (activity.config.showMedia) {
|
||||
IMAGES -> R.id.dialog_radio_images
|
||||
VIDEOS -> R.id.dialog_radio_videos
|
||||
else -> R.id.dialog_radio_images_and_videos
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RadioGroup
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/dialog_radio_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||
android:id="@+id/dialog_radio_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.MyCompatRadioButton
|
||||
android:id="@+id/dialog_radio_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.MyCompatRadioButton
|
||||
android:id="@+id/dialog_radio_images_and_videos"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/images_and_videos"/>
|
||||
|
||||
</RadioGroup>
|
Loading…
Reference in a new issue