couple cosmetic changes related to remembering the last video position

This commit is contained in:
tibbi 2018-11-01 12:27:42 +01:00
parent ad0cebf6a9
commit 32c2236e8d
35 changed files with 55 additions and 56 deletions

View file

@ -177,10 +177,10 @@ 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
settings_remember_last_video_position.isChecked = config.rememberLastVideoPosition
settings_remember_last_video_position_holder.setOnClickListener {
settings_remember_last_video_position.toggle()
config.rememberLastVideoPosition = settings_remember_last_video_position.isChecked
}
}

View file

@ -66,7 +66,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
private var mStoredHideExtendedDetails = false
private var mStoredBottomActions = true
private var mStoredExtendedDetails = 0
private var mStoredRememberLastVideo = false
private var mStoredRememberLastVideoPosition = false
private var mStoredLastVideoPath = ""
private var mStoredLastVideoProgress = 0
@ -170,8 +170,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
}
setupVideoDuration()
if (mStoredRememberLastVideo) {
setSavedProgress()
if (mStoredRememberLastVideoPosition) {
setLastVideoSavedProgress()
}
updateInstantSwitchWidths()
@ -208,7 +208,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
override fun onPause() {
super.onPause()
pauseVideo()
if (mStoredRememberLastVideo) {
if (mStoredRememberLastVideoPosition) {
saveVideoProgress()
}
@ -248,7 +248,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
mStoredHideExtendedDetails = hideExtendedDetails
mStoredExtendedDetails = extendedDetails
mStoredBottomActions = bottomActions
mStoredRememberLastVideo = rememberLastVideo
mStoredRememberLastVideoPosition = rememberLastVideoPosition
mStoredLastVideoPath = lastVideoPath
mStoredLastVideoProgress = lastVideoProgress
}
@ -342,21 +342,20 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
listener?.fragmentClicked()
}
private fun setSavedProgress() {
private fun setLastVideoSavedProgress() {
if (mStoredLastVideoPath == medium.path && mStoredLastVideoProgress > 0) {
setProgress(mStoredLastVideoProgress)
}
}
private fun initTimeHolder() {
val res = resources
val left = 0
val top = 0
var right = 0
var bottom = 0
if (hasNavBar()) {
if (res.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
bottom += context!!.navigationBarHeight
} else {
right += context!!.navigationBarWidth
@ -466,9 +465,9 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
setProgress(0)
}
if (mStoredRememberLastVideo) {
setSavedProgress()
clearSavedProgress()
if (mStoredRememberLastVideoPosition) {
setLastVideoSavedProgress()
clearLastVideoSavedProgress()
}
if (!wasEnded || context?.config?.loopVideos == false) {
@ -482,9 +481,9 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
activity!!.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
private fun clearSavedProgress() {
private fun clearLastVideoSavedProgress() {
mStoredLastVideoProgress = 0
mStoredLastVideoPath = "/"
mStoredLastVideoPath = ""
}
private fun pauseVideo() {

View file

@ -148,10 +148,6 @@ 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()
@ -369,8 +365,12 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getBoolean(BOTTOM_ACTIONS, true)
set(bottomActions) = prefs.edit().putBoolean(BOTTOM_ACTIONS, bottomActions).apply()
var rememberLastVideoPosition: Boolean
get() = prefs.getBoolean(REMEMBER_LAST_VIDEO_POSITION, false)
set(rememberLastVideoPosition) = prefs.edit().putBoolean(REMEMBER_LAST_VIDEO_POSITION, rememberLastVideoPosition).apply()
var lastVideoPath: String
get() = prefs.getString(LAST_VIDEO_PATH, "/")
get() = prefs.getString(LAST_VIDEO_PATH, "")
set(lastVideoPath) = prefs.edit().putString(LAST_VIDEO_PATH, lastVideoPath).apply()
var lastVideoProgress: Int

View file

@ -10,7 +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 REMEMBER_LAST_VIDEO_POSITION = "remember_last_video_position"
const val LOOP_VIDEOS = "loop_videos"
const val ANIMATE_GIFS = "animate_gifs"
const val MAX_BRIGHTNESS = "max_brightness"

View file

@ -279,7 +279,7 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_remember_last_video_holder"
android:id="@+id/settings_remember_last_video_position_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
@ -290,14 +290,14 @@
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_remember_last_video"
android:id="@+id/settings_remember_last_video_position"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingStart="@dimen/medium_margin"
android:paddingLeft="@dimen/medium_margin"
android:text="@string/remember_last_video"
android:text="@string/remember_last_video_position"
app:switchPadding="@dimen/medium_margin" />
</RelativeLayout>

View file

@ -137,7 +137,7 @@
<!-- Settings -->
<string name="autoplay_videos">تشغيل الفديوهات تلقائيا</string>
<string name="remember_last_video" >Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">تبديل رؤية اسم الملف</string>
<string name="loop_videos">حلقة الفيديو</string>
<string name="animate_gifs">عرض صور GIF المتحركة في الصور المصغرة</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Play videos automatically</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Toggle filename visibility</string>
<string name="loop_videos">Loop videos</string>
<string name="animate_gifs">Animate GIFs at thumbnails</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Reproduir vídeos automàticament</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Canviar la visibilitat del nom d\'arxiu</string>
<string name="loop_videos">Reproducció continua de vídeos</string>
<string name="animate_gifs">Animar les miniatures dels GIFs</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Automaticky přehrávat videa</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Přepnout viditelnost názvů souborů</string>
<string name="loop_videos">Přehrávat videa ve smyčce</string>
<string name="animate_gifs">Animovat náhledy souborů GIF</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Afspil automatisk videoer</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Toggle filename visibility</string>
<string name="loop_videos">Kør videoer i sløjfe</string>
<string name="animate_gifs">Animér GIF\'er i miniaturer</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Videos automatisch abspielen</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Beschriftungen ein/aus</string>
<string name="loop_videos">Videos in Endlosschleife abspielen</string>
<string name="animate_gifs">Kacheln von GIFs animieren</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Αυτόματη αναπαραγωγή βίντεο</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Αλλαγή προβολής ονόματος αρχείων</string>
<string name="loop_videos">Επανάληψη βίντεο</string>
<string name="animate_gifs">Εμφάνιση κινούμενων GIFs στα εικονίδια</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Reproducir vídeos automáticamente</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Cambiar la visibilidad del nombre de archivo</string>
<string name="loop_videos">Reproducción continua de vídeos</string>
<string name="animate_gifs">Animar las miniaturas de GIFs</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Toista videot automaattisesti</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Tiedostonimien näkyvyys</string>
<string name="loop_videos">Jatkuvat videot</string>
<string name="animate_gifs">Animoi GIFit pienoiskuvissa</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Lecture automatique des vidéos</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Permuter la visibilité des noms de fichier</string>
<string name="loop_videos">Lecture en boucle des vidéos</string>
<string name="animate_gifs">GIFs animés sur les miniatures</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Reproducir vídeos automticamente</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Mudar a visibilidade do ficheiro</string>
<string name="loop_videos">videos en bucle</string>
<string name="animate_gifs">Animar os GIFs na icona</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Automatsko pokretanje videa</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Uključi prikaz naziva datoteka</string>
<string name="loop_videos">Ponavljanje videa</string>
<string name="animate_gifs">Prikaz animacije GIF-ova na sličicama</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Play videos automatically</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Toggle filename visibility</string>
<string name="loop_videos">Loop videos</string>
<string name="animate_gifs">Animate GIFs at thumbnails</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Riproduci i video automaticamente</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Visibilità nome del file</string>
<string name="loop_videos">Ripeti i video</string>
<string name="animate_gifs">Anima le GIF in miniatura</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">ビデオを自動再生</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">ファイル名の表示を切り替え</string>
<string name="loop_videos">ビデオを繰り返し再生</string>
<string name="animate_gifs">アニメーションGIFを動かす</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">비디오 자동재생</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">파일이름 보기</string>
<string name="loop_videos">비디오 반복</string>
<string name="animate_gifs">섬네일에서 GIFs 애니메이션 활성화</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Groti vaizdo įrašus automatiškai</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Perjungti bylos pavadinimo matomumą</string>
<string name="loop_videos">Klipuoti vaizdo įrašus</string>
<string name="animate_gifs">Animuoti GIF\'us miniatiūrose</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Avspill videoer automatisk</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Vis/skjul filnavn</string>
<string name="loop_videos">Gjenta videoer</string>
<string name="animate_gifs">Animert GIF i minibildevisning</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Video\'s automatisch afspelen</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Bestandsnamen tonen</string>
<string name="loop_videos">Video\'s herhalen</string>
<string name="animate_gifs">GIF-bestanden afspelen in overzicht</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Odtwarzaj filmy automatycznie</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Pokazuj / ukrywaj nazwy plików</string>
<string name="loop_videos">Zapętlaj odtwarzanie filmów</string>
<string name="animate_gifs">Animowane miniatury GIFów</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Reproduzir vídeos automaticamente</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Mostrar/ocultar nome do arquivo</string>
<string name="loop_videos">Reproduzir vídeos em ciclo</string>
<string name="animate_gifs">Animação de GIFs nas miniaturas</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Reproduzir vídeos automaticamente</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Mostrar/ocultar nome do ficheiro</string>
<string name="loop_videos">Vídeos em ciclo</string>
<string name="animate_gifs">Animação de GIF nas miniaturas</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Воспроизводить видео автоматически</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Переключить отображение имени файла</string>
<string name="loop_videos">Повтор видео</string>
<string name="animate_gifs">Анимировать эскизы GIF</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Spúšťať videá automaticky</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Zapamätať si pozíciu posledného prehraného videa</string>
<string name="toggle_filename">Prepnúť viditeľnosť názvov súborov</string>
<string name="loop_videos">Automaticky reštartovať videá</string>
<string name="animate_gifs">Animovať GIF súbory pri náhľade</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Spela upp videor automatiskt</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Visa/dölj filnamn</string>
<string name="loop_videos">Spela upp videor om och om igen</string>
<string name="animate_gifs">Animera GIF-bilders miniatyrer</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Videoları otomatik olarak oynat</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Dosya adı görünürlüğünü değiştir</string>
<string name="loop_videos">Videolar döngüsü</string>
<string name="animate_gifs">Küçük resimlerde GIF\'leri canlandırın</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Відтворювати відео автоматично</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Перемкнути відображення імені файлу</string>
<string name="loop_videos">Зациклити відео</string>
<string name="animate_gifs">Анімувати ескізи GIF-файлів</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">自动播放</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">显示文件名</string>
<string name="loop_videos">循环播放视频</string>
<string name="animate_gifs">GIF 缩略图</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">自動播放影片</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">顯示檔案名稱</string>
<string name="loop_videos">影片循環播放</string>
<string name="animate_gifs">縮圖顯示GIF動畫</string>

View file

@ -133,7 +133,7 @@
<!-- Settings -->
<string name="autoplay_videos">Play videos automatically</string>
<string name="remember_last_video">Remember last video playback position</string>
<string name="remember_last_video_position">Remember last video playback position</string>
<string name="toggle_filename">Toggle filename visibility</string>
<string name="loop_videos">Loop videos</string>
<string name="animate_gifs">Animate GIFs at thumbnails</string>