diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt index cddd19ffe..c5352c5e3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt @@ -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) {} } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt index 92a4f19cf..e87253269 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt @@ -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) 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 edc38717b..dfe90ffc5 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 @@ -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) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt index e3078d10d..0ef8a6223 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt @@ -129,7 +129,7 @@ class VideoFragment : ViewPagerFragment() { } private fun launchVideoPlayer() { - activity!!.openPath(mMedium.path, false) + listener?.launchViewVideoIntent(mMedium.path) } private fun toggleFullscreen() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt index 8c2545ff7..5153859ad 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt @@ -28,6 +28,8 @@ abstract class ViewPagerFragment : Fragment() { fun goToPrevItem() fun goToNextItem() + + fun launchViewVideoIntent(path: String) } fun getMediumExtendedDetails(medium: Medium): String { 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 9baa22b50..1e06716ea 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 @@ -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 diff --git a/app/src/main/res/layout/bottom_video_time_holder.xml b/app/src/main/res/layout/bottom_video_time_holder.xml index 567ab5026..ec34b6501 100644 --- a/app/src/main/res/layout/bottom_video_time_holder.xml +++ b/app/src/main/res/layout/bottom_video_time_holder.xml @@ -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"/> + android:src="@drawable/ic_next_outline" + android:visibility="invisible"/>