Make broadcasts unique
Prevent broadcasts from Auxio builds being registered by other, different Auxio instances.
This commit is contained in:
parent
e85bdd0643
commit
dc26d70088
2 changed files with 12 additions and 6 deletions
|
@ -46,10 +46,12 @@ class MusicLoader(
|
||||||
|
|
||||||
private fun findMusic(): MusicLoaderResponse {
|
private fun findMusic(): MusicLoaderResponse {
|
||||||
try {
|
try {
|
||||||
|
val start = System.currentTimeMillis()
|
||||||
loadGenres()
|
loadGenres()
|
||||||
loadArtists()
|
loadArtists()
|
||||||
loadAlbums()
|
loadAlbums()
|
||||||
loadSongs()
|
loadSongs()
|
||||||
|
logD("Done in ${System.currentTimeMillis() - start}ms")
|
||||||
} catch (error: Exception) {
|
} catch (error: Exception) {
|
||||||
logE("Something went horribly wrong.")
|
logE("Something went horribly wrong.")
|
||||||
error.printStackTrace()
|
error.printStackTrace()
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.os.Build
|
||||||
import android.support.v4.media.session.MediaSessionCompat
|
import android.support.v4.media.session.MediaSessionCompat
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.media.app.NotificationCompat.MediaStyle
|
import androidx.media.app.NotificationCompat.MediaStyle
|
||||||
|
import org.oxycblt.auxio.BuildConfig
|
||||||
import org.oxycblt.auxio.MainActivity
|
import org.oxycblt.auxio.MainActivity
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.music.Song
|
import org.oxycblt.auxio.music.Song
|
||||||
|
@ -23,12 +24,14 @@ object NotificationUtils {
|
||||||
const val NOTIFICATION_ID = 0xA0A0
|
const val NOTIFICATION_ID = 0xA0A0
|
||||||
const val REQUEST_CODE = 0xA0C0
|
const val REQUEST_CODE = 0xA0C0
|
||||||
|
|
||||||
const val ACTION_LOOP = "ACTION_AUXIO_LOOP"
|
// Strings for each action, version name is applied so that broadcasts will only reach
|
||||||
const val ACTION_SHUFFLE = "ACTION_AUXIO_SHUFFLE"
|
// one instance of Auxio.
|
||||||
const val ACTION_SKIP_PREV = "ACTION_AUXIO_SKIP_PREV"
|
const val ACTION_LOOP = "ACTION_AUXIO_LOOP_" + BuildConfig.VERSION_NAME
|
||||||
const val ACTION_PLAY_PAUSE = "ACTION_AUXIO_PLAY_PAUSE"
|
const val ACTION_SHUFFLE = "ACTION_AUXIO_SHUFFLE_" + BuildConfig.VERSION_NAME
|
||||||
const val ACTION_SKIP_NEXT = "ACTION_AUXIO_SKIP_NEXT"
|
const val ACTION_SKIP_PREV = "ACTION_AUXIO_SKIP_PREV_" + BuildConfig.VERSION_NAME
|
||||||
const val ACTION_EXIT = "ACTION_AUXIO_EXIT"
|
const val ACTION_PLAY_PAUSE = "ACTION_AUXIO_PLAY_PAUSE_" + BuildConfig.VERSION_NAME
|
||||||
|
const val ACTION_SKIP_NEXT = "ACTION_AUXIO_SKIP_NEXT_" + BuildConfig.VERSION_NAME
|
||||||
|
const val ACTION_EXIT = "ACTION_AUXIO_EXIT_" + BuildConfig.VERSION_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,6 +133,7 @@ fun NotificationCompat.Builder.updatePlaying(context: Context) {
|
||||||
/**
|
/**
|
||||||
* Update the extra action on the media notification [E.G the Loop/Shuffle button]
|
* Update the extra action on the media notification [E.G the Loop/Shuffle button]
|
||||||
* @param context The context required to refresh the action
|
* @param context The context required to refresh the action
|
||||||
|
* @param useAltAction Whether to use the shuffle action or not, true if yes, false if no
|
||||||
*/
|
*/
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
fun NotificationCompat.Builder.updateExtraAction(context: Context, useAltAction: Boolean) {
|
fun NotificationCompat.Builder.updateExtraAction(context: Context, useAltAction: Boolean) {
|
||||||
|
|
Loading…
Reference in a new issue