move some settings

This commit is contained in:
Bnyro 2022-07-23 22:01:37 +02:00
parent 7a4a6024b7
commit b2806fc3d2
7 changed files with 57 additions and 21 deletions

View File

@ -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<SwitchPreferenceCompat>(PreferenceKeys.SYSTEM_CAPTION_STYLE)
val captionSettings = findPreference<Preference>(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

View File

@ -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"

View File

@ -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))

View File

@ -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()
}
}

View File

@ -188,7 +188,7 @@
<string name="no_video">No video</string>
<string name="audio">Audio</string>
<string name="video">Video</string>
<string name="downloading">Downloading</string>
<string name="downloading">Downloading</string>
<string name="player_autoplay">Autoplay</string>
<string name="hideTrendingPage">Hide trending page</string>
<string name="instance_frontend_url">URL to instance frontend</string>
@ -258,4 +258,6 @@
<string name="general">General</string>
<string name="general_summary">Language, region</string>
<string name="playingOnBackground">Playing on background …</string>
<string name="caption_settings">Caption settings</string>
<string name="downloading_apk">Downloading Apk …</string>
</resources>

View File

@ -42,22 +42,6 @@
<PreferenceCategory app:title="@string/app_behavior">
<ListPreference
android:icon="@drawable/ic_home"
app:defaultValue="home"
app:entries="@array/tabs"
app:entryValues="@array/tabsValue"
app:key="default_tab"
app:title="@string/defaultTab"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
android:icon="@drawable/ic_trending"
app:defaultValue="false"
app:key="hide_trending_page"
app:title="@string/hideTrendingPage"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:icon="@drawable/ic_label"
app:defaultValue="always"
@ -86,6 +70,11 @@
app:key="system_caption_style"
app:title="@string/system_caption_style" />
<Preference
android:icon="@drawable/ic_settings"
app:key="caption_settings"
app:title="@string/caption_settings" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -41,4 +41,24 @@
</PreferenceCategory>
<PreferenceCategory app:title="@string/behavior">
<ListPreference
android:icon="@drawable/ic_home"
app:defaultValue="home"
app:entries="@array/tabs"
app:entryValues="@array/tabsValue"
app:key="default_tab"
app:title="@string/defaultTab"
app:useSimpleSummaryProvider="true" />
<SwitchPreferenceCompat
android:icon="@drawable/ic_trending"
app:defaultValue="false"
app:key="hide_trending_page"
app:title="@string/hideTrendingPage"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory>
</PreferenceScreen>