mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
commit
bee4ba14f9
@ -97,7 +97,8 @@ class RouterActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
intent.putExtra(IntentData.videoId, videoId)
|
||||
} else -> {
|
||||
}
|
||||
else -> {
|
||||
val timeStamp = uri.getQueryParameter("t")
|
||||
val videoId = uri.path!!.replace("/", "")
|
||||
|
||||
|
@ -58,7 +58,7 @@ class PlaylistAdapter(
|
||||
root.setOnClickListener {
|
||||
NavigationHelper.navigateVideo(root.context, streamItem.url, playlistId)
|
||||
}
|
||||
val videoId = streamItem.url.toID()
|
||||
val videoId = streamItem.url!!.toID()
|
||||
root.setOnLongClickListener {
|
||||
VideoOptionsDialog(videoId)
|
||||
.show(childFragmentManager, VideoOptionsDialog::class.java.name)
|
||||
|
@ -15,7 +15,7 @@ object DatabaseHelper {
|
||||
streams.title,
|
||||
streams.uploadDate,
|
||||
streams.uploader,
|
||||
streams.uploaderUrl.toID(),
|
||||
streams.uploaderUrl!!.toID(),
|
||||
streams.uploaderAvatar,
|
||||
streams.thumbnailUrl,
|
||||
streams.duration
|
||||
|
@ -87,7 +87,7 @@ class ShareDialog(
|
||||
|
||||
// return the custom instance frontend url if available
|
||||
customInstances.forEach { instance ->
|
||||
if (instance.apiUrl == instancePref) return instance.apiUrl
|
||||
if (instance.apiUrl == instancePref) return instance.frontendUrl
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
@ -101,6 +101,7 @@ import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
|
||||
import com.google.android.exoplayer2.util.RepeatModeUtil
|
||||
import com.google.android.exoplayer2.video.VideoSize
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import kotlin.math.abs
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@ -108,7 +109,6 @@ import org.chromium.net.CronetEngine
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.abs
|
||||
|
||||
class PlayerFragment : BaseFragment() {
|
||||
|
||||
|
@ -4,7 +4,6 @@ import android.os.Bundle
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.activities.SettingsActivity
|
||||
import com.github.libretube.views.MaterialPreferenceFragment
|
||||
import java.util.*
|
||||
|
||||
class AudioVideoSettings : MaterialPreferenceFragment() {
|
||||
|
||||
|
@ -4,6 +4,7 @@ import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.work.Constraints
|
||||
@ -30,7 +31,11 @@ class NotificationHelper(
|
||||
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
|
||||
// the id where notification channels start
|
||||
private var notificationId = NotificationManager.activeNotifications.size + 5
|
||||
private var notificationId = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
NotificationManager.activeNotifications.size + 5
|
||||
} else {
|
||||
5
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the work manager task
|
||||
@ -117,7 +122,7 @@ class NotificationHelper(
|
||||
}
|
||||
|
||||
val lastSeenStreamId = PreferenceHelper.getLatestVideoId()
|
||||
val latestFeedStreamId = videoFeed[0].url.toID()
|
||||
val latestFeedStreamId = videoFeed[0].url!!.toID()
|
||||
|
||||
// first time notifications enabled or no new video available
|
||||
if (lastSeenStreamId == "" || lastSeenStreamId == latestFeedStreamId) {
|
||||
@ -126,7 +131,7 @@ class NotificationHelper(
|
||||
}
|
||||
|
||||
// filter the new videos out
|
||||
val lastSeenStreamItem = videoFeed.filter { it.url.toID() == lastSeenStreamId }
|
||||
val lastSeenStreamItem = videoFeed.filter { it.url!!.toID() == lastSeenStreamId }
|
||||
|
||||
// previous video not found
|
||||
if (lastSeenStreamItem.isEmpty()) return@runBlocking
|
||||
@ -141,7 +146,7 @@ class NotificationHelper(
|
||||
// create a notification for each new stream
|
||||
channelGroups.forEach { (_, streams) ->
|
||||
createNotification(
|
||||
group = streams[0].uploaderUrl.toID(),
|
||||
group = streams[0].uploaderUrl!!.toID(),
|
||||
title = streams[0].uploaderName.toString(),
|
||||
isSummary = true
|
||||
)
|
||||
@ -151,12 +156,12 @@ class NotificationHelper(
|
||||
createNotification(
|
||||
title = streamItem.title.toString(),
|
||||
description = streamItem.uploaderName.toString(),
|
||||
group = streamItem.uploaderUrl.toID()
|
||||
group = streamItem.uploaderUrl!!.toID()
|
||||
)
|
||||
}
|
||||
}
|
||||
// save the latest streams that got notified about
|
||||
PreferenceHelper.setLatestVideoId(videoFeed[0].url.toID())
|
||||
PreferenceHelper.setLatestVideoId(videoFeed[0].url!!.toID())
|
||||
}
|
||||
// return whether the work succeeded
|
||||
return success
|
||||
|
@ -5,18 +5,17 @@ import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.support.v4.media.session.MediaSessionCompat
|
||||
import coil.request.ImageRequest
|
||||
import com.github.libretube.activities.MainActivity
|
||||
import com.github.libretube.constants.BACKGROUND_CHANNEL_ID
|
||||
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
|
||||
import com.github.libretube.extensions.await
|
||||
import com.github.libretube.obj.Streams
|
||||
import com.google.android.exoplayer2.ExoPlayer
|
||||
import com.google.android.exoplayer2.Player
|
||||
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector
|
||||
import com.google.android.exoplayer2.ui.PlayerNotificationManager
|
||||
import java.net.URL
|
||||
|
||||
class NowPlayingNotification(
|
||||
private val context: Context,
|
||||
@ -43,7 +42,7 @@ class NowPlayingNotification(
|
||||
* The [DescriptionAdapter] is used to show title, uploaderName and thumbnail of the video in the notification
|
||||
* Basic example [here](https://github.com/AnthonyMarkD/AudioPlayerSampleTest)
|
||||
*/
|
||||
inner class DescriptionAdapter() :
|
||||
inner class DescriptionAdapter :
|
||||
PlayerNotificationManager.MediaDescriptionAdapter {
|
||||
/**
|
||||
* sets the title of the notification
|
||||
@ -83,36 +82,25 @@ class NowPlayingNotification(
|
||||
player: Player,
|
||||
callback: PlayerNotificationManager.BitmapCallback
|
||||
): Bitmap? {
|
||||
lateinit var bitmap: Bitmap
|
||||
var resizedBitmap: Bitmap? = null
|
||||
|
||||
/**
|
||||
* running on a new thread to prevent a NetworkMainThreadException
|
||||
*/
|
||||
Thread {
|
||||
try {
|
||||
/**
|
||||
* try to GET the thumbnail from the URL
|
||||
*/
|
||||
val inputStream = URL(streams?.thumbnailUrl).openStream()
|
||||
bitmap = BitmapFactory.decodeStream(inputStream)
|
||||
} catch (ex: java.lang.Exception) {
|
||||
ex.printStackTrace()
|
||||
val request = ImageRequest.Builder(context)
|
||||
.data(streams?.thumbnailUrl)
|
||||
.target { result ->
|
||||
val bitmap = (result as BitmapDrawable).bitmap
|
||||
resizedBitmap = Bitmap.createScaledBitmap(
|
||||
bitmap,
|
||||
bitmap.width,
|
||||
bitmap.width,
|
||||
false
|
||||
)
|
||||
}
|
||||
}.await()
|
||||
/**
|
||||
* returns the scaled bitmap if it got fetched successfully
|
||||
*/
|
||||
return try {
|
||||
val resizedBitmap = Bitmap.createScaledBitmap(
|
||||
bitmap,
|
||||
bitmap.width,
|
||||
bitmap.width,
|
||||
false
|
||||
)
|
||||
resizedBitmap
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
.build()
|
||||
|
||||
ImageHelper.imageLoader.enqueue(request)
|
||||
|
||||
// returns the scaled bitmap if it got fetched successfully
|
||||
return resizedBitmap
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="7dp"
|
||||
android:paddingVertical="10dp">
|
||||
@ -16,7 +16,6 @@
|
||||
<TextView
|
||||
android:id="@+id/playbackSpeed"
|
||||
style="@style/BottomSheetItem"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/playback_speed"
|
||||
app:drawableStartCompat="@drawable/ic_speed" />
|
||||
|
||||
@ -43,4 +42,5 @@
|
||||
style="@style/BottomSheetItem"
|
||||
android:text="@string/player_resize_mode"
|
||||
app:drawableStartCompat="@drawable/ic_aspect_ratio" />
|
||||
|
||||
</LinearLayout>
|
@ -20,7 +20,7 @@
|
||||
android:layout_weight="1"
|
||||
android:text="@string/share_with_time" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/timeCodeSwitch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
7
app/src/main/res/layout/view_preference_switch.xml
Normal file
7
app/src/main/res/layout/view_preference_switch.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.materialswitch.MaterialSwitch xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/switchWidget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:targetApi="n" />
|
@ -34,14 +34,12 @@
|
||||
android:id="@+id/channelFragment"
|
||||
android:name="com.github.libretube.fragments.ChannelFragment"
|
||||
android:label="channel"
|
||||
tools:layout="@layout/fragment_channel">
|
||||
</fragment>
|
||||
tools:layout="@layout/fragment_channel"></fragment>
|
||||
<fragment
|
||||
android:id="@+id/playlistFragment"
|
||||
android:name="com.github.libretube.fragments.PlaylistFragment"
|
||||
android:label="fragment_playlist"
|
||||
tools:layout="@layout/fragment_playlist">
|
||||
</fragment>
|
||||
tools:layout="@layout/fragment_playlist"></fragment>
|
||||
<fragment
|
||||
android:id="@+id/watchHistoryFragment"
|
||||
android:name="com.github.libretube.fragments.WatchHistoryFragment"
|
||||
|
@ -6,6 +6,10 @@
|
||||
<item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
|
||||
<item name="switchPreferenceCompatStyle">
|
||||
@style/Preference.SwitchPreferenceCompat.Material3
|
||||
</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="StartupTheme" parent="BaseTheme">
|
||||
|
@ -158,6 +158,8 @@
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:padding">10dp</item>
|
||||
<item name="android:layout_marginTop">2dp</item>
|
||||
<item name="android:layout_marginBottom">2dp</item>
|
||||
<item name="background">?attr/selectableItemBackground</item>
|
||||
|
||||
</style>
|
||||
@ -175,4 +177,11 @@
|
||||
|
||||
</style>
|
||||
|
||||
<!-- Uses Material Switches instead of the old ones -->
|
||||
<style name="Preference.SwitchPreferenceCompat.Material3" parent="@style/Preference.SwitchPreferenceCompat.Material">
|
||||
|
||||
<item name="widgetLayout">@layout/view_preference_switch</item>
|
||||
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -6,6 +6,10 @@
|
||||
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
|
||||
<item name="switchPreferenceCompatStyle">
|
||||
@style/Preference.SwitchPreferenceCompat.Material3
|
||||
</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="StartupTheme" parent="BaseTheme">
|
||||
|
@ -2,7 +2,7 @@
|
||||
appcompat = "1.5.0"
|
||||
lifecycle = "2.5.1"
|
||||
constraintlayout = "2.1.4"
|
||||
material = "1.6.0"
|
||||
material = "1.8.0-alpha01"
|
||||
navigation = "2.5.1"
|
||||
legacySupport = "1.0.0"
|
||||
preference = "1.2.0"
|
||||
@ -10,7 +10,7 @@ extJunit = "1.1.3"
|
||||
espresso = "3.4.0"
|
||||
workRuntime = "2.7.1"
|
||||
circleimageview = "3.1.0"
|
||||
exoplayer = "2.17.1"
|
||||
exoplayer = "2.18.1"
|
||||
multidex = "2.0.1"
|
||||
retrofit = "2.9.0"
|
||||
jacksonAnnotations = "2.13.3"
|
||||
|
Loading…
Reference in New Issue
Block a user