refactor: move constants into the files they're actually used in

This commit is contained in:
Bnyro 2023-09-10 12:51:03 +02:00
parent d4ba106aa7
commit 315f596776
16 changed files with 54 additions and 100 deletions

View File

@ -4,9 +4,6 @@ import android.app.Application
import androidx.core.app.NotificationChannelCompat import androidx.core.app.NotificationChannelCompat
import androidx.core.app.NotificationManagerCompat import androidx.core.app.NotificationManagerCompat
import androidx.work.ExistingPeriodicWorkPolicy import androidx.work.ExistingPeriodicWorkPolicy
import com.github.libretube.constants.DOWNLOAD_CHANNEL_ID
import com.github.libretube.constants.PLAYER_CHANNEL_ID
import com.github.libretube.constants.PUSH_CHANNEL_ID
import com.github.libretube.helpers.ImageHelper import com.github.libretube.helpers.ImageHelper
import com.github.libretube.helpers.NotificationHelper import com.github.libretube.helpers.NotificationHelper
import com.github.libretube.helpers.PreferenceHelper import com.github.libretube.helpers.PreferenceHelper
@ -65,21 +62,21 @@ class LibreTubeApp : Application() {
*/ */
private fun initializeNotificationChannels() { private fun initializeNotificationChannels() {
val downloadChannel = NotificationChannelCompat.Builder( val downloadChannel = NotificationChannelCompat.Builder(
DOWNLOAD_CHANNEL_ID, DOWNLOAD_CHANNEL_NAME,
NotificationManagerCompat.IMPORTANCE_LOW NotificationManagerCompat.IMPORTANCE_LOW
) )
.setName(getString(R.string.download_channel_name)) .setName(getString(R.string.download_channel_name))
.setDescription(getString(R.string.download_channel_description)) .setDescription(getString(R.string.download_channel_description))
.build() .build()
val playerChannel = NotificationChannelCompat.Builder( val playerChannel = NotificationChannelCompat.Builder(
PLAYER_CHANNEL_ID, PLAYER_CHANNEL_NAME,
NotificationManagerCompat.IMPORTANCE_LOW NotificationManagerCompat.IMPORTANCE_LOW
) )
.setName(getString(R.string.player_channel_name)) .setName(getString(R.string.player_channel_name))
.setDescription(getString(R.string.player_channel_description)) .setDescription(getString(R.string.player_channel_description))
.build() .build()
val pushChannel = NotificationChannelCompat.Builder( val pushChannel = NotificationChannelCompat.Builder(
PUSH_CHANNEL_ID, PUSH_CHANNEL_NAME,
NotificationManagerCompat.IMPORTANCE_DEFAULT NotificationManagerCompat.IMPORTANCE_DEFAULT
) )
.setName(getString(R.string.push_channel_name)) .setName(getString(R.string.push_channel_name))
@ -98,5 +95,9 @@ class LibreTubeApp : Application() {
companion object { companion object {
lateinit var instance: LibreTubeApp lateinit var instance: LibreTubeApp
const val DOWNLOAD_CHANNEL_NAME = "download_service"
const val PLAYER_CHANNEL_NAME = "player_mode"
const val PUSH_CHANNEL_NAME = "notification_worker"
} }
} }

View File

@ -2,14 +2,15 @@ package com.github.libretube.api
import com.github.libretube.api.obj.Instances import com.github.libretube.api.obj.Instances
import com.github.libretube.api.obj.SubmitSegmentResponse import com.github.libretube.api.obj.SubmitSegmentResponse
import com.github.libretube.constants.GITHUB_API_URL
import com.github.libretube.constants.SB_SUBMIT_API_URL
import com.github.libretube.obj.update.UpdateInfo import com.github.libretube.obj.update.UpdateInfo
import retrofit2.http.GET import retrofit2.http.GET
import retrofit2.http.POST import retrofit2.http.POST
import retrofit2.http.Query import retrofit2.http.Query
import retrofit2.http.Url import retrofit2.http.Url
private const val GITHUB_API_URL = "https://api.github.com/repos/libre-tube/LibreTube/releases/latest"
private const val SB_SUBMIT_API_URL = "https://sponsor.ajay.app/api/skipSegments"
interface ExternalApi { interface ExternalApi {
// only for fetching servers list // only for fetching servers list
@GET @GET

View File

@ -3,12 +3,13 @@ package com.github.libretube.api
import android.content.Context import android.content.Context
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.obj.Instances import com.github.libretube.api.obj.Instances
import com.github.libretube.constants.FALLBACK_INSTANCES_URL
import com.github.libretube.constants.PIPED_INSTANCES_URL
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
object InstanceHelper { object InstanceHelper {
private const val PIPED_INSTANCES_URL = "https://piped-instances.kavin.rocks"
private const val FALLBACK_INSTANCES_URL = "https://instances.tokhmi.xyz"
/** /**
* fetch official public instances from kavin.rocks as well as tokhmi.xyz as fallback * fetch official public instances from kavin.rocks as well as tokhmi.xyz as fallback
*/ */

View File

@ -7,7 +7,6 @@ import com.github.libretube.api.obj.Playlist
import com.github.libretube.api.obj.Playlists import com.github.libretube.api.obj.Playlists
import com.github.libretube.api.obj.StreamItem import com.github.libretube.api.obj.StreamItem
import com.github.libretube.constants.PreferenceKeys import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.constants.YOUTUBE_FRONTEND_URL
import com.github.libretube.db.DatabaseHolder import com.github.libretube.db.DatabaseHolder
import com.github.libretube.db.obj.LocalPlaylist import com.github.libretube.db.obj.LocalPlaylist
import com.github.libretube.enums.PlaylistType import com.github.libretube.enums.PlaylistType
@ -18,6 +17,7 @@ import com.github.libretube.helpers.ProxyHelper
import com.github.libretube.obj.FreeTubeImportPlaylist import com.github.libretube.obj.FreeTubeImportPlaylist
import com.github.libretube.obj.FreeTubeVideo import com.github.libretube.obj.FreeTubeVideo
import com.github.libretube.obj.PipedImportPlaylist import com.github.libretube.obj.PipedImportPlaylist
import com.github.libretube.ui.dialogs.ShareDialog.Companion.YOUTUBE_FRONTEND_URL
import com.github.libretube.util.deArrow import com.github.libretube.util.deArrow
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async import kotlinx.coroutines.async

View File

@ -1,6 +1,5 @@
package com.github.libretube.api package com.github.libretube.api
import com.github.libretube.constants.PIPED_API_URL
import com.github.libretube.constants.PreferenceKeys import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.helpers.PreferenceHelper import com.github.libretube.helpers.PreferenceHelper
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
@ -9,6 +8,7 @@ import retrofit2.Retrofit
import retrofit2.create import retrofit2.create
object RetrofitInstance { object RetrofitInstance {
private const val PIPED_API_URL = "https://pipedapi.kavin.rocks"
private val url get() = PreferenceHelper.getString(PreferenceKeys.FETCH_INSTANCE, PIPED_API_URL) private val url get() = PreferenceHelper.getString(PreferenceKeys.FETCH_INSTANCE, PIPED_API_URL)
private val authUrl private val authUrl
get() = when ( get() = when (

View File

@ -1,60 +0,0 @@
package com.github.libretube.constants
/**
* API link for the update checker
*/
const val GITHUB_API_URL = "https://api.github.com/repos/libre-tube/LibreTube/releases/latest"
const val SB_SUBMIT_API_URL = "https://sponsor.ajay.app/api/skipSegments"
/**
* Links for the about fragment
*/
const val WEBSITE_URL = "https://libre-tube.github.io/"
const val GITHUB_URL = "https://github.com/libre-tube/LibreTube"
const val PIPED_GITHUB_URL = "https://github.com/TeamPiped/Piped"
const val WEBLATE_URL = "https://hosted.weblate.org/projects/libretube/libretube/"
const val LICENSE_URL = "https://gnu.org/"
const val FAQ_URL = "https://libre-tube.github.io/#faq"
/**
* Social media links for the help activity
*/
const val MATRIX_URL = "https://matrix.to/#/#LibreTube:matrix.org"
const val MASTODON_URL = "https://fosstodon.org/@libretube"
const val LEMMY_URL = "https://feddit.rocks/c/libretube"
/**
* Share Dialog
*/
const val PIPED_FRONTEND_URL = "https://piped.video"
const val YOUTUBE_FRONTEND_URL = "https://www.youtube.com"
/**
* Retrofit Instance
*/
const val PIPED_API_URL = "https://pipedapi.kavin.rocks"
const val PIPED_INSTANCES_URL = "https://piped-instances.kavin.rocks"
const val FALLBACK_INSTANCES_URL = "https://instances.tokhmi.xyz"
/**
* Notification IDs
*/
const val PLAYER_NOTIFICATION_ID = 1
const val DOWNLOAD_PROGRESS_NOTIFICATION_ID = 2
/**
* Notification Channel IDs
*/
const val DOWNLOAD_CHANNEL_ID = "download_service"
const val PLAYER_CHANNEL_ID = "player_mode"
const val PUSH_CHANNEL_ID = "notification_worker"
/**
* Database
*/
const val DATABASE_NAME = "LibreTubeDatabase"
/**
* New Streams notifications
*/
const val NOTIFICATION_WORK_NAME = "NotificationService"

View File

@ -4,9 +4,10 @@ import androidx.room.Room
import androidx.room.migration.Migration import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase import androidx.sqlite.db.SupportSQLiteDatabase
import com.github.libretube.LibreTubeApp import com.github.libretube.LibreTubeApp
import com.github.libretube.constants.DATABASE_NAME
object DatabaseHolder { object DatabaseHolder {
private const val DATABASE_NAME = "LibreTubeDatabase"
private val MIGRATION_11_12 = object : Migration(11, 12) { private val MIGRATION_11_12 = object : Migration(11, 12) {
override fun migrate(database: SupportSQLiteDatabase) { override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL( database.execSQL(

View File

@ -6,12 +6,13 @@ import androidx.work.ExistingPeriodicWorkPolicy
import androidx.work.NetworkType import androidx.work.NetworkType
import androidx.work.PeriodicWorkRequestBuilder import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager import androidx.work.WorkManager
import com.github.libretube.constants.NOTIFICATION_WORK_NAME
import com.github.libretube.constants.PreferenceKeys import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.workers.NotificationWorker import com.github.libretube.workers.NotificationWorker
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
object NotificationHelper { object NotificationHelper {
private const val NOTIFICATION_WORK_NAME = "NotificationService"
/** /**
* Enqueue the work manager task * Enqueue the work manager task
*/ */

View File

@ -16,11 +16,10 @@ import androidx.core.util.set
import androidx.core.util.valueIterator import androidx.core.util.valueIterator
import androidx.lifecycle.LifecycleService import androidx.lifecycle.LifecycleService
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.github.libretube.LibreTubeApp.Companion.DOWNLOAD_CHANNEL_NAME
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.CronetHelper import com.github.libretube.api.CronetHelper
import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.RetrofitInstance
import com.github.libretube.constants.DOWNLOAD_CHANNEL_ID
import com.github.libretube.constants.DOWNLOAD_PROGRESS_NOTIFICATION_ID
import com.github.libretube.constants.IntentData import com.github.libretube.constants.IntentData
import com.github.libretube.db.DatabaseHolder.Database import com.github.libretube.db.DatabaseHolder.Database
import com.github.libretube.db.obj.Download import com.github.libretube.db.obj.Download
@ -390,7 +389,7 @@ class DownloadService : LifecycleService() {
notificationManager = getSystemService()!! notificationManager = getSystemService()!!
summaryNotificationBuilder = NotificationCompat summaryNotificationBuilder = NotificationCompat
.Builder(this, DOWNLOAD_CHANNEL_ID) .Builder(this, DOWNLOAD_CHANNEL_NAME)
.setSmallIcon(R.drawable.ic_launcher_lockscreen) .setSmallIcon(R.drawable.ic_launcher_lockscreen)
.setContentTitle(getString(R.string.downloading)) .setContentTitle(getString(R.string.downloading))
.setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE) .setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE)
@ -409,7 +408,7 @@ class DownloadService : LifecycleService() {
.getActivity(this@DownloadService, 0, intent, FLAG_CANCEL_CURRENT, false) .getActivity(this@DownloadService, 0, intent, FLAG_CANCEL_CURRENT, false)
return NotificationCompat return NotificationCompat
.Builder(this, DOWNLOAD_CHANNEL_ID) .Builder(this, DOWNLOAD_CHANNEL_NAME)
.setContentTitle("[${item.type}] ${item.fileName}") .setContentTitle("[${item.type}] ${item.fileName}")
.setProgress(0, 0, true) .setProgress(0, 0, true)
.setOngoing(true) .setOngoing(true)
@ -522,6 +521,7 @@ class DownloadService : LifecycleService() {
} }
companion object { companion object {
private const val DOWNLOAD_PROGRESS_NOTIFICATION_ID = 2
private const val DOWNLOAD_NOTIFICATION_GROUP = "download_notification_group" private const val DOWNLOAD_NOTIFICATION_GROUP = "download_notification_group"
const val ACTION_SERVICE_STARTED = const val ACTION_SERVICE_STARTED =
"com.github.libretube.services.DownloadService.ACTION_SERVICE_STARTED" "com.github.libretube.services.DownloadService.ACTION_SERVICE_STARTED"

View File

@ -10,10 +10,9 @@ import androidx.media3.common.C
import androidx.media3.common.MediaItem import androidx.media3.common.MediaItem
import androidx.media3.exoplayer.ExoPlayer import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector import androidx.media3.exoplayer.trackselection.DefaultTrackSelector
import com.github.libretube.LibreTubeApp.Companion.PLAYER_CHANNEL_NAME
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.constants.IntentData import com.github.libretube.constants.IntentData
import com.github.libretube.constants.PLAYER_CHANNEL_ID
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
import com.github.libretube.db.DatabaseHolder import com.github.libretube.db.DatabaseHolder
import com.github.libretube.db.obj.DownloadWithItems import com.github.libretube.db.obj.DownloadWithItems
import com.github.libretube.enums.FileType import com.github.libretube.enums.FileType
@ -23,6 +22,7 @@ import com.github.libretube.helpers.PlayerHelper
import com.github.libretube.helpers.PlayerHelper.loadPlaybackParams import com.github.libretube.helpers.PlayerHelper.loadPlaybackParams
import com.github.libretube.obj.PlayerNotificationData import com.github.libretube.obj.PlayerNotificationData
import com.github.libretube.util.NowPlayingNotification import com.github.libretube.util.NowPlayingNotification
import com.github.libretube.util.NowPlayingNotification.Companion.PLAYER_NOTIFICATION_ID
import kotlin.io.path.exists import kotlin.io.path.exists
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -38,7 +38,7 @@ class OfflinePlayerService : LifecycleService() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
val notification = NotificationCompat.Builder(this, PLAYER_CHANNEL_ID) val notification = NotificationCompat.Builder(this, PLAYER_CHANNEL_NAME)
.setContentTitle(getString(R.string.app_name)) .setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.playingOnBackground)) .setContentText(getString(R.string.playingOnBackground))
.setSmallIcon(R.drawable.ic_launcher_lockscreen) .setSmallIcon(R.drawable.ic_launcher_lockscreen)

View File

@ -19,14 +19,13 @@ import androidx.media3.common.PlaybackException
import androidx.media3.common.Player import androidx.media3.common.Player
import androidx.media3.exoplayer.ExoPlayer import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.exoplayer.trackselection.DefaultTrackSelector import androidx.media3.exoplayer.trackselection.DefaultTrackSelector
import com.github.libretube.LibreTubeApp.Companion.PLAYER_CHANNEL_NAME
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.JsonHelper import com.github.libretube.api.JsonHelper
import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.RetrofitInstance
import com.github.libretube.api.obj.Segment import com.github.libretube.api.obj.Segment
import com.github.libretube.api.obj.Streams import com.github.libretube.api.obj.Streams
import com.github.libretube.constants.IntentData import com.github.libretube.constants.IntentData
import com.github.libretube.constants.PLAYER_CHANNEL_ID
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
import com.github.libretube.db.DatabaseHelper import com.github.libretube.db.DatabaseHelper
import com.github.libretube.db.DatabaseHolder.Database import com.github.libretube.db.DatabaseHolder.Database
import com.github.libretube.db.obj.WatchPosition import com.github.libretube.db.obj.WatchPosition
@ -41,6 +40,7 @@ import com.github.libretube.helpers.ProxyHelper
import com.github.libretube.obj.PlayerNotificationData import com.github.libretube.obj.PlayerNotificationData
import com.github.libretube.parcelable.PlayerData import com.github.libretube.parcelable.PlayerData
import com.github.libretube.util.NowPlayingNotification import com.github.libretube.util.NowPlayingNotification
import com.github.libretube.util.NowPlayingNotification.Companion.PLAYER_NOTIFICATION_ID
import com.github.libretube.util.PlayingQueue import com.github.libretube.util.PlayingQueue
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -109,7 +109,7 @@ class OnlinePlayerService : LifecycleService() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
val notification = NotificationCompat.Builder(this, PLAYER_CHANNEL_ID) val notification = NotificationCompat.Builder(this, PLAYER_CHANNEL_NAME)
.setContentTitle(getString(R.string.app_name)) .setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.playingOnBackground)) .setContentText(getString(R.string.playingOnBackground))
.setSmallIcon(R.drawable.ic_launcher_lockscreen) .setSmallIcon(R.drawable.ic_launcher_lockscreen)

View File

@ -6,11 +6,6 @@ import android.os.Bundle
import androidx.core.text.HtmlCompat import androidx.core.text.HtmlCompat
import androidx.core.text.parseAsHtml import androidx.core.text.parseAsHtml
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.constants.GITHUB_URL
import com.github.libretube.constants.LICENSE_URL
import com.github.libretube.constants.PIPED_GITHUB_URL
import com.github.libretube.constants.WEBLATE_URL
import com.github.libretube.constants.WEBSITE_URL
import com.github.libretube.databinding.ActivityAboutBinding import com.github.libretube.databinding.ActivityAboutBinding
import com.github.libretube.helpers.ClipboardHelper import com.github.libretube.helpers.ClipboardHelper
import com.github.libretube.helpers.IntentHelper import com.github.libretube.helpers.IntentHelper
@ -111,4 +106,12 @@ class AboutActivity : BaseActivity() {
.setPositiveButton(R.string.okay, null) .setPositiveButton(R.string.okay, null)
.show() .show()
} }
companion object {
private const val WEBSITE_URL = "https://libre-tube.github.io/"
private const val GITHUB_URL = "https://github.com/libre-tube/LibreTube"
private const val PIPED_GITHUB_URL = "https://github.com/TeamPiped/Piped"
private const val WEBLATE_URL = "https://hosted.weblate.org/projects/libretube/libretube/"
private const val LICENSE_URL = "https://gnu.org/"
}
} }

View File

@ -1,10 +1,6 @@
package com.github.libretube.ui.activities package com.github.libretube.ui.activities
import android.os.Bundle import android.os.Bundle
import com.github.libretube.constants.FAQ_URL
import com.github.libretube.constants.LEMMY_URL
import com.github.libretube.constants.MASTODON_URL
import com.github.libretube.constants.MATRIX_URL
import com.github.libretube.databinding.ActivityHelpBinding import com.github.libretube.databinding.ActivityHelpBinding
import com.github.libretube.helpers.IntentHelper import com.github.libretube.helpers.IntentHelper
import com.github.libretube.ui.base.BaseActivity import com.github.libretube.ui.base.BaseActivity
@ -34,4 +30,11 @@ class HelpActivity : BaseActivity() {
IntentHelper.openLinkFromHref(this, supportFragmentManager, link) IntentHelper.openLinkFromHref(this, supportFragmentManager, link)
} }
} }
companion object {
private const val FAQ_URL = "https://libre-tube.github.io/#faq"
private const val MATRIX_URL = "https://matrix.to/#/#LibreTube:matrix.org"
private const val MASTODON_URL = "https://fosstodon.org/@libretube"
private const val LEMMY_URL = "https://feddit.rocks/c/libretube"
}
} }

View File

@ -7,9 +7,7 @@ import androidx.core.view.isVisible
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.constants.IntentData import com.github.libretube.constants.IntentData
import com.github.libretube.constants.PIPED_FRONTEND_URL
import com.github.libretube.constants.PreferenceKeys import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.constants.YOUTUBE_FRONTEND_URL
import com.github.libretube.databinding.DialogShareBinding import com.github.libretube.databinding.DialogShareBinding
import com.github.libretube.db.DatabaseHolder.Database import com.github.libretube.db.DatabaseHolder.Database
import com.github.libretube.enums.ShareObjectType import com.github.libretube.enums.ShareObjectType
@ -117,4 +115,9 @@ class ShareDialog : DialogFragment() {
// return the custom instance frontend url if available // return the custom instance frontend url if available
return customInstances.firstOrNull { it.apiUrl == instancePref }?.frontendUrl.orEmpty() return customInstances.firstOrNull { it.apiUrl == instancePref }?.frontendUrl.orEmpty()
} }
companion object {
const val YOUTUBE_FRONTEND_URL = "https://www.youtube.com"
private const val PIPED_FRONTEND_URL = "https://piped.video"
}
} }

View File

@ -22,10 +22,9 @@ import androidx.media3.common.MediaMetadata
import androidx.media3.common.Player import androidx.media3.common.Player
import androidx.media3.exoplayer.ExoPlayer import androidx.media3.exoplayer.ExoPlayer
import coil.request.ImageRequest import coil.request.ImageRequest
import com.github.libretube.LibreTubeApp.Companion.PLAYER_CHANNEL_NAME
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.constants.IntentData import com.github.libretube.constants.IntentData
import com.github.libretube.constants.PLAYER_CHANNEL_ID
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
import com.github.libretube.extensions.seekBy import com.github.libretube.extensions.seekBy
import com.github.libretube.extensions.toMediaMetadataCompat import com.github.libretube.extensions.toMediaMetadataCompat
import com.github.libretube.helpers.BackgroundHelper import com.github.libretube.helpers.BackgroundHelper
@ -346,7 +345,7 @@ class NowPlayingNotification(
* Initializes the [notificationBuilder] attached to the [player] and shows it. * Initializes the [notificationBuilder] attached to the [player] and shows it.
*/ */
private fun createNotificationBuilder() { private fun createNotificationBuilder() {
notificationBuilder = NotificationCompat.Builder(context, PLAYER_CHANNEL_ID) notificationBuilder = NotificationCompat.Builder(context, PLAYER_CHANNEL_NAME)
.setSmallIcon(R.drawable.ic_launcher_lockscreen) .setSmallIcon(R.drawable.ic_launcher_lockscreen)
.setContentIntent(createCurrentContentIntent()) .setContentIntent(createCurrentContentIntent())
.setDeleteIntent(createIntent(STOP)) .setDeleteIntent(createIntent(STOP))
@ -403,6 +402,7 @@ class NowPlayingNotification(
} }
companion object { companion object {
const val PLAYER_NOTIFICATION_ID = 1
private const val PREV = "prev" private const val PREV = "prev"
private const val NEXT = "next" private const val NEXT = "next"
private const val REWIND = "rewind" private const val REWIND = "rewind"

View File

@ -12,11 +12,11 @@ import androidx.core.app.PendingIntentCompat
import androidx.core.content.getSystemService import androidx.core.content.getSystemService
import androidx.work.CoroutineWorker import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import com.github.libretube.LibreTubeApp.Companion.PUSH_CHANNEL_NAME
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.SubscriptionHelper import com.github.libretube.api.SubscriptionHelper
import com.github.libretube.api.obj.StreamItem import com.github.libretube.api.obj.StreamItem
import com.github.libretube.constants.IntentData import com.github.libretube.constants.IntentData
import com.github.libretube.constants.PUSH_CHANNEL_ID
import com.github.libretube.constants.PreferenceKeys import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.extensions.TAG import com.github.libretube.extensions.TAG
import com.github.libretube.extensions.toID import com.github.libretube.extensions.toID
@ -205,7 +205,7 @@ class NotificationWorker(appContext: Context, parameters: WorkerParameters) :
} }
private fun createNotificationBuilder(group: String): NotificationCompat.Builder { private fun createNotificationBuilder(group: String): NotificationCompat.Builder {
return NotificationCompat.Builder(applicationContext, PUSH_CHANNEL_ID) return NotificationCompat.Builder(applicationContext, PUSH_CHANNEL_NAME)
.setSmallIcon(R.drawable.ic_launcher_lockscreen) .setSmallIcon(R.drawable.ic_launcher_lockscreen)
.setPriority(NotificationCompat.PRIORITY_DEFAULT) .setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true) .setAutoCancel(true)