summaryrefslogtreecommitdiffstats
path: root/src/android/java/src/org/qtproject/qt/android/bindings/QtActivity.java
Commit message (Collapse)AuthorAgeFilesLines
* Android: get rid of the redundant ENVIRONMENT_VARIABLES QtActivity fieldAssam Boudjelthia2023-11-101-11/+0
| | | | | | | | | | | | | | | | | This variable supposedly holds a list of environment variables that will be set by the Qt app, however, if a user needs to set an env variable, it can be already done either in C++: qputenv(key, value); Or in Java via (the same method that Qt plugin use): android.system.Os.setenv(key, value, override); Thus, such field just makes things more confusing overall only. Task-number: QTBUG-115017 Task-number: QTBUG-114593 Change-Id: I14856ed0720bfa2605da9c7d51173703df52bc58 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: add call QtActivity.appendApplicationParameters() to set argsAssam Boudjelthia2023-11-101-6/+0
| | | | | | | | | | | | | | Instead of having to set a field of the class QtActivity to set extra app parameters (i.e. passed when calling main()), make it doable via a new API call appendApplicationParameters(). Note that this is equivalent to setting the manifest metadata "android.app.arguments". Providing a dedicated method for this makes it cleaner and is the expected way. Task-number: QTBUG-115017 Task-number: QTBUG-114593 Change-Id: I407cb68e57fa9a1be24586e42cb947f9c7f4037e Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: set the default theme directly in QtActivity without reflectionAssam Boudjelthia2023-11-101-25/+0
| | | | | | | | | | | | | | | | | | | | | | | | Currently the default theme is looked for using reflection in the android.R package to get an id and then it's set. This is not needed if we set the theme directly in the user's QtActivity which would have access to that id directly pre-deployment. To make setting a theme more in line with Android, retreat to using setTheme() call directly for user projects instead of having to maintain some internal field to store the theme name and have the user set that if they want a different theme for their app. Also, the Android plugin seems to set an env var for QT_ANDROID_THEME with that default theme's name and that's used in QAndroidPlatformTheme to check a theme specific extracted theme style.json, however, the Java side doesn't seem to ever write to such a path, making this approach totally redundant. For that reason, this code path is now removed. Fixes: QTBUG-114075 Task-number: QTBUG-115017 Task-number: QTBUG-114593 Change-Id: I9ab3c025626aac2c09bc19eb7d846eca14a45070 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: Simplify Qt for Android hierarchy, less Java reflection!Assam Boudjelthia2023-10-121-359/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes takes Qt for Android Java code away from the Delegate classes that uses heavily Java reflection to invoke Activity/Service calls and overrides. So instead of that, now, we have a QtActivityBase and a QtServiceBase classes which handle the override logic needed for Qt directly without reflection. These Base classes extend Android's Activity and Service directly, and are inside the internal Qt android package (under Qt6Android.jar). For example, to handle onConfigurationChanged, instead of the current way where we need this in QtActivityDelegate: public void onConfigurationChanged(Configuration configuration) { try { m_super_onConfigurationChanged.invoke(m_activity, configuration); } catch (Exception e) { e.printStackTrace(); } handleUiModeChange(configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK); } And then this in QtActivity: @Override public void onConfigurationChanged(Configuration newConfig) { if (!QtLoader.invokeDelegate(newConfig).invoked) super.onConfigurationChanged(newConfig); } public void super_onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); } And having to keep it's Method handles around and then use Java reflection to call the override behavior done by Qt and the superclass methods. instead of that, we can do it now in QtActivityBase like: @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); handleUiModeChange(newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK); } Then, we would still have our user facing QtActivity class which extends QtActivityBase and benefit from the same implementation of Qt logic done in the base class. An additional benefit to this approach is that now QtActivity will be very lightweight and doesn't need to have all the boilerplate code as before. [ChangeLog][Android] Simplify Qt for Android public bindings (QActivity, QtService and QtApplication) by implementing base classes which use the delegate implementions directly and avoid reflection. Task-number: QTBUG-115014 Task-number: QTBUG-114593 Change-Id: Ie1eca74f989627be4468786a27e30b16209fc521 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: Clean QtActivity and QtService from uneccessary overridesAssam Boudjelthia2023-10-121-560/+38
| | | | | | | | | | | | Following the previous change in the chain, this removes override calls that have no implementation under Qt Delegates, so they can be removed and the default behavior would persist. Task-number: QTBUG-115014 Task-number: QTBUG-114593 Change-Id: Ia7c76e9b56c63cba935cb3d2ae3b6260d3462e51 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: remove overrides for uneccessary and deprecated methodsAssam Boudjelthia2023-10-121-83/+0
| | | | | | | | | | | | | Those overrides are deprecated and will print a warning during Gradle build, moreover, these calls don't have any implementation by Qt that's being triggered by the Qt Delegates classes, so they don't need to be kept in the Activity/Service main classes' implementations. Task-number: QTBUG-115014 Task-number: QTBUG-114593 Change-Id: If0c241206652c1a52e2396a24ec7ab63236e6308 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: remove uneccessary calls to QtNative from QtActivityAssam Boudjelthia2023-10-121-158/+0
| | | | | | | | | | | | These forward calls to QtNative don't need to be present inside the QtActivity implementation, all those calls are invoked by the Delegate classes. Task-number: QTBUG-115014 Task-number: QTBUG-114593 Change-Id: Id1bfa694687af3edc4e9b82b09cf13e1f8eba1de Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: Simplify the user facing Java bindingsAssam Boudjelthia2023-10-121-84/+89
| | | | | | | | | | | | | | | | Move QtLoader classes outside of the bindings package and into the internal Android Java package (Qt6Android.jar that is), to simplify Qt for Android project templates. This is because QtLoader classes are used to trigger Qt libs loading and the users don't need to necessarily know about it or find it in the project's source files. The classes in question: QtLoader, QtActivityLoader, and QtServiceLoader. Task-number: QTBUG-115014 Task-number: QTBUG-114593 Change-Id: I61f68abf6ee83fc45bc47ed9af7457db4f7deabc Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Improve Intent source app detectionJens Trillmann2023-07-311-3/+12
| | | | | | | | | | | | | Activity.getReferrer does not only return app IDs but also URLs if Intent.EXTRA_REFERRER is set on the Intent. In the case of Chrome the referrer is set to the website triggering the Intent. To improve the detection of the calling app we check first if the browser specific Browser.EXTRAS_APPLICATION_ID is set. If it is not set we fall back to Intent.getReferrer. Pick-to: 6.6 6.5 Change-Id: I33d1edd52de98486d9616713e531ea20ada87bcb Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Handle light/dark mode changesBartlomiej Moskal2022-10-261-2/+8
| | | | | | | | | | | | | | | | Update Theme's style according to current UiMode. New style.json file for dark mode was added (stored in separate subdirectory 'darkUiMode/'). Theme_DeviceDefault_DayNight[0] is used for extraction for API 29 or higher. Style is updated each time when UiMode is changed. [0]https://developer.android.com/reference/android/R.style#Theme_DeviceDefault_DayNight Task-number: QTBUG-83185 Pick-to: 6.4 6.2 Change-Id: Id26059231f41761d822d494ac6c641bf3cba3322 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Use SPDX license identifiers lefovers for some Java filesAssam Boudjelthia2022-10-041-35/+3
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. This amends 05fc3aef53348fb58be6308076e000825b704e58. Pick-to: 6.4 Change-Id: Ie6bbdcd0d764ce1295f45f2d41d7c1c1ab47d9a8 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Android A11Y: handle LocationChanged event only for focused elementIvan Solovev2022-05-161-2/+2
| | | | | | | | | | | | | | | | | | LocationChanged event unconditionally triggered invalidateVirtualViewId call. That call results in TYPE_WINDOW_CONTENT_CHANGED Android event, which causes a lot of background processing. That is not correct, because LocationChanged event is generated by every accessible element, not only the one that has A11Y focus. This patch checks event->uniqueId(), and processes only events that come from the focused accessible element. Done-with: Mike Achtelik <mike.achtelik@gmail.com> Task-number: QTBUG-102594 Pick-to: 6.3 6.2 5.15 Change-Id: I6b941733c9d215fed5ee5a7aeeb5be234add9ebe Reviewed-by: Mike Achtelik <mike.achtelik@gmail.com> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Android A11Y: handle valueChanged eventsIvan Solovev2022-02-151-0/+5
| | | | | | | | | | | | | | | | | | | | | Before this patch Android A11Y implementation was missing ValueChanged event handling. As a result, no update was given when the element's value was changed. Handling these events allows us to announce value changes on such objects like Slider, SpinBox, etc... This is a universal method of value-change announcement, so it supports all sorts of A11Y gestures. On the Java side a new function was introduced to announce the values, because we need to use the actual element's *value*, not its accessible name or description. Task-number: QTBUG-93396 Pick-to: 6.3 6.2 5.15 Change-Id: Ic44abd5f01b9b6f5468962131466edaf6a49d498 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
* Android: extract parentId for hidden object in advanceIvan Solovev2022-02-091-2/+2
| | | | | | | | | | | | | | | | | | This commit amends 850a7f1238e84b6960a84e12687e40cf939a44d9. We can't extract the parentId for the hidden object on Java side, because the Java call is executed in a separate thread, so the original hidden object can be destroyed somewhere in the middle of parentId() call. As a workaround, we get the parentId in advance, on C++ side, and pass it as a parameter to JNI function. Task-number: QTBUG-95764 Pick-to: 6.3 6.2 5.15 Change-Id: Ied2ab4ab39b947f3f582575cf77cc76fbac9e274 Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Revert "Android: Place cursor correctly on screen when editing"Rami Potinkara2021-10-261-8/+3
| | | | | | | | | | | | | | | This reverts commit 5c6b10c3cee5737dbc041d0463220898c8120807. It caused a regression such that the main window no longer resized or panned when the VKB is shown, in spite of android:windowSoftInputMode being set. Pick-to: 6.2 5.15 Task-number: QTBUG-95300 Task-number: QTBUG-96117 Task-number: QTBUG-97503 Change-Id: If56e1113eea69a940f6760bdb2ad06a93a0759c1 Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Add information about who launched this activity to intentsLars Schmertmann2021-08-261-0/+18
| | | | | | | | | | | * With this change, applications can easily determine the source of an intent without creating an own extension of QtActivity. * https://developer.android.com/reference/android/app/Activity#getReferrer() Task-number: QTBUG-84382 Pick-to: 6.2 Change-Id: I6a5200af1d997640f02e2b934343914fb5f32ccc Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Remove ministro codeAssam Boudjelthia2021-07-011-2/+0
| | | | | | | | | | | | | | Since Ministro no longer work on recent Android versions (Android 8+), and it hasn't been maintained and the repos are not updated, the existing code is practically a dead code. [ChangeLog][Android] Remove ministro code since it's been unmaintained and not working with recent Android versions. Task-number: QTBUG-85201 Pick-to: 6.2 Change-Id: I18d7b1e209cba3cfd04674060e9bf39aa5a5510f Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Android: Remove NoSuchMethodException errorPekka Gehör2021-05-101-0/+5
| | | | | | | | | | CleanUp NoSuchMethodException error(QtActivity.notifyQtAndroidPluginRunning) appears on application start up. Fixes: QTBUG-93620 Pick-to: 5.15 6.1 Change-Id: Ic835e00d02af17e1b48c0ff66d82e5957c635deb Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Remove NoSuchMethodException errorBartlomiej Moskal2021-04-271-0/+5
| | | | | | | | | | | CleanUp NoSuchMethodException error appears on application start up. Error appears after commit: e402e1103b874c0bf91a1bc754752ee73ffadf33 Fixes: QTBUG-92885 Change-Id: Idd4d09e51c8c721ad18f9bd396c990b51cd730e7 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Place cursor correctly on screen when editingPiotr Mikolajczyk2021-03-051-3/+8
| | | | | | | | | | | | When editing text the cursor is not placed correctly. So this has been achieved by tricking Android into thinking that the input area is only the line where the cursor is, so it is forced to keep it on screen. Fixes: QTBUG-91073 Pick-to: 5.15 Change-Id: Icc2e8315deb76ca1a84819d3fdceaa7b027b1174 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* Android: Qml accessibility fixesPiotr Mikolajczyk2020-12-081-0/+15
| | | | | | | | | | | | | | | | | | - Accessibility focus can follow the position of the widget (for example when swiping on a scrollview) - controls are clickable directly after appearing on the screen after scroll (previously you had to click somewhere else on the screen, and after that you could focus the newly appeared control) - checkbox and switch react correctly on click action - fixed combobox behavior with accessibility enabled Task-number: QTBUG-79611 Pick-to: 6.0 5.15 Change-Id: If36914ab0165f33593e68fd7ecf168693f8538a7 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: rename Android's package name for Qt 6Assam Boudjelthia2020-10-031-0/+1119
Rename Android package name org.qtproject.qt5.android to org.qtproject.qt.android to avoid inconsistency with Qt 6 name. Also, we include the major version number in the jar target. Task-number: QTBUG-86969 Change-Id: Ibb68947289be1079911b34ea157bf089cc52c47f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>