From eb20c802b2b52e6a453d5cbb1fdde26aaef4e3b9 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 10 Jan 2019 11:21:01 +0100 Subject: [PATCH] allow including videos in slideshows --- .../pro/activities/ViewPagerActivity.kt | 2 +- .../gallery/pro/dialogs/SlideshowDialog.kt | 7 ++++++ .../gallery/pro/helpers/Config.kt | 4 ++++ .../gallery/pro/helpers/Constants.kt | 1 + app/src/main/res/layout/dialog_slideshow.xml | 23 ++++++++++++++++++- 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index cda0390d8..c6811570a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -505,7 +505,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun getMediaForSlideshow(): Boolean { mSlideshowMedia = mMediaFiles.filter { - it.isImage() || (config.slideshowIncludeGIFs && it.isGIF()) + it.isImage() || (config.slideshowIncludeVideos && it.isVideo() || (config.slideshowIncludeGIFs && it.isGIF())) }.toMutableList() if (config.slideshowRandomOrder) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SlideshowDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SlideshowDialog.kt index 5e3c5f198..7ab0371a8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SlideshowDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SlideshowDialog.kt @@ -28,6 +28,11 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit activity.hideKeyboard(v) } + include_videos_holder.setOnClickListener { + interval_value.clearFocus() + include_videos.toggle() + } + include_gifs_holder.setOnClickListener { interval_value.clearFocus() include_gifs.toggle() @@ -74,6 +79,7 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit val config = activity.config view.apply { interval_value.setText(config.slideshowInterval.toString()) + include_videos.isChecked = config.slideshowIncludeVideos include_gifs.isChecked = config.slideshowIncludeGIFs random_order.isChecked = config.slideshowRandomOrder use_fade.isChecked = config.slideshowUseFade @@ -89,6 +95,7 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit activity.config.apply { slideshowInterval = interval.toInt() + slideshowIncludeVideos = view.include_videos.isChecked slideshowIncludeGIFs = view.include_gifs.isChecked slideshowRandomOrder = view.random_order.isChecked slideshowUseFade = view.use_fade.isChecked diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt index d886598a9..32467ca4b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt @@ -285,6 +285,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getInt(SLIDESHOW_INTERVAL, SLIDESHOW_DEFAULT_INTERVAL) set(slideshowInterval) = prefs.edit().putInt(SLIDESHOW_INTERVAL, slideshowInterval).apply() + var slideshowIncludeVideos: Boolean + get() = prefs.getBoolean(SLIDESHOW_INCLUDE_VIDEOS, false) + set(slideshowIncludeVideos) = prefs.edit().putBoolean(SLIDESHOW_INCLUDE_VIDEOS, slideshowIncludeVideos).apply() + var slideshowIncludeGIFs: Boolean get() = prefs.getBoolean(SLIDESHOW_INCLUDE_GIFS, false) set(slideshowIncludeGIFs) = prefs.edit().putBoolean(SLIDESHOW_INCLUDE_GIFS, slideshowIncludeGIFs).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index 8dcc57e1a..d96736b78 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -79,6 +79,7 @@ const val ALLOW_ONE_TO_ONE_ZOOM = "allow_one_to_one_zoom" // slideshow const val SLIDESHOW_INTERVAL = "slideshow_interval" +const val SLIDESHOW_INCLUDE_VIDEOS = "slideshow_include_videos" const val SLIDESHOW_INCLUDE_GIFS = "slideshow_include_gifs" const val SLIDESHOW_RANDOM_ORDER = "slideshow_random_order" const val SLIDESHOW_USE_FADE = "slideshow_use_fade" diff --git a/app/src/main/res/layout/dialog_slideshow.xml b/app/src/main/res/layout/dialog_slideshow.xml index 7915aa5dc..0bad63672 100644 --- a/app/src/main/res/layout/dialog_slideshow.xml +++ b/app/src/main/res/layout/dialog_slideshow.xml @@ -37,7 +37,7 @@ android:textSize="@dimen/normal_text_size"/> + + + + + +