This commit is contained in:
vfsfitvnm
2022-07-22 21:28:59 +02:00
parent 6474b52490
commit 6a8fdb7c11
4 changed files with 15 additions and 6 deletions

View File

@@ -73,6 +73,8 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val expandPlayerBottomSheet = intent?.extras?.getBoolean("expandPlayerBottomSheet", false) ?: false
uri = intent?.data
setContent {
@@ -189,7 +191,9 @@ class MainActivity : ComponentActivity() {
when (val uri = uri) {
null -> {
val playerBottomSheetState = rememberBottomSheetState(
lowerBound = Dimensions.collapsedPlayer, upperBound = maxHeight
lowerBound = Dimensions.collapsedPlayer,
upperBound = maxHeight,
isExpanded = expandPlayerBottomSheet
)
HomeScreen()

View File

@@ -417,7 +417,11 @@ class PlayerService : InvincibleService(), Player.Listener, PlaybackStatsListene
.setSmallIcon(player.playerError?.let { R.drawable.alert_circle }
?: R.drawable.app_icon)
.setOngoing(false)
.setContentIntent(activityPendingIntent<MainActivity>())
.setContentIntent(activityPendingIntent<MainActivity>(
flags = PendingIntent.FLAG_UPDATE_CURRENT
) {
putExtra("expandPlayerBottomSheet", true)
})
.setDeleteIntent(broadCastPendingIntent<NotificationDismissReceiver>())
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setCategory(NotificationCompat.CATEGORY_TRANSPORT)

View File

@@ -232,12 +232,12 @@ class BottomSheetState(
}
@Composable
fun rememberBottomSheetState(lowerBound: Dp, upperBound: Dp): BottomSheetState {
fun rememberBottomSheetState(lowerBound: Dp, upperBound: Dp, isExpanded: Boolean = false): BottomSheetState {
val density = LocalDensity.current
val coroutineScope = rememberCoroutineScope()
var wasExpanded by rememberSaveable {
mutableStateOf(false)
mutableStateOf(isExpanded)
}
return remember(lowerBound, upperBound, coroutineScope) {

View File

@@ -21,9 +21,10 @@ inline fun <reified T: BroadcastReceiver> Context.broadCastPendingIntent(
inline fun <reified T: Activity> Context.activityPendingIntent(
requestCode: Int = 0,
flags: Int = if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0,
flags: Int = 0,
block: Intent.() -> Unit = {},
): PendingIntent =
PendingIntent.getActivity(this, requestCode, intent<T>(), flags)
PendingIntent.getActivity(this, requestCode, intent<T>().apply(block), (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0) or flags)
val Context.isIgnoringBatteryOptimizations: Boolean
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {