mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
toggle autoplay while playing video
This commit is contained in:
parent
05ad4363ff
commit
c9740a2d5f
@ -284,7 +284,8 @@
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
|
||||
<service android:name=".services.BackgroundMode"
|
||||
<service
|
||||
android:name=".services.BackgroundMode"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
</application>
|
||||
|
@ -31,7 +31,8 @@ class ChaptersAdapter(
|
||||
|
||||
if (selectedPosition == position) {
|
||||
// get the color for highlighted controls
|
||||
val color = ThemeHelper.getThemeColor(root.context, android.R.attr.colorControlHighlight)
|
||||
val color =
|
||||
ThemeHelper.getThemeColor(root.context, android.R.attr.colorControlHighlight)
|
||||
chapterLL.setBackgroundColor(color)
|
||||
} else chapterLL.setBackgroundColor(Color.TRANSPARENT)
|
||||
root.setOnClickListener {
|
||||
|
@ -202,6 +202,7 @@ class PlayerFragment : Fragment() {
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentPlayerBinding.inflate(layoutInflater, container, false)
|
||||
exoPlayerView = binding.player
|
||||
playerBinding = binding.player.binding
|
||||
doubleTapOverlayBinding = binding.doubleTapOverlay.binding
|
||||
|
||||
@ -215,6 +216,8 @@ class PlayerFragment : Fragment() {
|
||||
|
||||
setUserPrefs()
|
||||
|
||||
if (autoplayEnabled == true) playerBinding.autoplayIV.setImageResource(R.drawable.ic_toggle_on)
|
||||
|
||||
val mainActivity = activity as MainActivity
|
||||
if (autoRotationEnabled) {
|
||||
// enable auto rotation
|
||||
@ -345,8 +348,6 @@ class PlayerFragment : Fragment() {
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.binding.container.visibility = View.VISIBLE
|
||||
|
||||
exoPlayerView = binding.player
|
||||
|
||||
binding.playerMotionLayout.addTransitionListener(object : MotionLayout.TransitionListener {
|
||||
override fun onTransitionStarted(
|
||||
motionLayout: MotionLayout?,
|
||||
@ -427,6 +428,16 @@ class PlayerFragment : Fragment() {
|
||||
playerBinding.advancedOptions.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
// autoplay toggle button
|
||||
playerBinding.autoplayLL.setOnClickListener {
|
||||
autoplayEnabled = if (autoplayEnabled) {
|
||||
playerBinding.autoplayIV.setImageResource(R.drawable.ic_toggle_off)
|
||||
false
|
||||
} else {
|
||||
playerBinding.autoplayIV.setImageResource(R.drawable.ic_toggle_on)
|
||||
true
|
||||
}
|
||||
}
|
||||
binding.playImageView.setOnClickListener {
|
||||
if (!exoPlayer.isPlaying) {
|
||||
// start or go on playing
|
||||
@ -680,7 +691,8 @@ class PlayerFragment : Fragment() {
|
||||
) as NotificationManager
|
||||
notificationManager.cancel(1)
|
||||
exoPlayer.release()
|
||||
activity?.requestedOrientation = if ((activity as MainActivity).autoRotationEnabled) ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
activity?.requestedOrientation =
|
||||
if ((activity as MainActivity).autoRotationEnabled) ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
else ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
|
@ -122,7 +122,10 @@ class PlaylistFragment : Fragment() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
// load locally stored playlists with the auth api
|
||||
if (isPipedPlaylist()) RetrofitInstance.authApi.getPlaylistNextPage(playlistId!!, nextPage!!)
|
||||
if (isPipedPlaylist()) RetrofitInstance.authApi.getPlaylistNextPage(
|
||||
playlistId!!,
|
||||
nextPage!!
|
||||
)
|
||||
RetrofitInstance.api.getPlaylistNextPage(playlistId!!, nextPage!!)
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
|
@ -65,10 +65,12 @@ class AppearanceSettings : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
|
||||
val systemCaptionStyle = findPreference<SwitchPreferenceCompat>(PreferenceKeys.SYSTEM_CAPTION_STYLE)
|
||||
val systemCaptionStyle =
|
||||
findPreference<SwitchPreferenceCompat>(PreferenceKeys.SYSTEM_CAPTION_STYLE)
|
||||
val captionSettings = findPreference<Preference>(PreferenceKeys.CAPTION_SETTINGS)
|
||||
|
||||
captionSettings?.isVisible = PreferenceHelper.getBoolean(PreferenceKeys.SYSTEM_CAPTION_STYLE, true)
|
||||
captionSettings?.isVisible =
|
||||
PreferenceHelper.getBoolean(PreferenceKeys.SYSTEM_CAPTION_STYLE, true)
|
||||
systemCaptionStyle?.setOnPreferenceChangeListener { _, newValue ->
|
||||
captionSettings?.isVisible = newValue as Boolean
|
||||
true
|
||||
|
@ -264,7 +264,8 @@ class InstanceSettings : PreferenceFragmentCompat() {
|
||||
val token = PreferenceHelper.getToken()
|
||||
if (token != "") {
|
||||
// check StorageAccess
|
||||
val accessGranted = PermissionHelper.isStoragePermissionGranted(activity as AppCompatActivity)
|
||||
val accessGranted =
|
||||
PermissionHelper.isStoragePermissionGranted(activity as AppCompatActivity)
|
||||
if (accessGranted) getContent.launch("*/*")
|
||||
else PermissionHelper.requestReadWrite(activity as AppCompatActivity)
|
||||
} else {
|
||||
|
@ -8,7 +8,6 @@ import androidx.preference.SwitchPreferenceCompat
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.activities.SettingsActivity
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class PlayerSettings : PreferenceFragmentCompat() {
|
||||
val TAG = "PlayerSettings"
|
||||
@ -51,7 +50,8 @@ class PlayerSettings : PreferenceFragmentCompat() {
|
||||
}
|
||||
defaultSubtitle?.entries = localeNames.toTypedArray()
|
||||
defaultSubtitle?.entryValues = localeCodes.toTypedArray()
|
||||
defaultSubtitle?.summaryProvider = Preference.SummaryProvider<ListPreference> { preference ->
|
||||
defaultSubtitle?.summaryProvider =
|
||||
Preference.SummaryProvider<ListPreference> { preference ->
|
||||
preference.entry
|
||||
}
|
||||
}
|
||||
|
10
app/src/main/res/drawable/ic_toggle_off.xml
Normal file
10
app/src/main/res/drawable/ic_toggle_off.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="@android:color/white"
|
||||
android:viewportWidth="48"
|
||||
android:viewportHeight="48">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M14,36q-5,0 -8.5,-3.5T2,24q0,-5 3.5,-8.5T14,12h20q5,0 8.5,3.5T46,24q0,5 -3.5,8.5T34,36ZM14,33h20q3.75,0 6.375,-2.625T43,24q0,-3.75 -2.625,-6.375T34,15L14,15q-3.75,0 -6.375,2.625T5,24q0,3.75 2.625,6.375T14,33ZM13.95,29.05q2.1,0 3.575,-1.475T19,24q0,-2.1 -1.475,-3.575T13.95,18.95q-2.1,0 -3.575,1.475T8.9,24q0,2.1 1.475,3.575t3.575,1.475ZM24,24Z" />
|
||||
</vector>
|
10
app/src/main/res/drawable/ic_toggle_on.xml
Normal file
10
app/src/main/res/drawable/ic_toggle_on.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="@android:color/white"
|
||||
android:viewportWidth="48"
|
||||
android:viewportHeight="48">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M14,36q-5,0 -8.5,-3.5T2,24q0,-5 3.5,-8.5T14,12h20q5,0 8.5,3.5T46,24q0,5 -3.5,8.5T34,36ZM14,33h20q3.75,0 6.375,-2.625T43,24q0,-3.75 -2.625,-6.375T34,15L14,15q-3.75,0 -6.375,2.625T5,24q0,3.75 2.625,6.375T14,33ZM34.05,29.05q2.1,0 3.575,-1.475T39.1,24q0,-2.1 -1.475,-3.575T34.05,18.95q-2.1,0 -3.575,1.475T29,24q0,2.1 1.475,3.575t3.575,1.475ZM24,24Z" />
|
||||
</vector>
|
@ -89,13 +89,44 @@
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/advanced_options"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginHorizontal="3dp"
|
||||
android:layout_marginTop="-12dp"
|
||||
android:layout_marginEnd="3dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone">
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/autoplayLL"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="1.5dp"
|
||||
android:text="@string/player_autoplay"
|
||||
android:textColor="@android:color/white" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/autoplayIV"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10dp"
|
||||
android:src="@drawable/ic_toggle_off" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/captions"
|
||||
@ -118,6 +149,8 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@id/exo_bottom_bar"
|
||||
android:layout_width="match_parent"
|
||||
@ -129,6 +162,7 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="15dp">
|
||||
|
||||
|
@ -372,7 +372,7 @@
|
||||
app:layout_constraintBottom_toBottomOf="@id/main_container"
|
||||
app:layout_constraintStart_toStartOf="@id/main_container"
|
||||
app:layout_constraintTop_toTopOf="@id/main_container"
|
||||
app:show_buffering="when_playing" >
|
||||
app:show_buffering="when_playing">
|
||||
|
||||
<com.github.libretube.views.DoubleTapOverlay
|
||||
android:id="@+id/doubleTapOverlay"
|
||||
@ -382,7 +382,6 @@
|
||||
</com.github.libretube.views.CustomExoPlayerView>
|
||||
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close_imageView"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -96,10 +96,10 @@
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/sub_channels_container"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:descendantFocusability="blocksDescendants">
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:visibility="gone">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/sub_channels"
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_settings"
|
||||
app:key="general"
|
||||
android:summary="@string/general_summary"
|
||||
app:key="general"
|
||||
app:title="@string/general" />
|
||||
|
||||
<Preference
|
||||
|
Loading…
Reference in New Issue
Block a user