Merge branch 'libre-tube:master' into master

This commit is contained in:
XelXen 2022-06-12 23:12:03 +05:30 committed by GitHub
commit 98413efde0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 15 deletions

View File

@ -49,6 +49,7 @@ import com.github.libretube.dialogs.AddtoPlaylistDialog
import com.github.libretube.dialogs.DownloadDialog
import com.github.libretube.dialogs.ShareDialog
import com.github.libretube.hideKeyboard
import com.github.libretube.obj.ChapterSegment
import com.github.libretube.obj.PipedStream
import com.github.libretube.obj.Segment
import com.github.libretube.obj.Segments
@ -80,6 +81,7 @@ import com.google.android.exoplayer2.upstream.DefaultDataSource
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
import com.google.android.exoplayer2.util.RepeatModeUtil
import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.squareup.picasso.Picasso
import java.io.IOException
@ -112,6 +114,7 @@ class PlayerFragment : Fragment() {
private lateinit var motionLayout: MotionLayout
private lateinit var exoPlayer: ExoPlayer
private lateinit var segmentData: Segments
private var relatedStreamsEnabled = true
private lateinit var relDownloadVideo: LinearLayout
@ -259,13 +262,9 @@ class PlayerFragment : Fragment() {
}
}
view.findViewById<com.google.android.material.card.MaterialCardView>(R.id.comments_toggle)
view.findViewById<MaterialCardView>(R.id.comments_toggle)
.setOnClickListener {
commentsRecView.visibility =
if (commentsRecView.isVisible) View.GONE else View.VISIBLE
relatedRecView.visibility =
if (relatedRecView.isVisible) View.GONE else View.VISIBLE
if (!commentsLoaded!!) fetchComments()
toggleComments()
}
// FullScreen button trigger
@ -328,6 +327,14 @@ class PlayerFragment : Fragment() {
GridLayoutManager(view.context, resources.getInteger(R.integer.grid_items))
}
private fun toggleComments() {
commentsRecView.visibility =
if (commentsRecView.isVisible) View.GONE else View.VISIBLE
relatedRecView.visibility =
if (relatedRecView.isVisible) View.GONE else View.VISIBLE
if (!commentsLoaded!!) fetchComments()
}
override fun onDestroy() {
super.onDestroy()
try {
@ -418,13 +425,19 @@ class PlayerFragment : Fragment() {
}
}
}
// check whether related streams are enabled
val sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(requireContext())
relatedStreamsEnabled = sharedPreferences.getBoolean("related_streams_toggle", true)
runOnUiThread {
createExoPlayer(view)
prepareExoPlayerView()
if (response.chapters != null) initializeChapters(response.chapters)
setResolutionAndSubtitles(view, response)
exoPlayer.prepare()
exoPlayer.play()
initializePlayerView(view, response)
if (!relatedStreamsEnabled) toggleComments()
}
}
}
@ -540,11 +553,12 @@ class PlayerFragment : Fragment() {
}
}
}
relatedRecView.adapter = TrendingAdapter(
response.relatedStreams!!,
childFragmentManager
)
if (relatedStreamsEnabled) {
relatedRecView.adapter = TrendingAdapter(
response.relatedStreams!!,
childFragmentManager
)
}
val description = response.description!!
view.findViewById<TextView>(R.id.player_description).text =
// detect whether the description is html formatted
@ -582,6 +596,12 @@ class PlayerFragment : Fragment() {
}
}
private fun initializeChapters(chapters: List<ChapterSegment>) {
chapters.forEach { chapter ->
Log.e(TAG, chapter.title!!)
}
}
private fun setResolutionAndSubtitles(view: View, response: Streams) {
var videosNameArray: Array<CharSequence> = arrayOf()
videosNameArray += "HLS"

View File

@ -19,8 +19,8 @@ class AppearanceSettings : PreferenceFragmentCompat() {
val themeToggle = findPreference<ListPreference>("theme_togglee")
themeToggle?.setOnPreferenceChangeListener { _, _ ->
activity?.recreate()
requireMainActivityRestart = true
ThemeHelper().restartMainActivity(requireContext())
true
}

View File

@ -60,8 +60,8 @@
<string name="changeLanguage">Language</string>
<string name="systemLanguage">System</string>
<string name="systemDefault">System</string>
<string name="lightTheme">Luminating light</string>
<string name="darkTheme">Dissapearing dark</string>
<string name="lightTheme">Light theme</string>
<string name="darkTheme">Dark theme</string>
<string name="subscribers">%1$s subscribers</string>
<string name="settings">Settings</string>
<string name="location">Location</string>
@ -107,7 +107,7 @@
<string name="color_yellow">Yeeting yellow</string>
<string name="color_green">Groovy green</string>
<string name="color_purple">Pleasurable purple</string>
<string name="oledTheme">Blind black</string>
<string name="oledTheme">Black theme</string>
<string name="material_you">Mystic Material 3</string>
<string name="sponsorblock_notifications">Notifications</string>
<string name="app_icon">Icon</string>
@ -171,4 +171,6 @@
<string name="invalid_url">Please enter a valid url</string>
<string name="version">Version %1$s</string>
<string name="about_summary">Get to know team LibreTube and how it all happens.</string>
<string name="related_streams">Related streams</string>
<string name="related_streams_summary">Show related streams to videos.</string>
</resources>

View File

@ -68,4 +68,15 @@
</PreferenceCategory>
<PreferenceCategory>
<SwitchPreference
app:key="related_streams_toggle"
app:title="@string/related_streams"
app:summary="@string/related_streams_summary"
android:defaultValue="true"
android:icon="@drawable/ic_list"/>
</PreferenceCategory>
</PreferenceScreen>