mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-27 06:57:59 +01:00
add an option to change media instantly by clicking on screen sides
This commit is contained in:
parent
246c0a0453
commit
9533204a50
12 changed files with 103 additions and 10 deletions
|
@ -24,6 +24,7 @@ import kotlinx.android.synthetic.main.fragment_holder.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentListener {
|
open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentListener {
|
||||||
|
|
||||||
private var mMedium: Medium? = null
|
private var mMedium: Medium? = null
|
||||||
private var mIsFullScreen = false
|
private var mIsFullScreen = false
|
||||||
private var mIsFromGallery = false
|
private var mIsFromGallery = false
|
||||||
|
@ -158,4 +159,8 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun videoEnded() = false
|
override fun videoEnded() = false
|
||||||
|
|
||||||
|
override fun goToPrevItem() {}
|
||||||
|
|
||||||
|
override fun goToNextItem() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
setupKeepLastModified()
|
setupKeepLastModified()
|
||||||
setupShowInfoBubble()
|
setupShowInfoBubble()
|
||||||
setupOneFingerZoom()
|
setupOneFingerZoom()
|
||||||
|
setupAllowInstantChange()
|
||||||
setupShowExtendedDetails()
|
setupShowExtendedDetails()
|
||||||
setupManageExtendedDetails()
|
setupManageExtendedDetails()
|
||||||
updateTextColors(settings_holder)
|
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() {
|
private fun setupShowExtendedDetails() {
|
||||||
settings_show_extended_details.isChecked = config.showExtendedDetails
|
settings_show_extended_details.isChecked = config.showExtendedDetails
|
||||||
settings_show_extended_details_holder.setOnClickListener {
|
settings_show_extended_details_holder.setOnClickListener {
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.simplemobiletools.gallery.activities
|
||||||
import android.animation.Animator
|
import android.animation.Animator
|
||||||
import android.animation.ValueAnimator
|
import android.animation.ValueAnimator
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.ActivityInfo
|
import android.content.pm.ActivityInfo
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
@ -820,11 +819,20 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun videoEnded(): Boolean {
|
override fun videoEnded(): Boolean {
|
||||||
if (mIsSlideshowActive)
|
if (mIsSlideshowActive) {
|
||||||
swipeToNextMedium()
|
swipeToNextMedium()
|
||||||
|
}
|
||||||
return mIsSlideshowActive
|
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() {
|
private fun checkSystemUI() {
|
||||||
if (mIsFullScreen) {
|
if (mIsFullScreen) {
|
||||||
hideSystemUI()
|
hideSystemUI()
|
||||||
|
|
|
@ -49,7 +49,12 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
lateinit var medium: Medium
|
lateinit var medium: Medium
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
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) {
|
if (!isFragmentVisible && activity is PhotoActivity) {
|
||||||
isFragmentVisible = true
|
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
|
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()
|
loadImage()
|
||||||
checkExtendedDetails()
|
checkExtendedDetails()
|
||||||
|
|
||||||
wasInit = true
|
wasInit = true
|
||||||
|
|
||||||
return view
|
return view
|
||||||
|
@ -109,6 +111,10 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
if (wasInit && (context!!.config.showExtendedDetails != storedShowExtendedDetails || context!!.config.extendedDetails != storedExtendedDetails)) {
|
if (wasInit && (context!!.config.showExtendedDetails != storedShowExtendedDetails || context!!.config.extendedDetails != storedExtendedDetails)) {
|
||||||
checkExtendedDetails()
|
checkExtendedDetails()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val allowInstantChange = context!!.config.allowInstantChange
|
||||||
|
view.instant_prev_item.beVisibleIf(allowInstantChange)
|
||||||
|
view.instant_next_item.beVisibleIf(allowInstantChange)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setMenuVisibility(menuVisible: Boolean) {
|
override fun setMenuVisibility(menuVisible: Boolean) {
|
||||||
|
|
|
@ -66,8 +66,12 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
||||||
lateinit var medium: Medium
|
lateinit var medium: Medium
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
mView = inflater.inflate(R.layout.pager_video_item, container, false)
|
mView = inflater.inflate(R.layout.pager_video_item, container, false).apply {
|
||||||
mTimeHolder = mView!!.video_time_holder
|
instant_prev_item.setOnClickListener { listener?.goToPrevItem() }
|
||||||
|
instant_next_item.setOnClickListener { listener?.goToNextItem() }
|
||||||
|
mTimeHolder = video_time_holder
|
||||||
|
}
|
||||||
|
|
||||||
medium = arguments!!.getSerializable(MEDIUM) as Medium
|
medium = arguments!!.getSerializable(MEDIUM) as Medium
|
||||||
|
|
||||||
// setMenuVisibility is not called at VideoActivity (third party intent)
|
// setMenuVisibility is not called at VideoActivity (third party intent)
|
||||||
|
@ -90,8 +94,15 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
activity!!.updateTextColors(mView!!.video_holder)
|
activity!!.updateTextColors(mView!!.video_holder)
|
||||||
mView!!.video_volume_controller.beVisibleIf(context!!.config.allowVideoGestures)
|
val allowVideoGestures = context!!.config.allowVideoGestures
|
||||||
mView!!.video_brightness_controller.beVisibleIf(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) {
|
if (context!!.config.showExtendedDetails != mStoredShowExtendedDetails || context!!.config.extendedDetails != mStoredExtendedDetails) {
|
||||||
checkExtendedDetails()
|
checkExtendedDetails()
|
||||||
|
|
|
@ -16,6 +16,10 @@ abstract class ViewPagerFragment : Fragment() {
|
||||||
fun fragmentClicked()
|
fun fragmentClicked()
|
||||||
|
|
||||||
fun videoEnded(): Boolean
|
fun videoEnded(): Boolean
|
||||||
|
|
||||||
|
fun goToPrevItem()
|
||||||
|
|
||||||
|
fun goToNextItem()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMediumExtendedDetails(medium: Medium): String {
|
fun getMediumExtendedDetails(medium: Medium): String {
|
||||||
|
|
|
@ -172,6 +172,10 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
get() = prefs.getBoolean(ONE_FINGER_ZOOM, false)
|
get() = prefs.getBoolean(ONE_FINGER_ZOOM, false)
|
||||||
set(oneFingerZoom) = prefs.edit().putBoolean(ONE_FINGER_ZOOM, oneFingerZoom).apply()
|
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 {
|
private fun getDirectoryColumnsField(): String {
|
||||||
val isPortrait = context.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
|
val isPortrait = context.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
|
||||||
return if (isPortrait) {
|
return if (isPortrait) {
|
||||||
|
|
|
@ -44,6 +44,7 @@ val SHOW_EXTENDED_DETAILS = "show_extended_details"
|
||||||
val EXTENDED_DETAILS = "extended_details"
|
val EXTENDED_DETAILS = "extended_details"
|
||||||
val LAST_FILE_CLEANUP = "last_file_cleanup"
|
val LAST_FILE_CLEANUP = "last_file_cleanup"
|
||||||
val ONE_FINGER_ZOOM = "one_finger_zoom"
|
val ONE_FINGER_ZOOM = "one_finger_zoom"
|
||||||
|
val ALLOW_INSTANT_CHANGE = "allow_instant_change"
|
||||||
|
|
||||||
// slideshow
|
// slideshow
|
||||||
val SLIDESHOW_INTERVAL = "slideshow_interval"
|
val SLIDESHOW_INTERVAL = "slideshow_interval"
|
||||||
|
|
|
@ -477,6 +477,26 @@
|
||||||
|
|
||||||
</RelativeLayout>
|
</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
|
<RelativeLayout
|
||||||
android:id="@+id/settings_show_extended_details_holder"
|
android:id="@+id/settings_show_extended_details_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -31,4 +31,16 @@
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:text="My image\nAnother line"/>
|
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>
|
</RelativeLayout>
|
||||||
|
|
|
@ -25,6 +25,18 @@
|
||||||
android:layout_width="@dimen/video_side_slider_width"
|
android:layout_width="@dimen/video_side_slider_width"
|
||||||
android:layout_height="match_parent"/>
|
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
|
<ImageView
|
||||||
android:id="@+id/video_play_outline"
|
android:id="@+id/video_play_outline"
|
||||||
android:layout_width="@dimen/play_outline_size_big"
|
android:layout_width="@dimen/play_outline_size_big"
|
||||||
|
|
|
@ -9,5 +9,6 @@
|
||||||
<dimen name="timer_padding">24dp</dimen>
|
<dimen name="timer_padding">24dp</dimen>
|
||||||
<dimen name="tmb_shadow_height">50dp</dimen>
|
<dimen name="tmb_shadow_height">50dp</dimen>
|
||||||
<dimen name="video_side_slider_width">150dp</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>
|
<dimen name="list_view_folder_thumbnail_size">72dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue