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