This Java code is mainly an internal implementation detail for
the Qt for Android plugin, and isn't meant to be public
in the first place.
Task-number: QTBUG-126371
Change-Id: I1155ba7912e2b89c681b57d259170087e840817f
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
(cherry picked from commit 9eed1704a1bf7cdf03825e99260e47c392213165)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This Java code is mainly an internal implementation detail for
the Qt for Android plugin, and isn't meant to be public
in the first place.
Task-number: QTBUG-126371
Change-Id: Ic111439a929fa5ad05aca98dd7fa024791a00883
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
(cherry picked from commit eb4e417ef64b832cddfb60fb9e20b0a04ec1ad2a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
If the Qt libs have not been loaded before the QtView is attached to
the window, it leads to accessing the input delegate, which only gets
initialized after the creation of the libs, so we get a null pointer
expection. Add a null check, and a boolean to make sure we update
the input delegate with the view once the libraries are loaded
and the input delegate has been created.
Task-number: QTBUG-126177
Change-Id: I7372596884c7d0ed6c9cca812b46399ecfb74367
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit dc62ddd1521a5754aec0031ade17743da3ed0585)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
If the Activity restart path is run while m_layout is null,
it would lead to a NullPointerException when trying to
access m_layout. Moreover, the code here doesn't make sense,
as m_layout.getParent() should probably be only done when
super.updateActivityAfterRestart() returns true because if
it returns false, the app will be restarted anyway.
Testing the restarting behavior of the Activity, it seems
that the code code doesn't really work in bringing the app
to a usable state after an activity restart, and this code
path should be re-evaluated. Thus, I'm simplifying the logic
to only restart the whole app, and later figure out a way to
do a proper smooth transition instead.
Fixes: QTBUG-124786
Pick-to: 6.7
Change-Id: I79f0c53c815bf71c831d0b930f358c9fd820a2d4
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
(cherry picked from commit 7602f71aa6cd10ff1b16d154fa967c8fce8e8d0a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
There was a small mistake in:
d2ae5ef51e3339c11b1c0ed0b09f9d17b9708f53 commit, which caused a
regression in the input method.
While the function parameter name has been changed, the assignment name
has not. This resulted in the values never actually getting updated.
Fixes: QTBUG-125410
Pick-to: 6.7
Change-Id: I8e64e991d02546ddd078fd273f0b57491c63b55c
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
(cherry picked from commit 79e00b0b25765b85b112b601fee70184b1efe3c0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The check was re-introduced in 7a9bc220c7
and moved to QtRootLayout in 6ff88f97a6.
It introduces an issue where the resizing of the application window does
not work if the its aspect ratio is different from the screen's aspect
ratio.
Fixes: QTBUG-126122
Pick-to: 6.7 6.7.2
Change-Id: Id6d26b247b9ca7a8d0e89e1fdea2d77db12a6cfe
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit a6b78e6f4dbbf688fc0b1d1487b86890b149d323)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Make classes that don't need to be public as package private
* Remove dead code that serves no purpose now.
* Use lambdas when needed.
* Use @UsedFromNativeCode for methods called from native code.
Change-Id: Ie34eec079366fb3ef048e0f49e03f507cdf90e97
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Updated Gradle to 8.7
Updated AGP to 8.4.0
Updated same versions in examples and docs macros
Task-number: QTBUG-113383
Change-Id: Ib2e841f2e57e576c5d689a208a275ce5e9e4b80f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Bump the minimum supported Android API from 23 to 28 i.e.
Android Oreo 9. This is done to focus more and more on
recent versions.
Fixes: QTBUG-125023
Task-number: QTBUG-124890
Change-Id: I4d510b771f413e5711dd44de454211e019c63db6
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
Add a new constructor that takes just the parent Context.
This constructor will not load the Qt libraries or start the
Qt app straight away - the new method loadQtLibraries()
will need to be called for that.
Change-Id: I4e94928d23cb9a495400413d0306961e521303d4
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
to keep the same format because \c is only used with two
tags which is unconsistent.
Pick-to: 6.7
Change-Id: Ie49f6c22a0f0813d49ea69865a80133ad81011c5
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
These are unused functions. They're only called through JNI and those
calls are now through the interface system, so through the interface,
which is the QtActivityDelegate object. These functions are also
already overridden and, in the case of openContextMenu, only
implemented by QtActivityDelegate anyways.
Task-number: QTBUG-118874
Change-Id: I69f41752626ac9892ecef8e40187dfe4663ab08a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Need a convenient way to access QtServiceEmbeddedDelegate from native
and create via QtView, so extend embedded delegate factory to handle
creating them.
QtView now initializes a QtEmbeddedViewInterface via
QtEmbeddedViewInterfaceFactory, which now has a generic create() API
that takes a Context object, and creates/returns a proper Service or
Activity delegate.
Task-number: QTBUG-118874
Change-Id: I8b04b280b9234f3ac3ab818b2d333430d1ac4e41
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Interface for input-related actions, based off of QtInputDelegate.
Implements all the QtInputDelegate functions called from native code
plus an extra function that allows the native side to get a
QtInputConnectionListener object for QtWindow creation.
Removed some unused functions and unmarked @UsedFromNativeCode in some
that are no longer called from native, but still used from java.
Added QtInputConnectionListener null checks in QtInputConnection, due
to the possibility of a non-existent InputInterface returning a null
QtInputConnectionListener for the QtInputConnection constructor.
Task-number: QTBUG-118874
Change-Id: I8d4cde3e0c735471d0fa30d16db20eb13542cdaa
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Small interface, just for QtLayout. This is used in
QtAndroid::qtLayout(), which is called by functions handling the
virtual keyboard and the keyboard handles.
Task-number: QTBUG-118874
Change-Id: Ib9b2830136d05dfd70c9c6ca86ac29be36cc5c30
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Implements interface for context menu in QtActivityDelegate and
QtEmbeddedDelegate.
Task-number: QTBUG-118874
Change-Id: I799ad1aca4beb789b87830b720abf0963ca09274
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
This will provide the JNI API used by QtAndroidAccessibility namespace
via QtAndroid namespace.
Removed unnecessary functions like createAccessibilityDelegate from
QtEmbeddedDelegate, moved the interface extension to where it is
actually supported: QtActivityDelegate.
Until now, QtActivityDelegateBase has called the QtEmbeddedDelegate
implementation on createAccessibilityDelegate() in order to create a
QtAccessibilityDelegate - which has not actually created the delegate -
and then done a null check before trying to call the - always null -
QtAccessibilityDelegate member.
The embedding and service-embedding usecases are now dealt with via the
interface validity checks on the C++ side, until an actual
implementation for those is completed.
Task-number: QTBUG-118874
Change-Id: Iea3db0e17ae80c0443e9027bdfe36bba311eed2b
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Add QtWindowInterface interface, to access native functionality related
to windows.
QtActivityBase now follows QtNative.onAppStateDetailsChanged in order
to register and unregister functionalities of QtActivityDelegate.
Task-number: QTBUG-118874
Change-Id: Ifad33bd7aac7683081f026f0591ef496909be095
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This class will be used by java delegates to register their supported
functionalities to the Qt/C++ side.
It registers two native functions: register- and
unregisterBackend, which will be used by the aforementioned
delegates.
It will be used by C++ classes which currently use
QtAndroid::qtActivityDelegate() to access a JNI object which implements
all these features in one big class.
Task-number: QTBUG-118874
Change-Id: I23a7e433104c20b96c08b682a96cfaec98ecb4a9
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This works better with the current Gradle 8.3 and supports
Android api 34 builds.
Task-number: QTBUG-106907
Change-Id: I816a1aa163a9aee0a5859872129cff62f81a2dea
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
This avoids linter warning like in
5dc9692e48ea15ab3da4283997547a2849f1944e:
Obsolete Gradle Dependency
Brings back the commit 3bae65e7d6
that was reverted earlier.
Pick-to: 6.7
Task-number: QTBUG-106907
Change-Id: Ia1e3362853b5d43299acf21d5f3ac099a478b396
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
This adds new aar target, as we do with apk targets, and an option
to androiddeployqt, --build-aar, which builds an AAR instead of APK.
AndroidManifest.xml of an AAR does not include application or activity
nodes, so we add an AAR specific manifest. Also the plugin type in
build.gradle will be com.android.library when choosing to build an
AAR.
Task-number: QTBUG-116955
Task-number: QTBUG-65567
Change-Id: Id33ac236f44038a8411ebfecdcc4e404c976e277
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This allows to later change the plugin type based on the options
provided for the androiddeployqt, such as when building an AAR.
Task-number: QTBUG-116955
Task-number: QTBUG-65567
Change-Id: I6314c8ab9edccbf953ae48543d5a002a9f807581
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
AGP version 7.4 deprecated the use of "package" attribute in the
manifest to specify the unique package name, it's instead been
moved to build.gradle file and set using "namespace" property.
This patch adds support of that to androiddeployqt.
Removing the "package" attribute from the default manifest would
break Qt Creator 13 and below because Qt Creator would fail to
deploy apps without such attribute in the manifest. For that reason
we'll defer removing it until a later version, for example Qt 6.10,
to allow some buffer for a Qt Creator that can handle that to be
adopted by users to reduce breakage.
[ChangeLog][Android] Add support for namespace in build.gradle instead
of the package attribute in the manifest.
Pick-to: 6.7
Task-number: QTBUG-106907
Change-Id: Ib0f0d6a6fbb3b38f605aadfdcc497067daf90297
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
31a0d99fa5 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>
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>
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>
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>
Amends 269187bfa2 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>
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>
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 0a92d881bb.
Pick-to: 6.7
Change-Id: Ia00407d827ca9217c9f49df55b4cf7001ac9871a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>