Skip to content

Commit f950e17

Browse files
Ghosutojoeyhuab
authored andcommitted
SystemUI: Improve music chip popup ui
neobuddy89: Only required elements. Do not increase size mini player. Signed-off-by: Ghosuto <clash.raja10@gmail.com> Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
1 parent 1f2fec3 commit f950e17

1 file changed

Lines changed: 144 additions & 50 deletions

File tree

packages/SystemUI/src/com/android/systemui/statusbar/OngoingActionProgressCompose.kt

Lines changed: 144 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -332,28 +332,63 @@ private fun MiniMediaPlayer(
332332
.asComposeRenderEffect()
333333
}
334334

335+
val cardBgBase = MaterialTheme.colorScheme.surfaceVariant
336+
337+
val onCardColor = Color.White
338+
339+
val onCardSubColor = onCardColor.copy(alpha = 0.55f)
340+
335341
Box(
336342
modifier = Modifier
337-
.padding(bottom = 12.dp, start = 12.dp, end = 12.dp)
343+
.padding(bottom = 12.dp, start = 10.dp, end = 10.dp)
338344
.width(cardWidth)
339345
.wrapContentHeight()
340346
.shadow(20.dp, cardShape)
341347
.clip(cardShape)
342348
) {
343349
if (hasRealArt) {
344-
BitmapImage(state.albumArt!!, null,
350+
BitmapImage(
351+
state.albumArt!!,
352+
null,
345353
contentScale = ContentScale.Crop,
346-
modifier = Modifier.matchParentSize().graphicsLayer {
347-
renderEffect = blurEffect; scaleX = 1.15f; scaleY = 1.15f
348-
})
354+
modifier = Modifier
355+
.matchParentSize()
356+
.graphicsLayer {
357+
renderEffect = blurEffect
358+
scaleX = 1.15f
359+
scaleY = 1.15f
360+
}
361+
)
362+
Box(
363+
Modifier
364+
.matchParentSize()
365+
.background(Color.Black.copy(alpha = 0.52f))
366+
)
349367
} else {
350-
Box(Modifier.matchParentSize()
351-
.background(MaterialTheme.colorScheme.surfaceVariant))
368+
Box(
369+
Modifier
370+
.matchParentSize()
371+
.background(
372+
Brush.linearGradient(
373+
colors = listOf(
374+
cardBgBase,
375+
cardBgBase.copy(alpha = 0.80f)
376+
)
377+
)
378+
)
379+
)
352380
}
353381

354-
Box(Modifier.matchParentSize()
355-
.background(Color.Black.copy(alpha = if (hasRealArt) 0.45f else 0f)))
356-
Box(Modifier.matchParentSize().background(accent.copy(alpha = 0.07f)))
382+
Box(
383+
Modifier
384+
.matchParentSize()
385+
.background(
386+
Brush.verticalGradient(
387+
0f to onCardColor.copy(alpha = 0.06f),
388+
0.35f to Color.Transparent
389+
)
390+
)
391+
)
357392

358393
Row(
359394
modifier = Modifier
@@ -385,7 +420,7 @@ private fun MiniMediaPlayer(
385420
painterResource(R.drawable.ic_default_music_icon),
386421
contentDescription = null,
387422
modifier = Modifier.size(26.dp),
388-
colorFilter = ColorFilter.tint(Color.White.copy(alpha = 0.55f))
423+
colorFilter = ColorFilter.tint(onCardColor.copy(alpha = 0.50f))
389424
)
390425
}
391426
}
@@ -396,15 +431,22 @@ private fun MiniMediaPlayer(
396431
) {
397432
Text(
398433
text = state.trackTitle ?: "",
399-
style = TextStyle(color = Color.White, fontSize = 13.sp,
400-
fontWeight = FontWeight.SemiBold),
434+
style = TextStyle(
435+
color = onCardColor,
436+
fontSize = 13.sp,
437+
fontWeight = FontWeight.Bold,
438+
letterSpacing = (-0.2).sp,
439+
),
401440
maxLines = 1, overflow = TextOverflow.Ellipsis
402441
)
403442
if (!state.artistName.isNullOrBlank()) {
404443
Text(
405444
text = state.artistName,
406-
style = TextStyle(color = Color.White.copy(alpha = 0.72f),
407-
fontSize = 11.sp),
445+
style = TextStyle(
446+
color = onCardSubColor,
447+
fontSize = 11.sp,
448+
fontWeight = FontWeight.Medium
449+
),
408450
maxLines = 1, overflow = TextOverflow.Ellipsis
409451
)
410452
}
@@ -417,8 +459,12 @@ private fun MiniMediaPlayer(
417459
verticalAlignment = Alignment.CenterVertically
418460
) {
419461
Text(formatMs(progressMs),
420-
style = TextStyle(color = Color.White.copy(alpha = 0.55f),
421-
fontSize = 9.sp, fontWeight = FontWeight.Medium))
462+
style = TextStyle(
463+
color = onCardSubColor,
464+
fontSize = 9.sp,
465+
fontWeight = FontWeight.Medium
466+
)
467+
)
422468
if (durationMs > 0)
423469
Text("-${formatMs(durationMs - progressMs)}",
424470
style = TextStyle(color = Color.White.copy(alpha = 0.55f),
@@ -437,30 +483,92 @@ private fun MiniMediaPlayer(
437483
verticalAlignment = Alignment.CenterVertically,
438484
horizontalArrangement = Arrangement.spacedBy(2.dp)
439485
) {
440-
PlayerButton(R.drawable.ic_media_control_skip_previous, "Previous",
441-
36.dp, 20.dp, Color.White.copy(alpha = 0.88f), onPrev)
442-
Box(
443-
modifier = Modifier.size(44.dp).clip(CircleShape)
444-
.background(Color.White.copy(alpha = 0.20f))
445-
.clickable(onClick = onPlayPause),
446-
contentAlignment = Alignment.Center
447-
) {
448-
Image(
449-
painter = painterResource(
450-
if (state.isMediaPlaying) R.drawable.ic_media_control_pause
451-
else R.drawable.ic_media_control_play),
452-
contentDescription = if (state.isMediaPlaying) "Pause" else "Play",
453-
modifier = Modifier.size(22.dp),
454-
colorFilter = ColorFilter.tint(Color.White)
455-
)
456-
}
457-
PlayerButton(R.drawable.ic_media_control_skip_next, "Next",
458-
36.dp, 20.dp, Color.White.copy(alpha = 0.88f), onNext)
486+
ControlButton(
487+
iconRes = R.drawable.ic_media_control_skip_previous,
488+
contentDescription = "Previous",
489+
tint = onCardColor,
490+
size = 36.dp,
491+
iconSize = 20.dp,
492+
onClick = onPrev,
493+
hasSurface = false
494+
)
495+
PlayPauseButton(
496+
isPlaying = state.isMediaPlaying,
497+
tint = onCardColor,
498+
surfaceColor = onCardColor.copy(alpha = 0.15f),
499+
onClick = onPlayPause,
500+
)
501+
ControlButton(
502+
iconRes = R.drawable.ic_media_control_skip_next,
503+
contentDescription = "Next",
504+
tint = onCardColor,
505+
size = 36.dp,
506+
iconSize = 20.dp,
507+
onClick = onNext,
508+
hasSurface = false
509+
)
459510
}
460511
}
461512
}
462513
}
463514

515+
@Composable
516+
private fun PlayPauseButton(
517+
isPlaying: Boolean,
518+
tint: Color,
519+
surfaceColor: Color,
520+
onClick: () -> Unit,
521+
) {
522+
Box(
523+
modifier = Modifier
524+
.width(64.dp)
525+
.height(40.dp)
526+
.clip(RoundedCornerShape(44.dp))
527+
.background(surfaceColor)
528+
.clickable(onClick = onClick),
529+
contentAlignment = Alignment.Center
530+
) {
531+
Image(
532+
painter = painterResource(
533+
if (isPlaying) R.drawable.ic_media_control_pause
534+
else R.drawable.ic_media_control_play
535+
),
536+
contentDescription = if (isPlaying) "Pause" else "Play",
537+
modifier = Modifier.size(22.dp),
538+
colorFilter = ColorFilter.tint(tint)
539+
)
540+
}
541+
}
542+
543+
@Composable
544+
private fun ControlButton(
545+
iconRes: Int,
546+
contentDescription: String,
547+
tint: Color,
548+
size: Dp,
549+
iconSize: Dp,
550+
onClick: () -> Unit,
551+
hasSurface: Boolean = false,
552+
) {
553+
Box(
554+
modifier = Modifier
555+
.size(size)
556+
.clip(CircleShape)
557+
.then(
558+
if (hasSurface) Modifier.background(tint.copy(alpha = 0.12f)) else Modifier
559+
)
560+
.clickable(onClick = onClick),
561+
contentAlignment = Alignment.Center
562+
) {
563+
Image(
564+
painter = painterResource(iconRes),
565+
contentDescription = contentDescription,
566+
modifier = Modifier.size(iconSize),
567+
colorFilter = ColorFilter.tint(tint)
568+
)
569+
}
570+
}
571+
464572
@Composable
465573
private fun SeekBarCompose(
466574
progressFraction: Float,
@@ -573,20 +681,6 @@ private fun SeekBarCompose(
573681
)
574682
}
575683

576-
@Composable
577-
private fun PlayerButton(
578-
iconRes: Int, contentDescription: String,
579-
size: Dp, iconSize: Dp, tint: Color, onClick: () -> Unit,
580-
) {
581-
Box(
582-
modifier = Modifier.size(size).clip(CircleShape).clickable(onClick = onClick),
583-
contentAlignment = Alignment.Center
584-
) {
585-
Image(painterResource(iconRes), contentDescription,
586-
modifier = Modifier.size(iconSize), colorFilter = ColorFilter.tint(tint))
587-
}
588-
}
589-
590684
@Composable
591685
private fun MusicChip(
592686
state: ProgressState,

0 commit comments

Comments
 (0)