diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt index c50d01c1a..45badc869 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt @@ -45,6 +45,7 @@ class SettingsActivity : SimpleActivity() { setupShowHiddenItems() setupDoExtraCheck() setupAutoplayVideos() + setupRememberLastVideo() setupLoopVideos() setupAnimateGifs() setupMaxBrightness() @@ -175,6 +176,14 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupRememberLastVideo() { + settings_remember_last_video.isChecked = config.rememberLastVideo + settings_remember_last_video_holder.setOnClickListener { + settings_remember_last_video.toggle() + config.rememberLastVideo = settings_remember_last_video.isChecked + } + } + private fun setupLoopVideos() { settings_loop_videos.isChecked = config.loopVideos settings_loop_videos_holder.setOnClickListener { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index 438565493..c60f20c31 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -66,6 +66,9 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S private var mStoredHideExtendedDetails = false private var mStoredBottomActions = true private var mStoredExtendedDetails = 0 + private var mStoredRememberLastVideo = false + private var mStoredLastVideoPath = "" + private var mStoredLastVideoProgress = 0 private lateinit var mTimeHolder: View private lateinit var mBrightnessSideScroll: MediaSideScroll @@ -167,6 +170,10 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } setupVideoDuration() + if (mStoredRememberLastVideo) { + setSavedProgress() + } + updateInstantSwitchWidths() return mView @@ -201,6 +208,10 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S override fun onPause() { super.onPause() pauseVideo() + if (mStoredRememberLastVideo) { + saveVideoProgress() + } + storeStateVariables() } @@ -237,6 +248,9 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S mStoredHideExtendedDetails = hideExtendedDetails mStoredExtendedDetails = extendedDetails mStoredBottomActions = bottomActions + mStoredRememberLastVideo = rememberLastVideo + mStoredLastVideoPath = lastVideoPath + mStoredLastVideoProgress = lastVideoProgress } } @@ -253,6 +267,18 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S checkExtendedDetails() } + private fun saveVideoProgress() { + if (!videoEnded()) { + mStoredLastVideoProgress = mExoPlayer!!.currentPosition.toInt() / 1000 + mStoredLastVideoPath = medium.path + } + + context!!.config.apply { + lastVideoProgress = mStoredLastVideoProgress + lastVideoPath = mStoredLastVideoPath + } + } + private fun initExoPlayer() { val isContentUri = medium.path.startsWith("content://") val uri = if (isContentUri) Uri.parse(medium.path) else Uri.fromFile(File(medium.path)) @@ -316,6 +342,12 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S listener?.fragmentClicked() } + private fun setSavedProgress() { + if (mStoredLastVideoPath == medium.path && mStoredLastVideoProgress > 0) { + setProgress(mStoredLastVideoProgress) + } + } + private fun initTimeHolder() { val res = resources val left = 0 @@ -434,6 +466,11 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S setProgress(0) } + if (mStoredRememberLastVideo) { + setSavedProgress() + clearSavedProgress() + } + if (!wasEnded || context?.config?.loopVideos == false) { mView.video_play_outline.setImageResource(R.drawable.ic_pause) mView.video_play_outline.alpha = PLAY_PAUSE_VISIBLE_ALPHA @@ -445,6 +482,11 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S activity!!.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } + private fun clearSavedProgress() { + mStoredLastVideoProgress = 0 + mStoredLastVideoPath = "/" + } + private fun pauseVideo() { if (mExoPlayer == null) { return diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt index 40838d5cd..fbb3a0831 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -148,6 +148,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(AUTOPLAY_VIDEOS, false) set(autoplay) = prefs.edit().putBoolean(AUTOPLAY_VIDEOS, autoplay).apply() + var rememberLastVideo: Boolean + get() = prefs.getBoolean(REMEMBER_LAST_VIDEO, false) + set(rememberVideo) = prefs.edit().putBoolean(REMEMBER_LAST_VIDEO, rememberVideo).apply() + var animateGifs: Boolean get() = prefs.getBoolean(ANIMATE_GIFS, false) set(animateGifs) = prefs.edit().putBoolean(ANIMATE_GIFS, animateGifs).apply() @@ -365,6 +369,14 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(BOTTOM_ACTIONS, true) set(bottomActions) = prefs.edit().putBoolean(BOTTOM_ACTIONS, bottomActions).apply() + var lastVideoPath: String + get() = prefs.getString(LAST_VIDEO_PATH, "/") + set(lastVideoPath) = prefs.edit().putString(LAST_VIDEO_PATH, lastVideoPath).apply() + + var lastVideoProgress: Int + get() = prefs.getInt(LAST_VIDEO_PROGRESS, 0) + set(lastVideoProgress) = prefs.edit().putInt(LAST_VIDEO_PROGRESS, lastVideoProgress).apply() + var visibleBottomActions: Int get() = prefs.getInt(VISIBLE_BOTTOM_ACTIONS, DEFAULT_BOTTOM_ACTIONS) set(visibleBottomActions) = prefs.edit().putInt(VISIBLE_BOTTOM_ACTIONS, visibleBottomActions).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt index fc438b9f6..529eae1c6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -10,6 +10,7 @@ const val SHOW_HIDDEN_MEDIA = "show_hidden_media" const val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden" const val IS_THIRD_PARTY_INTENT = "is_third_party_intent" const val AUTOPLAY_VIDEOS = "autoplay_videos" +const val REMEMBER_LAST_VIDEO = "remember_last_video" const val LOOP_VIDEOS = "loop_videos" const val ANIMATE_GIFS = "animate_gifs" const val MAX_BRIGHTNESS = "max_brightness" @@ -51,6 +52,8 @@ const val LAST_FILEPICKER_PATH = "last_filepicker_path" const val WAS_OTG_HANDLED = "was_otg_handled" const val TEMP_SKIP_DELETE_CONFIRMATION = "temp_skip_delete_confirmation" const val BOTTOM_ACTIONS = "bottom_actions" +const val LAST_VIDEO_PATH = "last_video_path" +const val LAST_VIDEO_PROGRESS = "last_video_progress" const val VISIBLE_BOTTOM_ACTIONS = "visible_bottom_actions" const val WERE_FAVORITES_PINNED = "were_favorites_pinned" const val WAS_RECYCLE_BIN_PINNED = "was_recycle_bin_pinned" diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 480a71a42..7699cd830 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -278,6 +278,30 @@ + + + + + + تشغيل الفديوهات تلقائيا + Remember last video playback position تبديل رؤية اسم الملف حلقة الفيديو عرض صور GIF المتحركة في الصور المصغرة diff --git a/app/src/main/res/values-az/strings.xml b/app/src/main/res/values-az/strings.xml index f4c0a18d5..f958f3eb4 100644 --- a/app/src/main/res/values-az/strings.xml +++ b/app/src/main/res/values-az/strings.xml @@ -133,6 +133,7 @@ Play videos automatically + Remember last video playback position Toggle filename visibility Loop videos Animate GIFs at thumbnails diff --git a/app/src/main/res/values-ca/strings.xml b/app/src/main/res/values-ca/strings.xml index 69eefa7e1..c50f3f613 100644 --- a/app/src/main/res/values-ca/strings.xml +++ b/app/src/main/res/values-ca/strings.xml @@ -133,6 +133,7 @@ Reproduir vídeos automàticament + Remember last video playback position Canviar la visibilitat del nom d\'arxiu Reproducció continua de vídeos Animar les miniatures dels GIFs diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 4f1dbe90f..d04c4332d 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -133,6 +133,7 @@ Automaticky přehrávat videa + Remember last video playback position Přepnout viditelnost názvů souborů Přehrávat videa ve smyčce Animovat náhledy souborů GIF diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 9d1ff44a5..1ab75de23 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -133,6 +133,7 @@ Afspil automatisk videoer + Remember last video playback position Toggle filename visibility Kør videoer i sløjfe Animér GIF\'er i miniaturer diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 8daec363c..6f40cef7e 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -133,6 +133,7 @@ Videos automatisch abspielen + Remember last video playback position Beschriftungen ein/aus Videos in Endlosschleife abspielen Kacheln von GIFs animieren diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 2151772da..bd01a4fae 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -133,6 +133,7 @@ Αυτόματη αναπαραγωγή βίντεο + Remember last video playback position Αλλαγή προβολής ονόματος αρχείων Επανάληψη βίντεο Εμφάνιση κινούμενων GIFs στα εικονίδια diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index bca8833e9..32544705f 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -133,6 +133,7 @@ Reproducir vídeos automáticamente + Remember last video playback position Cambiar la visibilidad del nombre de archivo Reproducción continua de vídeos Animar las miniaturas de GIFs diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index b52c133b6..83246ed98 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -133,6 +133,7 @@ Toista videot automaattisesti + Remember last video playback position Tiedostonimien näkyvyys Jatkuvat videot Animoi GIFit pienoiskuvissa diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 6c9c92456..9e7d19c1e 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -133,6 +133,7 @@ Lecture automatique des vidéos + Remember last video playback position Permuter la visibilité des noms de fichier Lecture en boucle des vidéos GIFs animés sur les miniatures @@ -235,7 +236,7 @@ This app is just one piece of a bigger series of apps. You can find the rest of them at https://www.simplemobiletools.com - + Reproducir vídeos automticamente + Remember last video playback position Mudar a visibilidade do ficheiro videos en bucle Animar os GIFs na icona diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index 4a630bd53..f0e73dd54 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -133,6 +133,7 @@ Automatsko pokretanje videa + Remember last video playback position Uključi prikaz naziva datoteka Ponavljanje videa Prikaz animacije GIF-ova na sličicama diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 1f5ac0187..9cccd5d2f 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -133,6 +133,7 @@ Play videos automatically + Remember last video playback position Toggle filename visibility Loop videos Animate GIFs at thumbnails diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 32020b611..dbf796ed5 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -133,6 +133,7 @@ Riproduci i video automaticamente + Remember last video playback position Visibilità nome del file Ripeti i video Anima le GIF in miniatura diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index c3277c39c..63f2adf24 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -133,6 +133,7 @@ ビデオを自動再生 + Remember last video playback position ファイル名の表示を切り替え ビデオを繰り返し再生 アニメーションGIFを動かす diff --git a/app/src/main/res/values-ko-rKR/strings.xml b/app/src/main/res/values-ko-rKR/strings.xml index 444819720..dcb77ea3c 100644 --- a/app/src/main/res/values-ko-rKR/strings.xml +++ b/app/src/main/res/values-ko-rKR/strings.xml @@ -133,6 +133,7 @@ 비디오 자동재생 + Remember last video playback position 파일이름 보기 비디오 반복 섬네일에서 GIFs 애니메이션 활성화 diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index d5f337c4a..152d534e9 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -133,6 +133,7 @@ Groti vaizdo įrašus automatiškai + Remember last video playback position Perjungti bylos pavadinimo matomumą Klipuoti vaizdo įrašus Animuoti GIF\'us miniatiūrose diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index e43d5aff1..b20d3af59 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -133,6 +133,7 @@ Avspill videoer automatisk + Remember last video playback position Vis/skjul filnavn Gjenta videoer Animert GIF i minibildevisning diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 8f3e79059..166bdd00f 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -133,6 +133,7 @@ Video\'s automatisch afspelen + Remember last video playback position Bestandsnamen tonen Video\'s herhalen GIF-bestanden afspelen in overzicht diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index e425709d8..e3a9098ce 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -133,6 +133,7 @@ Odtwarzaj filmy automatycznie + Remember last video playback position Pokazuj / ukrywaj nazwy plików Zapętlaj odtwarzanie filmów Animowane miniatury GIFów diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index ea89a1742..fc7633fe0 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -133,6 +133,7 @@ Reproduzir vídeos automaticamente + Remember last video playback position Mostrar/ocultar nome do arquivo Reproduzir vídeos em ciclo Animação de GIFs nas miniaturas diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 831672a39..b33623736 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -133,6 +133,7 @@ Reproduzir vídeos automaticamente + Remember last video playback position Mostrar/ocultar nome do ficheiro Vídeos em ciclo Animação de GIF nas miniaturas diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index c3dfaa82f..2d360ade9 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -133,6 +133,7 @@ Воспроизводить видео автоматически + Remember last video playback position Переключить отображение имени файла Повтор видео Анимировать эскизы GIF diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index aa9958573..2e93e630d 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -133,6 +133,7 @@ Spúšťať videá automaticky + Remember last video playback position Prepnúť viditeľnosť názvov súborov Automaticky reštartovať videá Animovať GIF súbory pri náhľade diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index f4337458d..05048a1a1 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -133,6 +133,7 @@ Spela upp videor automatiskt + Remember last video playback position Visa/dölj filnamn Spela upp videor om och om igen Animera GIF-bilders miniatyrer diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index c0c9309b0..bc8cdbd39 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -133,6 +133,7 @@ Videoları otomatik olarak oynat + Remember last video playback position Dosya adı görünürlüğünü değiştir Videolar döngüsü Küçük resimlerde GIF\'leri canlandırın diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index e5aded0ea..e4c77e84f 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -133,6 +133,7 @@ Відтворювати відео автоматично + Remember last video playback position Перемкнути відображення імені файлу Зациклити відео Анімувати ескізи GIF-файлів diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index c892d5254..2ef5c0a83 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -133,6 +133,7 @@ 自动播放 + Remember last video playback position 显示文件名 循环播放视频 GIF 缩略图 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 028154d0c..c417b293c 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -133,6 +133,7 @@ 自動播放影片 + Remember last video playback position 顯示檔案名稱 影片循環播放 縮圖顯示GIF動畫 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9a73e5676..bac1070bc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -133,6 +133,7 @@ Play videos automatically + Remember last video playback position Toggle filename visibility Loop videos Animate GIFs at thumbnails