mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
show the next/prev video player buttons only when appropriate
This commit is contained in:
parent
855f9abad5
commit
81857948be
7 changed files with 62 additions and 6 deletions
|
@ -30,7 +30,6 @@ import java.io.File
|
|||
import java.io.FileInputStream
|
||||
|
||||
open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentListener {
|
||||
|
||||
private var mMedium: Medium? = null
|
||||
private var mIsFullScreen = false
|
||||
private var mIsFromGallery = false
|
||||
|
@ -177,6 +176,10 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
|||
val mimeType = getUriMimeType(mUri.toString(), newUri)
|
||||
Intent(applicationContext, VideoPlayerActivity::class.java).apply {
|
||||
setDataAndType(newUri, mimeType)
|
||||
if (intent.extras != null) {
|
||||
putExtras(intent.extras!!)
|
||||
}
|
||||
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
@ -292,4 +295,6 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
|||
override fun goToPrevItem() {}
|
||||
|
||||
override fun goToNextItem() {}
|
||||
|
||||
override fun launchViewVideoIntent(path: String) {}
|
||||
}
|
||||
|
|
|
@ -161,8 +161,12 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
|||
video_curr_time.setOnClickListener { skip(false) }
|
||||
video_duration.setOnClickListener { skip(true) }
|
||||
video_toggle_play_pause.setOnClickListener { togglePlayPause() }
|
||||
video_next_file.setOnClickListener { }
|
||||
video_prev_file.setOnClickListener { }
|
||||
|
||||
video_next_file.beVisibleIf(intent.getBooleanExtra(SHOW_NEXT_ITEM, false))
|
||||
video_next_file.setOnClickListener { handleNextFile() }
|
||||
|
||||
video_prev_file.beVisibleIf(intent.getBooleanExtra(SHOW_PREV_ITEM, false))
|
||||
video_prev_file.setOnClickListener { handlePrevFile() }
|
||||
|
||||
video_player_holder.setOnTouchListener { view, event ->
|
||||
handleEvent(event)
|
||||
|
@ -542,6 +546,14 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleNextFile() {
|
||||
|
||||
}
|
||||
|
||||
private fun handlePrevFile() {
|
||||
|
||||
}
|
||||
|
||||
private fun resetPlayWhenReady() {
|
||||
mExoPlayer?.playWhenReady = false
|
||||
mPlayWhenReadyHandler.removeCallbacksAndMessages(null)
|
||||
|
|
|
@ -32,6 +32,7 @@ import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
|||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.gallery.pro.BuildConfig
|
||||
import com.simplemobiletools.gallery.pro.R
|
||||
import com.simplemobiletools.gallery.pro.adapters.MyPagerAdapter
|
||||
import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
||||
|
@ -53,6 +54,8 @@ import java.io.OutputStream
|
|||
import java.util.*
|
||||
|
||||
class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, ViewPagerFragment.FragmentListener {
|
||||
private val REQUEST_VIEW_VIDEO = 1
|
||||
|
||||
private var mPath = ""
|
||||
private var mDirectory = ""
|
||||
private var mIsFullScreen = false
|
||||
|
@ -917,6 +920,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
if (resultCode == Activity.RESULT_OK) {
|
||||
toast(R.string.wallpaper_set_successfully)
|
||||
}
|
||||
} else if (requestCode == REQUEST_VIEW_VIDEO) {
|
||||
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, resultData)
|
||||
}
|
||||
|
@ -1098,6 +1103,34 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
checkOrientation()
|
||||
}
|
||||
|
||||
override fun launchViewVideoIntent(path: String) {
|
||||
Thread {
|
||||
val newUri = getFinalUriFromPath(path, BuildConfig.APPLICATION_ID) ?: return@Thread
|
||||
val mimeType = getUriMimeType(path, newUri)
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
setDataAndType(newUri, mimeType)
|
||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
putExtra(IS_FROM_GALLERY, true)
|
||||
putExtra(REAL_FILE_PATH, path)
|
||||
putExtra(SHOW_PREV_ITEM, view_pager.currentItem != 0)
|
||||
putExtra(SHOW_NEXT_ITEM, view_pager.currentItem != mMediaFiles.size - 1)
|
||||
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
try {
|
||||
startActivityForResult(this, REQUEST_VIEW_VIDEO)
|
||||
} catch (e: NullPointerException) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
} else {
|
||||
if (!tryGenericMimeType(this, mimeType, newUri)) {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
private fun checkSystemUI() {
|
||||
if (mIsFullScreen) {
|
||||
hideSystemUI(true)
|
||||
|
|
|
@ -129,7 +129,7 @@ class VideoFragment : ViewPagerFragment() {
|
|||
}
|
||||
|
||||
private fun launchVideoPlayer() {
|
||||
activity!!.openPath(mMedium.path, false)
|
||||
listener?.launchViewVideoIntent(mMedium.path)
|
||||
}
|
||||
|
||||
private fun toggleFullscreen() {
|
||||
|
|
|
@ -28,6 +28,8 @@ abstract class ViewPagerFragment : Fragment() {
|
|||
fun goToPrevItem()
|
||||
|
||||
fun goToNextItem()
|
||||
|
||||
fun launchViewVideoIntent(path: String)
|
||||
}
|
||||
|
||||
fun getMediumExtendedDetails(medium: Medium): String {
|
||||
|
|
|
@ -92,6 +92,8 @@ const val FAVORITES = "favorites"
|
|||
const val RECYCLE_BIN = "recycle_bin"
|
||||
const val SHOW_FAVORITES = "show_favorites"
|
||||
const val SHOW_RECYCLE_BIN = "show_recycle_bin"
|
||||
const val SHOW_NEXT_ITEM = "show_next_item"
|
||||
const val SHOW_PREV_ITEM = "show_prev_item"
|
||||
const val MAX_COLUMN_COUNT = 20
|
||||
const val SHOW_TEMP_HIDDEN_DURATION = 300000L
|
||||
const val CLICK_MAX_DURATION = 150
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
android:layout_marginTop="@dimen/activity_margin"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:padding="@dimen/normal_margin"
|
||||
android:src="@drawable/ic_prev_outline"/>
|
||||
android:src="@drawable/ic_prev_outline"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/video_toggle_play_pause"
|
||||
|
@ -38,7 +39,8 @@
|
|||
android:layout_marginEnd="@dimen/small_margin"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:padding="@dimen/normal_margin"
|
||||
android:src="@drawable/ic_next_outline"/>
|
||||
android:src="@drawable/ic_next_outline"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/video_curr_time"
|
||||
|
|
Loading…
Reference in a new issue