Skip to content

Commit

Permalink
Felgo v3.7.0 NAI build from git:12f4ea7, Qt 5.13.2
Browse files Browse the repository at this point in the history
  • Loading branch information
felgoba committed Nov 5, 2020
0 parents commit 6ac241c
Show file tree
Hide file tree
Showing 88 changed files with 1,189 additions and 0 deletions.
8 changes: 8 additions & 0 deletions NativeIntegrationExample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
1 change: 1 addition & 0 deletions NativeIntegrationExample/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
32 changes: 32 additions & 0 deletions NativeIntegrationExample/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.felgo.nativeintegrationexample"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.felgo:felgo-android:3.+'

implementation 'org.jetbrains:annotations:15.0'
implementation 'com.android.support:support-annotations:28.0.0'
}
21 changes: 21 additions & 0 deletions NativeIntegrationExample/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
21 changes: 21 additions & 0 deletions NativeIntegrationExample/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<manifest package="com.felgo.nativeintegrationexample"
xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity android:name=".MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
141 changes: 141 additions & 0 deletions NativeIntegrationExample/app/src/main/assets/qml/Cube3D.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import VPlayApps 1.0
import QtQuick 2.9
// 3d imports
import QtQuick.Scene3D 2.0
import Qt3D.Core 2.0
import Qt3D.Render 2.0
import Qt3D.Input 2.0
import Qt3D.Extras 2.0
import QtSensors 5.9

App {
// use a license key to remove the splash screen
licenseKey: "7CFB6B4DBEAF65BACCA104174D8D10074AB9DE51CD8FADCE794842AC15A424B5DB0ADE80EA99588A8E581B8F019647F1C97F6569C4F81C27E76E8EFF8CB5581C1E761EDF6DC35D826EFFBB10C6041C97220674F01F425134E53A69B7BBCB2B31A3280C2A024F4123FE06EDAE4D31457F02FCB57EC9395DC271D2689AE58A78EB161021E10DDFCC4A069A5280CB401FC5D5207DDD384EF42EBAAA2F13FA7309A57A70AB5D164416AF06F000C5E3A0EC3871D47B876E0EB807171EF09F01A631B6CBF12ECD02F11677E93F0792A57EE53F83AE3E11AD94D1AF5FC5297B1E35F956EB8C0F8AF72DAADEB0B5320DA93F8A2396A52FB53F1107837C5DF03271B938612C0DF798B0F4A300B233FC3C7D8BFC7D52DFB4C0A216F9216FCCDD2C9A6C4F7288B71985AD6B3201F052D2B60DA904126FD44F74A195D9E46C4F6F6A24643EEA"


// Set screen to portrait in live client app (not needed for normal deployment)
onInitTheme: nativeUtils.preferredScreenOrientation = NativeUtils.ScreenOrientationPortrait

RotationSensor {
id: sensor
active: true
// We copy reading to custom property to use behavior on it
property real readingX: reading ? reading.x : 0
property real readingY: reading ? reading.y : 0
// We animate property changes for smoother movement of the cube
Behavior on readingX {NumberAnimation{duration: 200}}
Behavior on readingY {NumberAnimation{duration: 200}}

Component.onCompleted: {
console.log("sensor completed", active, busy, connectedToBackend, "types:" + QmlSensors.sensorTypes())
start()
console.log("sensor started", active, busy, connectedToBackend)
}
onActiveChanged: console.log("sensor active", active, busy, connectedToBackend)
// onBusyChanged: console.log("sensor busy", active, busy, connectedToBackend)

}

Page {
title: "3D Cube on Page"
backgroundColor: Theme.secondaryBackgroundColor

Column {
padding: dp(15)
spacing: dp(5)

AppText {
text: "x-axis " + sensor.readingX.toFixed(2)
}
AppText {
text: "y-axis " + sensor.readingY.toFixed(2)
}
}

// 3d object on top of camera
Scene3D {
id: scene3d
anchors.fill: parent
focus: true
aspects: ["input", "logic"]
cameraAspectRatioMode: Scene3D.AutomaticAspectRatio

Entity {

// The camera for the 3d world, to view our cube
Camera {
id: camera3D
projectionType: CameraLens.PerspectiveProjection
fieldOfView: 45
nearPlane : 0.1
farPlane : 1000.0
position: Qt.vector3d( 0.0, 0.0, 40.0 )
upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
}

components: [
RenderSettings {
activeFrameGraph: ForwardRenderer {
camera: camera3D
clearColor: "transparent"
}
},
InputSettings { }
]

PhongMaterial {
id: material
ambient: Theme.tintColor // Also available are diffuse, specular + shininess to control lighting behavior
}

// The 3d mesh for the cube
CuboidMesh {
id: cubeMesh
xExtent: 8
yExtent: 8
zExtent: 8
}

// Transform (rotate) the cube depending on sensor reading
Transform {
id: cubeTransform
// Create the rotation quaternion from the sensor reading
rotation: fromAxesAndAngles(Qt.vector3d(1,0,0), sensor.readingX*2, Qt.vector3d(0,1,0), sensor.readingY*2)
}

// The actuac 3d cube that consist of a mesh, a material and a transform component
Entity {
id: sphereEntity
components: [ cubeMesh, material, cubeTransform ]
}
}
} // Scene3D

// Color selection row
Row {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
spacing: dp(5)
padding: dp(15)

Repeater {
model: [Theme.tintColor, "red", "green", "#FFFF9500"]

Rectangle {
color: modelData
width: dp(48)
height: dp(48)
radius: dp(5)

MouseArea {
anchors.fill: parent
onClicked: {
material.ambient = modelData
}
}
}
}
}
} // Page
} // App
3 changes: 3 additions & 0 deletions NativeIntegrationExample/app/src/main/assets/qml/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stage": "publish"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.felgo.nativeintegrationexample;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.util.Log;

import com.felgo.ui.FelgoAndroidActivity;
import com.felgo.ui.FelgoAndroidFragment;

import org.qtproject.qt5.android.bindings.QtFragment;

public class MainActivity extends FelgoAndroidActivity {

private FelgoAndroidFragment m_qtFragment;

@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// activity_main.xml loads QML fragment:
setContentView(R.layout.activity_main);

Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

m_qtFragment = (FelgoAndroidFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_container);

// show QML fragment via code: (uncomment FrameLayout in activity_main.xml)
/* try {
getFragmentManager().beginTransaction()
.replace(R.id.fragment_container, new FelgoAndroidFragment()
.setQmlSource(getApplicationContext(), "qml/Cube3D.qml"),
null)
.addToBackStack(null)
.commit();
} catch (IOException ex) {
// qml file not found
Log.w("MainActivity", "Could not load QML file", ex);
}*/
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<vector xmlns:aapt="http://schemas.android.com/aapt"
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
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="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1"/>
</vector>
Loading

0 comments on commit 6ac241c

Please sign in to comment.