diff --git a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt index c7052b5ec..7363eb2bd 100644 --- a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt +++ b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt @@ -1,7 +1,12 @@ package com.github.libretube.preferences +import android.content.ActivityNotFoundException +import android.content.Intent import android.os.Bundle +import android.provider.Settings +import android.widget.Toast import androidx.preference.ListPreference +import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import androidx.preference.SwitchPreferenceCompat import com.github.libretube.R @@ -59,6 +64,25 @@ class AppearanceSettings : PreferenceFragmentCompat() { restartDialog.show(childFragmentManager, "RequireRestartDialog") true } + + val systemCaptionStyle = findPreference(PreferenceKeys.SYSTEM_CAPTION_STYLE) + val captionSettings = findPreference(PreferenceKeys.CAPTION_SETTINGS) + + captionSettings?.isVisible = PreferenceHelper.getBoolean(PreferenceKeys.SYSTEM_CAPTION_STYLE, true) + systemCaptionStyle?.setOnPreferenceChangeListener { _, newValue -> + captionSettings?.isVisible = newValue as Boolean + true + } + + captionSettings?.setOnPreferenceClickListener { + try { + val captionSettingsIntent = Intent(Settings.ACTION_CAPTIONING_SETTINGS) + startActivity(captionSettingsIntent) + } catch (e: ActivityNotFoundException) { + Toast.makeText(activity, R.string.error, Toast.LENGTH_SHORT).show() + } + true + } } // remove material you from accent color option if not available diff --git a/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt index 4507ef6b4..6b6332577 100644 --- a/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt +++ b/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt @@ -48,6 +48,7 @@ object PreferenceKeys { const val WATCH_HISTORY_TOGGLE = "watch_history_toggle" const val SEARCH_HISTORY_TOGGLE = "search_history_toggle" const val SYSTEM_CAPTION_STYLE = "system_caption_style" + const val CAPTION_SETTINGS = "caption_settings" const val SEEK_INCREMENT = "seek_increment" const val PLAYER_VIDEO_FORMAT = "player_video_format" const val DEFAULT_RESOLUTION = "default_res" diff --git a/app/src/main/java/com/github/libretube/services/UpdateService.kt b/app/src/main/java/com/github/libretube/services/UpdateService.kt index 3e161074e..47d3c3888 100644 --- a/app/src/main/java/com/github/libretube/services/UpdateService.kt +++ b/app/src/main/java/com/github/libretube/services/UpdateService.kt @@ -9,6 +9,7 @@ import android.content.IntentFilter import android.net.Uri import android.os.Environment import android.os.IBinder +import com.github.libretube.R import java.io.File class UpdateService : Service() { @@ -33,7 +34,7 @@ class UpdateService : Service() { val request: DownloadManager.Request = DownloadManager.Request(Uri.parse(downloadUrl)) - .setTitle("Downloading APK ...") + .setTitle(getString(R.string.downloading_apk)) .setDescription("") .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE) .setDestinationUri(Uri.fromFile(file)) diff --git a/app/src/main/java/com/github/libretube/util/PlayerHelper.kt b/app/src/main/java/com/github/libretube/util/PlayerHelper.kt index 3f6743996..96282452d 100644 --- a/app/src/main/java/com/github/libretube/util/PlayerHelper.kt +++ b/app/src/main/java/com/github/libretube/util/PlayerHelper.kt @@ -13,9 +13,8 @@ object PlayerHelper { var bitrate = 0 var audioUrl = "" audios.forEach { - val q = it.quality!!.replace(" kbps", "").toInt() - if (q > bitrate) { - bitrate = q + if (it.bitrate != null && it.bitrate!! > bitrate) { + bitrate = it.bitrate!! audioUrl = it.url.toString() } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7bdd874f0..c0b890ef7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -188,7 +188,7 @@ No video Audio Video - Downloading + Downloading … Autoplay Hide trending page URL to instance frontend @@ -258,4 +258,6 @@ General Language, region Playing on background … + Caption settings + Downloading Apk … \ No newline at end of file diff --git a/app/src/main/res/xml/appearance_settings.xml b/app/src/main/res/xml/appearance_settings.xml index 6aa43067e..ca44e1203 100644 --- a/app/src/main/res/xml/appearance_settings.xml +++ b/app/src/main/res/xml/appearance_settings.xml @@ -42,22 +42,6 @@ - - - - + + \ No newline at end of file diff --git a/app/src/main/res/xml/general_settings.xml b/app/src/main/res/xml/general_settings.xml index bbfcfc3a8..91ba8bfd5 100644 --- a/app/src/main/res/xml/general_settings.xml +++ b/app/src/main/res/xml/general_settings.xml @@ -41,4 +41,24 @@ + + + + + + + + \ No newline at end of file