From 560788d4cb1734a1275f6c018bfd7ea797795c04 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Fri, 4 Dec 2026 11:33:41 +0000 Subject: [PATCH 1/7] feat(android): add liquid glass chrome --- .../logseq/ui/extensions/LiquidGlass.kt | 83 +++++++++++++++++++ .../logseq/ui/extensions/LogseqExtensions.kt | 21 +++-- shared/src/logseq/view.ml | 3 +- shared/src/logseq/view_base.ml | 17 ++++ shared/src/logseq/view_base.mli | 1 + shared/src/logseq/view_screens.ml | 9 +- shared/test/logseq/app_test.ml | 6 +- 7 files changed, 123 insertions(+), 17 deletions(-) create mode 100644 android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt diff --git a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt new file mode 100644 index 00000000..b2538d65 --- /dev/null +++ b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt @@ -0,0 +1,83 @@ +package com.logseq.logseq.ui.extensions + +import androidx.compose.foundation.BorderStroke +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxScope +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.draw.shadow +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.graphics.lerp +import androidx.compose.ui.graphics.luminance +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import dev.lui.luiThemeColor + +/** + * Lightweight Android counterpart of the iOS Liquid Glass treatment. + * + * Android has no system backdrop material for floating in-window controls. The + * shared semantic contract is therefore rendered as a translucent, luminous + * surface rather than a capture-and-blur pass, keeping scrolling and editing + * inexpensive while preserving the glass silhouette, tint, rim, and highlight. + */ +@Composable +fun Modifier.logseqLiquidGlass( + shape: Shape, + elevation: Dp = 10.dp, +): Modifier { + val scheme = MaterialTheme.colorScheme + val base = luiThemeColor("glass") ?: scheme.surfaceContainerHigh + val outline = luiThemeColor("border") ?: scheme.outlineVariant + val dark = scheme.surface.luminance() < 0.5f + val baseAlpha = if (dark) 0.54f else 0.72f + val highlight = lerp(base, Color.White, if (dark) 0.22f else 0.34f) + val lower = lerp(base, Color.Black, if (dark) 0.10f else 0.025f) + val brush = Brush.verticalGradient( + 0f to highlight.copy(alpha = baseAlpha), + 0.42f to base.copy(alpha = baseAlpha - if (dark) 0.04f else 0.06f), + 1f to lower.copy(alpha = baseAlpha - if (dark) 0.08f else 0.10f), + ) + return this + .shadow( + elevation = elevation, + shape = shape, + clip = false, + ambientColor = Color.Black.copy(alpha = if (dark) 0.36f else 0.16f), + spotColor = Color.Black.copy(alpha = if (dark) 0.42f else 0.20f), + ) + .clip(shape) + .background(brush) + .border( + BorderStroke(1.dp, outline.copy(alpha = if (dark) 0.42f else 0.56f)), + shape, + ) +} + +@Composable +fun LogseqLiquidGlassSurface( + shape: Shape, + modifier: Modifier = Modifier, + elevation: Dp = 10.dp, + content: @Composable BoxScope.() -> Unit, +) { + Box(modifier.logseqLiquidGlass(shape, elevation), content = content) +} + +@Composable +fun Modifier.logseqCircleLiquidGlass(): Modifier = logseqLiquidGlass(CircleShape, elevation = 7.dp) + +@Composable +fun Modifier.logseqCapsuleLiquidGlass(): Modifier = logseqLiquidGlass(CircleShape) + +@Composable +fun Modifier.logseqRoundedLiquidGlass(radius: Dp): Modifier = + logseqLiquidGlass(RoundedCornerShape(radius), elevation = 8.dp) diff --git a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt index f3593f65..8d1ea1a8 100644 --- a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt +++ b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt @@ -1,7 +1,6 @@ package com.logseq.logseq.ui.extensions import androidx.activity.compose.BackHandler -import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource @@ -145,6 +144,17 @@ fun logseqExtensionRegistry( val group = luiThemeColor("settings-group") ?: colors.surface MaterialTheme(colorScheme = colors.copy(surface = group)) { Children() } } + registerTweak( + "liquid-glass", + "lui-tweak-v1|12:liquid-glass|profiles:android/kotlin,ios/swiftui|properties:5:shape:string:required:none", + properties = listOf(LuiExtensionProperty("shape", LuiExtensionValueKind.STRING, required = true)), + ) { + val shape = when (string("shape")) { + "container", "rounded-rectangle" -> RoundedCornerShape(20.dp) + else -> CircleShape + } + Box(Modifier.logseqLiquidGlass(shape)) { Children() } + } register( "outliner-row-swipe", "lui-extension-v1|18:outliner-row-swipe|profiles:android/kotlin|standard-children:1|children:|properties:12:marker-inset:int:required:none,7:enabled:bool:required:none,8:block-id:string:required:none|events:16:toggle-selection[4:uuid:string:required]", @@ -290,13 +300,8 @@ fun logseqExtensionRegistry( val inset = (int("inset") ?: 4).dp val accent = luiThemeColor("link", foreground = true) ?: MaterialTheme.colorScheme.primary val foreground = luiThemeColor("foreground", foreground = true) ?: MaterialTheme.colorScheme.onSurface - val glass = luiThemeColor("glass") ?: MaterialTheme.colorScheme.surfaceContainer val selection = luiThemeColor("bottom-tab-selected") ?: MaterialTheme.colorScheme.secondaryContainer - Surface( - shape = CircleShape, - color = glass, - border = BorderStroke(1.dp, luiThemeColor("border") ?: MaterialTheme.colorScheme.outlineVariant), - ) { + LogseqLiquidGlassSurface(shape = CircleShape) { Row(Modifier.padding(inset).selectableGroup(), verticalAlignment = Alignment.CenterVertically) { for (index in 0 until items.length()) { val item = items.getJSONObject(index) @@ -307,7 +312,7 @@ fun logseqExtensionRegistry( Box( modifier = Modifier.size(width = cellWidth, height = 50.dp) .clip(CircleShape) - .background(if (active) selection else Color.Transparent) + .background(if (active) selection.copy(alpha = 0.58f) else Color.Transparent) .selectable(selected = active, role = Role.Tab, onClick = { emit("select", "index" to index) }) .testTag("tab.bottom.$name") .semantics { contentDescription = title }, diff --git a/shared/src/logseq/view.ml b/shared/src/logseq/view.ml index 7b171e4d..bd97faba 100644 --- a/shared/src/logseq/view.ml +++ b/shared/src/logseq/view.ml @@ -328,7 +328,8 @@ let native_search_presentation_schema () = let liquid_glass_schema () = let open Lui_protocol in let open Lui_extension in - Lui_extension.tweak "liquid-glass" [ profile IOS SwiftUIHost ] + Lui_extension.tweak "liquid-glass" + [ profile IOS SwiftUIHost; profile AndroidOS KotlinHost ] [ Lui_extension.property "shape" StringScalar true None ] let native_control_tint_schema () = diff --git a/shared/src/logseq/view_base.ml b/shared/src/logseq/view_base.ml index c89b404b..4d4aa4a4 100644 --- a/shared/src/logseq/view_base.ml +++ b/shared/src/logseq/view_base.ml @@ -1682,6 +1682,23 @@ let with_liquid_glass shape (elem : Lui_elements.t) : Lui_elements.t = tweak | _ -> Lui_elements.mount context ?parent elem) +let with_native_liquid_glass shape (elem : Lui_elements.t) : Lui_elements.t = + Lui_elements.custom (fun context parent -> + match Lui_ui.profile context with + | { Lui_protocol.profile_os = Lui_protocol.IOS; + profile_host = Lui_protocol.SwiftUIHost; + } + | { Lui_protocol.profile_os = Lui_protocol.AndroidOS; + profile_host = Lui_protocol.KotlinHost; + } -> + let tweak = Lui_ui.platform_tweak context "liquid-glass" in + Lui_ui.extension_property context tweak "shape" + (StringValue shape); + ignore (Lui_elements.mount context ~parent:tweak elem); + Lui_elements.attach context parent tweak; + tweak + | _ -> Lui_elements.mount context ?parent elem) + let rich_block_content ?(show_code_language = true) ?interaction ?row_actions row_source ~on_event : Lui_elements.t = Lui_elements.custom (fun context parent -> let node = Lui_ui.extension context "outliner-block-content" in diff --git a/shared/src/logseq/view_base.mli b/shared/src/logseq/view_base.mli index cdf2148e..4ff06b1f 100644 --- a/shared/src/logseq/view_base.mli +++ b/shared/src/logseq/view_base.mli @@ -404,6 +404,7 @@ val with_float_prop_signal : float Signal.signal -> Lui_elements.t -> Lui_elements.t val with_liquid_glass : string -> Lui_elements.t -> Lui_elements.t +val with_native_liquid_glass : string -> Lui_elements.t -> Lui_elements.t val rich_block_content : ?show_code_language:bool -> ?interaction:string -> ?row_actions:Lui_protocol.wire_value Signal.signal -> Model.outline_row Signal.signal -> diff --git a/shared/src/logseq/view_screens.ml b/shared/src/logseq/view_screens.ml index 88b9d350..ca31cb09 100644 --- a/shared/src/logseq/view_screens.ml +++ b/shared/src/logseq/view_screens.ml @@ -272,9 +272,7 @@ let bottom_tab_row ~android ~tab_width ~action_width model_source send : t = action "capture-circle" "Capture" "button.composer.expand" Model.ExpandComposer ?on_long_press:(if android then None else Some (press send (Model.ChooseAttachment "quick-photos"))); ] in - let actions = - if android then box ~background:"glass" ~border_width:1 ~border_color:"border" ~corner_radius:29 [actions] - else View_base.with_liquid_glass "bottom-actions" actions in + let actions = View_base.with_native_liquid_glass "bottom-actions" actions in row ~grow:1.0 ~gap:8 ~main:`space_between ~cross:`center ~accessibility_identifier:"row.bottom.capture" [tabs; actions] @@ -721,8 +719,9 @@ let journal_overflow_menu ~android model_source send = ] let android_header_action action = - column ~width:44 ~height:44 ~corner_radius:22 - ~background:"glass" ~main:`center ~cross:`center [action] + View_base.with_native_liquid_glass "circle" + (column ~width:44 ~height:44 ~corner_radius:22 + ~main:`center ~cross:`center [action]) let tasks_options_visible current = View_base.tasks_destination_ current && View_base.node_navigation_inactive_ current diff --git a/shared/test/logseq/app_test.ml b/shared/test/logseq/app_test.ml index 6d6fa28b..023118f6 100644 --- a/shared/test/logseq/app_test.ml +++ b/shared/test/logseq/app_test.ml @@ -2006,7 +2006,7 @@ let native_search_presentation_extension_contract_is_pinned () = (Some "lui-extension-v1|26:native-search-presentation|profiles:android/kotlin,ios/swiftui|standard-children:1|children:|properties:10:back-title:string:optional:none,11:clear-title:string:optional:none,11:close-title:string:optional:none,12:status-title:string:optional:none,28:bottom-occupies-layout-space:bool:required:none,5:depth:int:required:none,5:query:string:required:none,5:title:string:required:none,9:presented:bool:required:none|events:13:query-changed[5:query:string:required],4:back[5:count:int:required],7:dismiss[],7:present[]") -let liquid_glass_remains_an_ios_local_tweak () = +let liquid_glass_is_a_native_local_tweak () = let registry = View.extension_registry () in let schema = Lui_extension.schema registry "liquid-glass" in check ~msg:"app-specific appearance does not expand the standard LUI protocol" @@ -2016,7 +2016,7 @@ let liquid_glass_remains_an_ios_local_tweak () = | Some current -> Some (Lui_extension.tweak_fingerprint current) | None -> None) (Some - "lui-tweak-v1|12:liquid-glass|profiles:ios/swiftui|properties:5:shape:string:required:none") + "lui-tweak-v1|12:liquid-glass|profiles:android/kotlin,ios/swiftui|properties:5:shape:string:required:none") let extension_kind runtime node = Hashtbl.find_opt runtime.Lui_runtime.runtime_extension_nodes node @@ -11868,7 +11868,7 @@ let cases = case "outliner-block-content-extension-contract-is-pinned" outliner_block_content_extension_contract_is_pinned; case "native-navigation-stack-extension-contract-is-pinned" native_navigation_stack_extension_contract_is_pinned; case "native-search-presentation-extension-contract-is-pinned" native_search_presentation_extension_contract_is_pinned; - case "liquid-glass-remains-an-ios-local-tweak" liquid_glass_remains_an_ios_local_tweak; + case "liquid-glass-is-a-native-local-tweak" liquid_glass_is_a_native_local_tweak; case "outliner-drag-selects-once-and-drop-keeps-placement" outliner_drag_selects_once_and_drop_keeps_placement; case "initial-shell-renders-the-graph-picker-without-a-selected-graph" initial_shell_renders_the_graph_picker_without_a_selected_graph; case "graph-picker-not-ready-status-matches-main-copy" graph_picker_not_ready_status_matches_main_copy; From 2840cb2b17ed384a319950863647064e4fc08968 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Fri, 4 Dec 2026 11:42:49 +0000 Subject: [PATCH 2/7] fix(ios): accept shared liquid glass fingerprint --- apple/Sources/Logseq/LGLiquidGlassTweak.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apple/Sources/Logseq/LGLiquidGlassTweak.swift b/apple/Sources/Logseq/LGLiquidGlassTweak.swift index 7e9e12d1..4cd4cd50 100644 --- a/apple/Sources/Logseq/LGLiquidGlassTweak.swift +++ b/apple/Sources/Logseq/LGLiquidGlassTweak.swift @@ -5,7 +5,7 @@ import SwiftUI enum LGLiquidGlassTweak { static let identifier = "liquid-glass" static let fingerprint = - "lui-tweak-v1|12:liquid-glass|profiles:ios/swiftui|properties:5:shape:string:required:none" + "lui-tweak-v1|12:liquid-glass|profiles:android/kotlin,ios/swiftui|properties:5:shape:string:required:none" static func register(in registry: LUIAppleExtensionRegistry) throws { try registry.registerTweak( From 8984c69d0eca9fdb208e2454b678aaab5b8c029c Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Fri, 4 Dec 2026 12:01:53 +0000 Subject: [PATCH 3/7] feat(android): render liquid glass with Haze Use Haze's source-backed Glass renderer for the floating Android chrome instead of a flat gradient approximation. Capture the navigation content once for the small glass surfaces and keep the shared selected-tab token transparency intact. --- android/app/build.gradle.kts | 2 + .../logseq/ui/extensions/LiquidGlass.kt | 78 +++++++------------ .../logseq/ui/extensions/LogseqExtensions.kt | 17 +++- 3 files changed, 45 insertions(+), 52 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index af8e3f04..13769b3a 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -205,6 +205,8 @@ dependencies { implementation("androidx.profileinstaller:profileinstaller:1.4.1") implementation("com.squareup.okhttp3:okhttp:4.12.0") implementation("ru.noties:jlatexmath-android:0.2.0") + implementation("dev.chrisbanes.haze:haze:2.1.0") + implementation("dev.chrisbanes.haze:haze-glass:2.1.0") // Android provides org.json; only host JVM tests need the separate library. testImplementation("org.json:json:20260814") diff --git a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt index b2538d65..1ad2d1b7 100644 --- a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt +++ b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt @@ -1,83 +1,61 @@ package com.logseq.logseq.ui.extensions -import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.background -import androidx.compose.foundation.border import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxScope -import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable +import androidx.compose.runtime.compositionLocalOf +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.shadow -import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.Shape -import androidx.compose.ui.graphics.lerp -import androidx.compose.ui.graphics.luminance import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import dev.lui.luiThemeColor +import dev.chrisbanes.haze.HazeInput +import dev.chrisbanes.haze.HazeState +import dev.chrisbanes.haze.glass.GlassStyle +import dev.chrisbanes.haze.glass.hazeGlass +import dev.chrisbanes.haze.rememberHazeState + +/** Shared capture state for the small floating chrome surfaces. */ +val LocalLogseqHazeState = compositionLocalOf { null } /** - * Lightweight Android counterpart of the iOS Liquid Glass treatment. - * - * Android has no system backdrop material for floating in-window controls. The - * shared semantic contract is therefore rendered as a translucent, luminous - * surface rather than a capture-and-blur pass, keeping scrolling and editing - * inexpensive while preserving the glass silhouette, tint, rim, and highlight. + * Android Liquid Glass implemented with Haze's source-backed Glass renderer. + * Only small floating chrome surfaces use the Glass effect; scrolling content + * is captured as the backdrop source and is otherwise ordinary Compose drawing. */ @Composable fun Modifier.logseqLiquidGlass( - shape: Shape, - elevation: Dp = 10.dp, + shape: RoundedCornerShape, + elevation: Dp = 8.dp, ): Modifier { - val scheme = MaterialTheme.colorScheme - val base = luiThemeColor("glass") ?: scheme.surfaceContainerHigh - val outline = luiThemeColor("border") ?: scheme.outlineVariant - val dark = scheme.surface.luminance() < 0.5f - val baseAlpha = if (dark) 0.54f else 0.72f - val highlight = lerp(base, Color.White, if (dark) 0.22f else 0.34f) - val lower = lerp(base, Color.Black, if (dark) 0.10f else 0.025f) - val brush = Brush.verticalGradient( - 0f to highlight.copy(alpha = baseAlpha), - 0.42f to base.copy(alpha = baseAlpha - if (dark) 0.04f else 0.06f), - 1f to lower.copy(alpha = baseAlpha - if (dark) 0.08f else 0.10f), - ) + val state = LocalLogseqHazeState.current ?: rememberHazeState() + val style = remember(shape) { + GlassStyle.regular.then { + shape(shape) + } + } return this .shadow( elevation = elevation, shape = shape, clip = false, - ambientColor = Color.Black.copy(alpha = if (dark) 0.36f else 0.16f), - spotColor = Color.Black.copy(alpha = if (dark) 0.42f else 0.20f), + ambientColor = Color.Black.copy(alpha = 0.16f), + spotColor = Color.Black.copy(alpha = 0.20f), ) - .clip(shape) - .background(brush) - .border( - BorderStroke(1.dp, outline.copy(alpha = if (dark) 0.42f else 0.56f)), - shape, + .hazeGlass( + input = HazeInput.Backdrop(state), + style = style, ) } @Composable fun LogseqLiquidGlassSurface( - shape: Shape, + shape: RoundedCornerShape, modifier: Modifier = Modifier, - elevation: Dp = 10.dp, + elevation: Dp = 8.dp, content: @Composable BoxScope.() -> Unit, ) { Box(modifier.logseqLiquidGlass(shape, elevation), content = content) } - -@Composable -fun Modifier.logseqCircleLiquidGlass(): Modifier = logseqLiquidGlass(CircleShape, elevation = 7.dp) - -@Composable -fun Modifier.logseqCapsuleLiquidGlass(): Modifier = logseqLiquidGlass(CircleShape) - -@Composable -fun Modifier.logseqRoundedLiquidGlass(radius: Dp): Modifier = - logseqLiquidGlass(RoundedCornerShape(radius), elevation = 8.dp) diff --git a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt index 8d1ea1a8..4a01ff2d 100644 --- a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt +++ b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt @@ -62,6 +62,8 @@ import dev.lui.LuiExtensionProperty import dev.lui.LuiExtensionRegistry import dev.lui.LuiExtensionValueKind import dev.lui.luiThemeColor +import dev.chrisbanes.haze.hazeSource +import dev.chrisbanes.haze.rememberHazeState // Port of the former logseq_extensions.dart — the Logseq-specific // extension hosts. Fingerprints are generated by the OCaml core and must @@ -312,7 +314,7 @@ fun logseqExtensionRegistry( Box( modifier = Modifier.size(width = cellWidth, height = 50.dp) .clip(CircleShape) - .background(if (active) selection.copy(alpha = 0.58f) else Color.Transparent) + .background(if (active) selection else Color.Transparent) .selectable(selected = active, role = Role.Tab, onClick = { emit("select", "index" to index) }) .testTag("tab.bottom.$name") .semantics { contentDescription = title }, @@ -441,12 +443,14 @@ private fun NavigationBoundary(context: LuiExtensionContext) { } } var journalTitle by remember { mutableStateOf(null) } + val hazeState = rememberHazeState() BoxWithConstraints(Modifier.fillMaxSize()) { val width = maxWidth.value.toInt() LaunchedEffect(width) { context.emit("viewport-changed", "width" to width) } CompositionLocalProvider( dev.lui.LocalLuiSectionTitle provides journalTitle, dev.lui.LocalLuiSectionTitleChanged provides { journalTitle = it }, + LocalLogseqHazeState provides hazeState, ) { val childIds = context.children if (childIds.size == 2) { @@ -463,7 +467,9 @@ private fun NavigationBoundary(context: LuiExtensionContext) { val chromeHeight = remember { mutableIntStateOf(0) } Box(Modifier.fillMaxSize()) { CompositionLocalProvider(LocalBottomChromeHeight provides chromeHeight) { - Column(Modifier.fillMaxSize()) { NavigationContent(context, childIds[0], dismissesComposer) } + Column(Modifier.fillMaxSize().hazeSource(hazeState, zIndex = 1f)) { + NavigationContent(context, childIds[0], dismissesComposer) + } } val chromeModifier = Modifier .align(Alignment.BottomCenter) @@ -491,6 +497,13 @@ private fun NavigationContent(context: LuiExtensionContext, contentId: Long, dis val focus = LocalFocusManager.current val keyboard = LocalSoftwareKeyboardController.current Box(Modifier.fillMaxSize()) { + LocalLogseqHazeState.current?.let { state -> + Box( + Modifier.fillMaxSize() + .background(MaterialTheme.colorScheme.background) + .hazeSource(state, zIndex = 0f), + ) + } context.child(contentId) if (dismissesComposer) { Box(Modifier.fillMaxSize() From 15d1daa44bb4116200a6c4e4e7c0d40ad8fa0898 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Fri, 4 Dec 2026 12:08:01 +0000 Subject: [PATCH 4/7] fix(android): capture header glass backdrop Keep the background color inside the zero-z Haze source so nested header controls have a real fallback backdrop instead of capturing a transparent box. --- .../com/logseq/logseq/ui/extensions/LogseqExtensions.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt index 4a01ff2d..3761cd18 100644 --- a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt +++ b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt @@ -500,8 +500,8 @@ private fun NavigationContent(context: LuiExtensionContext, contentId: Long, dis LocalLogseqHazeState.current?.let { state -> Box( Modifier.fillMaxSize() - .background(MaterialTheme.colorScheme.background) - .hazeSource(state, zIndex = 0f), + .hazeSource(state, zIndex = 0f) + .background(MaterialTheme.colorScheme.background), ) } context.child(contentId) From d1aa084952d6bf24868bc873fd81beaad53df751 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Fri, 4 Dec 2026 12:08:01 +0000 Subject: [PATCH 5/7] fix(android): fill glass on fallback renderer Android 12L and below use Haze's non-shader Glass renderer, which cannot synthesize Regular's base fill. Supply a theme surface tint only on that path. --- .../com/logseq/logseq/ui/extensions/LiquidGlass.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt index 1ad2d1b7..cd7ade58 100644 --- a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt +++ b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt @@ -1,8 +1,10 @@ package com.logseq.logseq.ui.extensions +import android.os.Build import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.compositionLocalOf import androidx.compose.runtime.remember @@ -31,9 +33,15 @@ fun Modifier.logseqLiquidGlass( elevation: Dp = 8.dp, ): Modifier { val state = LocalLogseqHazeState.current ?: rememberHazeState() - val style = remember(shape) { + // Haze's non-shader Glass fallback (Android 12L and below) does not + // synthesize Regular's base fill, so give only that path a theme tint. + val fallbackTint = MaterialTheme.colorScheme.surface.copy(alpha = 0.82f) + val style = remember(shape, fallbackTint) { GlassStyle.regular.then { shape(shape) + if (Build.VERSION.SDK_INT < 33) { + tint(fallbackTint) + } } } return this From 2272933442cac6024c40843d754b8eb8df87544b Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Fri, 4 Dec 2026 12:22:04 +0000 Subject: [PATCH 6/7] feat(android): animate bottom tab glass selection --- .../logseq/ui/extensions/LogseqExtensions.kt | 125 ++++++++++++++---- 1 file changed, 102 insertions(+), 23 deletions(-) diff --git a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt index 3761cd18..80ffeaa3 100644 --- a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt +++ b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LogseqExtensions.kt @@ -1,14 +1,18 @@ package com.logseq.logseq.ui.extensions import androidx.activity.compose.BackHandler +import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.animation.core.spring import androidx.compose.foundation.background import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.detectHorizontalDragGestures import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding @@ -36,6 +40,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.setValue import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.Alignment @@ -44,14 +49,17 @@ import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.Color import androidx.compose.ui.draw.clip +import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.testTag import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.logseq.logseq.runtime.logseqIconResolver @@ -64,6 +72,7 @@ import dev.lui.LuiExtensionValueKind import dev.lui.luiThemeColor import dev.chrisbanes.haze.hazeSource import dev.chrisbanes.haze.rememberHazeState +import kotlin.math.roundToInt // Port of the former logseq_extensions.dart — the Logseq-specific // extension hosts. Fingerprints are generated by the OCaml core and must @@ -297,36 +306,106 @@ fun logseqExtensionRegistry( ) { val encoded = string("items") ?: "[]" val items = remember(encoded) { JSONArray(encoded) } + val count = items.length() val selected = int("selected-index") val cellWidth = (int("cell-width") ?: 50).dp val inset = (int("inset") ?: 4).dp val accent = luiThemeColor("link", foreground = true) ?: MaterialTheme.colorScheme.primary val foreground = luiThemeColor("foreground", foreground = true) ?: MaterialTheme.colorScheme.onSurface val selection = luiThemeColor("bottom-tab-selected") ?: MaterialTheme.colorScheme.secondaryContainer + var dragPosition by remember { mutableStateOf(null) } + var pendingSelection by remember { mutableStateOf(null) } + val currentSelected by rememberUpdatedState(selected) + LaunchedEffect(selected) { pendingSelection = null } + val settledPosition = (pendingSelection ?: selected ?: 0).coerceIn(0, maxOf(0, count - 1)).toFloat() + val animatedPosition by animateFloatAsState( + targetValue = settledPosition, + animationSpec = spring(), + label = "bottom-tab-indicator", + ) + val indicatorPosition = dragPosition ?: animatedPosition + val density = LocalDensity.current + val layoutDirection = LocalLayoutDirection.current + val cellWidthPx = with(density) { cellWidth.toPx() } + val insetPx = with(density) { inset.toPx() } + val stripWidthPx = count * cellWidthPx + 2 * insetPx + + fun rawIndexAt(x: Float): Float { + val horizontal = if (layoutDirection == LayoutDirection.Rtl) stripWidthPx - x else x + return (horizontal - insetPx) / cellWidthPx - 0.5f + } + + fun elasticIndex(raw: Float): Float { + val clamped = raw.coerceIn(0f, (count - 1).toFloat()) + val overshoot = ((raw - clamped) * 0.2f).coerceIn(-0.08f, 0.08f) + return clamped + overshoot + } + LogseqLiquidGlassSurface(shape = CircleShape) { - Row(Modifier.padding(inset).selectableGroup(), verticalAlignment = Alignment.CenterVertically) { - for (index in 0 until items.length()) { - val item = items.getJSONObject(index) - val title = item.getString("title") - val name = item.getString("name") - val active = index == selected - val symbol = logseqIconResolver.icon(item.getString(if (active) "selectedImage" else "image")) - Box( - modifier = Modifier.size(width = cellWidth, height = 50.dp) - .clip(CircleShape) - .background(if (active) selection else Color.Transparent) - .selectable(selected = active, role = Role.Tab, onClick = { emit("select", "index" to index) }) - .testTag("tab.bottom.$name") - .semantics { contentDescription = title }, - contentAlignment = Alignment.Center, - ) { - if (symbol != null) { - Box(Modifier.size(26.dp)) { - Icon(symbol, contentDescription = null, modifier = Modifier.fillMaxSize(), - tint = if (active) accent else foreground) - if (item.optBoolean("unread")) { - Box(Modifier.align(Alignment.TopCenter).padding(top = 9.dp).size(4.dp) - .background(accent, CircleShape).testTag("notifications.unread-dot")) + Box( + Modifier.size(width = cellWidth * count + inset * 2, height = 50.dp + inset * 2) + .selectableGroup() + .pointerInput(count, cellWidthPx, insetPx, layoutDirection) { + if (count == 0 || cellWidthPx <= 0f) return@pointerInput + detectHorizontalDragGestures( + onDragStart = { offset -> dragPosition = elasticIndex(rawIndexAt(offset.x)) }, + onDragEnd = { + dragPosition?.let { position -> + val target = position.roundToInt().coerceIn(0, count - 1) + if (target != currentSelected) { + pendingSelection = target + emit("select", "index" to target) + } + } + dragPosition = null + }, + onDragCancel = { dragPosition = null }, + ) { change, _ -> + dragPosition = elasticIndex(rawIndexAt(change.position.x)) + change.consume() + } + }, + ) { + val hasIndicator = count > 0 && + (dragPosition != null || pendingSelection != null || (selected != null && selected in 0 until count)) + if (hasIndicator) { + val indicatorX = if (layoutDirection == LayoutDirection.Rtl) { + inset + cellWidth * (count - 1 - indicatorPosition) + } else { + inset + cellWidth * indicatorPosition + } + var indicatorModifier = Modifier.offset(x = indicatorX, y = inset) + .size(width = cellWidth, height = 50.dp) + .clip(CircleShape) + .background(selection) + if (dragPosition != null) { + indicatorModifier = indicatorModifier.logseqLiquidGlass(CircleShape, elevation = 0.dp) + } + Box(indicatorModifier) + } + Row(Modifier.padding(inset), verticalAlignment = Alignment.CenterVertically) { + for (index in 0 until count) { + val item = items.getJSONObject(index) + val title = item.getString("title") + val name = item.getString("name") + val active = index == (dragPosition?.roundToInt() ?: pendingSelection ?: selected) + val symbol = logseqIconResolver.icon(item.getString(if (active) "selectedImage" else "image")) + Box( + modifier = Modifier.size(width = cellWidth, height = 50.dp) + .clip(CircleShape) + .selectable(selected = active, role = Role.Tab, onClick = { emit("select", "index" to index) }) + .testTag("tab.bottom.$name") + .semantics { contentDescription = title }, + contentAlignment = Alignment.Center, + ) { + if (symbol != null) { + Box(Modifier.size(26.dp)) { + Icon(symbol, contentDescription = null, modifier = Modifier.fillMaxSize(), + tint = if (active) accent else foreground) + if (item.optBoolean("unread")) { + Box(Modifier.align(Alignment.TopCenter).padding(top = 9.dp).size(4.dp) + .background(accent, CircleShape).testTag("notifications.unread-dot")) + } } } } From 602a10fd2663689e8f020d675fdb7e8ae1a762ab Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Fri, 4 Dec 2026 14:50:40 +0000 Subject: [PATCH 7/7] fix(android): move glass light off button centers --- .../main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt index cd7ade58..10415dc9 100644 --- a/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt +++ b/android/app/src/main/kotlin/com/logseq/logseq/ui/extensions/LiquidGlass.kt @@ -8,6 +8,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.compositionLocalOf import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.shadow import androidx.compose.ui.graphics.Color @@ -39,6 +40,8 @@ fun Modifier.logseqLiquidGlass( val style = remember(shape, fallbackTint) { GlassStyle.regular.then { shape(shape) + // Centered light reads as a white dot inside small circular chrome. + lightPosition(Alignment.TopCenter) if (Build.VERSION.SDK_INT < 33) { tint(fallbackTint) }