Implement #122
This commit is contained in:
@@ -73,6 +73,8 @@ class MainActivity : ComponentActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
val expandPlayerBottomSheet = intent?.extras?.getBoolean("expandPlayerBottomSheet", false) ?: false
|
||||||
|
|
||||||
uri = intent?.data
|
uri = intent?.data
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
@@ -189,7 +191,9 @@ class MainActivity : ComponentActivity() {
|
|||||||
when (val uri = uri) {
|
when (val uri = uri) {
|
||||||
null -> {
|
null -> {
|
||||||
val playerBottomSheetState = rememberBottomSheetState(
|
val playerBottomSheetState = rememberBottomSheetState(
|
||||||
lowerBound = Dimensions.collapsedPlayer, upperBound = maxHeight
|
lowerBound = Dimensions.collapsedPlayer,
|
||||||
|
upperBound = maxHeight,
|
||||||
|
isExpanded = expandPlayerBottomSheet
|
||||||
)
|
)
|
||||||
|
|
||||||
HomeScreen()
|
HomeScreen()
|
||||||
|
|||||||
@@ -417,7 +417,11 @@ class PlayerService : InvincibleService(), Player.Listener, PlaybackStatsListene
|
|||||||
.setSmallIcon(player.playerError?.let { R.drawable.alert_circle }
|
.setSmallIcon(player.playerError?.let { R.drawable.alert_circle }
|
||||||
?: R.drawable.app_icon)
|
?: R.drawable.app_icon)
|
||||||
.setOngoing(false)
|
.setOngoing(false)
|
||||||
.setContentIntent(activityPendingIntent<MainActivity>())
|
.setContentIntent(activityPendingIntent<MainActivity>(
|
||||||
|
flags = PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
) {
|
||||||
|
putExtra("expandPlayerBottomSheet", true)
|
||||||
|
})
|
||||||
.setDeleteIntent(broadCastPendingIntent<NotificationDismissReceiver>())
|
.setDeleteIntent(broadCastPendingIntent<NotificationDismissReceiver>())
|
||||||
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
.setVisibility(Notification.VISIBILITY_PUBLIC)
|
||||||
.setCategory(NotificationCompat.CATEGORY_TRANSPORT)
|
.setCategory(NotificationCompat.CATEGORY_TRANSPORT)
|
||||||
|
|||||||
@@ -232,12 +232,12 @@ class BottomSheetState(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun rememberBottomSheetState(lowerBound: Dp, upperBound: Dp): BottomSheetState {
|
fun rememberBottomSheetState(lowerBound: Dp, upperBound: Dp, isExpanded: Boolean = false): BottomSheetState {
|
||||||
val density = LocalDensity.current
|
val density = LocalDensity.current
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
|
||||||
var wasExpanded by rememberSaveable {
|
var wasExpanded by rememberSaveable {
|
||||||
mutableStateOf(false)
|
mutableStateOf(isExpanded)
|
||||||
}
|
}
|
||||||
|
|
||||||
return remember(lowerBound, upperBound, coroutineScope) {
|
return remember(lowerBound, upperBound, coroutineScope) {
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ inline fun <reified T: BroadcastReceiver> Context.broadCastPendingIntent(
|
|||||||
|
|
||||||
inline fun <reified T: Activity> Context.activityPendingIntent(
|
inline fun <reified T: Activity> Context.activityPendingIntent(
|
||||||
requestCode: Int = 0,
|
requestCode: Int = 0,
|
||||||
flags: Int = if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0,
|
flags: Int = 0,
|
||||||
|
block: Intent.() -> Unit = {},
|
||||||
): PendingIntent =
|
): 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
|
val Context.isIgnoringBatteryOptimizations: Boolean
|
||||||
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
|||||||
Reference in New Issue
Block a user