Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ class AndroidFeedbackRecordingTest(private val scenario: String) {
private fun pause() {
drain(); captureFrame()
}
private fun waitForSearchResult(uuid: String) {
ui.waitUntil(10_000) {
drain()
ui.onAllNodesWithTag("search.result.$uuid").fetchSemanticsNodes().isNotEmpty()
}
}
private fun pauseWithoutDrain() = captureFrame()
private fun captureFrame() {
ui.waitForIdle(); Thread.sleep(1800)
Expand All @@ -129,7 +135,7 @@ class AndroidFeedbackRecordingTest(private val scenario: String) {
ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED)
.first().window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING)
}
private fun mount(page: Int, dark: Boolean = false) {
private fun mount(page: Int, dark: Boolean = false, darkTheme: String? = null) {
val directory = File(context.cacheDir, "feedback-recording").apply { deleteRecursively(); mkdirs() }
graph = File(directory, "graphs/feedback").apply { mkdirs() }
if (scenario == "notifications") notificationFixture = recentNotifications(directory)
Expand Down Expand Up @@ -159,8 +165,8 @@ class AndroidFeedbackRecordingTest(private val scenario: String) {
apply(opened); apply(selected)
host("local-graph-ids", """["feedback"]""")
host("graph-loading", "false")
if (dark) host("settings", """{"appearance":"dark","language":"system","systemLanguage":"en-US","spellCheck":true,"autoCorrection":true,"sidebarTabs":[],"baseURL":"http://127.0.0.1:1","version":"QA","revision":"feedback"}""")
ui.setContent { MaterialExpressiveTheme(colorScheme = if (dark) LogseqTheme.darkScheme else LogseqTheme.lightScheme, typography = LogseqTheme.typography) {
if (dark) host("settings", """{"appearance":"dark","darkTheme":"${darkTheme ?: "black"}","language":"system","systemLanguage":"en-US","spellCheck":true,"autoCorrection":true,"sidebarTabs":[],"baseURL":"http://127.0.0.1:1","version":"QA","revision":"feedback"}""")
ui.setContent { MaterialExpressiveTheme(colorScheme = LogseqTheme.colorScheme(dark, darkTheme ?: "solarized"), typography = LogseqTheme.typography) {
CompositionLocalProvider(dev.lui.LocalLuiThemeDark provides dark,
LocalContentColor provides androidx.compose.material3.MaterialTheme.colorScheme.onBackground,
dev.lui.LocalLuiSemanticColors provides LogseqTheme.semanticColors(androidx.compose.material3.MaterialTheme.colorScheme)) {
Expand Down Expand Up @@ -195,20 +201,21 @@ class AndroidFeedbackRecordingTest(private val scenario: String) {
}
return inbox
}
private fun mountProjection(projection: JSONObject) {
private fun mountProjection(projection: JSONObject, authenticationCode: Int = 3) {
lateinit var native: LogseqNativeBridge
val backend = LuiBackend(onEvent = { dispatchFixtureEvent(it, native) },
extensions = logseqExtensionRegistry { it }, icons = logseqIconResolver)
filter = LuiPatchFilter(backend)
native = LogseqNativeBridge(onPatch = { if (it.isNotEmpty()) filter.applyJson(it) })
bridge = native
val root = native.initialize(authenticationCode = 3)
val root = native.initialize(authenticationCode = authenticationCode)
val result = JSONObject().put("graphName", "Recording graph")
.put("selectedGraphId", "recording").put("isGraphUnlocked", true)
.put("syncConnected", false).put("selectedPage", JSONObject.NULL)
.put("nodeRoutes", JSONArray()).put("outlinerRows", JSONArray())
projection.keys().forEach { result.put(it, projection.get(it)) }
filter.applyJson(native.applySnapshot(JSONObject().put("ok", true).put("result", result).toString()))
native.applySnapshot(JSONObject().put("ok", true).put("result", result).toString())
.takeIf { it.isNotEmpty() }?.let(filter::applyJson)
ui.setContent { MaterialExpressiveTheme(colorScheme = LogseqTheme.lightScheme, typography = LogseqTheme.typography) {
Box(Modifier.fillMaxSize().background(androidx.compose.material3.MaterialTheme.colorScheme.background)
.logseqContentHostInsets()) { backend.Content(root) }
Expand All @@ -231,6 +238,93 @@ class AndroidFeedbackRecordingTest(private val scenario: String) {
}
private fun recordCase() {
when (scenario) {
"login-progress" -> {
mountProjection(JSONObject().put("selectedGraphId", JSONObject.NULL), authenticationCode = 1)
ui.onNodeWithTag("button.sign-in").performClick()
ui.onNodeWithTag("field.auth.email").performTextInput("tester@example.com")
ui.onNodeWithTag("field.auth.password").performTextInput("fixture-password")
instrumentation.runOnMainSync {
val activity = ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED).first()
androidx.core.view.WindowCompat.getInsetsController(activity.window, activity.window.decorView)
.hide(androidx.core.view.WindowInsetsCompat.Type.ime())
}
ui.onNodeWithTag("button.auth.submit").performClick()
pauseWithoutDrain()
ui.onNodeWithTag("auth.loading", useUnmergedTree = true).assertIsDisplayed()
if (verify) ui.onNodeWithTag("sign-in.loading", useUnmergedTree = true).assertDoesNotExist()
}
"search-empty-alignment" -> {
mount(1, dark = true)
ui.onNodeWithTag("button.search").performClick()
pause()
val screen = ui.onNodeWithTag("native-search-presentation", useUnmergedTree = true)
.getUnclippedBoundsInRoot()
val icon = ui.onNodeWithTag("search.empty.icon", useUnmergedTree = true)
.assertIsDisplayed().getUnclippedBoundsInRoot()
if (verify) assertEquals("Center the empty state across the search viewport",
(screen.left + screen.right).value / 2, (icon.left + icon.right).value / 2, 1f)
}
"confirmation-spacing" -> {
mount(1, dark = true)
fun checkDialog(title: String, dialogTag: String, actionTag: String) {
pause()
ui.onNodeWithText(title).assertIsDisplayed()
val dialog = ui.onNodeWithTag(dialogTag, useUnmergedTree = true)
.assertIsDisplayed().getUnclippedBoundsInRoot()
val action = ui.onNodeWithTag(actionTag, useUnmergedTree = true)
.assertIsDisplayed().getUnclippedBoundsInRoot()
if (verify) assertTrue("Use standard alert padding below the buttons",
dialog.bottom - action.bottom <= 32.dp)
}
ui.onNodeWithTag("button.overflow-menu").performClick()
ui.onNodeWithTag("button.page.delete").performClick()
checkDialog("Delete page?", "dialog.page-delete", "button.page-delete.confirm")
ui.onNodeWithTag("button.page-delete.cancel").performClick()
ui.onNodeWithTag("button.outliner.zoom.${uuid(11)}.Journal content").performClick()
pause()
ui.onNodeWithTag("button.overflow-menu").performClick()
ui.onNodeWithTag("button.block.delete").performClick()
checkDialog("Delete block?", "dialog.page-delete", "button.page-delete.confirm")
ui.onNodeWithTag("button.page-delete.cancel").performClick()
ui.onNodeWithTag("button.navigation.back").performClick()
drain()
ui.onNodeWithTag("button.sidebar").performClick()
ui.onNodeWithTag("button.sidebar.settings").performClick()
ui.onNodeWithTag("button.sign-out").performScrollTo().performClick()
checkDialog("Sign out?", "dialog.sign-out", "button.sign-out.confirm")
ui.onNodeWithTag("button.sign-out.cancel").performClick()
}
"recent-navigation" -> {
mount(1, dark = true)
val sidebar = request("loadSidebar")
val before = JSONObject(sidebar).getJSONObject("result").getJSONArray("recentPages")
apply(sidebar)
ui.onNodeWithTag("button.search").performClick()
ui.onNodeWithTag("field.search").performTextInput("Formula")
val hits = JSONObject(request("searchNodes", "Formula")).getJSONObject("result").getJSONArray("searchResults")
val page = (0 until hits.length()).map(hits::getJSONObject).single { it.getBoolean("isPage") }
val target = page.getString("uuid")
waitForSearchResult(target)
pause()
ui.onNodeWithTag("search.result.$target").performClick()
pause()
ui.onNodeWithTag("button.search.close").performClick()
ui.onNodeWithTag("button.sidebar").performClick()
pause()
if (verify) {
val result = JSONObject(request("loadSidebar")).getJSONObject("result")
assertTrue((0 until before.length()).any { before.getJSONObject(it).getString("uuid") == target })
assertEquals(before.toString(), result.getJSONArray("recentPages").toString())
ui.onNodeWithTag("link.sidebar.page.$target").assertIsDisplayed()
}
}
"liquid-chrome" -> {
mount(1, dark = true, darkTheme = "black")
ui.onNodeWithTag("button.search").assertIsDisplayed()
ui.onNodeWithTag("button.overflow-menu").assertIsDisplayed()
ui.onNodeWithTag("tab.bottom.tasks").performClick()
pause()
}
"slash-template" -> {
mount(1)
ignoreAdjustResize()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.logseq.logseq.ui.extensions

import android.os.Build
import androidx.compose.foundation.border
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.shape.RoundedCornerShape
Expand All @@ -19,6 +21,7 @@ import dev.chrisbanes.haze.HazeState
import dev.chrisbanes.haze.glass.GlassStyle
import dev.chrisbanes.haze.glass.hazeGlass
import dev.chrisbanes.haze.rememberHazeState
import dev.lui.LocalLuiThemeDark

/** Shared capture state for the small floating chrome surfaces. */
val LocalLogseqHazeState = compositionLocalOf<HazeState?> { null }
Expand All @@ -32,21 +35,37 @@ val LocalLogseqHazeState = compositionLocalOf<HazeState?> { null }
fun Modifier.logseqLiquidGlass(
shape: RoundedCornerShape,
elevation: Dp = 8.dp,
showOutline: Boolean = true,
): Modifier {
val state = LocalLogseqHazeState.current ?: rememberHazeState()
// 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) {
val colors = MaterialTheme.colorScheme
val dark = LocalLuiThemeDark.current ?: isSystemInDarkTheme()
val tint = when {
Build.VERSION.SDK_INT < 33 -> (if (dark) Color(0xff242424) else colors.surface).copy(alpha = 0.82f)
dark -> Color(0xff3f3f3f).copy(alpha = 0.48f)
else -> Color.Unspecified
}
val style = remember(shape, dark, tint) {
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)
if (dark) {
// Regular follows the system appearance. Use its dark optics
// when Logseq's own appearance setting selects dark mode.
specularIntensity(0.38f)
edgeShadow(Color.Black.copy(alpha = 0.32f))
ambientResponse(0.08f)
contrast(0.08f)
whitePoint(-0.22f)
chromaMultiplier(1.1f)
}
if (tint != Color.Unspecified) tint(tint)
}
}
val outline = if (showOutline && dark) {
Modifier.border(1.dp, colors.onSurface.copy(alpha = 0.12f), shape)
} else Modifier
return this
.shadow(
elevation = elevation,
Expand All @@ -55,6 +74,7 @@ fun Modifier.logseqLiquidGlass(
ambientColor = Color.Black.copy(alpha = 0.16f),
spotColor = Color.Black.copy(alpha = 0.20f),
)
.then(outline)
.hazeGlass(
input = HazeInput.Backdrop(state),
style = style,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,9 @@ fun logseqExtensionRegistry(
.clip(CircleShape)
.background(selection)
if (dragPosition != null) {
indicatorModifier = indicatorModifier.logseqLiquidGlass(CircleShape, elevation = 0.dp)
indicatorModifier = indicatorModifier.logseqLiquidGlass(
CircleShape, elevation = 0.dp, showOutline = false,
)
}
Box(indicatorModifier)
}
Expand Down
4 changes: 3 additions & 1 deletion shared/src/logseq/core/graph_read.ml
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ let built_in_class db eid =
| Some (Ds.Keyword ident) -> S.starts_with ~prefix:"logseq.class/" ident
| _ -> false

let recent_page_limit = 15

let sidebar_pages decrypt_title db =
let favorites =
match favorite_page_eid db with
Expand Down Expand Up @@ -615,7 +617,7 @@ let sidebar_pages decrypt_title db =
| Seq.Nil -> Seq.Nil
| Seq.Cons (x, rest) -> Seq.Cons (x, take (n - 1) rest)
in
{ favorites; recent_pages = List.of_seq (take 15 recent_seq) }
{ favorites; recent_pages = List.of_seq (take recent_page_limit recent_seq) }

let page_block decrypt_title db eid =
match page_summary decrypt_title db eid with
Expand Down
2 changes: 2 additions & 0 deletions shared/src/logseq/core/graph_read.mli
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ type sidebar_pages =
; recent_pages : Cache_model.entity_summary list
}

val recent_page_limit : int

val value : Datascript.db -> int -> string -> Datascript.value option
val latest_code_language : Datascript.db -> string option
val display_type_for_eid : Datascript.db -> int -> string option
Expand Down
28 changes: 17 additions & 11 deletions shared/src/logseq/core/mobile_session.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ let discard_value result =
| Ok _ -> Ok ()
| Error message -> Error message

let load_page_uuids prefix catalog graph_id =
match Sqlite.restore_string catalog (prefix ^ graph_id) with
| None -> []
| Some body ->
(try match Yojson.Basic.from_string body with
| `List values -> List.filter_map (function `String uuid -> Some uuid | _ -> None) values
| _ -> []
with Yojson.Json_error _ -> [])

let save_page_uuids prefix catalog graph_id uuids =
Sqlite.store_string catalog (prefix ^ graph_id)
(Yojson.Basic.to_string (`List (List.map (fun uuid -> `String uuid) uuids)))

let host_options ?journal_tasks ?show_journal_tasks (database : Database.mobile_database) ring catalog =
let graph = database.graph in
let visible_agenda () =
Expand All @@ -40,17 +53,10 @@ let host_options ?journal_tasks ?show_journal_tasks (database : Database.mobile_
Some
(fun () -> Sqlite.restore_string catalog graph_catalog_address)
| None -> None);
load_collapsed_nodes = Option.map (fun catalog graph_id ->
match Sqlite.restore_string catalog ("logseq/collapsed-nodes/v1/" ^ graph_id) with
| None -> []
| Some body ->
(try match Yojson.Basic.from_string body with
| `List values -> List.filter_map (function `String uuid -> Some uuid | _ -> None) values
| _ -> []
with Yojson.Json_error _ -> [])) catalog;
save_collapsed_nodes = Option.map (fun catalog graph_id uuids ->
Sqlite.store_string catalog ("logseq/collapsed-nodes/v1/" ^ graph_id)
(Yojson.Basic.to_string (`List (List.map (fun uuid -> `String uuid) uuids)))) catalog;
load_collapsed_nodes = Option.map (load_page_uuids "logseq/collapsed-nodes/v1/") catalog;
save_collapsed_nodes = Option.map (save_page_uuids "logseq/collapsed-nodes/v1/") catalog;
load_recent_pages = Option.map (load_page_uuids "logseq/recent-pages/v1/") catalog;
save_recent_pages = Option.map (save_page_uuids "logseq/recent-pages/v1/") catalog;
save_graph_catalog =
(match catalog with
| Some catalog ->
Expand Down
11 changes: 4 additions & 7 deletions shared/src/logseq/core/rpc_session.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1501,12 +1501,7 @@ let set_journal_title_format session fields =
| Error message -> Rpc.failure "date_format_failed" message

let select_page session payload =
match
( payload
, match (host session).Types.graph_sidebar_pages with
| Some load -> load ()
| None -> None )
with
match payload, So.load_sidebar_pages session with
| Some uuid, Some pages ->
(match
List.find_opt
Expand All @@ -1515,8 +1510,9 @@ let select_page session payload =
with
| Some page ->
clear_node_navigation session;
let _, zoom = So.sidebar_node_destination session page in
let destination, zoom = So.sidebar_node_destination session page in
set_sidebar_page session page ~zoom;
So.record_page_visit ~sidebar:pages session destination.uuid;
snapshot_visible session
| None ->
Rpc.failure "unknown_page" "The selected page is not available")
Expand Down Expand Up @@ -1554,6 +1550,7 @@ let open_node_with_route ~replace session fields =
let open_route () =
if replace then clear_node_navigation session;
push_node_route session route;
So.record_page_visit session page.uuid;
snapshot_visible session in
if replace then after_finishing_outliner_edit session open_route
else open_route ()
Expand Down
Loading
Loading