Android: Extend app state listener interface with native plugin state

Instead of using the generic onAppStateDetailsChanged function, use a
specific callback for native plugin readiness state in cases where only
native plugin readiness matters.

Add default empty implementations for both functions in the interface.

Task-number: QTBUG-118874
Change-Id: Ie736b0e7789400421247648cb3a008712fd959c5
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
bb10
Petri Virkkunen 2024-02-26 13:07:33 +02:00
parent ed3ce4ebfa
commit e46adeb599
3 changed files with 21 additions and 6 deletions

View File

@ -89,11 +89,17 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase
public void onAppStateDetailsChanged(QtNative.ApplicationStateDetails details) {
synchronized (this) {
m_stateDetails = details;
if (m_stateDetails.nativePluginIntegrationReady) {
}
}
@Override
public void onNativePluginIntegrationReadyChanged(boolean ready)
{
synchronized (this) {
if (ready) {
QtNative.runAction(() -> {
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
QtDisplayManager.setApplicationDisplayMetrics(m_activity,
metrics.widthPixels,
QtDisplayManager.setApplicationDisplayMetrics(m_activity, metrics.widthPixels,
metrics.heightPixels);
});

View File

@ -196,7 +196,8 @@ class QtNative
}
interface AppStateDetailsListener {
void onAppStateDetailsChanged(ApplicationStateDetails details);
default void onAppStateDetailsChanged(ApplicationStateDetails details) {}
default void onNativePluginIntegrationReadyChanged(boolean ready) {}
}
// Keep in sync with src/corelib/global/qnamespace.h
@ -228,6 +229,7 @@ class QtNative
public static void notifyNativePluginIntegrationReady(boolean ready)
{
m_stateDetails.nativePluginIntegrationReady = ready;
notifyNativePluginIntegrationReadyChanged(ready);
notifyAppStateDetailsChanged(m_stateDetails);
}
@ -258,6 +260,13 @@ class QtNative
}
}
static void notifyNativePluginIntegrationReadyChanged(boolean ready) {
synchronized (m_appStateListenersLock) {
for (final AppStateDetailsListener listener : m_appStateListeners)
listener.onNativePluginIntegrationReadyChanged(ready);
}
}
static void notifyAppStateDetailsChanged(ApplicationStateDetails details) {
synchronized (m_appStateListenersLock) {
for (AppStateDetailsListener listener : m_appStateListeners)

View File

@ -38,10 +38,10 @@ class QtServiceEmbeddedDelegate implements QtEmbeddedViewInterface, QtNative.App
}
@Override
public void onAppStateDetailsChanged(QtNative.ApplicationStateDetails details)
public void onNativePluginIntegrationReadyChanged(boolean ready)
{
synchronized (this) {
if (details.nativePluginIntegrationReady) {
if (ready) {
QtNative.runAction(() -> {
if (m_view == null)
return;