Skip to content

Open-source Android PDF and document toolkit with PDF tools, Office viewing, XLSX editing, scanning, and image editing. Built with Kotlin and Jetpack Compose.

Viewer: the blue More tools button no longer blinks as its menu folds back

chethan616d752064a8099
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/LiquidMorph.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/LiquidMorph.kt
index cbd3129..06fe539 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/LiquidMorph.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/LiquidMorph.kt
@@ -201,6 +201,9 @@ internal fun LiquidMorphSurface(
androidx.compose.runtime.DisposableEffect(Unit) { onDispose { gone() } }
// the button's own tint (a blue Done, a candy button): the glass keeps it at both ends
val tint = MorphAnchors.tintAt(anchor) ?: Color.Unspecified
+ // a solid button (the viewer's blue More tools) is solid blue at the morph's circle end too: at
+ // 75% over the glass it came back lighter than the real button and blinked as it took over
+ val solidTint = MorphAnchors.solidAt(anchor)
BackHandler(enabled = !shut, onBack = onDismiss)
val host = LocalGlassOverlayHost.current ?: return@GlassOverlay
val bars = WindowInsets.systemBars
@@ -410,7 +413,7 @@ internal fun LiquidMorphSurface(
val menuWash = adaptiveWash(lum).glassTint(style).let { it.copy(alpha = (it.alpha + busyAlpha).coerceAtMost(0.75f)) }
val plain = menuWash.let { it.copy(alpha = it.alpha * w) }
val wash = when {
- tint.isSpecified -> androidx.compose.ui.graphics.lerp(tint.copy(alpha = 0.75f), plain, w)
+ tint.isSpecified -> androidx.compose.ui.graphics.lerp(tint.copy(alpha = if (solidTint) 1f else 0.75f), plain, w)
// the adaptive button's own wash at its end, the menu's as it opens
adaptiveOn -> androidx.compose.ui.graphics.lerp(adaptiveWash(aroundLum()).let { it.copy(alpha = it.alpha * 0.7f) }, menuWash, w)
else -> plain
@@ -457,6 +460,7 @@ internal fun LiquidMorphSurface(
if (tint.isSpecified) {
drawRect(tint, blendMode = androidx.compose.ui.graphics.BlendMode.Hue)
drawRect(tint.copy(alpha = 0.75f))
+ if (solidTint) drawRect(tint)
} else if (adaptiveOn) {
drawRect(adaptiveWash(aroundLum()).let { it.copy(alpha = it.alpha * 0.7f) })
}
diff --git a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/MorphButton.kt b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/MorphButton.kt
index 3f39254..f780040 100644
--- a/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/MorphButton.kt
+++ b/android/app/src/main/java/com/chethan616/clearpdf/ui/glass/MorphButton.kt
@@ -189,7 +189,15 @@ object MorphAnchors {
private val tints = HashMap<Long, Color>()
- internal fun setTint(r: Rect, tint: Color) { if (tint.isSpecified) tints[key(r)] = tint else tints.remove(key(r)) }
+ internal fun setTint(r: Rect, tint: Color, solid: Boolean = false) {
+ if (tint.isSpecified) tints[key(r)] = tint else tints.remove(key(r))
+ if (solid && tint.isSpecified) solids.add(key(r)) else solids.remove(key(r))
+ }
+
+ private val solids = HashSet<Long>()
+
+ /** Whether the button at [r] paints its tint solid (the viewer's blue More tools): its morph must too. */
+ internal fun solidAt(r: Rect): Boolean = key(r) in solids
internal fun tintAt(r: Rect): Color? = tints[key(r)]