Commit 320ef18e authored by Richard Lin's avatar Richard Lin
Browse files

Add: AndroidController

1. AndroidController is simulate the app running on the IVI.
2. By this app, one can change the scene on cluster.
3. (TODO)By this app, one can download scenes or delete scenes to cluster.
parent 97242ccf
File mode changed from 100644 to 100755
QT += quick remoteobjects
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
dynamicclient.cpp \
sceneinfo.cpp \
scenemanager.cpp
RESOURCES += \
qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
HEADERS += \
dynamicclient.h \
sceneinfo.h \
scenemanager.h
android*{
message("android")
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
deployment.path = /assets/
deployment.files += \
OnlineScenes/Archermind/sceneInfo.json \
OnlineScenes/kria-cluster-2d/sceneInfo.json \
OnlineScenes/kria-cluster-3d/sceneInfo.json \
OnlineScenes/qmlcluster/sceneInfo.json \
OnlineScenes/Triton/sceneInfo.json \
OnlineScenes/Archermind/libArchemind.so \
OnlineScenes/kria-cluster-2d/libkria-cluster-2d.so \
OnlineScenes/kria-cluster-3d/libkria-cluster-3d.so \
OnlineScenes/qmlcluster/libqmlcluster.so \
OnlineScenes/Triton/libTriton.so \
OnlineScenes/Archermind/snapShot.png \
OnlineScenes/kria-cluster-2d/snapShot.png \
OnlineScenes/kria-cluster-3d/snapShot.png \
OnlineScenes/qmlcluster/snapShot.png \
OnlineScenes/Triton/snapShot.png
INSTALLS += deployment
# INCLUDEPATH += /usr/include
DISTFILES += \
android/AndroidManifest.xml \
android/gradle/wrapper/gradle-wrapper.jar \
android/gradlew \
android/res/values/libs.xml \
android/build.gradle \
android/gradle/wrapper/gradle-wrapper.properties \
android/gradlew.bat \
android/assets/OnlineScenes/Archermind/sceneInfo.json \
android/assets/OnlineScenes/kria-cluster-2d/sceneInfo.json \
android/assets/OnlineScenes/kria-cluster-3d/sceneInfo.json \
android/assets/OnlineScenes/qmlcluster/sceneInfo.json \
android/assets/OnlineScenes/Triton/sceneInfo.json \
android/assets/OnlineScenes/Archermind/libArchemind.so \
android/assets/OnlineScenes/kria-cluster-2d/libkria-cluster-2d.so \
android/assets/OnlineScenes/kria-cluster-3d/libkria-cluster-3d.so \
android/assets/OnlineScenes/qmlcluster/libqmlcluster.so \
android/assets/OnlineScenes/Triton/libTriton.so \
android/assets/OnlineScenes/Archermind/snapShot.png \
android/assets/OnlineScenes/kria-cluster-2d/snapShot.png \
android/assets/OnlineScenes/kria-cluster-3d/snapShot.png \
android/assets/OnlineScenes/qmlcluster/snapShot.png \
android/assets/OnlineScenes/Triton/snapShot.png
}
contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
ANDROID_EXTRA_LIBS =
}
/****************************************************************************
**
** Copyright (C) 2017, 2018 Pelagicore AG
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Triton IVI UI.
**
** $QT_BEGIN_LICENSE:GPL-QTAS$
** Commercial License Usage
** Licensees holding valid commercial Qt Automotive Suite licenses may use
** this file in accordance with the commercial license agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and The Qt Company. For
** licensing terms and conditions see https://www.qt.io/terms-conditions.
** For further information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
** SPDX-License-Identifier: GPL-3.0
**
****************************************************************************/
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
Dialog {
id: connectionDialog
property string url
property string statusText
property var lastUrls
modal: true
signal accepted(bool accepted)
contentItem: Frame {
implicitWidth: connectionDialog.width
implicitHeight: connectionDialog.height
ColumnLayout {
anchors.fill: parent
Label {
text: qsTr("Connection settings")
Layout.alignment: Qt.AlignCenter
}
ColumnLayout {
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft
Label {
text: qsTr("Server URL")
}
ComboBox {
id: urlCombo
Layout.fillWidth: true
editable: true
editText: url
model: lastUrls
onEditTextChanged: url = editText
height: d.ratio(30)
}
}
RowLayout {
spacing: d.ratio(20)
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
Button {
text: qsTr("Connect")
onClicked: connectionDialog.accepted(true)
}
Button {
text: qsTr("Cancel")
onClicked: connectionDialog.accepted(false)
}
}
}
}
}
import QtQuick 2.8
import QtQuick.Window 2.2
Window {
id: root
visible: true
width: 720
height: 1920
Item {
id: d
function ratio(origninal) {
return origninal*root.width/720
}
}
color: "black"//"mintcream"
Component.onCompleted: {
connectionDialog.open()
}
ConnectionDialog {
id: connectionDialog
statusText: connectionManager.stateString
lastUrls: connectionManager.lastUrls
x: (parent.width-width) /2
y: (parent.height-height) /2
width: parent.width / 1.2
height: parent.height / 3
onAccepted: {
if (accepted) {
connectionManager.connectToServer(url);
}
connectionDialog.close();
}
Connections {
target: connectionManager
onServerUrlChanged: {
if (connectionManager.serverUrl.toString().length)
connectionDialog.url = connectionManager.serverUrl.toString();
}
}
Connections {
target: connectionManager
onIsValidChanged: {
if (connectionManager.isValid)
connectionDialog.close();
}
}
}
Text {
id: state
font.pixelSize: d.ratio(10)
color: "white"
text: "State:" + connectionManager.stateString
x: root.width - width - d.ratio(20)
y: root.height - height - d.ratio(20)
horizontalAlignment: Text.AlignRight
}
Text {
id: error
font.pixelSize: d.ratio(10)
color: "white"
text: "Error:" + connectionManager.errorString
x: d.ratio(20)
y: root.height - height - d.ratio(20)
horizontalAlignment: Text.AlignRight
}
MouseArea {
id: showConnection
x: 0
y: state.y
width: root.width
height: root.height - state.y
onClicked: {
connectionDialog.open();
}
}
SceneSelector {
id: sceneSelector
x: 0
y: 0
width: root.width
height: state.y
}
}
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Scene Changing Framework Demo.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.7
GridView {
id: ss
model: sceneModel
ListModel {
id: sceneModel
}
signal currentSceneChanged
function loadModel() {
sceneModel.clear();
var list = sceneManager.sceneList;
console.log("scene count = " + list.length )
for (var j = 0; j < list.length; j ++) {
sceneModel.append({
name: list[j].name,
version: list[j].version,
description: list[j].description,
isDownload: list[j].isDownload,
isOnSite: 0,
isCurrent: 0});
}
console.log("loacl model count = " + sceneModel.count )
for (var i = 0; i < onsiteSceneManager.sceneCount(); i ++) {
var found = 0;
for (var k = 0; k < sceneModel.count; k ++) {
var onsiteName = onsiteSceneManager.sceneName(i)
var onsiteVersion = onsiteSceneManager.sceneVersion(i)
if (sceneModel.get(k).name === onsiteName && sceneModel.get(k).version === onsiteVersion ) {
sceneModel.setProperty(k, "isOnSite", 1);
found = 1;
break;
}
}
if (found === 0) {
sceneModel.append({
name: onsiteSceneManager.sceneName(i),
version: onsiteSceneManager.sceneVersion(i),
description: "",
isDownload: 0,
isOnSite: 1,
isCurrent: 0});
}
}
processCurrent();
}
function processCurrent() {
var currentSceneName = onsiteSceneManager.currentSceneName();
for (var k = 0; k < sceneModel.count; k ++) {
if (sceneModel.get(k).name === currentSceneName ) {
sceneModel.setProperty(k, "isCurrent", 1);
break;
}
}
currentSceneChanged();
}
Connections {
target: connectionManager
onIsValidChanged: {
if(connectionManager.isValid)
loadModel()
}
}
Connections {
target: sceneManager
onSceneListChanged: {
loadModel()
}
}
Connections {
target: onsiteSceneManager
onCurrentSceneChanged: {
processCurrent()
}
}
focus: true
cellHeight: ss.width / 2
cellWidth: cellHeight
delegate: Rectangle {
id: sceneItem
property bool isSelected: false
width: ss.width / 2.2
height: width
clip: true
border.color: color
border.width: d.ratio(2)
color: isSelected? "blue" : "lightblue"
Image {
id: sceneSnapShot
x:0
width: sceneItem.width * 2
height: sourceSize.height * (width / sourceSize.width)
anchors.bottom: sceneItem.bottom
fillMode: Image.PreserveAspectFit
source: "image://sceneManager/" + name
}
SequentialAnimation {
running: isSelected
loops: Animation.Infinite
PauseAnimation {
duration: 1000
}
NumberAnimation {
target: sceneSnapShot
property: "x"
duration: 4000
from: 0
to: sceneItem.width - sceneSnapShot.width
}
PauseAnimation {
duration: 1000
}
NumberAnimation {
target: sceneSnapShot
property: "x"
duration: 4000
from: sceneItem.width - sceneSnapShot.width
to: 0
}
}
Text {
id: sceneName
opacity: 1
color: "mintcream"
font.pixelSize: sceneItem.height * 0.15
anchors.left: sceneItem.left
text: name
Behavior on opacity{
PropertyAnimation {duration: 1000}
}
}
Column {
id: doubleClickContent
opacity: 0
anchors.fill: sceneItem
Rectangle {
id: pbSetScene
color: "green"
width: doubleClickContent.width
height: doubleClickContent.height * 0.3
Text {
id: pbText
width: pbSetScene.width
height: pbSetScene.height
anchors.verticalCenter: parent.verticalCenter
color: "white"
text: " click to rock"
font.pixelSize: sceneItem.height * 0.15
}
Row {
anchors.right: pbSetScene.right
anchors.bottom: pbSetScene.bottom
height: pbSetScene.height
Repeater {
height: doubleClickContent.height * 0.05
model: 4
Image {
id: name
source: "qrc:/img/star.png"
width: doubleClickContent.height * 0.05
height: doubleClickContent.height * 0.05
}
}
Text {
text: " 4.5 "
height: doubleClickContent.height * 0.05
color: "white"
font.pixelSize: sceneItem.height * 0.05
}
}
}
Text {
id: sceneDescripion
width: doubleClickContent.width
height: doubleClickContent.height * 0.7
color: "mintcream"
font.pixelSize: sceneItem.height * 0.1
text: description
wrapMode: Text.WordWrap
}
Behavior on opacity{
PropertyAnimation {duration: 1000}
}
}
MouseArea {
anchors.fill: sceneItem
onClicked: {
if(ss.currentIndex === index) {
if (doubleClickContent.opacity !==1) {
//second click
sceneName.opacity = 0;
doubleClickContent.opacity = 1;
} else {
//third click
onsiteSceneManager.setSceneName(name);
}
} else {
ss.currentIndex = index
}
}
}
Connections {
target: ss
onCurrentIndexChanged: {
if (index == ss.currentIndex)
sceneItem.isSelected = true;
else {
sceneItem.isSelected = false;
sceneSnapShot.x = 0;
sceneName.opacity = 1;
doubleClickContent.opacity = 0;
}
}
}
}
}
<?xml version="1.0"?>
<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Used to specify custom system library path to run with local system libs -->
<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>