mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
commit
e024435f03
@ -30,6 +30,7 @@ import com.github.libretube.R
|
||||
import com.github.libretube.databinding.ActivityMainBinding
|
||||
import com.github.libretube.fragments.PlayerFragment
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import com.github.libretube.services.ClosingService
|
||||
import com.github.libretube.util.ConnectionHelper
|
||||
import com.github.libretube.util.CronetHelper
|
||||
@ -62,12 +63,12 @@ class MainActivity : AppCompatActivity() {
|
||||
CronetHelper.initCronet(this.applicationContext)
|
||||
|
||||
RetrofitInstance.url =
|
||||
PreferenceHelper.getString("selectInstance", PIPED_API_URL)!!
|
||||
PreferenceHelper.getString(PreferenceKeys.FETCH_INSTANCE, PIPED_API_URL)!!
|
||||
// set auth instance
|
||||
RetrofitInstance.authUrl =
|
||||
if (PreferenceHelper.getBoolean("auth_instance_toggle", false)) {
|
||||
if (PreferenceHelper.getBoolean(PreferenceKeys.AUTH_INSTANCE_TOGGLE, false)) {
|
||||
PreferenceHelper.getString(
|
||||
"selectAuthInstance",
|
||||
PreferenceKeys.AUTH_INSTANCE,
|
||||
PIPED_API_URL
|
||||
)!!
|
||||
} else {
|
||||
@ -76,7 +77,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
// save whether the data saver mode is enabled
|
||||
Globals.dataSaverModeEnabled = PreferenceHelper.getBoolean(
|
||||
"data_saver_mode",
|
||||
PreferenceKeys.DATA_SAVER_MODE,
|
||||
false
|
||||
)
|
||||
|
||||
@ -98,12 +99,12 @@ class MainActivity : AppCompatActivity() {
|
||||
window.navigationBarColor = color
|
||||
|
||||
// hide the trending page if enabled
|
||||
val hideTrendingPage = PreferenceHelper.getBoolean("hide_trending_page", false)
|
||||
val hideTrendingPage = PreferenceHelper.getBoolean(PreferenceKeys.HIDE_TRENDING_PAGE, false)
|
||||
if (hideTrendingPage) binding.bottomNav.menu.findItem(R.id.homeFragment).isVisible =
|
||||
false
|
||||
|
||||
// save start tab fragment id
|
||||
startFragmentId = when (PreferenceHelper.getString("default_tab", "home")) {
|
||||
startFragmentId = when (PreferenceHelper.getString(PreferenceKeys.DEFAULT_TAB, "home")) {
|
||||
"home" -> R.id.homeFragment
|
||||
"subscriptions" -> R.id.subscriptionsFragment
|
||||
"library" -> R.id.libraryFragment
|
||||
@ -117,7 +118,7 @@ class MainActivity : AppCompatActivity() {
|
||||
navController.navigate(startFragmentId)
|
||||
|
||||
val labelVisibilityMode = when (
|
||||
PreferenceHelper.getString("label_visibility", "always")
|
||||
PreferenceHelper.getString(PreferenceKeys.LABEL_VISIBILITY, "always")
|
||||
) {
|
||||
"always" -> NavigationBarView.LABEL_VISIBILITY_LABELED
|
||||
"selected" -> NavigationBarView.LABEL_VISIBILITY_SELECTED
|
||||
|
@ -8,6 +8,7 @@ import com.github.libretube.PIPED_FRONTEND_URL
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.YOUTUBE_FRONTEND_URL
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class ShareDialog(
|
||||
@ -57,7 +58,7 @@ class ShareDialog(
|
||||
// get the frontend url if it's a custom instance
|
||||
private fun getCustomInstanceFrontendUrl(): String {
|
||||
val instancePref = PreferenceHelper.getString(
|
||||
"selectInstance",
|
||||
PreferenceKeys.FETCH_INSTANCE,
|
||||
PIPED_FRONTEND_URL
|
||||
)
|
||||
|
||||
|
@ -13,6 +13,7 @@ import com.github.libretube.R
|
||||
import com.github.libretube.adapters.TrendingAdapter
|
||||
import com.github.libretube.databinding.FragmentHomeBinding
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import com.github.libretube.util.LocaleHelper
|
||||
import com.github.libretube.util.RetrofitInstance
|
||||
import retrofit2.HttpException
|
||||
@ -41,11 +42,11 @@ class HomeFragment : Fragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val grid = PreferenceHelper.getString(
|
||||
"grid",
|
||||
PreferenceKeys.GRID_COLUMNS,
|
||||
resources.getInteger(R.integer.grid_items).toString()
|
||||
)!!
|
||||
|
||||
val regionPref = PreferenceHelper.getString("region", "sys")!!
|
||||
val regionPref = PreferenceHelper.getString(PreferenceKeys.REGION, "sys")!!
|
||||
|
||||
// get the system default country if auto region selected
|
||||
region = if (regionPref == "sys") {
|
||||
|
@ -16,6 +16,7 @@ import com.github.libretube.adapters.PlaylistsAdapter
|
||||
import com.github.libretube.databinding.FragmentLibraryBinding
|
||||
import com.github.libretube.dialogs.CreatePlaylistDialog
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import com.github.libretube.util.RetrofitInstance
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
@ -48,7 +49,7 @@ class LibraryFragment : Fragment() {
|
||||
|
||||
// hide watch history button of history disabled
|
||||
val watchHistoryEnabled =
|
||||
PreferenceHelper.getBoolean("watch_history_toggle", true)
|
||||
PreferenceHelper.getBoolean(PreferenceKeys.WATCH_HISTORY_TOGGLE, true)
|
||||
if (!watchHistoryEnabled) {
|
||||
binding.showWatchHistory.visibility = View.GONE
|
||||
} else {
|
||||
|
@ -57,6 +57,7 @@ import com.github.libretube.obj.StreamItem
|
||||
import com.github.libretube.obj.Streams
|
||||
import com.github.libretube.obj.Subscribe
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import com.github.libretube.services.IS_DOWNLOAD_RUNNING
|
||||
import com.github.libretube.util.BackgroundMode
|
||||
import com.github.libretube.util.ConnectionHelper
|
||||
@ -232,67 +233,67 @@ class PlayerFragment : Fragment() {
|
||||
|
||||
// save whether auto rotation is enabled
|
||||
autoRotationEnabled = PreferenceHelper.getBoolean(
|
||||
"auto_fullscreen",
|
||||
PreferenceKeys.AUTO_FULLSCREEN,
|
||||
false
|
||||
)
|
||||
|
||||
// save whether related streams and autoplay are enabled
|
||||
autoplayEnabled = PreferenceHelper.getBoolean(
|
||||
"autoplay",
|
||||
PreferenceKeys.AUTO_PLAY,
|
||||
false
|
||||
)
|
||||
relatedStreamsEnabled = PreferenceHelper.getBoolean(
|
||||
"related_streams_toggle",
|
||||
PreferenceKeys.RELATED_STREAMS,
|
||||
true
|
||||
)
|
||||
|
||||
playbackSpeed = PreferenceHelper.getString(
|
||||
"playback_speed",
|
||||
PreferenceKeys.PLAYBACK_SPEED,
|
||||
"1F"
|
||||
)!!
|
||||
|
||||
fullscreenOrientationPref = PreferenceHelper.getString(
|
||||
"fullscreen_orientation",
|
||||
PreferenceKeys.FULLSCREEN_ORIENTATION,
|
||||
"ratio"
|
||||
)!!
|
||||
|
||||
pausePlayerOnScreenOffEnabled = PreferenceHelper.getBoolean(
|
||||
"pause_screen_off",
|
||||
PreferenceKeys.PAUSE_ON_SCREEN_OFF,
|
||||
false
|
||||
)
|
||||
|
||||
watchPositionsEnabled = PreferenceHelper.getBoolean(
|
||||
"watch_positions_toggle",
|
||||
PreferenceKeys.WATCH_POSITION_TOGGLE,
|
||||
true
|
||||
)
|
||||
|
||||
watchHistoryEnabled = PreferenceHelper.getBoolean(
|
||||
"watch_history_toggle",
|
||||
PreferenceKeys.WATCH_HISTORY_TOGGLE,
|
||||
true
|
||||
)
|
||||
|
||||
useSystemCaptionStyle = PreferenceHelper.getBoolean(
|
||||
"system_caption_style",
|
||||
PreferenceKeys.SYSTEM_CAPTION_STYLE,
|
||||
true
|
||||
)
|
||||
|
||||
seekIncrement = PreferenceHelper.getString(
|
||||
"seek_increment",
|
||||
PreferenceKeys.SEEK_INCREMENT,
|
||||
"5"
|
||||
)?.toLong()!! * 1000
|
||||
|
||||
videoFormatPreference = PreferenceHelper.getString(
|
||||
"player_video_format",
|
||||
PreferenceKeys.PLAYER_VIDEO_FORMAT,
|
||||
"WEBM"
|
||||
)!!
|
||||
|
||||
defRes = PreferenceHelper.getString(
|
||||
"default_res",
|
||||
PreferenceKeys.DEFAULT_RESOLUTION,
|
||||
""
|
||||
)!!
|
||||
|
||||
bufferingGoal = PreferenceHelper.getString(
|
||||
"buffering_goal",
|
||||
PreferenceKeys.BUFFERING_GOAL,
|
||||
"50"
|
||||
)?.toInt()!! * 1000
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import com.github.libretube.adapters.SearchHistoryAdapter
|
||||
import com.github.libretube.adapters.SearchSuggestionsAdapter
|
||||
import com.github.libretube.databinding.FragmentSearchBinding
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import com.github.libretube.util.RetrofitInstance
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import retrofit2.HttpException
|
||||
@ -271,7 +272,7 @@ class SearchFragment : Fragment() {
|
||||
|
||||
private fun addToHistory(query: String) {
|
||||
val searchHistoryEnabled =
|
||||
PreferenceHelper.getBoolean("search_history_toggle", true)
|
||||
PreferenceHelper.getBoolean(PreferenceKeys.SEARCH_HISTORY_TOGGLE, true)
|
||||
if (searchHistoryEnabled) {
|
||||
var historyList = PreferenceHelper.getHistory()
|
||||
|
||||
|
@ -18,6 +18,7 @@ import com.github.libretube.adapters.SubscriptionAdapter
|
||||
import com.github.libretube.adapters.SubscriptionChannelAdapter
|
||||
import com.github.libretube.databinding.FragmentSubscriptionsBinding
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import com.github.libretube.util.RetrofitInstance
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
@ -56,7 +57,7 @@ class SubscriptionsFragment : Fragment() {
|
||||
binding.subProgress.visibility = View.VISIBLE
|
||||
|
||||
val grid = PreferenceHelper.getString(
|
||||
"grid",
|
||||
PreferenceKeys.GRID_COLUMNS,
|
||||
resources.getInteger(R.integer.grid_items).toString()
|
||||
)!!
|
||||
binding.subFeed.layoutManager = GridLayoutManager(view.context, grid.toInt())
|
||||
|
@ -18,14 +18,14 @@ class AdvancedSettings : PreferenceFragmentCompat() {
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.advanced))
|
||||
|
||||
val dataSaverMode = findPreference<SwitchPreferenceCompat>("data_saver_mode")
|
||||
val dataSaverMode = findPreference<SwitchPreferenceCompat>(PreferenceKeys.DATA_SAVER_MODE)
|
||||
dataSaverMode?.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||||
true
|
||||
}
|
||||
|
||||
val resetSettings = findPreference<Preference>("reset_settings")
|
||||
val resetSettings = findPreference<Preference>(PreferenceKeys.RESET_SETTINGS)
|
||||
resetSettings?.setOnPreferenceClickListener {
|
||||
showResetDialog()
|
||||
true
|
||||
|
@ -18,21 +18,21 @@ class AppearanceSettings : PreferenceFragmentCompat() {
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.appearance))
|
||||
|
||||
val themeToggle = findPreference<ListPreference>("theme_toggle")
|
||||
val themeToggle = findPreference<ListPreference>(PreferenceKeys.THEME_MODE)
|
||||
themeToggle?.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||||
true
|
||||
}
|
||||
|
||||
val pureTheme = findPreference<SwitchPreferenceCompat>("pure_theme")
|
||||
val pureTheme = findPreference<SwitchPreferenceCompat>(PreferenceKeys.PURE_THEME)
|
||||
pureTheme?.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||||
true
|
||||
}
|
||||
|
||||
val accentColor = findPreference<ListPreference>("accent_color")
|
||||
val accentColor = findPreference<ListPreference>(PreferenceKeys.ACCENT_COLOR)
|
||||
updateAccentColorValues(accentColor!!)
|
||||
accentColor.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
@ -40,27 +40,27 @@ class AppearanceSettings : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
|
||||
val iconChange = findPreference<ListPreference>("icon_change")
|
||||
val iconChange = findPreference<ListPreference>(PreferenceKeys.APP_ICON)
|
||||
iconChange?.setOnPreferenceChangeListener { _, newValue ->
|
||||
ThemeHelper.changeIcon(requireContext(), newValue.toString())
|
||||
true
|
||||
}
|
||||
|
||||
val gridColumns = findPreference<ListPreference>("grid")
|
||||
val gridColumns = findPreference<ListPreference>(PreferenceKeys.GRID_COLUMNS)
|
||||
gridColumns?.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||||
true
|
||||
}
|
||||
|
||||
val hideTrending = findPreference<SwitchPreferenceCompat>("hide_trending_page")
|
||||
val hideTrending = findPreference<SwitchPreferenceCompat>(PreferenceKeys.HIDE_TRENDING_PAGE)
|
||||
hideTrending?.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||||
true
|
||||
}
|
||||
|
||||
val labelVisibilityMode = findPreference<ListPreference>("label_visibility")
|
||||
val labelVisibilityMode = findPreference<ListPreference>(PreferenceKeys.LABEL_VISIBILITY)
|
||||
labelVisibilityMode?.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||||
|
@ -15,21 +15,21 @@ class HistorySettings : PreferenceFragmentCompat() {
|
||||
settingsActivity.changeTopBarText(getString(R.string.history))
|
||||
|
||||
// clear search history
|
||||
val clearHistory = findPreference<Preference>("clear_history")
|
||||
val clearHistory = findPreference<Preference>(PreferenceKeys.CLEAR_SEARCH_HISTORY)
|
||||
clearHistory?.setOnPreferenceClickListener {
|
||||
PreferenceHelper.removePreference("search_history")
|
||||
true
|
||||
}
|
||||
|
||||
// clear watch history and positions
|
||||
val clearWatchHistory = findPreference<Preference>("clear_watch_history")
|
||||
val clearWatchHistory = findPreference<Preference>(PreferenceKeys.CLEAR_WATCH_HISTORY)
|
||||
clearWatchHistory?.setOnPreferenceClickListener {
|
||||
PreferenceHelper.removePreference("watch_history")
|
||||
true
|
||||
}
|
||||
|
||||
// clear watch positions
|
||||
val clearWatchPositions = findPreference<Preference>("clear_watch_positions")
|
||||
val clearWatchPositions = findPreference<Preference>(PreferenceKeys.CLEAR_WATCH_POSITIONS)
|
||||
clearWatchPositions?.setOnPreferenceClickListener {
|
||||
PreferenceHelper.removePreference("watch_positions")
|
||||
true
|
||||
|
@ -115,14 +115,14 @@ class InstanceSettings : PreferenceFragmentCompat() {
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.instance))
|
||||
|
||||
val instance = findPreference<ListPreference>("selectInstance")
|
||||
val instance = findPreference<ListPreference>(PreferenceKeys.FETCH_INSTANCE)
|
||||
// fetchInstance()
|
||||
initCustomInstances(instance!!)
|
||||
instance.setOnPreferenceChangeListener { _, newValue ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||||
RetrofitInstance.url = newValue.toString()
|
||||
if (!PreferenceHelper.getBoolean("auth_instance_toggle", false)) {
|
||||
if (!PreferenceHelper.getBoolean(PreferenceKeys.AUTH_INSTANCE_TOGGLE, false)) {
|
||||
RetrofitInstance.authUrl = newValue.toString()
|
||||
logout()
|
||||
}
|
||||
@ -130,10 +130,10 @@ class InstanceSettings : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
|
||||
val authInstance = findPreference<ListPreference>("selectAuthInstance")
|
||||
val authInstance = findPreference<ListPreference>(PreferenceKeys.AUTH_INSTANCE)
|
||||
initCustomInstances(authInstance!!)
|
||||
// hide auth instance if option deselected
|
||||
if (!PreferenceHelper.getBoolean("auth_instance_toggle", false)) {
|
||||
if (!PreferenceHelper.getBoolean(PreferenceKeys.AUTH_INSTANCE_TOGGLE, false)) {
|
||||
authInstance.isVisible = false
|
||||
}
|
||||
authInstance.setOnPreferenceChangeListener { _, newValue ->
|
||||
@ -146,7 +146,7 @@ class InstanceSettings : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
|
||||
val authInstanceToggle = findPreference<SwitchPreferenceCompat>("auth_instance_toggle")
|
||||
val authInstanceToggle = findPreference<SwitchPreferenceCompat>(PreferenceKeys.AUTH_INSTANCE_TOGGLE)
|
||||
authInstanceToggle?.setOnPreferenceChangeListener { _, newValue ->
|
||||
authInstance.isVisible = newValue == true
|
||||
logout()
|
||||
@ -158,14 +158,14 @@ class InstanceSettings : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
|
||||
val customInstance = findPreference<Preference>("customInstance")
|
||||
val customInstance = findPreference<Preference>(PreferenceKeys.CUSTOM_INSTANCE)
|
||||
customInstance?.setOnPreferenceClickListener {
|
||||
val newFragment = CustomInstanceDialog()
|
||||
newFragment.show(childFragmentManager, "CustomInstanceDialog")
|
||||
true
|
||||
}
|
||||
|
||||
val clearCustomInstances = findPreference<Preference>("clearCustomInstances")
|
||||
val clearCustomInstances = findPreference<Preference>(PreferenceKeys.CLEAR_CUSTOM_INSTANCES)
|
||||
clearCustomInstances?.setOnPreferenceClickListener {
|
||||
PreferenceHelper.removePreference("customInstances")
|
||||
val intent = Intent(context, SettingsActivity::class.java)
|
||||
@ -173,7 +173,7 @@ class InstanceSettings : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
|
||||
val login = findPreference<Preference>("login_register")
|
||||
val login = findPreference<Preference>(PreferenceKeys.LOGIN_REGISTER)
|
||||
val token = PreferenceHelper.getToken()
|
||||
if (token != "") login?.setTitle(R.string.logout)
|
||||
login?.setOnPreferenceClickListener {
|
||||
@ -188,7 +188,7 @@ class InstanceSettings : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
|
||||
val deleteAccount = findPreference<Preference>("delete_account")
|
||||
val deleteAccount = findPreference<Preference>(PreferenceKeys.DELETE_ACCOUNT)
|
||||
deleteAccount?.setOnPreferenceClickListener {
|
||||
val token = PreferenceHelper.getToken()
|
||||
if (token != "") {
|
||||
@ -200,7 +200,7 @@ class InstanceSettings : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
|
||||
val importFromYt = findPreference<Preference>("import_from_yt")
|
||||
val importFromYt = findPreference<Preference>(PreferenceKeys.IMPORT_SUBS)
|
||||
importFromYt?.setOnPreferenceClickListener {
|
||||
importSubscriptions()
|
||||
true
|
||||
|
@ -16,12 +16,12 @@ class PlayerSettings : PreferenceFragmentCompat() {
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.audio_video))
|
||||
|
||||
val playerOrientation = findPreference<ListPreference>("fullscreen_orientation")
|
||||
val autoRotateToFullscreen = findPreference<SwitchPreferenceCompat>("auto_fullscreen")
|
||||
val playerOrientation = findPreference<ListPreference>(PreferenceKeys.FULLSCREEN_ORIENTATION)
|
||||
val autoRotateToFullscreen = findPreference<SwitchPreferenceCompat>(PreferenceKeys.AUTO_FULLSCREEN)
|
||||
|
||||
// only show the player orientation option if auto fullscreen is disabled
|
||||
playerOrientation?.isEnabled != PreferenceHelper.getBoolean(
|
||||
"auto_fullscreen",
|
||||
PreferenceKeys.AUTO_FULLSCREEN,
|
||||
false
|
||||
)
|
||||
|
||||
|
@ -0,0 +1,70 @@
|
||||
package com.github.libretube.preferences
|
||||
|
||||
/**
|
||||
* keys for the shared preferences
|
||||
*/
|
||||
object PreferenceKeys {
|
||||
/**
|
||||
* General
|
||||
*/
|
||||
const val LANGUAGE = "language"
|
||||
const val REGION = "region"
|
||||
|
||||
/**
|
||||
* Appearance
|
||||
*/
|
||||
const val THEME_MODE = "theme_toggle"
|
||||
const val PURE_THEME = "pure_theme"
|
||||
const val ACCENT_COLOR = "accent_color"
|
||||
const val GRID_COLUMNS = "grid"
|
||||
const val DEFAULT_TAB = "default_tab"
|
||||
const val LABEL_VISIBILITY = "label_visibility"
|
||||
const val HIDE_TRENDING_PAGE = "hide_trending_page"
|
||||
const val APP_ICON = "icon_change"
|
||||
|
||||
/**
|
||||
* Instance
|
||||
*/
|
||||
const val FETCH_INSTANCE = "selectInstance"
|
||||
const val AUTH_INSTANCE = "selectAuthInstance"
|
||||
const val AUTH_INSTANCE_TOGGLE = "auth_instance_toggle"
|
||||
const val CUSTOM_INSTANCE = "customInstance"
|
||||
const val CLEAR_CUSTOM_INSTANCES = "clearCustomInstances"
|
||||
const val LOGIN_REGISTER = "login_register"
|
||||
const val DELETE_ACCOUNT = "delete_account"
|
||||
const val IMPORT_SUBS = "import_from_yt"
|
||||
|
||||
/**
|
||||
* Player
|
||||
*/
|
||||
const val AUTO_FULLSCREEN = "auto_fullscreen"
|
||||
const val AUTO_PLAY = "autoplay"
|
||||
const val RELATED_STREAMS = "related_streams_toggle"
|
||||
const val PLAYBACK_SPEED = "playback_speed"
|
||||
const val FULLSCREEN_ORIENTATION = "fullscreen_orientation"
|
||||
const val PAUSE_ON_SCREEN_OFF = "pause_screen_off"
|
||||
const val WATCH_POSITION_TOGGLE = "watch_position_toggle"
|
||||
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 SEEK_INCREMENT = "seek_increment"
|
||||
const val PLAYER_VIDEO_FORMAT = "player_video_format"
|
||||
const val DEFAULT_RESOLUTION = "default_res"
|
||||
const val BUFFERING_GOAL = "buffering_goal"
|
||||
|
||||
/**
|
||||
* Download
|
||||
*/
|
||||
const val DOWNLOAD_VIDEO_FORMAT = "video_format"
|
||||
const val DOWNLOAD_LOCATION = "download_location"
|
||||
const val DOWNLOAD_FOLDER = "download_folder"
|
||||
|
||||
/**
|
||||
* Advanced
|
||||
*/
|
||||
const val DATA_SAVER_MODE = "data_saver_mode"
|
||||
const val RESET_SETTINGS = "reset_settings"
|
||||
const val CLEAR_SEARCH_HISTORY = "clear_search_history"
|
||||
const val CLEAR_WATCH_HISTORY = "clear_watch_history"
|
||||
const val CLEAR_WATCH_POSITIONS = "clear_watch_positions"
|
||||
}
|
@ -21,6 +21,7 @@ import com.arthenica.ffmpegkit.FFmpegKit
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.obj.DownloadType
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import java.io.File
|
||||
|
||||
var IS_DOWNLOAD_RUNNING = false
|
||||
@ -52,7 +53,7 @@ class DownloadService : Service() {
|
||||
videoUrl = intent.getStringExtra("videoUrl")!!
|
||||
audioUrl = intent.getStringExtra("audioUrl")!!
|
||||
duration = intent.getIntExtra("duration", 1)
|
||||
extension = PreferenceHelper.getString("video_format", ".mp4")!!
|
||||
extension = PreferenceHelper.getString(PreferenceKeys.DOWNLOAD_VIDEO_FORMAT, ".mp4")!!
|
||||
downloadType = if (audioUrl != "" && videoUrl != "") DownloadType.MUX
|
||||
else if (audioUrl != "") DownloadType.AUDIO
|
||||
else if (videoUrl != "") DownloadType.VIDEO
|
||||
@ -86,8 +87,8 @@ class DownloadService : Service() {
|
||||
Log.e(TAG, "Directory already have")
|
||||
}
|
||||
|
||||
val downloadLocationPref = PreferenceHelper.getString("download_location", "")
|
||||
val folderName = PreferenceHelper.getString("download_folder", "LibreTube")
|
||||
val downloadLocationPref = PreferenceHelper.getString(PreferenceKeys.DOWNLOAD_LOCATION, "")
|
||||
val folderName = PreferenceHelper.getString(PreferenceKeys.DOWNLOAD_FOLDER, "LibreTube")
|
||||
|
||||
val location = when (downloadLocationPref) {
|
||||
"downloads" -> Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS)
|
||||
|
@ -5,6 +5,7 @@ import android.content.Context
|
||||
import android.support.v4.media.session.MediaSessionCompat
|
||||
import com.github.libretube.obj.Streams
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import com.google.android.exoplayer2.C
|
||||
import com.google.android.exoplayer2.ExoPlayer
|
||||
import com.google.android.exoplayer2.MediaItem
|
||||
@ -71,7 +72,7 @@ class BackgroundMode {
|
||||
*/
|
||||
player!!.addListener(object : Player.Listener {
|
||||
override fun onPlaybackStateChanged(@Player.State state: Int) {
|
||||
val autoplay = PreferenceHelper.getBoolean("autoplay", false)
|
||||
val autoplay = PreferenceHelper.getBoolean(PreferenceKeys.AUTO_PLAY, false)
|
||||
if (state == Player.STATE_ENDED) {
|
||||
if (autoplay) playNextVideo(c)
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ import android.content.Context
|
||||
import android.os.Build
|
||||
import android.telephony.TelephonyManager
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import java.util.*
|
||||
|
||||
object LocaleHelper {
|
||||
|
||||
fun updateLanguage(context: Context) {
|
||||
val languageName = PreferenceHelper.getString("language", "sys")
|
||||
val languageName = PreferenceHelper.getString(PreferenceKeys.LANGUAGE, "sys")
|
||||
if (languageName == "sys") updateLocaleConf(context, Locale.getDefault())
|
||||
else if ("$languageName".length < 3) {
|
||||
val locale = Locale(languageName.toString())
|
||||
|
@ -12,13 +12,14 @@ import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.text.HtmlCompat
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
import com.github.libretube.preferences.PreferenceKeys
|
||||
import com.google.android.material.color.DynamicColors
|
||||
|
||||
object ThemeHelper {
|
||||
|
||||
fun updateTheme(activity: AppCompatActivity) {
|
||||
val themeMode = PreferenceHelper.getString("theme_toggle", "A")!!
|
||||
val pureThemeEnabled = PreferenceHelper.getBoolean("pure_theme", false)
|
||||
val themeMode = PreferenceHelper.getString(PreferenceKeys.THEME_MODE, "A")!!
|
||||
val pureThemeEnabled = PreferenceHelper.getBoolean(PreferenceKeys.PURE_THEME, false)
|
||||
|
||||
updateAccentColor(activity, pureThemeEnabled)
|
||||
updateThemeMode(themeMode)
|
||||
@ -30,7 +31,7 @@ object ThemeHelper {
|
||||
) {
|
||||
val theme = when (
|
||||
PreferenceHelper.getString(
|
||||
"accent_color",
|
||||
PreferenceKeys.ACCENT_COLOR,
|
||||
"purple"
|
||||
)
|
||||
) {
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_trash"
|
||||
app:key="clear_history"
|
||||
app:key="clear_search_history"
|
||||
app:title="@string/clear_history" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
Loading…
Reference in New Issue
Block a user