Merge pull request #862 from Bnyro/master

move some settings
This commit is contained in:
Bnyro 2022-07-23 22:03:31 +02:00 committed by GitHub
commit 2a1a97d8f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 21 deletions

View File

@ -1,7 +1,12 @@
package com.github.libretube.preferences package com.github.libretube.preferences
import android.content.ActivityNotFoundException
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.provider.Settings
import android.widget.Toast
import androidx.preference.ListPreference import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreferenceCompat import androidx.preference.SwitchPreferenceCompat
import com.github.libretube.R import com.github.libretube.R
@ -59,6 +64,25 @@ class AppearanceSettings : PreferenceFragmentCompat() {
restartDialog.show(childFragmentManager, "RequireRestartDialog") restartDialog.show(childFragmentManager, "RequireRestartDialog")
true 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 // 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 WATCH_HISTORY_TOGGLE = "watch_history_toggle"
const val SEARCH_HISTORY_TOGGLE = "search_history_toggle" const val SEARCH_HISTORY_TOGGLE = "search_history_toggle"
const val SYSTEM_CAPTION_STYLE = "system_caption_style" const val SYSTEM_CAPTION_STYLE = "system_caption_style"
const val CAPTION_SETTINGS = "caption_settings"
const val SEEK_INCREMENT = "seek_increment" const val SEEK_INCREMENT = "seek_increment"
const val PLAYER_VIDEO_FORMAT = "player_video_format" const val PLAYER_VIDEO_FORMAT = "player_video_format"
const val DEFAULT_RESOLUTION = "default_res" const val DEFAULT_RESOLUTION = "default_res"

View File

@ -9,6 +9,7 @@ import android.content.IntentFilter
import android.net.Uri import android.net.Uri
import android.os.Environment import android.os.Environment
import android.os.IBinder import android.os.IBinder
import com.github.libretube.R
import java.io.File import java.io.File
class UpdateService : Service() { class UpdateService : Service() {
@ -33,7 +34,7 @@ class UpdateService : Service() {
val request: DownloadManager.Request = val request: DownloadManager.Request =
DownloadManager.Request(Uri.parse(downloadUrl)) DownloadManager.Request(Uri.parse(downloadUrl))
.setTitle("Downloading APK ...") .setTitle(getString(R.string.downloading_apk))
.setDescription("") .setDescription("")
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE) .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE)
.setDestinationUri(Uri.fromFile(file)) .setDestinationUri(Uri.fromFile(file))

View File

@ -13,9 +13,8 @@ object PlayerHelper {
var bitrate = 0 var bitrate = 0
var audioUrl = "" var audioUrl = ""
audios.forEach { audios.forEach {
val q = it.quality!!.replace(" kbps", "").toInt() if (it.bitrate != null && it.bitrate!! > bitrate) {
if (q > bitrate) { bitrate = it.bitrate!!
bitrate = q
audioUrl = it.url.toString() audioUrl = it.url.toString()
} }
} }

View File

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

View File

@ -42,22 +42,6 @@
<PreferenceCategory app:title="@string/app_behavior"> <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 <ListPreference
android:icon="@drawable/ic_label" android:icon="@drawable/ic_label"
app:defaultValue="always" app:defaultValue="always"
@ -86,6 +70,11 @@
app:key="system_caption_style" app:key="system_caption_style"
app:title="@string/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> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@ -41,4 +41,24 @@
</PreferenceCategory> </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> </PreferenceScreen>