add an option to change media instantly by clicking on screen sides

This commit is contained in:
tibbi 2018-01-27 23:35:28 +01:00
parent 246c0a0453
commit 9533204a50
12 changed files with 103 additions and 10 deletions

View file

@ -24,6 +24,7 @@ import kotlinx.android.synthetic.main.fragment_holder.*
import java.io.File
open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentListener {
private var mMedium: Medium? = null
private var mIsFullScreen = false
private var mIsFromGallery = false
@ -158,4 +159,8 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
}
override fun videoEnded() = false
override fun goToPrevItem() {}
override fun goToNextItem() {}
}

View file

@ -55,6 +55,7 @@ class SettingsActivity : SimpleActivity() {
setupKeepLastModified()
setupShowInfoBubble()
setupOneFingerZoom()
setupAllowInstantChange()
setupShowExtendedDetails()
setupManageExtendedDetails()
updateTextColors(settings_holder)
@ -286,6 +287,14 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupAllowInstantChange() {
settings_allow_instant_change.isChecked = config.allowInstantChange
settings_allow_instant_change_holder.setOnClickListener {
settings_allow_instant_change.toggle()
config.allowInstantChange = settings_allow_instant_change.isChecked
}
}
private fun setupShowExtendedDetails() {
settings_show_extended_details.isChecked = config.showExtendedDetails
settings_show_extended_details_holder.setOnClickListener {

View file

@ -3,7 +3,6 @@ package com.simplemobiletools.gallery.activities
import android.animation.Animator
import android.animation.ValueAnimator
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.res.Configuration
@ -820,11 +819,20 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
}
override fun videoEnded(): Boolean {
if (mIsSlideshowActive)
if (mIsSlideshowActive) {
swipeToNextMedium()
}
return mIsSlideshowActive
}
override fun goToPrevItem() {
view_pager.setCurrentItem(view_pager.currentItem - 1, false)
}
override fun goToNextItem() {
view_pager.setCurrentItem(view_pager.currentItem + 1, false)
}
private fun checkSystemUI() {
if (mIsFullScreen) {
hideSystemUI()

View file

@ -49,7 +49,12 @@ class PhotoFragment : ViewPagerFragment() {
lateinit var medium: Medium
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
view = inflater.inflate(R.layout.pager_photo_item, container, false) as ViewGroup
view = (inflater.inflate(R.layout.pager_photo_item, container, false) as ViewGroup).apply {
subsampling_view.setOnClickListener { photoClicked() }
gif_view.setOnClickListener { photoClicked() }
instant_prev_item.setOnClickListener { listener?.goToPrevItem() }
instant_next_item.setOnClickListener { listener?.goToNextItem() }
}
if (!isFragmentVisible && activity is PhotoActivity) {
isFragmentVisible = true
@ -88,11 +93,8 @@ class PhotoFragment : ViewPagerFragment() {
}
isFullscreen = activity!!.window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == View.SYSTEM_UI_FLAG_FULLSCREEN
view.subsampling_view.setOnClickListener { photoClicked() }
view.gif_view.setOnClickListener { photoClicked() }
loadImage()
checkExtendedDetails()
wasInit = true
return view
@ -109,6 +111,10 @@ class PhotoFragment : ViewPagerFragment() {
if (wasInit && (context!!.config.showExtendedDetails != storedShowExtendedDetails || context!!.config.extendedDetails != storedExtendedDetails)) {
checkExtendedDetails()
}
val allowInstantChange = context!!.config.allowInstantChange
view.instant_prev_item.beVisibleIf(allowInstantChange)
view.instant_next_item.beVisibleIf(allowInstantChange)
}
override fun setMenuVisibility(menuVisible: Boolean) {

View file

@ -66,8 +66,12 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
lateinit var medium: Medium
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
mView = inflater.inflate(R.layout.pager_video_item, container, false)
mTimeHolder = mView!!.video_time_holder
mView = inflater.inflate(R.layout.pager_video_item, container, false).apply {
instant_prev_item.setOnClickListener { listener?.goToPrevItem() }
instant_next_item.setOnClickListener { listener?.goToNextItem() }
mTimeHolder = video_time_holder
}
medium = arguments!!.getSerializable(MEDIUM) as Medium
// setMenuVisibility is not called at VideoActivity (third party intent)
@ -90,8 +94,15 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
override fun onResume() {
super.onResume()
activity!!.updateTextColors(mView!!.video_holder)
mView!!.video_volume_controller.beVisibleIf(context!!.config.allowVideoGestures)
mView!!.video_brightness_controller.beVisibleIf(context!!.config.allowVideoGestures)
val allowVideoGestures = context!!.config.allowVideoGestures
val allowInstantChange = context!!.config.allowInstantChange
mView!!.apply {
video_volume_controller.beVisibleIf(allowVideoGestures)
video_brightness_controller.beVisibleIf(allowVideoGestures)
instant_prev_item.beVisibleIf(allowInstantChange)
instant_next_item.beVisibleIf(allowInstantChange)
}
if (context!!.config.showExtendedDetails != mStoredShowExtendedDetails || context!!.config.extendedDetails != mStoredExtendedDetails) {
checkExtendedDetails()

View file

@ -16,6 +16,10 @@ abstract class ViewPagerFragment : Fragment() {
fun fragmentClicked()
fun videoEnded(): Boolean
fun goToPrevItem()
fun goToNextItem()
}
fun getMediumExtendedDetails(medium: Medium): String {

View file

@ -172,6 +172,10 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getBoolean(ONE_FINGER_ZOOM, false)
set(oneFingerZoom) = prefs.edit().putBoolean(ONE_FINGER_ZOOM, oneFingerZoom).apply()
var allowInstantChange: Boolean
get() = prefs.getBoolean(ALLOW_INSTANT_CHANGE, false)
set(allowInstantChange) = prefs.edit().putBoolean(ALLOW_INSTANT_CHANGE, allowInstantChange).apply()
private fun getDirectoryColumnsField(): String {
val isPortrait = context.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
return if (isPortrait) {

View file

@ -44,6 +44,7 @@ val SHOW_EXTENDED_DETAILS = "show_extended_details"
val EXTENDED_DETAILS = "extended_details"
val LAST_FILE_CLEANUP = "last_file_cleanup"
val ONE_FINGER_ZOOM = "one_finger_zoom"
val ALLOW_INSTANT_CHANGE = "allow_instant_change"
// slideshow
val SLIDESHOW_INTERVAL = "slideshow_interval"

View file

@ -477,6 +477,26 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_allow_instant_change_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_allow_instant_change"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingLeft="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin"
android:text="@string/allow_instant_change"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_show_extended_details_holder"
android:layout_width="match_parent"

View file

@ -31,4 +31,16 @@
android:visibility="gone"
tools:text="My image\nAnother line"/>
<RelativeLayout
android:id="@+id/instant_prev_item"
android:layout_width="@dimen/instant_change_bar_width"
android:layout_height="match_parent"/>
<RelativeLayout
android:id="@+id/instant_next_item"
android:layout_width="@dimen/instant_change_bar_width"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>

View file

@ -25,6 +25,18 @@
android:layout_width="@dimen/video_side_slider_width"
android:layout_height="match_parent"/>
<RelativeLayout
android:id="@+id/instant_prev_item"
android:layout_width="@dimen/instant_change_bar_width"
android:layout_height="match_parent"/>
<RelativeLayout
android:id="@+id/instant_next_item"
android:layout_width="@dimen/instant_change_bar_width"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
<ImageView
android:id="@+id/video_play_outline"
android:layout_width="@dimen/play_outline_size_big"

View file

@ -9,5 +9,6 @@
<dimen name="timer_padding">24dp</dimen>
<dimen name="tmb_shadow_height">50dp</dimen>
<dimen name="video_side_slider_width">150dp</dimen>
<dimen name="instant_change_bar_width">60dp</dimen>
<dimen name="list_view_folder_thumbnail_size">72dp</dimen>
</resources>