Qt: faster app icons on start
Three things still held icons up: - The app list was built on Qt's thread, so nothing on screen could paint (icons included) until every app was listed and labelled. HomeActivity now lists apps on its own thread and answers through Native.appList. - Each icon was drawn, PNG-encoded in Java and decoded again in C++. Icons now cross as raw premultiplied RGBA, and drawn ones are kept in the cache dir, keyed by the app's last update, so a fresh start just reads them. - The closed drawer made its icons at the same time as home. It now waits 1.5s, or until it opens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hiQsCq11CwCPnKPp9D
This commit is contained in:
7 files changed
+115
-16
No files matched your search
@@ -67,6 +67,13 @@ void jLegacyHome(JNIEnv *env, jclass, jstring json) {
|
||||
post([=] { emit g_backend->legacyHome(s); });
|
||||
}
|
||||
|
||||
void jAppList(JNIEnv *env, jclass, jstring json) {
|
||||
const char *c = env->GetStringUTFChars(json, nullptr);
|
||||
const QByteArray s(c);
|
||||
env->ReleaseStringUTFChars(json, c);
|
||||
post([=] { g_backend->takeAppList(s); });
|
||||
}
|
||||
|
||||
void registerNatives() {
|
||||
static bool done = false;
|
||||
if (done) return;
|
||||
@@ -81,6 +88,7 @@ void registerNatives() {
|
||||
{"widgetGrab", "(I)V", reinterpret_cast<void *>(jWidgetGrab)},
|
||||
{"widgetDrag", "(II)V", reinterpret_cast<void *>(jWidgetDrag)},
|
||||
{"widgetDrop", "(Z)V", reinterpret_cast<void *>(jWidgetDrop)},
|
||||
{"appList", "(Ljava/lang/String;)V", reinterpret_cast<void *>(jAppList)},
|
||||
{"legacyHome", "(Ljava/lang/String;)V", reinterpret_cast<void *>(jLegacyHome)},
|
||||
};
|
||||
QJniEnvironment env;
|
||||
@@ -149,6 +157,21 @@ QVariantList Backend::apps() const {
|
||||
return out;
|
||||
}
|
||||
|
||||
// apps(), without holding up the UI thread meanwhile: the list arrives as appsLoaded.
|
||||
void Backend::requestApps() {
|
||||
#ifdef Q_OS_ANDROID
|
||||
callVoid("listApps");
|
||||
#else
|
||||
QTimer::singleShot(0, this, [this] { takeAppList(demo(QStringLiteral("apps.json")).toJson(QJsonDocument::Compact)); });
|
||||
#endif
|
||||
}
|
||||
|
||||
void Backend::takeAppList(const QByteArray &json) {
|
||||
const QVariantList out = appList(QJsonDocument::fromJson(json));
|
||||
if (!out.isEmpty()) QSettings().setValue(QStringLiteral("apps"), QString::fromUtf8(json));
|
||||
emit appsLoaded(out);
|
||||
}
|
||||
|
||||
QVariantList Backend::savedApps() const {
|
||||
return appList(QJsonDocument::fromJson(QSettings().value(QStringLiteral("apps")).toString().toUtf8()));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user