Add example showcasing Embedding QML to native Android Java project
Add new example showcasing how to embed QML into native Android Java application. New folder platforms/android, which include the new Android Java project and Qt project in their own project folders. Pick-to: 6.7 Fixes: QTBUG-120716 Change-Id: Ibab8b7653eb7d4199b93630d03f3543d0d734c4a Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
|
@ -6,6 +6,7 @@ qt_examples_build_begin(EXTERNAL_BUILD)
|
|||
add_subdirectory(qml)
|
||||
if(TARGET Qt6::Quick)
|
||||
add_subdirectory(quick)
|
||||
add_subdirectory(platforms)
|
||||
endif()
|
||||
if(TARGET Qt6::QuickTemplates2)
|
||||
add_subdirectory(quickcontrols)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
# Copyright (C) 2024 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
if(ANDROID)
|
||||
add_subdirectory(android)
|
||||
endif()
|
|
@ -0,0 +1,10 @@
|
|||
*.user
|
||||
build/
|
||||
qml_in_java_based_android_project/.idea/
|
||||
qml_in_java_based_android_project/.gradle/
|
||||
qml_in_java_based_android_project/local.properties
|
||||
qml_in_java_based_android_project/app/libs/
|
||||
qml_in_java_based_android_project/app/src/main/res/xml/qtprovider_paths.xml
|
||||
qml_in_java_based_android_project/app/src/main/res/values/libs.xml
|
||||
qml_in_java_based_android_project/app/assets/android_rcc_bundle.rcc
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# 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)
|
|
@ -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 qml_in_android_view
|
||||
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}
|
||||
)
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 .
|
||||
)
|
|
@ -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 26
|
||||
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'
|
||||
}
|
||||
|
|
@ -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>
|
||||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,165 @@
|
|||
// 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.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.qtproject.qt.android.QtQuickView;
|
||||
|
||||
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 QtQuickView.StatusChangeListener {
|
||||
|
||||
private static final String TAG = "myTag";
|
||||
private final Colors m_colors = new Colors();
|
||||
private final Map<Integer, String> m_statusNames = new HashMap<Integer, String>() {{
|
||||
put(QtQuickView.STATUS_READY, " READY");
|
||||
put(QtQuickView.STATUS_LOADING, " LOADING");
|
||||
put(QtQuickView.STATUS_ERROR, " ERROR");
|
||||
put(QtQuickView.STATUS_NULL, " NULL");
|
||||
}};
|
||||
private int m_qmlButtonSignalListenerId;
|
||||
private LinearLayout m_mainLinear;
|
||||
private FrameLayout m_qmlFrameLayout;
|
||||
private QtQuickView m_qmlView;
|
||||
private LinearLayout m_androidControlsLayout;
|
||||
private TextView m_getPropertyValueText;
|
||||
private TextView m_qmlStatus;
|
||||
private SwitchCompat m_switch;
|
||||
private View m_box;
|
||||
|
||||
@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.qmlStatus);
|
||||
m_androidControlsLayout = findViewById(R.id.javaLinear);
|
||||
m_box = findViewById(R.id.box);
|
||||
|
||||
m_switch = findViewById(R.id.switch1);
|
||||
m_switch.setOnClickListener(view -> switchListener());
|
||||
|
||||
m_qmlView = new QtQuickView(this, "qrc:/qt/qml/qml_in_android_view/main.qml",
|
||||
"qml_in_android_view");
|
||||
// Set status change listener for m_qmlView
|
||||
// listener implemented below in OnStatusChanged
|
||||
m_qmlView.setStatusChangeListener(this);
|
||||
ViewGroup.LayoutParams params = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
m_qmlFrameLayout = findViewById(R.id.qmlFrame);
|
||||
m_qmlFrameLayout.addView(m_qmlView, params);
|
||||
|
||||
Button button = findViewById(R.id.button);
|
||||
button.setOnClickListener(view -> onClickListener());
|
||||
|
||||
// Check target device orientation on launch
|
||||
handleOrientationChanges();
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(int status) {
|
||||
Log.i(TAG, "Status of QtQuickView: " + status);
|
||||
|
||||
final String qmlStatus = getResources().getString(R.string.qml_view_status)
|
||||
+ m_statusNames.get(status);
|
||||
|
||||
// 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
|
||||
if (status == QtQuickView.STATUS_READY && !m_switch.isChecked()) {
|
||||
m_qmlButtonSignalListenerId = m_qmlView.connectSignalListener("onClicked", Object.class,
|
||||
(String signal, Object o) -> {
|
||||
Log.i(TAG, "QML button clicked");
|
||||
m_androidControlsLayout.setBackgroundColor(Color.parseColor(m_colors.getColor()));
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void onClickListener() {
|
||||
// Set the QML view root object property "colorStringFormat" value to
|
||||
// color from Colors.getColor()
|
||||
m_qmlView.setProperty("colorStringFormat", m_colors.getColor());
|
||||
|
||||
String qmlBackgroundColor = m_qmlView.getProperty("colorStringFormat");
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
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);
|
||||
m_qmlView.disconnectSignalListener(m_qmlButtonSignalListenerId);
|
||||
} else {
|
||||
Log.i(TAG, "QML button onClicked signal listener connected");
|
||||
text.setText(R.string.disconnect_qml_button_signal_listener);
|
||||
m_qmlButtonSignalListenerId = m_qmlView.connectSignalListener("onClicked",
|
||||
Object.class, (String t, Object value) -> {
|
||||
Log.i(TAG, "QML button clicked");
|
||||
m_androidControlsLayout.setBackgroundColor(Color.parseColor(m_colors.getColor()));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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>
|
|
@ -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>
|
||||
|
|
@ -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/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/button"
|
||||
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/switch1"
|
||||
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/box"
|
||||
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>
|
||||
|
|
@ -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>
|
||||
|
|
@ -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>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 21 KiB |
|
@ -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>
|
||||
|
|
@ -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>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="switchStyle">
|
||||
<item name="android:textSize">12sp</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -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>
|
|
@ -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>
|
||||
|
|
@ -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>
|
||||
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
|
|
@ -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
|
|
@ -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'
|