diff options
author | Petri Virkkunen <petri.virkkunen@qt.io> | 2024-02-15 09:48:56 +0200 |
---|---|---|
committer | Petri Virkkunen <petri.virkkunen@qt.io> | 2024-04-30 22:17:04 +0300 |
commit | f1fa33aeb3757d67785550953d3ae0c25a512cb7 (patch) | |
tree | 54c082e3eabe984516d6e170d54e34b9314eb262 /src/android/jar/src | |
parent | 9ef4435fbf68d2f628047ad75ef7104cf498682b (diff) |
Android: Add interface to handle interactions between delegate and QtView
Classes implementing QtEmbeddedViewConnector should support embedded
usecases for both Service and regular Activity embedding.
Any features that QtView requires from a delegate should be accessible
via this interface.
Task-number: QTBUG-118874
Change-Id: I238c6ef0451b1d08514c65f57e2875d31c5f4da9
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Diffstat (limited to 'src/android/jar/src')
3 files changed, 37 insertions, 9 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java index 5545b0a09d..898596e460 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java @@ -21,7 +21,9 @@ import android.view.ViewGroup; import java.util.ArrayList; import java.util.HashMap; -class QtEmbeddedDelegate extends QtActivityDelegateBase implements QtNative.AppStateDetailsListener { +class QtEmbeddedDelegate extends QtActivityDelegateBase + implements QtNative.AppStateDetailsListener, QtEmbeddedViewInterface +{ // TODO simplistic implementation with one QtView, expand to support multiple views QTBUG-117649 private QtView m_view; private QtNative.ApplicationStateDetails m_stateDetails; @@ -126,6 +128,14 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase implements QtNative.AppS return m_view.getQtWindow(); } + // QtEmbeddedViewInterface implementation begin + @Override + public void startQtApplication(String appParams, String mainLib) + { + super.startNativeApplication(appParams, mainLib); + } + + @Override public void queueLoadWindow() { synchronized (this) { @@ -134,12 +144,15 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase implements QtNative.AppS } } - void setView(QtView view) { + @Override + public void setView(QtView view) + { m_view = view; updateInputDelegate(); if (m_view != null) registerGlobalFocusChangeListener(m_view); } + // QtEmbeddedViewInterface implementation end private void updateInputDelegate() { if (m_view == null) { diff --git a/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedViewInterface.java b/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedViewInterface.java new file mode 100644 index 0000000000..a83a65e32c --- /dev/null +++ b/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedViewInterface.java @@ -0,0 +1,15 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +package org.qtproject.qt.android; + +/** + * QtEmbeddedViewInterface is intended to encapsulate the needs of QtView, so that the Activity and + * Service implementations of these functions may be split clearly, and the interface can be stored + * and used conveniently in QtView. +**/ +interface QtEmbeddedViewInterface { + void startQtApplication(String appParams, String mainLib); + void setView(QtView view); + void queueLoadWindow(); +}; diff --git a/src/android/jar/src/org/qtproject/qt/android/QtView.java b/src/android/jar/src/org/qtproject/qt/android/QtView.java index b253548a5c..ddf70b3b5b 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtView.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtView.java @@ -31,7 +31,7 @@ abstract class QtView extends ViewGroup { protected long m_windowReference; protected long m_parentWindowReference; protected QtWindowListener m_windowListener; - protected QtEmbeddedDelegate m_delegate; + protected QtEmbeddedViewInterface m_viewInterface; // Implement in subclass to handle the creation of the QWindow and its parent container. // TODO could we take care of the parent window creation and parenting outside of the // window creation method to simplify things if user would extend this? Preferably without @@ -60,7 +60,7 @@ abstract class QtView extends ViewGroup { } QtEmbeddedLoader loader = new QtEmbeddedLoader(context); - m_delegate = QtEmbeddedDelegateFactory.create((Activity)context); + m_viewInterface = QtEmbeddedDelegateFactory.create((Activity)context); loader.setMainLibraryName(appLibName); addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override @@ -80,22 +80,22 @@ abstract class QtView extends ViewGroup { }); loader.loadQtLibraries(); // Start Native Qt application - m_delegate.startNativeApplication(loader.getApplicationParameters(), - loader.getMainLibraryPath()); + m_viewInterface.startQtApplication(loader.getApplicationParameters(), + loader.getMainLibraryPath()); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - m_delegate.setView(this); - m_delegate.queueLoadWindow(); + m_viewInterface.setView(this); + m_viewInterface.queueLoadWindow(); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); destroyWindow(); - m_delegate.setView(null); + m_viewInterface.setView(null); } @Override |