1
0
mirror of https://github.com/ultrasonic/ultrasonic synced 2025-01-27 07:46:09 +01:00

Squashed commit of the following:

commit 7a8f20ade7d2522c1281b63a31c3e9630df12553
Author: Holger Müller <github@euhm.de>
Date:   Fri Apr 8 23:21:15 2022 +0200

    make build working with target sdk 31

commit 5890c32b7eb91621ce628ac6d900cb00a1481d71
Author: Holger Müller <github@euhm.de>
Date:   Fri Apr 8 22:57:23 2022 +0200

    make build working with target sdk 31

commit 1c7c4839b3eed5eef8298c2ddce22812e14d6329
Merge: 48b0cdea 92ef78a3
Author: Holger Müller <github@euhm.de>
Date:   Fri Apr 8 21:55:14 2022 +0200

    Merge remote-tracking branch 'upstream/media3-flat' into media3-flat

commit 48b0cdea83433cc29760972c522a497f812d6d30
Merge: 9101980c 3ca25ed1
Author: Holger Müller <github@euhm.de>
Date:   Fri Apr 8 19:58:55 2022 +0200

    Merge remote-tracking branch 'upstream/media3-flat' into media3-flat

commit 9101980cb6d8972ee6e49b58737b36c4ac36e495
Merge: 515690ab 97798446
Author: Holger Müller <github@euhm.de>
Date:   Fri Apr 8 17:07:54 2022 +0200

    Merge remote-tracking branch 'upstream/media3-flat' into media3-flat

commit 515690abaccd5405709b1fe877a9ef9c9bbf3e21
Author: Holger Müller <github@euhm.de>
Date:   Thu Apr 7 08:55:42 2022 +0200

    made button off mode better visible
This commit is contained in:
tzugen 2022-04-17 06:58:39 +02:00
parent 788538ee6a
commit 3691428a68
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
3 changed files with 26 additions and 12 deletions

View File

@ -15,9 +15,9 @@
*/
package org.moire.ultrasonic.playback
import android.annotation.SuppressLint
import android.app.PendingIntent
import android.content.Intent
import android.os.Build
import androidx.media3.common.AudioAttributes
import androidx.media3.common.C
import androidx.media3.common.C.CONTENT_TYPE_MUSIC
@ -132,11 +132,14 @@ class PlaybackService : MediaLibraryService(), KoinComponent {
.build()
}
@SuppressLint("UnspecifiedImmutableFlag")
private fun getPendingIntentForContent(): PendingIntent {
val intent = Intent(this, NavigationActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
val flags = PendingIntent.FLAG_UPDATE_CURRENT
var flags = PendingIntent.FLAG_UPDATE_CURRENT
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// needed starting Android 12 (S = 31)
flags = flags or PendingIntent.FLAG_IMMUTABLE
}
intent.putExtra(Constants.INTENT_SHOW_PLAYER, true)
return PendingIntent.getActivity(this, 0, intent, flags)
}

View File

@ -7,13 +7,13 @@
package org.moire.ultrasonic.provider
import android.annotation.SuppressLint
import android.app.PendingIntent
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Environment
import android.view.KeyEvent
import android.widget.RemoteViews
@ -164,7 +164,6 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() {
/**
* Link up various button actions using [PendingIntent].
*/
@SuppressLint("UnspecifiedImmutableFlag")
private fun linkButtons(context: Context, views: RemoteViews, playerActive: Boolean) {
var intent = Intent(
context,
@ -173,8 +172,13 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() {
if (playerActive) intent.putExtra(Constants.INTENT_SHOW_PLAYER, true)
intent.action = "android.intent.action.MAIN"
intent.addCategory("android.intent.category.LAUNCHER")
var flags = PendingIntent.FLAG_UPDATE_CURRENT
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// needed starting Android 12 (S = 31)
flags = flags or PendingIntent.FLAG_IMMUTABLE
}
var pendingIntent =
PendingIntent.getActivity(context, 10, intent, PendingIntent.FLAG_UPDATE_CURRENT)
PendingIntent.getActivity(context, 10, intent, flags)
views.setOnClickPendingIntent(R.id.appwidget_coverart, pendingIntent)
views.setOnClickPendingIntent(R.id.appwidget_top, pendingIntent)
@ -185,7 +189,12 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() {
Intent.EXTRA_KEY_EVENT,
KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE)
)
pendingIntent = PendingIntent.getBroadcast(context, 11, intent, 0)
flags = 0
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// needed starting Android 12 (S = 31)
flags = flags or PendingIntent.FLAG_IMMUTABLE
}
pendingIntent = PendingIntent.getBroadcast(context, 11, intent, flags)
views.setOnClickPendingIntent(R.id.control_play, pendingIntent)
intent = Intent(Constants.CMD_PROCESS_KEYCODE)
intent.component = ComponentName(context, MediaButtonIntentReceiver::class.java)
@ -193,7 +202,7 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() {
Intent.EXTRA_KEY_EVENT,
KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT)
)
pendingIntent = PendingIntent.getBroadcast(context, 12, intent, 0)
pendingIntent = PendingIntent.getBroadcast(context, 12, intent, flags)
views.setOnClickPendingIntent(R.id.control_next, pendingIntent)
intent = Intent(Constants.CMD_PROCESS_KEYCODE)
intent.component = ComponentName(context, MediaButtonIntentReceiver::class.java)
@ -201,7 +210,7 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() {
Intent.EXTRA_KEY_EVENT,
KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PREVIOUS)
)
pendingIntent = PendingIntent.getBroadcast(context, 13, intent, 0)
pendingIntent = PendingIntent.getBroadcast(context, 13, intent, flags)
views.setOnClickPendingIntent(R.id.control_previous, pendingIntent)
}
}

View File

@ -7,7 +7,6 @@
package org.moire.ultrasonic.service
import android.annotation.SuppressLint
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
@ -154,11 +153,14 @@ class DownloadService : Service() {
return notificationBuilder.build()
}
@SuppressLint("UnspecifiedImmutableFlag")
private fun getPendingIntentForContent(): PendingIntent {
val intent = Intent(this, NavigationActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
val flags = PendingIntent.FLAG_UPDATE_CURRENT
var flags = PendingIntent.FLAG_UPDATE_CURRENT
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// needed starting Android 12 (S = 31)
flags = flags or PendingIntent.FLAG_IMMUTABLE
}
intent.putExtra(Constants.INTENT_SHOW_PLAYER, true)
return PendingIntent.getActivity(this, 0, intent, flags)
}