Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 40 additions & 9 deletions app/src/main/java/com/theveloper/pixelplay/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import android.content.Context
import android.content.ComponentName
import android.content.Intent
import android.os.Build
import android.graphics.RenderEffect as AndroidRenderEffect
import android.graphics.Shader as AndroidShader
import androidx.compose.ui.graphics.asComposeRenderEffect
import android.os.Bundle
import android.os.Trace
import android.provider.Settings
Expand Down Expand Up @@ -912,14 +915,38 @@ class MainActivity : ComponentActivity() {
bottomSpacerPx = spacerPx
)

AppNavigation(
playerViewModel = playerViewModel,
navController = navController,
paddingValues = innerPadding,
userPreferencesRepository = userPreferencesRepository,
onSearchBarActiveChange = { isSearchBarActive = it },
onOpenSidebar = { scope.launch { drawerState.open() } }
)
val expansionFractionProvider = remember(playerViewModel.playerContentExpansionFraction) {
{ playerViewModel.playerContentExpansionFraction.value }
}

Box(
modifier = Modifier
.fillMaxSize()
.graphicsLayer {
val fraction = expansionFractionProvider()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val blurPx = fraction * 100f // 40px target blur at 100% expanded
if (blurPx > 0f) {
renderEffect = AndroidRenderEffect.createBlurEffect(
blurPx,
blurPx,
AndroidShader.TileMode.CLAMP
).asComposeRenderEffect()
} else {
renderEffect = null
}
}
}
) {
AppNavigation(
playerViewModel = playerViewModel,
navController = navController,
paddingValues = innerPadding,
userPreferencesRepository = userPreferencesRepository,
onSearchBarActiveChange = { isSearchBarActive = it },
onOpenSidebar = { scope.launch { drawerState.open() } }
)
}

val isExpandedOrExpanding by remember {
derivedStateOf {
Expand All @@ -935,7 +962,11 @@ class MainActivity : ComponentActivity() {
Box(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.surfaceContainerLowest.copy(alpha = 0.6f))
.background(
MaterialTheme.colorScheme.surfaceContainerLowest.copy(
alpha = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) 0.35f else 0.6f
)
)
.pointerInput(Unit) {
detectTapGestures {
playerViewModel.collapsePlayerSheet()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.theveloper.pixelplay.data.preferences

data class FullPlayerLoadingTweaks(
val delayAll: Boolean = true,
val delayAll: Boolean = false,
val delayAlbumCarousel: Boolean = true,
val delaySongMetadata: Boolean = true,
val delayProgressBar: Boolean = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,7 @@ private fun ToneTargetOption(
ListItem(
modifier = Modifier
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp))
.clickable(onClick = onClick),
colors = ListItemDefaults.colors(
containerColor = MaterialTheme.colorScheme.surfaceContainerHighest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,30 @@ internal class QueueSheetController(
resetDragPipeline()

val isFastUpward = velocity < -520f
val isFastDownward = velocity > 700f
val isFastDownward = velocity > 450f
val minFlingTravelPx = minFlingTravelPxProvider()
val hasMeaningfulUpwardTravel = totalDrag < -minFlingTravelPx
// Quick upward flicks on full player can be short in travel but high in intent.
val hasQuickUpwardTravel = totalDrag < -(minFlingTravelPx * 0.35f)
val shouldExpandFromQuickFling = isFastUpward && hasQuickUpwardTravel
val dragThresholdPx = dragThresholdPxProvider()
val shouldExpand = shouldExpandFromQuickFling ||
(isFastUpward && hasMeaningfulUpwardTravel) ||
(!isFastDownward && (
settledOffset < hiddenOffset - dragThresholdPx ||
totalDrag < -dragThresholdPx
))

// Directional intent: a clear drag past the threshold in either direction
// commits to that direction. This makes dismissing from the header reliable
// (downward drag past threshold → close) while still letting upward drags
// from the closed state open the sheet.
val hasCommittedDownwardDrag = totalDrag > dragThresholdPx
val hasCommittedUpwardDrag = totalDrag < -dragThresholdPx

val shouldExpand = when {
shouldExpandFromQuickFling -> true
isFastUpward && hasMeaningfulUpwardTravel -> true
isFastDownward -> false
hasCommittedDownwardDrag -> false
hasCommittedUpwardDrag -> true
// Tiny residual drag: snap to whichever half the sheet ended in.
else -> settledOffset < hiddenOffset * 0.5f
}

animate(shouldExpand)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand All @@ -51,7 +49,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.lerp as lerpDp
import coil.size.Size
import com.theveloper.pixelplay.data.model.Song
import com.theveloper.pixelplay.presentation.components.AutoScrollingTextOnDemand
import com.theveloper.pixelplay.presentation.components.AutoScrollingText
import com.theveloper.pixelplay.presentation.components.ShimmerBox
import androidx.compose.ui.res.stringResource
import com.theveloper.pixelplay.R
Expand Down Expand Up @@ -240,8 +238,6 @@ fun EnhancedSongListItem(
}
} else {
// Actual Song Item Layout
var applyTextMarquee by remember { mutableStateOf(false) }

Surface(
modifier = modifier
.fillMaxWidth()
Expand All @@ -268,18 +264,9 @@ fun EnhancedSongListItem(
onClick()
}
},
onLongPress = {
onLongPress = {
// Long press always activates/toggles selection
onLongPress()
},
onPress = {
if (!isSelectionMode) {
try {
awaitRelease()
} finally {
applyTextMarquee = false
}
}
}
)
},
Expand Down Expand Up @@ -345,11 +332,10 @@ fun EnhancedSongListItem(
.weight(1f)
) {
if (isHighlighted && !isSelectionMode) {
AutoScrollingTextOnDemand(
AutoScrollingText(
text = song.title,
style = MaterialTheme.typography.bodyLarge,
style = MaterialTheme.typography.bodyLarge.copy(fontWeight = FontWeight.SemiBold),
gradientEdgeColor = containerColor,
expansionFractionProvider = { 1f },
)

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private fun GenreCard(
val textMeasurer = rememberTextMeasurer()
val density = LocalDensity.current
val titleStartPadding = 14.dp
val titleEndPadding = 14.dp
val titleEndPadding = if (isGridView) 14.dp else 96.dp
val titlePresentation = remember(
genre.id,
genre.name,
Expand All @@ -215,12 +215,14 @@ private fun GenreCard(
density.density,
density.fontScale
) {
val startPaddingPx = with(density) { titleStartPadding.roundToPx() }
val endPaddingPx = with(density) { titleEndPadding.roundToPx() }
GenreTypography.resolveTitlePresentation(
genreId = genre.id,
genreName = genre.name,
isGridView = isGridView,
cardWidthPx = with(density) { maxWidth.roundToPx() },
horizontalPaddingPx = with(density) { titleStartPadding.roundToPx() },
horizontalPaddingPx = (startPaddingPx + endPaddingPx) / 2,
textMeasurer = textMeasurer
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ object GenreTypography {
return when {
isGridView && profile.wordCount >= 3 -> 0.56f
isGridView -> 0.52f
profile.wordCount >= 3 -> 0.66f
else -> 0.62f
else -> 1.0f
}
}

Expand Down
Loading