diff options
Diffstat (limited to 'examples/platforms/android')
77 files changed, 1746 insertions, 0 deletions
diff --git a/examples/platforms/android/.gitignore b/examples/platforms/android/.gitignore new file mode 100644 index 0000000000..e1bb0d95b4 --- /dev/null +++ b/examples/platforms/android/.gitignore @@ -0,0 +1,10 @@ +*.user +build/ +**/.idea/ +**/.gradle/ +**/local.properties +**/app/libs/ +**/app/src/main/res/xml/qtprovider_paths.xml +**/app/src/main/res/values/libs.xml +**/app/assets/android_rcc_bundle.rcc + diff --git a/examples/platforms/android/CMakeLists.txt b/examples/platforms/android/CMakeLists.txt new file mode 100644 index 0000000000..7ed54f821d --- /dev/null +++ b/examples/platforms/android/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +qt_internal_add_example(qml_in_android_view) +qt_internal_add_example(qml_in_java_based_android_project) +qt_internal_add_example(qml_in_kotlin_based_android_project) diff --git a/examples/platforms/android/doc/images/portrait_java.png b/examples/platforms/android/doc/images/portrait_java.png Binary files differnew file mode 100644 index 0000000000..266f0a2709 --- /dev/null +++ b/examples/platforms/android/doc/images/portrait_java.png diff --git a/examples/platforms/android/doc/src/qml_in_android_studio_projects.qdoc b/examples/platforms/android/doc/src/qml_in_android_studio_projects.qdoc new file mode 100644 index 0000000000..be1fa8b7a2 --- /dev/null +++ b/examples/platforms/android/doc/src/qml_in_android_studio_projects.qdoc @@ -0,0 +1,186 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + \page qml-in-android-studio-projects-example.html + \title QML in Android Studio Projects + \brief Uses a \l {Qt Quick View Android Class}{QtQuickView} + to embed a QML component into Android projects. + \ingroup qtquickexamples + + \section1 Overview + + This example contains a QML project that you can import into Android Studio + with the \l {Qt Tools for Android Studio} plugin + and Java and Kotlin projects that utilize the + \l {Qt Quick View Android Class}{QtQuickView} API. + + For more information on how QML works, see the \l {Qt Qml}. This + documentation will focus on how a QML component is embedded into + Java- and Kotlin-based Android applications. + + \image portrait_java.png + + First, we look at the \c MainActivity's onCreate() method of the Java + and Kotlin projects. + + For a Java-based project: + + \snippet android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/MainActivity.java onCreate + + For a Kotlin-based project: + + \snippet android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/MainActivity.kt onCreate + + \note in the Kotlin project we use \l {Android: View binding}{View binding} + to access the UI components of the application: + + \snippet android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/MainActivity.kt binding + + Inside the \c onCreate() method, an instance of + \l {Qt Quick View Android Class}{QtQuickView} named + \c m_qmlView is created by giving it the Java/Kotlin application Context, + URI of the QML project's \c main.qml file and the name of the QML project's + main library as parameters. + + For a Java-based project: + + \snippet android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/MainActivity.java m_qmlView + + For a Kotlin-based project: + + \snippet android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/MainActivity.kt m_qmlView + + \c m_qmlView is then added to Android FrameLayout ViewGroup with + appropriate layout parameters. + + For a Java-based project: + + \snippet android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/MainActivity.java layoutParams + + For a Kotlin-based project: + + \snippet android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/MainActivity.kt layoutParams + + \section1 Interacting with the QML component + + To interact with the embedded QML component we first need to implement + the \l {Qt Quick View Android Class}{QtQuickView} public interface + \l [Qt Quick View Android Class]{public interface StatusChangeListener}{StatusChangeListener}. + + For a Java-based project: + + \code + public class MainActivity extends AppCompatActivity implements + QtQuickView.StatusChangeListener{ + ... + } + \endcode + + IFor a Kotlin-based project: + + \code + class MainActivity : AppCompatActivity(), QtQuickView.StatusChangeListener{ + ... + } + \endcode + + Then, define an override for the + \l [Qt Quick View Android Class]{public interface StatusChangeListener}{StatusChangeListener} + callback function \c onStatusChanged(). + + For a Java-based project: + + \snippet android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/MainActivity.java onStatusChanged + + For a Kotlin-based project: + + \snippet android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/MainActivity.kt onStatusChanged + + Then, set that listener to listen for status changes of \c m_qmlView + with the \l [Qt Quick View Android Class]{public void setStatusChangeListener(StatusChangeListener listener)}{setStatusChangeListener()}. + + For a Java-based project: + + \snippet android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/MainActivity.java setStatusChangeListener + + For a Kotlin-based project: + + \snippet android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/MainActivity.kt setStatusChangeListener + + The overridden callback function \c onStatusChanged() receives + \c StatusChanged() signal containing the current + \l [Qt Quick View Android Class]{Status values}{Status value} of the + \c m_qmlView. If this + \l [Qt Quick View Android Class]{Status values}{Status value} + is confirmed to be + \l [Qt Quick View Android Class]{Status values}{STATUS_READY}, + we can start interacting with the QML view. + + \section1 Getting and setting QML view property values + + Getting and setting QML view property values happens through the + \l [Qt Quick View Android Class]{public <T extends Object> T getProperty(String propertyName)}{QtQuickView.getProperty()} + and \l [Qt Quick View Android Class]{public void setProperty(String propertyName, Object value)}{QtQuickView.setProperty()} + methods. + + The root object of the QML component's background color is set when a click + event of an Android button occurs. + + For a Java-based project: + + \snippet android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/MainActivity.java onClickListener + + For a Kotlin-based project: + + \snippet android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/MainActivity.kt onClickListener + + With the \l [Qt Quick View Android Class]{public void setProperty(StringpropertyName, Object value)}{QtQuickView.setProperty()} + method we set the "colorStringFormat" property value to a random color + value that is fetched from the project's \c Colors.java class. + + The \l [Qt Quick View Android Class]{public <T extends Object> T getProperty (String propertyName)}{QtQuickView.getProperty()}{QtQuickView.getProperty()} + method is used here to fetch the current background color of the root + object of the QML component and then show it to the user on the Android + side of the application. + + \section1 Signal listeners + + \l {Qt Quick View Android Class}{QtQuickView} class offers a + connectSignalListener() and disconnectSignalListener() methods which are + used to connect and disconnect a signal listener to a signal that is + declared in the QML component root object. + + Here we connect a signal listener to the \c onClicked() signal of the + QML component. + + For a Java-based project: + + \snippet android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/MainActivity.java qml signal listener + + For a Kotlin-based project: + + \snippet android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/MainActivity.kt qml signal listener + + The \c onClicked() signal is emitted every time the button on the QML UI is + clicked. That signal is then received by this listener and the background + color of the layout holding the Android side of the application is set to + a random color value fetched from the project's \c Colors.java class. + + The \l [Qt Quick View Android Class]{public <T> int addSignalListener(String signalName, Class<T> argType, SignalListener<T> listener)}{QtQuickView.connectSignalListener()} + returns a unique signal listener id which we store and use later to + identify and disconnect the listener. + + For a Java-based project: + + \snippet android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/MainActivity.java disconnect qml signal listener + + For a Kotlin-based project: + + \snippet android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/MainActivity.kt disconnect qml signal listener + + Here, the previously connected signal listener is disconnected using the + \l [Qt Quick View Android Class]{public boolean removeSignalListener(int signalListenerId)}{QtQuickView.disconnectSignalListener()} + method by giving it the unique signal listener id. + +*/ diff --git a/examples/platforms/android/qml_in_android_view/CMakeLists.txt b/examples/platforms/android/qml_in_android_view/CMakeLists.txt new file mode 100644 index 0000000000..86d3c6243f --- /dev/null +++ b/examples/platforms/android/qml_in_android_view/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +cmake_minimum_required(VERSION 3.16) + +project(qml_in_android_view VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(Qt6 6.7 REQUIRED COMPONENTS Quick) + +qt_standard_project_setup(REQUIRES 6.6) + +qt_add_executable(qml_in_android_view + main.cpp +) + +qt_add_qml_module(qml_in_android_view + URI qmlModule + VERSION 1.0 + QML_FILES Main.qml +) + +target_link_libraries(qml_in_android_view + PRIVATE Qt6::Quick +) + +install(TARGETS qml_in_android_view + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + diff --git a/examples/platforms/android/qml_in_android_view/Main.qml b/examples/platforms/android/qml_in_android_view/Main.qml new file mode 100644 index 0000000000..3ed2b6f58b --- /dev/null +++ b/examples/platforms/android/qml_in_android_view/Main.qml @@ -0,0 +1,87 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +import QtQuick +import QtQuick.Controls + +Rectangle { + id: mainRectangle + + property string colorStringFormat: "#1CB669" + + signal onClicked() + + color: colorStringFormat + + Text { + id: helloText + + text: "QML" + color: "white" + font.pixelSize: 72 + fontSizeMode: Text.VerticalFit + // Height is calculated based on display orientation + // from Screen height, dividing numbers are based on what what seem + // to look good on most displays + height: Screen.width > Screen.height ? Screen.height / 8 : (Screen.height / 2) / 8 + font.bold: true + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: 5 + horizontalAlignment: Text.AlignHCenter + } + + + Text { + id: changeColorText + + text: "Tap button to change Java view background color" + wrapMode: Text.Wrap + color: "white" + font.pixelSize: 58 + fontSizeMode: Text.Fit + // Height and width are calculated based on display orientation + // from Screen height and width, dividing numbers are based on what seem to + // look good on most displays + height: Screen.width > Screen.height ? Screen.height / 8 : (Screen.height / 2) / 8 + width: Screen.width > Screen.height ? (Screen.width / 2) / 2 : Screen.width / 2 + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: helloText.bottom + anchors.topMargin: Screen.height / 10 + horizontalAlignment: Text.AlignHCenter + } + + Button { + id: button + // Width is calculated from changeColorText which is calculated from Screen size + // dividing numbers are base on what seems to look good on most displays + width: changeColorText.width / 1.6 + height: changeColorText.height * 1.2 + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: changeColorText.bottom + anchors.topMargin: height / 5 + + onClicked: mainRectangle.onClicked() + + background: Rectangle { + id: buttonBackground + + radius: 14 + color: "#6200EE" + opacity: button.down ? 0.6 : 1 + scale: button.down ? 0.9 : 1 + } + contentItem: Text { + id: buttonText + + text: "CHANGE COLOR" + color: "white" + font.pixelSize: 58 + minimumPixelSize: 10 + fontSizeMode: Text.Fit + font.bold: true + wrapMode: Text.Wrap + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } +} diff --git a/examples/platforms/android/qml_in_android_view/main.cpp b/examples/platforms/android/qml_in_android_view/main.cpp new file mode 100644 index 0000000000..c195699a0f --- /dev/null +++ b/examples/platforms/android/qml_in_android_view/main.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +#include <QGuiApplication> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + return app.exec(); +} + diff --git a/examples/platforms/android/qml_in_java_based_android_project/CMakeLists.txt b/examples/platforms/android/qml_in_java_based_android_project/CMakeLists.txt new file mode 100644 index 0000000000..ed5212d564 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +cmake_minimum_required(VERSION 3.16) + +project(qml_in_java_based_android_project VERSION 0.1 LANGUAGES CXX) + +install(DIRECTORY + gradle + app + DESTINATION . +) +install(FILES + settings.gradle + gradle.properties + build.gradle + CMakeLists.txt + DESTINATION . +) diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/build.gradle b/examples/platforms/android/qml_in_java_based_android_project/app/build.gradle new file mode 100644 index 0000000000..ab25257151 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/build.gradle @@ -0,0 +1,56 @@ +plugins { + id 'com.android.application' +} + +android { + namespace 'com.example.qml_in_java_based_android_project' + compileSdk 34 + + defaultConfig { + applicationId "com.example.qml_in_java_based_android_project" + minSdk 28 + targetSdk 34 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + packagingOptions { + jniLibs { + useLegacyPackaging true + } + } + sourceSets { + main { + assets { + srcDirs 'assets' + } + jniLibs { + srcDirs 'libs' + } + } + } +} + +dependencies { + + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.9.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' +} + diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/AndroidManifest.xml b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..f058a307fb --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools"> + + <application + android:allowBackup="true" + android:dataExtractionRules="@xml/data_extraction_rules" + android:fullBackupContent="@xml/backup_rules" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:roundIcon="@mipmap/ic_launcher_round" + android:supportsRtl="true" + android:theme="@style/Theme.MyApplication" + tools:targetApi="34"> + <activity + android:name=".MainActivity" + android:exported="true" + android:configChanges="orientation|screenLayout|screenSize"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + </activity> + </application> + +</manifest> + diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/Colors.java b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/Colors.java new file mode 100644 index 0000000000..ba2a9265f9 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/Colors.java @@ -0,0 +1,35 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +package com.example.qml_in_java_based_android_project; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Stack; + +class Colors { + private final Stack<Integer> recycle; + private final Stack<Integer> colors; + + public Colors() { + colors = new Stack<>(); + recycle = new Stack<>(); + recycle.addAll(Arrays.asList( + 0xff1CB669, 0xff00414A, 0xff27138B, + 0xffB5C10E, 0xff373F26, 0xffAF93DF, + 0xff817505 + ) + ); + } + + public String getColor() { + if (colors.size()==0) { + while (!recycle.isEmpty()) + colors.push(recycle.pop()); + Collections.shuffle(colors); + } + int color = colors.pop(); + recycle.push(color); + return String.format("#%06X", (0xFFFFFF & color)); + } +} + diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/MainActivity.java b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/MainActivity.java new file mode 100644 index 0000000000..4c75a2dcc9 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/java/com/example/qml_in_java_based_android_project/MainActivity.java @@ -0,0 +1,179 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +package com.example.qml_in_java_based_android_project; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.SwitchCompat; +import android.content.res.Configuration; +import android.graphics.Color; +import android.os.Bundle; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.LinearLayout; +import android.widget.TextView; +import org.qtproject.qt.android.QtQmlStatus; +import org.qtproject.qt.android.QtQmlStatusChangeListener; +import org.qtproject.qt.android.QtQuickView; +import org.qtproject.example.qml_in_android_view.QmlModule.Main; +import java.util.HashMap; +import java.util.Map; + +// Implement QtQuickView StatusChangeListener interface to get status updates +// from the underlying QQuickView +public class MainActivity extends AppCompatActivity implements QtQmlStatusChangeListener { + + private static final String TAG = "myTag"; + private final Colors m_colors = new Colors(); + private final Map<QtQmlStatus, String> m_statusNames = new HashMap<QtQmlStatus, String>() {{ + put(QtQmlStatus.READY, " READY"); + put(QtQmlStatus.LOADING, " LOADING"); + put(QtQmlStatus.ERROR, " ERROR"); + put(QtQmlStatus.NULL, " NULL"); + }}; + private int m_qmlButtonSignalListenerId; + private LinearLayout m_mainLinear; + private FrameLayout m_qmlFrameLayout; + private QtQuickView m_qtQuickView; + private Main m_mainQmlComponent; + private LinearLayout m_androidControlsLayout; + private TextView m_getPropertyValueText; + private TextView m_qmlStatus; + private SwitchCompat m_switch; + private View m_box; + + //! [onCreate] + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + m_mainLinear = findViewById(R.id.mainLinear); + m_getPropertyValueText = findViewById(R.id.getPropertyValueText); + m_qmlStatus = findViewById(R.id.qmlStatusText); + m_androidControlsLayout = findViewById(R.id.javaLinear); + m_box = findViewById(R.id.qmlColorBox); + m_switch = findViewById(R.id.disconnectQmlListenerSwitch); + m_switch.setOnClickListener(view -> switchListener()); + m_mainQmlComponent = new Main(); + //! [m_qmlView] + m_qtQuickView = new QtQuickView(this); + //! [m_qmlView] + + // Set status change listener for m_qmlView + // listener implemented below in OnStatusChanged + //! [setStatusChangeListener] + m_mainQmlComponent.setStatusChangeListener(this); + //! [setStatusChangeListener] + //! [layoutParams] + ViewGroup.LayoutParams params = new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + m_qmlFrameLayout = findViewById(R.id.qmlFrame); + m_qmlFrameLayout.addView(m_qtQuickView, params); + //! [layoutParams] + m_qtQuickView.loadComponent(m_mainQmlComponent); + + findViewById(R.id.changeQmlColorButton).setOnClickListener(view -> onClickListener()); + + // Check target device orientation on launch + handleOrientationChanges(); + } + + //! [onCreate] + @Override + public void onConfigurationChanged(@NonNull Configuration newConfig) { + super.onConfigurationChanged(newConfig); + handleOrientationChanges(); + } + + private void handleOrientationChanges() { + // When specific target device display configurations (listed in AndroidManifest.xml + // android:configChanges) change, get display metrics and make needed changes to UI + DisplayMetrics displayMetrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); + ViewGroup.LayoutParams qmlFrameLayoutParams = m_qmlFrameLayout.getLayoutParams(); + ViewGroup.LayoutParams linearLayoutParams = m_androidControlsLayout.getLayoutParams(); + + if (displayMetrics.heightPixels > displayMetrics.widthPixels) { + m_mainLinear.setOrientation(LinearLayout.VERTICAL); + qmlFrameLayoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; + qmlFrameLayoutParams.height = 0; + linearLayoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; + linearLayoutParams.height = 0; + } else { + m_mainLinear.setOrientation(LinearLayout.HORIZONTAL); + qmlFrameLayoutParams.width = 0; + qmlFrameLayoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; + linearLayoutParams.width = 0; + linearLayoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; + } + m_qmlFrameLayout.setLayoutParams(qmlFrameLayoutParams); + m_androidControlsLayout.setLayoutParams(linearLayoutParams); + } + + //! [onClickListener] + public void onClickListener() { + // Set the QML view root object property "colorStringFormat" value to + // color from Colors.getColor() + m_mainQmlComponent.setColorStringFormat(m_colors.getColor()); + + String qmlBackgroundColor = m_mainQmlComponent.getColorStringFormat(); + + // Display the QML View background color code + m_getPropertyValueText.setText(qmlBackgroundColor); + + // Display the QML View background color in a view + m_box.setBackgroundColor(Color.parseColor(qmlBackgroundColor)); + } + //! [onClickListener] + + public void switchListener() { + TextView text = findViewById(R.id.switchText); + // Disconnect QML button signal listener if switch is On using the saved signal listener Id + // and connect it again if switch is turned off + if (m_switch.isChecked()) { + Log.i(TAG, "QML button onClicked signal listener disconnected"); + text.setText(R.string.connect_qml_button_signal_listener); + //! [disconnect qml signal listener] + m_mainQmlComponent.disconnectSignalListener(m_qmlButtonSignalListenerId); + //! [disconnect qml signal listener] + } else { + Log.i(TAG, "QML button onClicked signal listener connected"); + text.setText(R.string.disconnect_qml_button_signal_listener); + m_qmlButtonSignalListenerId = m_mainQmlComponent.connectOnClickedListener( + (String name, Void v) -> { + Log.i(TAG, "QML button clicked"); + m_androidControlsLayout.setBackgroundColor(Color.parseColor(m_colors.getColor())); + }); + } + } + //! [onStatusChanged] + @Override + public void onStatusChanged(QtQmlStatus qtQmlStatus) { + Log.i(TAG, "Status of QtQuickView: " + qtQmlStatus); + + final String qmlStatus = getResources().getString(R.string.qml_view_status) + + m_statusNames.get(qtQmlStatus); + + // Show current QML View status in a textview + m_qmlStatus.setText(qmlStatus); + + // Connect signal listener to "onClicked" signal from main.qml + // addSignalListener returns int which can be used later to identify the listener + //! [qml signal listener] + if (qtQmlStatus == QtQmlStatus.READY && !m_switch.isChecked()) { + m_qmlButtonSignalListenerId = m_mainQmlComponent.connectOnClickedListener( + (String name, Void v) -> { + Log.i(TAG, "QML button clicked"); + m_androidControlsLayout.setBackgroundColor(Color.parseColor(m_colors.getColor())); + }); + + } + //! [qml signal listener] + } + //! [onStatusChanged] +} + diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/drawable/ic_launcher_background.xml b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000000..ca3826a46c --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?> +<vector + android:height="108dp" + android:width="108dp" + android:viewportHeight="108" + android:viewportWidth="108" + xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#3DDC84" + android:pathData="M0,0h108v108h-108z"/> + <path android:fillColor="#00000000" android:pathData="M9,0L9,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,0L19,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M29,0L29,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M39,0L39,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M49,0L49,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M59,0L59,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M69,0L69,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M79,0L79,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M89,0L89,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M99,0L99,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,9L108,9" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,19L108,19" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,29L108,29" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,39L108,39" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,49L108,49" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,59L108,59" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,69L108,69" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,79L108,79" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,89L108,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,99L108,99" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,29L89,29" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,39L89,39" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,49L89,49" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,59L89,59" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,69L89,69" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,79L89,79" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M29,19L29,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M39,19L39,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M49,19L49,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M59,19L59,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M69,19L69,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M79,19L79,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> +</vector> diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/drawable/ic_launcher_foreground.xml b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000000..9a5435b534 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,31 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:aapt="http://schemas.android.com/aapt" + android:width="108dp" + android:height="108dp" + android:viewportWidth="108" + android:viewportHeight="108"> + <path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z"> + <aapt:attr name="android:fillColor"> + <gradient + android:endX="85.84757" + android:endY="92.4963" + android:startX="42.9492" + android:startY="49.59793" + android:type="linear"> + <item + android:color="#44000000" + android:offset="0.0" /> + <item + android:color="#00000000" + android:offset="1.0" /> + </gradient> + </aapt:attr> + </path> + <path + android:fillColor="#FFFFFF" + android:fillType="nonZero" + android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z" + android:strokeWidth="1" + android:strokeColor="#00000000" /> +</vector> + diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/layout/activity_main.xml b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000000..69a55e9242 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,165 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/mainLinear" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".MainActivity" + android:orientation="vertical" + android:baselineAligned="false"> + + <FrameLayout + android:id="@+id/qmlFrame" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1"> + + </FrameLayout> + + <LinearLayout + android:id="@+id/javaLinear" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:background="@color/lilac" + android:orientation="vertical"> + + + <TextView + android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="8dp" + android:gravity="center_horizontal" + android:includeFontPadding="false" + android:text="@string/java" + android:textColor="@color/white" + android:textSize="24sp" + android:textStyle="bold" /> + + <TextView + android:id="@+id/qmlStatusText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="16dp" + android:gravity="center_horizontal" + android:text="@string/qml_view_status" + android:textColor="@color/white"/> + + <LinearLayout + android:id="@+id/buttonAndSwitchLayout" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal" + android:orientation="horizontal" + android:layout_marginTop="16dp"> + + <LinearLayout + android:id="@+id/buttonLinearLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:layout_weight="1"> + + <TextView + android:id="@+id/changeColorText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal" + android:maxLines="3" + android:text="@string/change_qml_background" + android:textColor="@color/white" /> + + <Button + android:id="@+id/changeQmlColorButton" + android:layout_width="100dp" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="8dp" + android:text="@string/button" + android:textSize="14sp" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/switchLinearLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:layout_weight="1"> + + <TextView + android:id="@+id/switchText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal" + android:maxLines="3" + android:text="@string/disconnect_qml_button_signal_listener" + android:textColor="@color/white" /> + + <androidx.appcompat.widget.SwitchCompat + android:id="@+id/disconnectQmlListenerSwitch" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="8dp" + app:showText="true" + app:switchTextAppearance="@style/switchStyle" + android:switchTextAppearance="@android:style/TextAppearance.Small" + android:textOff="@string/off" + android:textOn="@string/on" + tools:ignore="UseSwitchCompatOrMaterialXml" /> + </LinearLayout> + + </LinearLayout> + + <LinearLayout + android:id="@+id/qmlColorLinear" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="horizontal" + android:padding="10dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:layout_weight="1"> + + <TextView + android:id="@+id/qmlViewBackgroundText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal" + android:maxLines="2" + android:text="@string/qml_view_background_color" + android:textColor="@color/white" /> + + <TextView + android:id="@+id/getPropertyValueText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal" + android:textColor="@color/white" /> + </LinearLayout> + + <View + android:id="@+id/qmlColorBox" + android:layout_width="100dp" + android:layout_height="50dp" + android:layout_gravity="center_horizontal" + android:background="@android:color/transparent" + android:layout_weight="0"/> + </LinearLayout> + + </LinearLayout> + +</LinearLayout> + diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000000..3ff874648d --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> + diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000000..3ff874648d --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> + diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differnew file mode 100644 index 0000000000..f043b66984 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp Binary files differnew file mode 100644 index 0000000000..53e483046c --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differnew file mode 100644 index 0000000000..5646cd4957 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differnew file mode 100644 index 0000000000..8121c6f7c2 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp Binary files differnew file mode 100644 index 0000000000..da81ab2c05 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differnew file mode 100644 index 0000000000..d68eb57118 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differnew file mode 100644 index 0000000000..818fa2b2dc --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp Binary files differnew file mode 100644 index 0000000000..57d6591183 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differnew file mode 100644 index 0000000000..cf05b107f0 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differnew file mode 100644 index 0000000000..30855a994a --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp Binary files differnew file mode 100644 index 0000000000..385517a7eb --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differnew file mode 100644 index 0000000000..10ec83e5f4 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differnew file mode 100644 index 0000000000..5a9dab1d44 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp Binary files differnew file mode 100644 index 0000000000..62d203c390 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp Binary files differnew file mode 100644 index 0000000000..52d2c11162 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/values/colors.xml b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/values/colors.xml new file mode 100644 index 0000000000..30d00eda0f --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/values/colors.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="purple_500">#FF6200EE</color> + <color name="purple_700">#FF3700B3</color> + <color name="teal_200">#FF03DAC5</color> + <color name="teal_700">#FF018786</color> + <color name="black">#FF000000</color> + <color name="white">#FFFFFFFF</color> + <color name="lilac">#AF93DF</color> +</resources> + diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/values/strings.xml b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/values/strings.xml new file mode 100644 index 0000000000..67d301c48c --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/values/strings.xml @@ -0,0 +1,13 @@ +<resources> + <string name="app_name">qml_in_java_based_android_project</string> + <string name="button">Change color</string> + <string name="java">Java</string> + <string name="change_qml_background">Tap button to change QML view background color</string> + <string name="disconnect_qml_button_signal_listener">Tap switch to disconnect QML button signal listener</string> + <string name="connect_qml_button_signal_listener">Tap switch to connect QML button signal listener</string> + <string name="on">On</string> + <string name="off">Off</string> + <string name="qml_view_status">QML view status: </string> + <string name="qml_view_background_color">QML view background color:</string> +</resources> + diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/values/styles.xml b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/values/styles.xml new file mode 100644 index 0000000000..bce864063a --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/values/styles.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="switchStyle"> + <item name="android:textSize">12sp</item> + </style> +</resources> diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/values/themes.xml b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/values/themes.xml new file mode 100644 index 0000000000..515cb95981 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ +<resources xmlns:tools="http://schemas.android.com/tools"> + <!-- Base application theme. --> + <style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> + <!-- Primary brand color. --> + <item name="colorPrimary">@color/purple_500</item> + <item name="colorPrimaryVariant">@color/purple_700</item> + <item name="colorOnPrimary">@color/white</item> + <!-- Secondary brand color. --> + <item name="colorSecondary">@color/teal_200</item> + <item name="colorSecondaryVariant">@color/teal_700</item> + <item name="colorOnSecondary">@color/black</item> + <!-- Status bar color. --> + <item name="android:statusBarColor">?attr/colorPrimaryVariant</item> + <!-- Customize your theme here. --> + </style> +</resources> diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/xml/backup_rules.xml b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/xml/backup_rules.xml new file mode 100644 index 0000000000..04dd1acfe3 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/xml/backup_rules.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + Sample backup rules file; uncomment and customize as necessary. + See https://developer.android.com/guide/topics/data/autobackup + for details. + Note: This file is ignored for devices older that API 31 + See https://developer.android.com/about/versions/12/backup-restore +--> +<full-backup-content> +</full-backup-content> + diff --git a/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/xml/data_extraction_rules.xml b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 0000000000..9840b57766 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/app/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + Sample data extraction rules file; uncomment and customize as necessary. + See https://developer.android.com/about/versions/12/backup-restore#xml-changes + for details. +--> +<data-extraction-rules> + <cloud-backup> + </cloud-backup> +</data-extraction-rules> + diff --git a/examples/platforms/android/qml_in_java_based_android_project/build.gradle b/examples/platforms/android/qml_in_java_based_android_project/build.gradle new file mode 100644 index 0000000000..b92d690313 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/build.gradle @@ -0,0 +1,4 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { +id 'com.android.application' version '7.4.1' apply false +} diff --git a/examples/platforms/android/qml_in_java_based_android_project/gradle.properties b/examples/platforms/android/qml_in_java_based_android_project/gradle.properties new file mode 100644 index 0000000000..dacb776f4a --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/gradle.properties @@ -0,0 +1,22 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true + diff --git a/examples/platforms/android/qml_in_java_based_android_project/gradle/wrapper/gradle-wrapper.properties b/examples/platforms/android/qml_in_java_based_android_project/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..e94b8a6800 --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Thu Feb 08 15:14:57 EET 2024 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/examples/platforms/android/qml_in_java_based_android_project/settings.gradle b/examples/platforms/android/qml_in_java_based_android_project/settings.gradle new file mode 100644 index 0000000000..80a48f7b1a --- /dev/null +++ b/examples/platforms/android/qml_in_java_based_android_project/settings.gradle @@ -0,0 +1,17 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "qml_in_java_based_android_project" +include ':app' diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/CMakeLists.txt b/examples/platforms/android/qml_in_kotlin_based_android_project/CMakeLists.txt new file mode 100644 index 0000000000..efa2575b8f --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +cmake_minimum_required(VERSION 3.16) + +project(qml_in_kotlin_based_android_project VERSION 0.1 LANGUAGES CXX) + +install(DIRECTORY + gradle + app + DESTINATION . +) +install(FILES + settings.gradle + gradle.properties + build.gradle + CMakeLists.txt + DESTINATION . +) diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/build.gradle b/examples/platforms/android/qml_in_kotlin_based_android_project/app/build.gradle new file mode 100644 index 0000000000..be631746b6 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/build.gradle @@ -0,0 +1,64 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' +} + +android { + namespace 'com.example.qml_in_kotlin_based_android_project' + compileSdk 34 + + defaultConfig { + applicationId "com.example.qml_in_kotlin_based_android_project" + minSdk 26 + targetSdk 34 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildFeatures { + viewBinding = true + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + packagingOptions { + jniLibs { + useLegacyPackaging true + } + } + sourceSets { + main { + assets { + srcDirs 'assets' + } + jniLibs { + srcDirs 'libs' + } + } + } +} + +dependencies { + + implementation 'androidx.core:core-ktx:1.10.1' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.11.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' +} diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/AndroidManifest.xml b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..fb183e2d79 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools"> + + <application + android:allowBackup="true" + android:dataExtractionRules="@xml/data_extraction_rules" + android:fullBackupContent="@xml/backup_rules" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:roundIcon="@mipmap/ic_launcher_round" + android:supportsRtl="true" + android:theme="@style/Theme.Qml_in_kotlin_based_android_project" + tools:targetApi="34"> + <activity + android:name=".MainActivity" + android:exported="true" + android:configChanges="screenSize|screenLayout|orientation"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + </activity> + </application> + +</manifest> diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/Colors.kt b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/Colors.kt new file mode 100644 index 0000000000..7770497796 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/Colors.kt @@ -0,0 +1,31 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +package com.example.qml_in_kotlin_based_android_project + +import java.util.Collections +import java.util.Stack + +internal class Colors { + private val recycle: Stack<Int> = Stack() + private val colors: Stack<Int> = Stack() + + init { + recycle.addAll( + mutableListOf( + -0xe34997, -0xffbeb6, -0xd8ec75, + -0x4a3ef2, -0xc8c0da, -0x506c21, + -0x7e8afb + ) + ) + } + + fun getColor(): String { + if (colors.size == 0) { + while (!recycle.isEmpty()) colors.push(recycle.pop()) + Collections.shuffle(colors) + } + val color = colors.pop() + recycle.push(color) + return String.format("#%06X", 0xFFFFFF and color) + } +} diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/MainActivity.kt b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/MainActivity.kt new file mode 100644 index 0000000000..4ec1591709 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/java/com/example/qml_in_kotlin_based_android_project/MainActivity.kt @@ -0,0 +1,156 @@ +package com.example.qml_in_kotlin_based_android_project + +import android.content.res.Configuration +import android.graphics.Color +import android.os.Bundle +import android.util.DisplayMetrics +import android.util.Log +import android.view.ViewGroup +import android.widget.FrameLayout +import android.widget.LinearLayout +import androidx.appcompat.app.AppCompatActivity +import com.example.qml_in_kotlin_based_android_project.databinding.ActivityMainBinding +import org.qtproject.qt.android.QtQuickView + +class MainActivity : AppCompatActivity(), QtQuickView.StatusChangeListener { + + private val TAG = "myTag" + private val m_colors: Colors = Colors() + private lateinit var m_binding: ActivityMainBinding + private var m_qmlButtonSignalListenerId = 0 + private var m_qmlView: QtQuickView? = null + private val m_statusNames = hashMapOf( + QtQuickView.STATUS_READY to "READY", + QtQuickView.STATUS_LOADING to "LOADING", + QtQuickView.STATUS_ERROR to "ERROR", + QtQuickView.STATUS_NULL to "NULL" + ) + //! [onCreate] + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + //! [binding] + m_binding = ActivityMainBinding.inflate(layoutInflater) + val view = m_binding.root + setContentView(view) + //! [binding] + + m_binding.signalSwitch.setOnClickListener { switchListener() } + + //! [m_qmlView] + m_qmlView = QtQuickView( + this, "qrc:/qt/qml/qml_in_android_view/main.qml", + "qml_in_android_view" + ) + //! [m_qmlView] + + // Set status change listener for m_qmlView + // listener implemented below in OnStatusChanged + //! [setStatusChangeListener] + m_qmlView!!.setStatusChangeListener(this) + //! [setStatusChangeListener] + + //! [layoutParams] + val params: ViewGroup.LayoutParams = FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT + ) + m_binding.qmlFrame.addView(m_qmlView, params) + //! [layoutParams] + + m_binding.changeColorButton.setOnClickListener { onClickListener() } + + // Check target device orientation on launch + handleOrientationChanges() + } + //! [onCreate] + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + handleOrientationChanges() + } + + private fun handleOrientationChanges() { + // When specific target device display configurations (listed in AndroidManifest.xml + // android:configChanges) change, get display metrics and make needed changes to UI + val displayMetrics = DisplayMetrics() + windowManager.defaultDisplay.getMetrics(displayMetrics) + val qmlFrameLayoutParams = m_binding.qmlFrame.layoutParams + val linearLayoutParams = m_binding.kotlinLinear.layoutParams + + if (displayMetrics.heightPixels > displayMetrics.widthPixels) { + m_binding.mainLinear.orientation = LinearLayout.VERTICAL + qmlFrameLayoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT + qmlFrameLayoutParams.height = 0 + linearLayoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT + linearLayoutParams.height = 0 + } else { + m_binding.mainLinear.orientation = LinearLayout.HORIZONTAL + qmlFrameLayoutParams.width = 0 + qmlFrameLayoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT + linearLayoutParams.width = 0 + linearLayoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT + } + m_binding.qmlFrame.layoutParams = qmlFrameLayoutParams + m_binding.kotlinLinear.layoutParams = linearLayoutParams + } + //! [onClickListener] + private fun onClickListener() { + // Set the QML view root object property "colorStringFormat" value to + // color from Colors.getColor() + m_qmlView!!.setProperty("colorStringFormat", m_colors.getColor()) + + val qmlBackgroundColor = m_qmlView!!.getProperty<String>("colorStringFormat") + + // Display the QML View background color code + m_binding.getPropertyValueText.text = qmlBackgroundColor + + // Display the QML View background color in a view + m_binding.colorBox.setBackgroundColor(Color.parseColor(qmlBackgroundColor)) + } + //! [onClickListener] + + private fun switchListener() { + // Disconnect QML button signal listener if switch is On using the saved signal listener Id + // and connect it again if switch is turned off + if (m_binding.signalSwitch.isChecked) { + Log.v(TAG, "QML button onClicked signal listener disconnected") + m_binding.switchText.setText(R.string.connect_qml_button_signal_listener) + //! [disconnect qml signal listener] + m_qmlView!!.disconnectSignalListener(m_qmlButtonSignalListenerId) + //! [disconnect qml signal listener] + } else { + Log.v(TAG, "QML button onClicked signal listener connected") + m_binding.switchText.setText(R.string.disconnect_qml_button_signal_listener) + m_qmlButtonSignalListenerId = m_qmlView!!.connectSignalListener<Any>( + "onClicked", + Any::class.java + ) { t: String?, value: Any? -> + Log.i(TAG, "QML button clicked") + m_binding.kotlinLinear.setBackgroundColor(Color.parseColor(m_colors.getColor())) + } + } + } + + //! [onStatusChanged] + override fun onStatusChanged(status: Int) { + Log.v(TAG, "Status of QtQuickView: $status") + + val qmlStatus = (resources.getString(R.string.qml_view_status) + + m_statusNames[status]) + + // Show current QML View status in a textview + m_binding.qmlStatus.text = qmlStatus + + // Connect signal listener to "onClicked" signal from main.qml + // addSignalListener returns int which can be used later to identify the listener + //! [qml signal listener] + if (status == QtQuickView.STATUS_READY && !m_binding.signalSwitch.isChecked) { + m_qmlButtonSignalListenerId = m_qmlView!!.connectSignalListener( + "onClicked", Any::class.java + ) { _: String?, _: Any? -> + Log.v(TAG, "QML button clicked") + m_binding.kotlinLinear.setBackgroundColor(Color.parseColor(m_colors.getColor())) + } + } + //! [qml signal listener] + } + //! [onStatusChanged] +} diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/drawable/ic_launcher_background.xml b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000000..ca3826a46c --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?> +<vector + android:height="108dp" + android:width="108dp" + android:viewportHeight="108" + android:viewportWidth="108" + xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#3DDC84" + android:pathData="M0,0h108v108h-108z"/> + <path android:fillColor="#00000000" android:pathData="M9,0L9,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,0L19,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M29,0L29,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M39,0L39,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M49,0L49,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M59,0L59,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M69,0L69,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M79,0L79,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M89,0L89,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M99,0L99,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,9L108,9" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,19L108,19" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,29L108,29" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,39L108,39" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,49L108,49" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,59L108,59" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,69L108,69" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,79L108,79" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,89L108,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,99L108,99" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,29L89,29" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,39L89,39" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,49L89,49" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,59L89,59" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,69L89,69" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,79L89,79" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M29,19L29,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M39,19L39,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M49,19L49,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M59,19L59,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M69,19L69,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M79,19L79,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> +</vector> diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/drawable/ic_launcher_foreground.xml b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000000..7706ab9e6d --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:aapt="http://schemas.android.com/aapt" + android:width="108dp" + android:height="108dp" + android:viewportWidth="108" + android:viewportHeight="108"> + <path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z"> + <aapt:attr name="android:fillColor"> + <gradient + android:endX="85.84757" + android:endY="92.4963" + android:startX="42.9492" + android:startY="49.59793" + android:type="linear"> + <item + android:color="#44000000" + android:offset="0.0" /> + <item + android:color="#00000000" + android:offset="1.0" /> + </gradient> + </aapt:attr> + </path> + <path + android:fillColor="#FFFFFF" + android:fillType="nonZero" + android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z" + android:strokeWidth="1" + android:strokeColor="#00000000" /> +</vector> diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/layout/activity_main.xml b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000000..03f01fdd25 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/mainLinear" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".MainActivity" + android:orientation="vertical" + android:baselineAligned="false"> + + <FrameLayout + android:id="@+id/qmlFrame" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1"> + + </FrameLayout> + + <LinearLayout + android:id="@+id/kotlinLinear" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:background="@color/lilac" + android:orientation="vertical"> + + + <TextView + android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="8dp" + android:gravity="center_horizontal" + android:includeFontPadding="false" + android:text="@string/kotlin" + android:textColor="@color/white" + android:textSize="24sp" + android:textStyle="bold" /> + + <TextView + android:id="@+id/qmlStatus" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="16dp" + android:gravity="center_horizontal" + android:text="@string/qml_view_status" + android:textColor="@color/white"/> + + <LinearLayout + android:id="@+id/buttonAndSwitchLayout" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal" + android:orientation="horizontal" + android:layout_marginTop="16dp"> + + <LinearLayout + android:id="@+id/buttonLinearLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:layout_weight="1"> + + <TextView + android:id="@+id/changeColorText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal" + android:maxLines="3" + android:text="@string/change_qml_background" + android:textColor="@color/white" /> + + <Button + android:id="@+id/changeColorButton" + android:layout_width="100dp" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="8dp" + android:text="@string/button" + android:textSize="14sp" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/switchLinearLayout" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:layout_weight="1"> + + <TextView + android:id="@+id/switchText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal" + android:maxLines="3" + android:text="@string/disconnect_qml_button_signal_listener" + android:textColor="@color/white" /> + + <androidx.appcompat.widget.SwitchCompat + android:id="@+id/signalSwitch" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="8dp" + android:switchTextAppearance="@android:style/TextAppearance.Small" + android:textOff="@string/off" + android:textOn="@string/on" + app:switchTextAppearance="@style/switchStyle" + app:showText="true" + tools:ignore="UseSwitchCompatOrMaterialXml" /> + </LinearLayout> + + </LinearLayout> + + <LinearLayout + android:id="@+id/qmlColorLinear" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="horizontal" + android:padding="10dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:layout_weight="1"> + + <TextView + android:id="@+id/qmlViewBackgroundText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal" + android:maxLines="2" + android:text="@string/qml_view_background_color" + android:textColor="@color/white" /> + + <TextView + android:id="@+id/getPropertyValueText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal" + android:textColor="@color/white" /> + </LinearLayout> + + <View + android:id="@+id/colorBox" + android:layout_width="100dp" + android:layout_height="50dp" + android:layout_gravity="center_horizontal" + android:background="@android:color/transparent" + android:layout_weight="0"/> + </LinearLayout> + + </LinearLayout> + +</LinearLayout> diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000000..3ff874648d --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> + diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000000..3ff874648d --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> + diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher.webp Binary files differnew file mode 100644 index 0000000000..f043b66984 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp Binary files differnew file mode 100644 index 0000000000..53e483046c --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp Binary files differnew file mode 100644 index 0000000000..5646cd4957 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher.webp Binary files differnew file mode 100644 index 0000000000..8121c6f7c2 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp Binary files differnew file mode 100644 index 0000000000..da81ab2c05 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp Binary files differnew file mode 100644 index 0000000000..d68eb57118 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher.webp Binary files differnew file mode 100644 index 0000000000..818fa2b2dc --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp Binary files differnew file mode 100644 index 0000000000..57d6591183 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp Binary files differnew file mode 100644 index 0000000000..cf05b107f0 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp Binary files differnew file mode 100644 index 0000000000..30855a994a --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp Binary files differnew file mode 100644 index 0000000000..385517a7eb --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp Binary files differnew file mode 100644 index 0000000000..10ec83e5f4 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp Binary files differnew file mode 100644 index 0000000000..5a9dab1d44 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp Binary files differnew file mode 100644 index 0000000000..62d203c390 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp Binary files differnew file mode 100644 index 0000000000..52d2c11162 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/values/colors.xml b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/values/colors.xml new file mode 100644 index 0000000000..d38e4ce6b3 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="purple_500">#FF6200EE</color> + <color name="purple_700">#FF3700B3</color> + <color name="teal_200">#FF03DAC5</color> + <color name="teal_700">#FF018786</color> + <color name="black">#FF000000</color> + <color name="white">#FFFFFFFF</color> + <color name="lilac">#AF93DF</color> +</resources> diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/values/strings.xml b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/values/strings.xml new file mode 100644 index 0000000000..12661a6334 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/values/strings.xml @@ -0,0 +1,12 @@ +<resources> + <string name="app_name">qml_in_kotlin_based_android_project</string> + <string name="button">Change color</string> + <string name="kotlin">Kotlin</string> + <string name="change_qml_background">Tap button to change QML view background color</string> + <string name="disconnect_qml_button_signal_listener">Tap switch to disconnect QML button signal listener</string> + <string name="connect_qml_button_signal_listener">Tap switch to connect QML button signal listener</string> + <string name="on">On</string> + <string name="off">Off</string> + <string name="qml_view_status">QML view status: </string> + <string name="qml_view_background_color">QML view background color:</string> +</resources> diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/values/styles.xml b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/values/styles.xml new file mode 100644 index 0000000000..bce864063a --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/values/styles.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="switchStyle"> + <item name="android:textSize">12sp</item> + </style> +</resources> diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/values/themes.xml b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/values/themes.xml new file mode 100644 index 0000000000..b501d7b323 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ +<resources xmlns:tools="http://schemas.android.com/tools"> + <!-- Base application theme. --> + <style name="Theme.Qml_in_kotlin_based_android_project" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> + <!-- Primary brand color. --> + <item name="colorPrimary">@color/purple_500</item> + <item name="colorPrimaryVariant">@color/purple_700</item> + <item name="colorOnPrimary">@color/white</item> + <!-- Secondary brand color. --> + <item name="colorSecondary">@color/teal_200</item> + <item name="colorSecondaryVariant">@color/teal_700</item> + <item name="colorOnSecondary">@color/black</item> + <!-- Status bar color. --> + <item name="android:statusBarColor">?attr/colorPrimaryVariant</item> + <!-- Customize your theme here. --> + </style> +</resources> diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/xml/backup_rules.xml b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/xml/backup_rules.xml new file mode 100644 index 0000000000..148c18b659 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/xml/backup_rules.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + Sample backup rules file; uncomment and customize as necessary. + See https://developer.android.com/guide/topics/data/autobackup + for details. + Note: This file is ignored for devices older that API 31 + See https://developer.android.com/about/versions/12/backup-restore +--> +<full-backup-content> + <!-- + <include domain="sharedpref" path="."/> + <exclude domain="sharedpref" path="device.xml"/> +--> +</full-backup-content> diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/xml/data_extraction_rules.xml b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 0000000000..0c4f95cab9 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/app/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + Sample data extraction rules file; uncomment and customize as necessary. + See https://developer.android.com/about/versions/12/backup-restore#xml-changes + for details. +--> +<data-extraction-rules> + <cloud-backup> + <!-- TODO: Use <include> and <exclude> to control what is backed up. + <include .../> + <exclude .../> + --> + </cloud-backup> + <!-- + <device-transfer> + <include .../> + <exclude .../> + </device-transfer> + --> +</data-extraction-rules> diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/build.gradle b/examples/platforms/android/qml_in_kotlin_based_android_project/build.gradle new file mode 100644 index 0000000000..97e3f23ff2 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/build.gradle @@ -0,0 +1,5 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { +id 'com.android.application' version '8.2.2' apply false + id 'org.jetbrains.kotlin.android' version '1.9.22' apply false +} diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/gradle.properties b/examples/platforms/android/qml_in_kotlin_based_android_project/gradle.properties new file mode 100644 index 0000000000..2cbd6d19d3 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/gradle.properties @@ -0,0 +1,23 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/gradle/wrapper/gradle-wrapper.properties b/examples/platforms/android/qml_in_kotlin_based_android_project/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..a3353773cb --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Thu Mar 21 11:14:46 EET 2024 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/examples/platforms/android/qml_in_kotlin_based_android_project/settings.gradle b/examples/platforms/android/qml_in_kotlin_based_android_project/settings.gradle new file mode 100644 index 0000000000..a30bfe06d0 --- /dev/null +++ b/examples/platforms/android/qml_in_kotlin_based_android_project/settings.gradle @@ -0,0 +1,17 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "qml_in_kotlin_based_android_project" +include ':app' |