v0.9.0: the Qt front end as an Android APK, images in the transcript
Two strands land together: the window draws pictures now, and the whole front end builds, installs and runs on the phone with the engine linked in-process. Images (the "make a picture actually show up" part) - Engine, additively: cst_agent_hooks_t.on_tool_images(call, list, n, ud) fires when a call left attachments behind, and cst_agent_pending_rel() / cst_agent_pending_is_image() read that list without the app touching the store. tests/test_attach.c::test_agent_pending pins the three cases (an image, a stored name that passes cst_attach_rel_ok, out-of-range NULL). - App: image://cstattach/<stored name> (app/src/ui/SessionImages.cpp) serves only the current session's attachment directory, checked with cst_attach_rel_ok, decodes down to the requested sourceSize and never upscales, and holds a mutex because requestImage() runs on the render thread while the directory can change underneath it. AgentCore gained attachmentDir(), pendingImages(), the toolImages()/promptImages() signals and hookToolImages(); history() gives replayed rows their images too. - QML: ImageStrip.qml (a thumb strip, <=150 px tall, shaped by the picture, tooltip with name/size/origin, the file's name when it went missing), wired into MessageCard and ToolCard. Qt 6's ListModel cannot hold a list-valued role (append() reads back undefined, setProperty drops it), so a row carries one image per line as <stored>|<name>|<origin>|<w>x<h> and ImageStrip decodes that. Android (the engine is already in the APK; this is the front end) - app/src/main.cpp: on Android the workspace, config, tmp and HOME go under the app's own data directory before the engine opens anything, because QDir::currentPath() is "/" there and /tmp is not writable. - app/android/: the manifest (QtApplication/QtActivity, INTERNET and POST_NOTIFICATIONS, adjustResize, no storage permission -- the picker will be the system one), strings, a vector icon; minSdk 24 and targetSdk 35 come from app/CMakeLists.txt through QT_ANDROID_MIN/TARGET_SDK_VERSION. - app/src/platform/android/AndroidTools.cpp: the Android file behind PlatformInit(), owner "app:android" (notification, clipboard, share sheet, file picker are stubs for now, so the tool list does not lie about them). - app/tools/selftest.c decides its scratch workspace with os_temp_dir(), so the C smoke test runs on the device too. - scripts/build_apk_android.sh: sources to installed APK in one command (environment checks, qt-cmake configure, --target apk, adb install), and the host-side plumbing the NixOS + qt.io combination needs -- the NDK sysroot include dirs for Qt's FindGLESv2/FindEGL (they only look under <sysroot>/include), -L$PREFIX/lib on the shared/module link lines as well as the executables', the Android debug keystore created on first use with QT_ANDROID_SIGN_APK + QT_ANDROID_KEYSTORE_* (androiddeployqt copies the unsigned gradle output and signs it itself), and the #!/bin/bash shebang of the build-tools wrappers, which NixOS does not have. - scripts/gradle-android-init.gradle (installed into ~/.gradle/init.d/): the release lint task is switched off -- lintVitalAnalyzeRelease resolves its own tool jars straight from dl.google.com, bypassing every repository the build configures, and fails the build after all the real work is done. - Icons: app/icons/*.svg (Breeze's 24@3x files, the 19 names the window asks for) are compiled in as :/cst-icons and ThemeIcons.cpp falls back to them when the platform has no icon theme. On the phone the Qt theme lookup found nothing and the QML glyph fallback was an empty box in the phone's fonts. - docs/android.md: "The APK (Qt front end)" -- the SDK assembled without sdkmanager, the host Qt's missing libraries on NixOS, the Gradle mirrors, lint, signing -- and a Status that says what runs where. app/README.md gains the images and APK lines, and stops claiming Android platform tools that are still stubs. Verified: engine `make check` green; desktop `cst-app-selftest: OK` and --uitest all checks pass; phone (NX789J, Android 16, arm64-v8a) -- the APK installs, starts on the workspace under /data/user/0/xyz.whcself.cstagent/ files/, a turn reaches a configured provider over HTTPS from inside the ART process and renders the reply, rotation keeps the session and docks the sidebar, and the toolbar/card icons draw. Version 0.9.0. mode = coding
This commit is contained in:
+78
-2
@@ -76,13 +76,23 @@ if(CST_APP_GUI)
|
||||
# main.cpp loads) and let CMake generate the qmldir of qml/ for us.
|
||||
qt_policy(SET QTP0001 NEW)
|
||||
qt_policy(SET QTP0004 NEW)
|
||||
# The front end's platform tools: one file per platform, the same split
|
||||
# core/ToolProvider.cpp makes. Android brings its own (JNI, owner
|
||||
# "app:android"); the other platforms still use the Linux file, whose
|
||||
# registration entry point is simply not called there.
|
||||
if(ANDROID)
|
||||
set(CST_APP_PLATFORM_SRC src/platform/android/AndroidTools.cpp)
|
||||
else()
|
||||
set(CST_APP_PLATFORM_SRC src/platform/linux/NotifyTool.cpp)
|
||||
endif()
|
||||
qt_add_executable(cst-agent-app
|
||||
src/main.cpp
|
||||
src/core/AgentCore.cpp
|
||||
src/core/ToolProvider.cpp
|
||||
src/ui/UiTest.cpp
|
||||
src/ui/ThemeIcons.cpp
|
||||
src/platform/linux/NotifyTool.cpp)
|
||||
src/ui/SessionImages.cpp
|
||||
${CST_APP_PLATFORM_SRC})
|
||||
target_include_directories(cst-agent-app PRIVATE
|
||||
src "${CMAKE_CURRENT_SOURCE_DIR}/../include")
|
||||
target_compile_definitions(cst-agent-app PRIVATE CST_APP_VERSION="${PROJECT_VERSION}")
|
||||
@@ -96,6 +106,52 @@ if(CST_APP_GUI)
|
||||
set_target_properties(cst-agent-app PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||
endif()
|
||||
|
||||
# --- Android (APK) -----------------------------------------------------
|
||||
# The engine is compiled in (top-level CMakeLists: -DCST_BUILD_TUI=OFF,
|
||||
# -DCST_BUILD_WEBUI=OFF, so src/webui_stub.c stands in for the server and
|
||||
# nothing listens on a port). The manifest, icons and strings live in
|
||||
# app/android/, which androiddeployqt copies next to its own gradle
|
||||
# project. minSdk 24 is the engine's own API_LEVEL (scripts/
|
||||
# build_third_party_android.sh builds curl/mbedTLS for android-24).
|
||||
if(ANDROID)
|
||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/../include/cst_version.h"
|
||||
_cst_ver_lines REGEX "#define CST_VERSION_(MAJOR|MINOR|PATCH) ")
|
||||
foreach(_line ${_cst_ver_lines})
|
||||
if(_line MATCHES "CST_VERSION_MAJOR ([0-9]+)")
|
||||
set(_cst_vmaj "${CMAKE_MATCH_1}")
|
||||
elseif(_line MATCHES "CST_VERSION_MINOR ([0-9]+)")
|
||||
set(_cst_vmin "${CMAKE_MATCH_1}")
|
||||
elseif(_line MATCHES "CST_VERSION_PATCH ([0-9]+)")
|
||||
set(_cst_vpat "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endforeach()
|
||||
set_target_properties(cst-agent-app PROPERTIES
|
||||
QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android"
|
||||
QT_ANDROID_MIN_SDK_VERSION 24
|
||||
QT_ANDROID_TARGET_SDK_VERSION 35
|
||||
QT_ANDROID_VERSION_NAME "${_cst_vmaj}.${_cst_vmin}.${_cst_vpat}"
|
||||
QT_ANDROID_VERSION_CODE 1
|
||||
QT_ANDROID_ABIS "${ANDROID_ABI}")
|
||||
message(STATUS "app: Android package "
|
||||
"${_cst_vmaj}.${_cst_vmin}.${_cst_vpat}, ABI ${ANDROID_ABI}, "
|
||||
"minSdk 24, targetSdk 35")
|
||||
|
||||
# Signing: androiddeployqt signs the APK itself and refuses a signed
|
||||
# gradle output ("Could not copy unsigned APK"), so the keystore goes
|
||||
# here, not into gradle. The path, alias and passwords arrive through
|
||||
# the QT_ANDROID_KEYSTORE_* environment variables;
|
||||
# scripts/build_apk_android.sh points them at the standard Android debug
|
||||
# key it creates on first use, and CST_ANDROID_KEYSTORE overrides it.
|
||||
if(DEFINED ENV{QT_ANDROID_KEYSTORE_PATH} AND NOT "$ENV{QT_ANDROID_KEYSTORE_PATH}" STREQUAL "")
|
||||
set(QT_ANDROID_SIGN_APK TRUE)
|
||||
message(STATUS "app: signing the APK with "
|
||||
"$ENV{QT_ANDROID_KEYSTORE_PATH} ($ENV{QT_ANDROID_KEYSTORE_ALIAS})")
|
||||
else()
|
||||
message(STATUS "app: QT_ANDROID_KEYSTORE_PATH unset -- the APK stays "
|
||||
"unsigned and 'adb install' will refuse it (INSTALL_PARSE_FAILED_NO_CERTIFICATES)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Theme is read by every component, so it is a QML singleton (one instance,
|
||||
# no object needed in the tree).
|
||||
set_source_files_properties(qml/Theme.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
|
||||
@@ -105,7 +161,7 @@ if(CST_APP_GUI)
|
||||
# requires absolute URLs" on every start).
|
||||
foreach(_qml Main ChatView Sidebar SessionRow MessageCard ToolCard ThinkBlock
|
||||
NoteLine TodoPanel Composer ConsentDialog AskDialog SettingsDialog
|
||||
ThemeIcon Theme)
|
||||
ThemeIcon Theme ImageStrip)
|
||||
set_source_files_properties(qml/${_qml}.qml PROPERTIES QT_RESOURCE_ALIAS ${_qml}.qml)
|
||||
endforeach()
|
||||
qt_add_qml_module(cst-agent-app
|
||||
@@ -126,6 +182,26 @@ if(CST_APP_GUI)
|
||||
qml/AskDialog.qml
|
||||
qml/SettingsDialog.qml
|
||||
qml/ThemeIcon.qml
|
||||
qml/ImageStrip.qml
|
||||
qml/Theme.qml)
|
||||
|
||||
# The icons the window asks for, compiled in (app/icons, Breeze's scalable
|
||||
# names copied at 24@3x). The desktop finds them in the platform's icon
|
||||
# theme and only falls back to these (ThemeIcons.cpp); a machine without
|
||||
# any theme -- Android -- has nothing else, and before this the QML glyph
|
||||
# fallback was all that showed, which the phone's fonts cannot render.
|
||||
set(CST_APP_ICONS
|
||||
go-down mail-attachment application-menu settings-configure edit-copy
|
||||
edit-delete arrow-down arrow-right list-add task-complete box
|
||||
document-edit text-x-generic folder-open edit-find code-context
|
||||
internet-services format-list-unordered help-hint)
|
||||
set(_cst_icon_files "")
|
||||
foreach(_icon ${CST_APP_ICONS})
|
||||
list(APPEND _cst_icon_files "${CMAKE_CURRENT_SOURCE_DIR}/icons/${_icon}.svg")
|
||||
endforeach()
|
||||
qt_add_resources(cst-agent-app "cst_icons"
|
||||
PREFIX "/cst-icons"
|
||||
BASE "${CMAKE_CURRENT_SOURCE_DIR}/icons"
|
||||
FILES ${_cst_icon_files})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user