summaryrefslogtreecommitdiffstats
path: root/src/android/jar
Commit message (Collapse)AuthorAgeFilesLines
* Android: Notify listener about app state changes when quittingPetri Virkkunen10 days1-1/+1
| | | | | | | | | | Specifically the isStarted flag is set to false in QtNative.quitApp. This should be listened to by functionality interface providers to unregister their interfaces, in case the Activity is restarted. Task-number: QTBUG-118874 Change-Id: Iadf5ab548c4e865c89ed4b83d258f09d6c767e16 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Extend app state listener interface with native plugin statePetri Virkkunen10 days3-6/+21
| | | | | | | | | | | | 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>
* Android: Add delegate class for embedding QML into Android ServicesPetri Virkkunen10 days2-0/+116
| | | | | | | | | | QtServiceEmbeddedDelegate implements QtEmbeddedViewInterface to allow QtView communication, listens to Qt plugin load state and loads embedded views. Task-number: QTBUG-118874 Change-Id: I673eefd8da425c96af436b2286899f699752d60a Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: Add interface to handle interactions between delegate and QtViewPetri Virkkunen10 days4-9/+38
| | | | | | | | | | | | 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>
* Android: Delete parent window in QtView instead of just the child viewPetri Virkkunen10 days2-21/+9
| | | | | | | | | | | | | | Since the parent window wraps the QtView, it should always be destroyed when the QtView is, and live inside QtView rather than the delegate. Destroying the parent window will always destroy the child window, so do not destroy the child window separately. Move createRootWindow and deleteWindow native functions to QtView. Fixes: QTBUG-124908 Change-Id: Ib6b3c6388a9dd3f74d16fa09a442b0a6f8ccb336 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Do not call exit when embedded Qt application is stoppedPetri Virkkunen10 days1-0/+1
| | | | | | | | | | | Q4A apps call exit() when leaving main(), unless the flag QT_ANDROID_NO_EXIT_CALL is set. For embedded applications this is incorrect behavior, because calling exit() will also make the host application shut down. Task-number: QTBUG-123711 Change-Id: I693f65d22568ab7d2a094a3c2336bf392cee214f Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: remove duplicated code for handling UI mode changesVolker Hilsheimer2024-04-261-27/+0
| | | | | | | | | The QtActivityDelegate::handleUiModeChange(int) handler implementation is identical to the one in QtActivityDelegateBase, so no need to override. Change-Id: I9753bc6fa22554c99bd127bdfa85d10007eb551c Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Propagate a11y ObjectShow events to screen readerJens Trillmann2024-04-252-0/+17
| | | | | | | | | | | | Sending an ObjectShow event, e.g. by setting QQuickItem::visible to true, has to trigger a refresh of the screen reader hierarchy. If the signal is ignored the source of the signal will be ignored by the screen reader. Fixes: QTBUG-122436 Pick-to: 6.5 6.7 Change-Id: I32ee2e8b2602cd0dd9b9a83ff1fe426d88d137a8 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Detect mouse buttonsAxel Spoerl2024-04-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | The mouseDown() and mouseUp() methods in androidjniinput.cpp hardcoded Qt::LeftButton to all mouse-press / release events. If a mouse is connected to an android device, all three buttons are mapped to the left button. Extend both mehtods' signature by a mouse button state. Add a converter method to map from Android button states to Qt::MouseButtons. Add a sendMouseButtonEvents method, that iterates through all buttons pressed/released and sends the respective events to QWSI. Adapt the mouse handler in java, to obtain and pass the button state to C++. The patch can't be verified in an autotest. Testlib's mouse emulation injects into QWSI. Fixes: QTBUG-99106 Pick-to: 6.7 6.6 6.5 6.2 Change-Id: I933f490901928db9761d2ef254ae1e5b4f473f28 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Fix crash when selecting text on a TextFieldAhmed El Khazari2024-04-182-5/+16
| | | | | | | | | | | | | The crash is due to absence of the helper class that manages the selection in QtInputDelegate. As a fix, updateInputDelegate() is introduced when setView(), where the instantiation and clearance of EditPopupMenu is made. On the other hand, the nullity of EditPopupMenu in QTEmbeddedDelegate is handled. Fixes: QTBUG-122740 Pick-to: 6.7 Change-Id: Iac5cded7be7530dde8c739265fc9402670714d39 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: fix 180 degree orientation issueLauri Pohjanheimo2024-04-123-28/+33
| | | | | | | | | | | | | | | | On android documentation orientation changes are sent via onConfigurationChanged callback. Previous implementation based orientation detection to onSizeChanged callback. That callback is not called when orientation turns 180 degrees. i.e. between landscape and inverted landscape. This fix adds detection to on onConfigurationChanged to catch those cases. Fixes: QTBUG-118887 Fixes: QTBUG-118236 Pick-to: 6.7 6.5 Change-Id: Ie2f81798de97e460de839f7ebfde9a9efa25909f Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: runAction can now be run past queueLauri Pohjanheimo2024-04-092-8/+18
| | | | | | | | | | | | On vulkan implementation it was possible that when going background destroySurface was queued and then run when coming back foreground that caused vulkan not being able to draw. Fixes: QTBUG-118985 Fixes: QTBUG-118840 Pick-to: 6.7 Change-Id: I5957b74b89384ea84fc09d9b55afcccf5c82e390 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android/QtView: Set also x and y of the wrapped foreign QWindowTinja Paavoseppä2024-04-042-5/+8
| | | | | | | | | | Previously, we have set the size of the QWindow to match the QtView. Also set its x and y coordinate to match, just to keep the window and the view in sync. Pick-to: 6.7 Change-Id: I0ea89a11e4526a0a996e7b62ac126808358b6bc7 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android/Embedding QML: Resize also parent windowTinja Paavoseppä2024-04-041-2/+2
| | | | | | | | | | | | | | | | The parent window created from the QtView had an empty size. Also set its size when creating the window, and when resizing the QtView. Replace parent window show() call with showNormal() to avoid switching it to a fullscreen window. As a drive-by, use setGeometry() instead of setting the width and height separately to trigger only one geometry update for the platform window. Pick-to: 6.7 Change-Id: I91e350c1748a9e76879faa8bfcab7575f6155f02 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Make QtView extend ViewGroup instead of QtLayoutTinja Paavoseppä2024-04-042-5/+46
| | | | | | | | | | | | QtView should only have one child, the QtWindow, and that should always match the QtView's size, so the handling for absolute layout is unnecessary. Task-number: QTBUG-121516 Task-number: QTBUG-123306 Pick-to: 6.7 Change-Id: I77024ab9619e68ab98357518ad07535a2ff9614c Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Make QtLayout support MATCH_PARENT layout paramsTinja Paavoseppä2024-04-041-5/+5
| | | | | | | | | | | | | QtLayout did not properly handle resizing child views to the parent's size when their layout params width or height were MATCH_PARENT. This was mostly visible when embedding QML to a normal Android app, as there the Android view hierarchy is responsible for setting the size, instead of Qt setting it every time the QWindow size changes. Task-number: QTBUG-123306 Pick-to: 6.7 Change-Id: I08cbfa8e352d0cb2ca5b6e5aa40e891a62b82eb4 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Choose correct icon for QMessageBoxBartlomiej Moskal2024-04-031-10/+0
| | | | | | | | | | | | | | | | | | | | QMessageBox contains an icon that can be set using icon type. Before this commit, android.R.attr.alertDialogIcon was used regardless of the expected icon type. Only if setting failed, the icon from android.R.drawable was set (depending on the expected icon type). Previously, usage of android.R.attr.alertDialogIcon was the way to consider Theme in choosing icon view. Since 31a0d99fa565d39bf39f0c3ae5ed00859679a969 commit, getDrawable(id, theme) is used with second parameter: Resources.Theme. Because of that we can start to use only icons from android.R.drawable and remove usage of android.R.attr.alertDialogIcon Fixes: QTBUG-123334 Pick-to: 6.7 6.6 6.5 Change-Id: I6cfdaf30aea5d132e38ba5d78054089b51cf5f13 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Resize QWindow when its QtView is resizedTinja Paavoseppä2024-03-131-0/+15
| | | | | | | | | | If the Android View is resized, the QWindow instantiated by it should be resized accordingly. Task-number: QTBUG-122626 Pick-to: 6.7 Change-Id: I7bfbca149f927718d1e28cdabfa8759afbd06039 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Synchronize window creation in QtEmbeddedDelegateTinja Paavoseppä2024-03-131-12/+23
| | | | | | | | | | | | | | Qt window loading is initiated either when the QtView is attached to its Android window, or when the Android QPA plugin has been loaded and is ready, depending on the order. Since the window attachment happens in the Android UI thread, and the Android QPA plugin callback happens in Qt thread, add synchronized block to make sure the execution stays ordered. Fixes: QTBUG-122626 Pick-to: 6.7 Change-Id: Id476032f02aa8990432a02f62b6bf6237a17e7ac Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: don't add lib prefix to loaded libs unconditionallyAssam Boudjelthia2024-03-131-3/+6
| | | | | | | | | | | | | Some libs don't necessarily have the lib prefix in their names, 3rd party libs and Qt for Python might have that, so no need to always add that prefix to loaded libs is the lib name already contains a .so suffix. Fixes: QTBUG-123286 Pick-to: 6.7 6.7.0 Change-Id: Ib65215d9b4410c5c9e00aa0642f48ab45c92fe03 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: Do Thread.sleep before loading Qt libraries in Debug ModeCristian Adam2024-03-092-4/+8
| | | | | | | | | | | | | | Amends 269187bfa272f9456aad6a6233100d846915f175 which added the sleep but just loading the main library. This commit moves the delay before any library is being loaded. Also log the fact the thread is sleeping and advertise how to use the env QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS variable. Fixes: QTCREATORBUG-30425 Pick-to: 6.7 6.7.0 Change-Id: Ic1370e0b9fcce8c6074f768e5d94e5aa4a0a7824 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Add Thread.sleep before loading main in Debug modeCristian Adam2024-03-073-0/+22
| | | | | | | | | | | | | | This helps with the jdb debugging settling, and the native debugger can hit breakpoints at the beginning of main() function or in case of unittests at initTestCase() function. By default in debug mode the delay is 1000ms. This value can be changed with the environment variable: QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS Fixes: QTCREATORBUG-30425 Pick-to: 6.7 6.7.0 Change-Id: Ica0c6080c55468579a28eecf8f45cff68d99c3a8 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Fix inverted equals condition on QtAccessibilityDelegateTinja Paavoseppä2024-03-041-1/+1
| | | | | | | | | | | Got inverted during child window refactoring, leading to broken accessibility. Amends commit 0a92d881bb91d3ff14187e7838af1cad9ad1070c. Task-number: QTBUG-122827 Pick-to: 6.7 Change-Id: Icbde94097eb0b33171f18f8a30c935d0b950c545 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Bring back QtActivityDelegate.insertNativeView()Soheil Armin2024-02-281-0/+41
| | | | | | | | | | | | | Temporarily bring back the QtActivityDelegate.insertNativeView() and QtActivityDelegate.setNativeViewGeometry() (replacement for setSurfaceGeometry()) as they are still in use by the ActivityView module of QtAndroidAutomotive. They have been removed by 0a92d881bb91d3ff14187e7838af1cad9ad1070c. Pick-to: 6.7 Change-Id: Ia00407d827ca9217c9f49df55b4cf7001ac9871a Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: run runAction() actions in onPause stateLauri Pohjanheimo2024-02-261-2/+4
| | | | | | | | | | Fixes QTBUG-113255 by running graphics related actions also onPaused state when the paused app is visible. Also corrects possible other problems where UI should be updated while app is onPaused state. Fixes: QTBUG-113255 Pick-to: 6.7 Change-Id: I02ee6b0713ec5f08ebba676c5edf94d2c1f81958 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Add QtEditText to QtWindow in constructorTinja Paavoseppä2024-02-221-2/+2
| | | | | | | | | | | | | | | Of course, createSurface() is called more than once, for example when coming back from the background, and you cannot add a View to the layout more than once, since this leads to an uncaught exception and a crash. So add the QtEditText once, in the constructor, as is indeed sensible. Fixes: QTBUG-122648 Pick-to: 6.7 Change-Id: I7ef48951cd8a1c99935f5e96c70b6dbf0c745803 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Revert "Android: move referral global field to local variable in QtActivityBase"Julian Greilich2024-02-221-4/+4
| | | | | | | | | | This reverts commit 5b5f4344daa4df023007cd59efdf8f36b00bb150. Reason for revert: Without the key being public, we would have to duplicate this variable in our application code when fetching the stored referrer. Pick-to: 6.7 Change-Id: I46ad3618da9912c41f8248f871c24dd41015af2b Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Move QtDisplayManager dpi calculations to functionsPetri Virkkunen2024-02-221-10/+13
| | | | | | | | | | In order to use the same functionality from outside the class and avoid reimplementation, moving the dpi minimum value check to functions. Pick-to: 6.7 Change-Id: I242b18fafab1b6283a46bda8b59e87adf50e5c0b Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Do not register focus listener for null view in QtEmbeddedDelegatePetri Virkkunen2024-02-221-1/+2
| | | | | | | | A null view can not be focused. Pick-to: 6.7 Change-Id: I0564dd554a304e2e60e3ae83c4782ac348edcd9b Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Change license in files to avoid LGPL and non-LGPL license mixLucie Gérard2024-02-204-4/+4
| | | | | | | | | | | | | | | | | | | | According to QUIP-18 [1], all module files should be LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only or LicenseRef-Qt-Commercial OR GPL-3.0-only LGPD and non-LGPL licenses should not be mixed in a given directory. The files in this patch are the only ones in their directory with non-LGPL license. The license is changed to that of the other module files in the same directory. [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: Id58248a6f60438e01e77e9448f07e3057d173260 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Android: Implement input connection listener in QtInputDelegateTinja Paavoseppä2024-02-193-28/+21
| | | | | | | | | | | This way we can just pass the input delegate as the listener for QtEditText when we create it, and having the listener in a separate member doesn't provide a real benefit anyway. Task-number: QTBUG-118139 Pick-to: 6.7 Change-Id: I0125c87ecd39eed550a120ea8326d2c50a1b016e Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Fix code style issues in QtEditTextTinja Paavoseppä2024-02-191-16/+16
| | | | | | | | | Remove m_ prefix from function arguments. Move constructor to be the first method. Pick-to: 6.7 Change-Id: I8854c3964ccd609666d8bbae631e59bcaee768f3 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Move textfield option handling to QtEditTextPetri Virkkunen2024-02-192-133/+135
| | | | | | | | | | | | Previously QtEditText input method hints, input type and caps mode were parsed and set inside QtInputDelegate. Given these things are only relevant for QtEditText and did not use any QtInputDelegate internals, moved them to QtEditText. Task-number: QTBUG-118139 Pick-to: 6.7 Change-Id: I5162e890679f6e14adf42647572c0fb96ad451b9 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Request QtEditText focus when its window is touchedTinja Paavoseppä2024-02-153-9/+1
| | | | | | | | | | | This allows switching focus between different Qt windows, which combined with the previous changes enables keyboard focus for child windows. Task-number: QTBUG-118139 Pick-to: 6.7 Change-Id: I4b237166dee264a22b2e3dd1ca4d82e0cfce376b Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: QtActivityDelegateBase listens to focus events from child viewsPetri Virkkunen2024-02-154-0/+24
| | | | | | | | | | | | | In order to detect gaining/losing and moving focus between windows, implement GlobalFocusChangeListener for the root View. Add a surfaceFocusChanged native function in QAndroidPlatformWindow in order to follow these focus changes. Task-number: QTBUG-118139 Pick-to: 6.7 Change-Id: Ia9bf6249c28a420f42793a9829aef31b12757630 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Move QtEditText to QtWindowTinja Paavoseppä2024-02-154-30/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Every QtWindow has its own QtEditText. QtInputDelegate uses QtEditText from the QtWindow which has the focus. QtEditText is a View class which handles the creation of the input connection, and encapsulates other various keyboard input related functionalities. Previously we have only had one, which requests focus when the software keyboard is opened. However, with the introduction of child windows, it does not make sense for all the windows to operate through this one instance. Furthermore, since it always needs to have focus to be able to open the software keyboard, this leads to a bit surprising behavior in the focus chain if we want to make each window focusable, not just the top level one. Having each window have its own QtEditText makes sure when a window gets focus, the focus doesn't leave outside of the matching view's own scope, making it easier to handle. This should also make it easier to clean up keyboard input related events tied to a window when that window is removed. Task-number: QTBUG-118139 Pick-to: 6.7 Change-Id: Idd1a9407bc0c48660f2885d3bda28e46d42c08a0 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: QtEditText support for full-screen soft keyboardRami Potinkara2024-02-152-14/+56
| | | | | | | | | | | | Full-screen soft keyboard support added. Including functionality for copy-cut-paste and line change. Future TODO QTBUG-121522 Task-number: QTBUG-109367 Pick-to: 6.7 6.6 6.5 6.2 Change-Id: Ia5632cacc910c7ebde0e40608c2abd027b8f953a Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Remove unused QtLayout.TouchListenerTinja Paavoseppä2024-02-122-38/+1
| | | | | | | | | Now that QtWindow extends QtLayout again, the touch listener interface is unused as QtWindow can directly handle the touch events. Pick-to: 6.7 Change-Id: Ic58b5ab7644ffb3a60833b6507115b20db3f29de Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Change QtWindow Runnables to lambdasTinja Paavoseppä2024-02-121-70/+46
| | | | | | Pick-to: 6.7 Change-Id: I19a3e0a0a035a49965d7643db3ebdb72de95a3a9 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Make QtWindow package privateTinja Paavoseppä2024-02-121-1/+1
| | | | | | Pick-to: 6.7 Change-Id: I0231193c3118619b4d2fc9f4e7f0f85ddd0b41b8 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Move bringChildToFront() call to Android UI threadTinja Paavoseppä2024-02-121-5/+7
| | | | | | | | | Cannot change view hierarchy outside of Android UI thread. Task-number: QTBUG-116187 Pick-to: 6.7 Change-Id: I05d36a28d16480519a6919047272be9f3cf667d0 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Revert "Android: Make QtWindow wrap the QtLayout instead of inherit it"Tinja Paavoseppä2024-02-123-51/+38
| | | | | | | | | | | | | | | | This reverts commit 2bc7d38bd63843c4598ed501e3adbf0e39162c61. The real cause for the problems was the missing runAction() in bringChildToFront(), creating the QtLayout could still be done in Qt thread without problems, just as long as its hierarchy is not changed outside of Android UI thread. Let QtWindow extend QtLayout again - the missing runAction() causing problems is added back in a follow up commit. Task-number: QTBUG-116187 Pick-to: 6.7 Change-Id: Ib4211c40adf573f9f6dd6300b275cff0ce718fba Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: fix style extraction when set to noneAssam Boudjelthia2024-02-061-0/+3
| | | | | | | | | | | If extract_android_style meta data is set to none currently the app still tries to extract full stlye and crashes. If this option is set no style data should be extracted after this patch. Pick-to: 6.7 Fixes: QTBUG-121667 Change-Id: I764e1eb6a582073196f991ca930d245d17a1f7e5 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* Android: Set up style also when using QtEmbeddedLoaderTinja Paavoseppä2024-01-312-4/+8
| | | | | | | | | | | | Embedded loader was missing style set up, leading to a crash when platform theme style data was loaded. As a drive by, change the style set up to use Context instead of Activity, since it doesn't require Activity. Fixes: QTBUG-119532 Pick-to: 6.7 Change-Id: I434233e173cc2c90d981bbf2aa0044117a20b17f Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Add classes to embed QML into native AndroidTinja Paavoseppä2024-01-306-5/+252
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add classes that make it possible to add QML as a View into a native Android app: QtView: Base class for QtQuickView, handles non-Quick dependent operations. In essence a Java ViewGroup class which loads a QWindow and embeds it into itself. QtEmbeddedLoader: Extends QtLoader for embedded case, creates the embedded version of QtActivityDelegate and provides an embedded-specific path to loading Qt libraries (Mostly just allows users to set the name of the main lib) QtAndroidWindowEmbedding namespace: Deals with calls from QtEmbeddedDelegate to create/destroy QWindow and from QtView to show the window. Take the QtEmbeddedDelegate introduced in an earlier commit into use, and add functionality for loading QWindows for QtViews and managing QtViews into it. Add a factory for creating instances of QtEmbeddedDelegate. The factory holds a map of QtEmbeddedDelegate objects and creates them, with the Activity as the key. This is to make it so that the same delegate can be used by multiple views which share the same Context. Known issues left: * keyboard focus not working, as with other child windows Pick-to: 6.7 Task-number: QTBUG-118872 Change-Id: I94a5f9b4f904c05cc6368cf20f273fcf10d31f17 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Create QtWindow layout and set parent in the calling threadTinja Paavoseppä2024-01-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | In the QtWindow constructor, creation of the layout and setting the parent window were posted on the Android UI thread, leading to them being called at a later point. If QAndroidPlatformWindow did not have a parent at the point it was created in, but setParent() was called shortly after, the QtWindow.setParent() call with the actual intended parent got invoked before the Runnable posted in the constructor got ran, leading to the parent being overwritten with the null one passed to the constructor, essentially leaving the QtWindow as a top level one, while the QAndroidPlatformWindow was a child window. The above would happen more often with foreign child windows, sometimes causing hang ups when the parent of the foreign child window was shown. Creating the QtLayout outside of the Android UI thread seems to be safe, as long as we only modify its view hierarchy inside it. Pick-to: 6.7 Task-number: QTBUG-116187 Change-Id: If1ed1983f5d6ba56e625148ee6a61771234a2aa1 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Let QtLoader handle different Contexts when initializingTinja Paavoseppä2024-01-243-68/+61
| | | | | | | | | | | | | | | QtLoader now calls the correct methods when initializing static classes and retrieving ContextInfo based on the type of the Context (Activity or Service). This is done to avoid the need for code duplication when introducing other QtLoader sub classes that deal with the same Context types, such as the loader for the use case where Qt is used from a native Android app. Abstract methods and their implementations in subclasses aimed at handling this removed as a result. Pick-to: 6.7 Change-Id: I6cda8e4733594a6a3963cf0fd8217de2fbd408f8 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Add a context delegate for embedding QML to native AndroidTinja Paavoseppä2024-01-215-142/+448
| | | | | | | | | | | | | | | | | | | | | | | | When we are embedding a QML view to a non-Qt Android app, there are a lot of functionalities that are shared with the refular Qt Android app, but some are not. We should not, for example, try to control the hosting Activity. Create a base class that both the QtActivityDelegate, used for the standard Qt for Android app, and the delegate for the embedding case can extend. In this commit, the QtEmbeddedDelegate is very simple, the biggest difference to QtActivityDelegate being it does not create a QtLayout or instantiate a QtAccessibilityDelegate. It does start the Qt app, without waiting for a layout, and register to listen for changes in the state of the Qt app. Taking the embedded delegate into use, loading the embedded QML views and their handling is added in a follow up commit. Task-number: QTBUG-118872 Pick-to: 6.7 Change-Id: Id390a2b35c70b35880523886bf6fcf59d420cb42 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Add possibility to provide app main lib name without metadataTinja Paavoseppä2024-01-163-8/+22
| | | | | | | | | | | | | | | | | | Normally, the app's main library's name is read from a metadata field in the AndroidManifest.xml file, which is filled out by androiddeployqt. Add a protected variable in QtLoader for the app main library name that can be set to provide the library name without the metadata field. This is useful in cases where we don't have a manifest file filled by androiddeployqt, for example when embedding QML to an existing Android app. As a side effect, change the name of existing variable for the main library and the method to access it to make it more explicit they refer to the library's absolute path. Pick-to: 6.7 Change-Id: I869547818f4d0272668a1052d7bc6916b7bf5a98 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Add possibility to listen for changes in app statesTinja Paavoseppä2024-01-161-0/+31
| | | | | | | | | | This is useful for example the embedded QML case, where we want to make sure everything from Qt side is ready before we start to create Qt windows. Pick-to: 6.7 Change-Id: I8148405e35cc8ebb89110f05e07cef06f8ff3709 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>