mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
add an option to loop slideshows
This commit is contained in:
parent
afa72a1aad
commit
8ea418dad6
5 changed files with 47 additions and 2 deletions
|
@ -301,8 +301,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
view_pager.endFakeDrag()
|
||||
|
||||
if (view_pager.currentItem == oldPosition) {
|
||||
stopSlideshow()
|
||||
toast(R.string.slideshow_ended)
|
||||
slideshowEnded(forward)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,6 +329,19 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
animator.start()
|
||||
}
|
||||
|
||||
private fun slideshowEnded(forward: Boolean) {
|
||||
if (config.loopSlideshow) {
|
||||
if (forward) {
|
||||
view_pager.setCurrentItem(0, false)
|
||||
} else {
|
||||
view_pager.setCurrentItem(view_pager.adapter!!.count - 1, false)
|
||||
}
|
||||
} else {
|
||||
stopSlideshow()
|
||||
toast(R.string.slideshow_ended)
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopSlideshow() {
|
||||
if (mIsSlideshowActive) {
|
||||
showSystemUI()
|
||||
|
|
|
@ -61,6 +61,11 @@ class SlideshowDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
|||
interval_value.clearFocus()
|
||||
move_backwards.toggle()
|
||||
}
|
||||
|
||||
loop_slideshow_holder.setOnClickListener {
|
||||
interval_value.clearFocus()
|
||||
loop_slideshow.toggle()
|
||||
}
|
||||
}
|
||||
setupValues()
|
||||
|
||||
|
@ -93,6 +98,7 @@ class SlideshowDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
|||
random_order.isChecked = config.slideshowRandomOrder
|
||||
use_fade.isChecked = config.slideshowUseFade
|
||||
move_backwards.isChecked = config.slideshowMoveBackwards
|
||||
loop_slideshow.isChecked = config.loopSlideshow
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,6 +115,7 @@ class SlideshowDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
|||
slideshowRandomOrder = view.random_order.isChecked
|
||||
slideshowUseFade = view.use_fade.isChecked
|
||||
slideshowMoveBackwards = view.move_backwards.isChecked
|
||||
loopSlideshow = view.loop_slideshow.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -272,4 +272,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
var slideshowMoveBackwards: Boolean
|
||||
get() = prefs.getBoolean(SLIDESHOW_MOVE_BACKWARDS, false)
|
||||
set(slideshowMoveBackwards) = prefs.edit().putBoolean(SLIDESHOW_MOVE_BACKWARDS, slideshowMoveBackwards).apply()
|
||||
|
||||
var loopSlideshow: Boolean
|
||||
get() = prefs.getBoolean(SLIDESHOW_LOOP, false)
|
||||
set(loopSlideshow) = prefs.edit().putBoolean(SLIDESHOW_LOOP, loopSlideshow).apply()
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ val SLIDESHOW_INCLUDE_GIFS = "slideshow_include_gifs"
|
|||
val SLIDESHOW_RANDOM_ORDER = "slideshow_random_order"
|
||||
val SLIDESHOW_USE_FADE = "slideshow_use_fade"
|
||||
val SLIDESHOW_MOVE_BACKWARDS = "slideshow_move_backwards"
|
||||
val SLIDESHOW_LOOP = "loop_slideshow"
|
||||
val SLIDESHOW_DEFAULT_INTERVAL = 5
|
||||
val SLIDESHOW_SCROLL_DURATION = 500L
|
||||
|
||||
|
|
|
@ -161,5 +161,26 @@
|
|||
android:text="@string/move_backwards"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/loop_slideshow_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/move_backwards_holder"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/loop_slideshow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:text="@string/loop_slideshow"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
</ScrollView>
|
||||
|
|
Loading…
Reference in a new issue