fixed android setup
added missing c++11 methods
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<manifest package="java.indoor" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
|
<manifest package="indoor.java" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="16"/>
|
<uses-sdk android:minSdkVersion="16"/>
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<application android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/app_name">
|
<application android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/app_name">
|
||||||
|
|
||||||
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="our.java.stuff.MyActivity" android:label="TEST" android:screenOrientation="unspecified">
|
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="indoor.java.MyActivity" android:label="TEST" android:screenOrientation="unspecified">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package our.java.stuff;
|
package indoor.java;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import org.qtproject.qt5.android.bindings.QtActivity;
|
import org.qtproject.qt5.android.bindings.QtActivity;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package java.indoor;
|
package indoor.java;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
|||||||
2
main.cpp
2
main.cpp
@@ -1,3 +1,5 @@
|
|||||||
|
#include <misc/fixc11.h>
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
|
|
||||||
|
|||||||
@@ -11,22 +11,22 @@ MapView::MapView(QWidget* parent) : QGLWidget(parent) {
|
|||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glShadeModel(GL_SMOOTH);
|
//glShadeModel(GL_SMOOTH);
|
||||||
glEnable(GL_LIGHTING);
|
//glEnable(GL_LIGHTING);
|
||||||
glEnable(GL_LIGHT0);
|
//glEnable(GL_LIGHT0);
|
||||||
|
|
||||||
static GLfloat lightPosition[4] = { 0, 0, 10, 1.0 };
|
//static GLfloat lightPosition[4] = { 0, 0, 10, 1.0 };
|
||||||
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
|
//glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::paintGL() {
|
void MapView::paintGL() {
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glLoadIdentity();
|
//glLoadIdentity();
|
||||||
glTranslatef(0.0, 0.0, -10.0);
|
//glTranslatef(0.0, 0.0, -10.0);
|
||||||
glRotatef(20 / 16.0, 1.0, 0.0, 0.0);
|
//glRotatef(20 / 16.0, 1.0, 0.0, 0.0);
|
||||||
glRotatef(30 / 16.0, 0.0, 1.0, 0.0);
|
//glRotatef(30 / 16.0, 0.0, 1.0, 0.0);
|
||||||
glRotatef(60 / 16.0, 0.0, 0.0, 1.0);
|
//glRotatef(60 / 16.0, 0.0, 0.0, 1.0);
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,20 +34,20 @@ MapView::MapView(QWidget* parent) : QGLWidget(parent) {
|
|||||||
int side = qMin(width, height);
|
int side = qMin(width, height);
|
||||||
glViewport((width - side) / 2, (height - side) / 2, side, side);
|
glViewport((width - side) / 2, (height - side) / 2, side, side);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
//glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
//glLoadIdentity();
|
||||||
#ifdef QT_OPENGL_ES_1
|
#ifdef QT_OPENGL_ES_1
|
||||||
glOrthof(-2, +2, -2, +2, 1.0, 15.0);
|
glOrthof(-2, +2, -2, +2, 1.0, 15.0);
|
||||||
#else
|
#else
|
||||||
glOrtho(-2, +2, -2, +2, 1.0, 15.0);
|
//glOrtho(-2, +2, -2, +2, 1.0, 15.0);
|
||||||
#endif
|
#endif
|
||||||
glMatrixMode(GL_MODELVIEW);
|
//glMatrixMode(GL_MODELVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::draw()
|
void MapView::draw()
|
||||||
{
|
{
|
||||||
qglColor(Qt::red);
|
qglColor(Qt::red);
|
||||||
glBegin(GL_QUADS);
|
/*glBegin(GL_QUADS);
|
||||||
glNormal3f(0,0,-1);
|
glNormal3f(0,0,-1);
|
||||||
glVertex3f(-1,-1,0);
|
glVertex3f(-1,-1,0);
|
||||||
glVertex3f(-1,1,0);
|
glVertex3f(-1,1,0);
|
||||||
@@ -78,5 +78,5 @@ MapView::MapView(QWidget* parent) : QGLWidget(parent) {
|
|||||||
glVertex3f(-1,1,0);
|
glVertex3f(-1,1,0);
|
||||||
glVertex3f(-1,-1,0);
|
glVertex3f(-1,-1,0);
|
||||||
glVertex3f(0,0,1.2);
|
glVertex3f(0,0,1.2);
|
||||||
glEnd();
|
glEnd();*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef DEBUG_H
|
#ifndef NAV_DEBUG_H
|
||||||
#define DEBUG_H
|
#define NAV_DEBUG_H
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@@ -13,4 +13,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DEBUG_H
|
#endif // NAV_DEBUG_H
|
||||||
|
|||||||
@@ -2,12 +2,49 @@
|
|||||||
#define FIXC11_H
|
#define FIXC11_H
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
//namespace std {
|
namespace std {
|
||||||
|
|
||||||
// template <typename T> T sqrt(const T val) {return ::sqrt(val);}
|
//template <typename T> T sqrt(const T val) {return ::sqrt(val);}
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
template <typename T> string to_string(const T val) {
|
||||||
|
stringstream ss;
|
||||||
|
ss << val;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> T round(const T val) {
|
||||||
|
return ::round(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
// http://stackoverflow.com/questions/19478687/no-member-named-stoi-in-namespace-std
|
||||||
|
int stoi(const std::string& str) {
|
||||||
|
std::istringstream is(str);
|
||||||
|
int val; is >> val; return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
// analog zu oben
|
||||||
|
float stof(const std::string& str) {
|
||||||
|
std::istringstream is(str);
|
||||||
|
float val; is >> val; return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
// analog zu oben
|
||||||
|
double stod(const std::string& str) {
|
||||||
|
std::istringstream is(str);
|
||||||
|
double val; is >> val; return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
// analog zu oben
|
||||||
|
uint64_t stol(const std::string& str) {
|
||||||
|
std::istringstream is(str);
|
||||||
|
uint64_t val; is >> val; return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // FIXC11_H
|
#endif // FIXC11_H
|
||||||
|
|||||||
5
qml.qrc
5
qml.qrc
@@ -1,6 +1,3 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/"/>
|
||||||
<file>main.qml</file>
|
|
||||||
<file>MainForm.ui.qml</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public:
|
|||||||
/** get the Accelerometer sensor */
|
/** get the Accelerometer sensor */
|
||||||
static AccelerometerSensor& getAccelerometer() {
|
static AccelerometerSensor& getAccelerometer() {
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
return AccelerometerSensor::get();
|
return AccelerometerSensorAndroid::get();
|
||||||
#else
|
#else
|
||||||
return AccelerometerSensorDummy::get();
|
return AccelerometerSensorDummy::get();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef ACCELEROMETERSENSOR_H
|
#ifndef ACCELEROMETERSENSORANDROID_H
|
||||||
#define ACCELEROMETERSENSOR_H
|
#define ACCELEROMETERSENSORANDROID_H
|
||||||
|
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include <QtSensors/QAccelerometer>
|
#include <QtSensors/QAccelerometer>
|
||||||
|
|
||||||
|
#include "../AccelerometerSensor.h"
|
||||||
|
|
||||||
class AccelerometerSensorAndroid : public AccelerometerSensor {
|
class AccelerometerSensorAndroid : public AccelerometerSensor {
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/** singleton access */
|
/** singleton access */
|
||||||
static AccelerometerSensor& get() {
|
static AccelerometerSensorAndroid& get() {
|
||||||
static AccelerometerSensor acc;
|
static AccelerometerSensorAndroid acc;
|
||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,12 +44,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void stop() override {
|
void stop() override {
|
||||||
throw "todo";
|
throw "TODO";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif ANDROID
|
#endif ANDROID
|
||||||
|
|
||||||
#endif // ACCELEROMETERSENSOR_H
|
#endif // ACCELEROMETERSENSORANDROID_H
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#include <QAndroidJniObject>
|
#include <QAndroidJniObject>
|
||||||
|
|
||||||
#include "Debug.h"
|
#include "../../misc/Debug.h"
|
||||||
#include "WiFiSensor.h"
|
#include "../WiFiSensor.h"
|
||||||
|
|
||||||
class WiFiSensorAndroid : public WiFiSensor {
|
class WiFiSensorAndroid : public WiFiSensor {
|
||||||
|
|
||||||
@@ -27,11 +27,15 @@ public:
|
|||||||
void start() override {
|
void start() override {
|
||||||
|
|
||||||
// start scanning
|
// start scanning
|
||||||
int res = QAndroidJniObject::callStaticMethod<int>("java/indoor/WiFi", "start", "()I");
|
int res = QAndroidJniObject::callStaticMethod<int>("indoor/java/WiFi", "start", "()I");
|
||||||
(void) res;
|
(void) res;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stop() override {
|
||||||
|
throw "todo";
|
||||||
|
}
|
||||||
|
|
||||||
/** called from java. handle the given incoming scan result */
|
/** called from java. handle the given incoming scan result */
|
||||||
void handle(const std::string& data) {
|
void handle(const std::string& data) {
|
||||||
|
|
||||||
@@ -59,7 +63,7 @@ public:
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
/** called after each successful WiFi scan */
|
/** called after each successful WiFi scan */
|
||||||
JNIEXPORT void JNICALL Java_java_indoor_WiFi_onScanComplete(JNIEnv* env, jobject jobj, jbyteArray arrayID) {
|
JNIEXPORT void JNICALL Java_indoor_java_WiFi_onScanComplete(JNIEnv* env, jobject jobj, jbyteArray arrayID) {
|
||||||
(void) env; (void) jobj;
|
(void) env; (void) jobj;
|
||||||
jsize length = env->GetArrayLength(arrayID);
|
jsize length = env->GetArrayLength(arrayID);
|
||||||
jboolean isCopy;
|
jboolean isCopy;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ TEMPLATE = app
|
|||||||
QT += qml opengl
|
QT += qml opengl
|
||||||
|
|
||||||
# android?
|
# android?
|
||||||
#QT += androidextras sensors
|
QT += androidextras sensors
|
||||||
#DEFINES += ANDROID
|
DEFINES += ANDROID
|
||||||
|
|
||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
|
|
||||||
@@ -16,6 +16,7 @@ INCLUDEPATH += \
|
|||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
_android/src/WiFi.java \
|
_android/src/WiFi.java \
|
||||||
|
_android/src/MyActivity.java \
|
||||||
_android/AndroidManifest.xml
|
_android/AndroidManifest.xml
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
|||||||
Reference in New Issue
Block a user