mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 14:50:30 +05:30
commit
3564b15b43
@ -39,7 +39,6 @@ import com.github.libretube.util.CronetHelper
|
||||
import com.github.libretube.util.LocaleHelper
|
||||
import com.github.libretube.util.RetrofitInstance
|
||||
import com.github.libretube.util.ThemeHelper
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
import com.google.android.material.color.DynamicColors
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
@ -47,7 +46,6 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
lateinit var binding: ActivityMainBinding
|
||||
|
||||
private lateinit var bottomNavigationView: BottomNavigationView
|
||||
lateinit var navController: NavController
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -90,7 +88,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
// hide the trending page if enabled
|
||||
val hideTrendingPage = PreferenceHelper.getBoolean(this, "hide_trending_page", false)
|
||||
if (hideTrendingPage) bottomNavigationView.menu.findItem(R.id.homeFragment).isVisible =
|
||||
if (hideTrendingPage) binding.bottomNav.menu.findItem(R.id.homeFragment).isVisible =
|
||||
false
|
||||
|
||||
// navigate to the default start tab
|
||||
|
@ -68,7 +68,11 @@ class SettingsActivity : AppCompatActivity() {
|
||||
.beginTransaction()
|
||||
.replace(R.id.settings, MainSettings())
|
||||
.commit()
|
||||
binding.topBarTextView.text = getString(R.string.settings)
|
||||
changeTopBarText(getString(R.string.settings))
|
||||
}
|
||||
}
|
||||
|
||||
fun changeTopBarText(text: String) {
|
||||
if (this::binding.isInitialized) binding.topBarTextView.text = text
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package com.github.libretube.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.widget.Toast
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.activities.SettingsActivity
|
||||
import com.github.libretube.databinding.DialogCustomInstanceBinding
|
||||
import com.github.libretube.obj.CustomInstance
|
||||
import com.github.libretube.preferences.PreferenceHelper
|
||||
@ -45,8 +43,7 @@ class CustomInstanceDialog : DialogFragment() {
|
||||
URL(customInstance.frontendUrl).toURI()
|
||||
|
||||
PreferenceHelper.saveCustomInstance(requireContext(), customInstance)
|
||||
val intent = Intent(context, SettingsActivity::class.java)
|
||||
startActivity(intent)
|
||||
activity?.recreate()
|
||||
dismiss()
|
||||
} catch (e: Exception) {
|
||||
// invalid URL
|
||||
|
@ -454,18 +454,12 @@ class PlayerFragment : Fragment() {
|
||||
relatedStreams = response.relatedStreams
|
||||
|
||||
runOnUiThread {
|
||||
if (response.chapters != null) initializeChapters(response.chapters)
|
||||
// set media sources for the player
|
||||
setResolutionAndSubtitles(view, response)
|
||||
exoPlayer.prepare()
|
||||
prepareExoPlayerView()
|
||||
initializePlayerView(view, response)
|
||||
// support for time stamped links
|
||||
if (arguments?.getLong("timeStamp") != null) {
|
||||
val position = arguments?.getLong("timeStamp")!! * 1000
|
||||
exoPlayer.seekTo(position)
|
||||
}
|
||||
seekToWatchPosition()
|
||||
exoPlayer.prepare()
|
||||
exoPlayer.play()
|
||||
exoPlayerView.useController = true
|
||||
initializePlayerNotification(requireContext())
|
||||
@ -485,12 +479,17 @@ class PlayerFragment : Fragment() {
|
||||
run()
|
||||
}
|
||||
|
||||
// seek to saved watch position if available
|
||||
private fun seekToWatchPosition() {
|
||||
// seek to saved watch position if available
|
||||
val watchPositions = PreferenceHelper.getWatchPositions(requireContext())
|
||||
watchPositions.forEach {
|
||||
if (it.videoId == videoId) exoPlayer.seekTo(it.position)
|
||||
}
|
||||
// support for time stamped links
|
||||
if (arguments?.getLong("timeStamp") != null) {
|
||||
val position = arguments?.getLong("timeStamp")!! * 1000
|
||||
exoPlayer.seekTo(position)
|
||||
}
|
||||
}
|
||||
|
||||
// the function is working recursively
|
||||
@ -658,6 +657,9 @@ class PlayerFragment : Fragment() {
|
||||
|
||||
playerBinding.exoTitle.text = response.title
|
||||
|
||||
// init the chapters recyclerview
|
||||
if (response.chapters != null) initializeChapters(response.chapters)
|
||||
|
||||
// Listener for play and pause icon change
|
||||
exoPlayer.addListener(object : Player.Listener {
|
||||
override fun onIsPlayingChanged(isPlaying: Boolean) {
|
||||
|
@ -34,7 +34,7 @@ class AboutFragment : Fragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.binding.topBarTextView.text = getString(R.string.about)
|
||||
settingsActivity.changeTopBarText(getString(R.string.about))
|
||||
|
||||
binding.website.setOnClickListener {
|
||||
openLinkFromHref(WEBSITE_URL)
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.github.libretube.preferences
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
@ -16,7 +15,7 @@ class AdvancedSettings : PreferenceFragmentCompat() {
|
||||
setPreferencesFromResource(R.xml.advanced_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.binding.topBarTextView.text = getString(R.string.advanced)
|
||||
settingsActivity.changeTopBarText(getString(R.string.advanced))
|
||||
|
||||
// clear search history
|
||||
val clearHistory = findPreference<Preference>("clear_history")
|
||||
@ -50,8 +49,7 @@ class AdvancedSettings : PreferenceFragmentCompat() {
|
||||
PreferenceHelper.setToken(requireContext(), "")
|
||||
|
||||
requireMainActivityRestart = true
|
||||
val intent = Intent(context, SettingsActivity::class.java)
|
||||
startActivity(intent)
|
||||
activity?.recreate()
|
||||
}
|
||||
.setNegativeButton(getString(R.string.cancel)) { _, _ -> }
|
||||
.setTitle(R.string.reset)
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.github.libretube.preferences
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
@ -17,20 +16,19 @@ class AppearanceSettings : PreferenceFragmentCompat() {
|
||||
setPreferencesFromResource(R.xml.appearance_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.binding.topBarTextView.text = getString(R.string.appearance)
|
||||
settingsActivity.changeTopBarText(getString(R.string.appearance))
|
||||
|
||||
val themeToggle = findPreference<ListPreference>("theme_togglee")
|
||||
themeToggle?.setOnPreferenceChangeListener { _, _ ->
|
||||
requireMainActivityRestart = true
|
||||
ThemeHelper.restartMainActivity(requireContext())
|
||||
activity?.recreate()
|
||||
true
|
||||
}
|
||||
|
||||
val accentColor = findPreference<Preference>("accent_color")
|
||||
accentColor?.setOnPreferenceChangeListener { _, _ ->
|
||||
requireMainActivityRestart = true
|
||||
val intent = Intent(context, SettingsActivity::class.java)
|
||||
startActivity(intent)
|
||||
activity?.recreate()
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ class InstanceSettings : PreferenceFragmentCompat() {
|
||||
setPreferencesFromResource(R.xml.instance_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.binding.topBarTextView.text = getString(R.string.instance)
|
||||
settingsActivity.changeTopBarText(getString(R.string.instance))
|
||||
|
||||
val instance = findPreference<ListPreference>("selectInstance")
|
||||
// fetchInstance()
|
||||
|
@ -12,6 +12,6 @@ class PlayerSettings : PreferenceFragmentCompat() {
|
||||
setPreferencesFromResource(R.xml.player_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.binding.topBarTextView.text = getString(R.string.player)
|
||||
settingsActivity.changeTopBarText(getString(R.string.player))
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ class SponsorBlockSettings : PreferenceFragmentCompat() {
|
||||
setPreferencesFromResource(R.xml.sponsorblock_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.binding.topBarTextView.text = getString(R.string.sponsorblock)
|
||||
settingsActivity.changeTopBarText(getString(R.string.sponsorblock))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user