Implement #122
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user