fixed android setup
added missing c++11 methods
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?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"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
<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>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package our.java.stuff;
|
||||
package indoor.java;
|
||||
|
||||
import android.os.Bundle;
|
||||
import org.qtproject.qt5.android.bindings.QtActivity;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package java.indoor;
|
||||
package indoor.java;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
|
||||
2
main.cpp
2
main.cpp
@@ -1,3 +1,5 @@
|
||||
#include <misc/fixc11.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
|
||||
@@ -11,22 +11,22 @@ MapView::MapView(QWidget* parent) : QGLWidget(parent) {
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
//glShadeModel(GL_SMOOTH);
|
||||
//glEnable(GL_LIGHTING);
|
||||
//glEnable(GL_LIGHT0);
|
||||
|
||||
static GLfloat lightPosition[4] = { 0, 0, 10, 1.0 };
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
|
||||
//static GLfloat lightPosition[4] = { 0, 0, 10, 1.0 };
|
||||
//glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
|
||||
|
||||
}
|
||||
|
||||
void MapView::paintGL() {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -10.0);
|
||||
glRotatef(20 / 16.0, 1.0, 0.0, 0.0);
|
||||
glRotatef(30 / 16.0, 0.0, 1.0, 0.0);
|
||||
glRotatef(60 / 16.0, 0.0, 0.0, 1.0);
|
||||
//glLoadIdentity();
|
||||
//glTranslatef(0.0, 0.0, -10.0);
|
||||
//glRotatef(20 / 16.0, 1.0, 0.0, 0.0);
|
||||
//glRotatef(30 / 16.0, 0.0, 1.0, 0.0);
|
||||
//glRotatef(60 / 16.0, 0.0, 0.0, 1.0);
|
||||
draw();
|
||||
}
|
||||
|
||||
@@ -34,20 +34,20 @@ MapView::MapView(QWidget* parent) : QGLWidget(parent) {
|
||||
int side = qMin(width, height);
|
||||
glViewport((width - side) / 2, (height - side) / 2, side, side);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
//glMatrixMode(GL_PROJECTION);
|
||||
//glLoadIdentity();
|
||||
#ifdef QT_OPENGL_ES_1
|
||||
glOrthof(-2, +2, -2, +2, 1.0, 15.0);
|
||||
#else
|
||||
glOrtho(-2, +2, -2, +2, 1.0, 15.0);
|
||||
//glOrtho(-2, +2, -2, +2, 1.0, 15.0);
|
||||
#endif
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
//glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
void MapView::draw()
|
||||
{
|
||||
qglColor(Qt::red);
|
||||
glBegin(GL_QUADS);
|
||||
/*glBegin(GL_QUADS);
|
||||
glNormal3f(0,0,-1);
|
||||
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(0,0,1.2);
|
||||
glEnd();
|
||||
glEnd();*/
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
#ifndef NAV_DEBUG_H
|
||||
#define NAV_DEBUG_H
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@@ -13,4 +13,4 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#endif // DEBUG_H
|
||||
#endif // NAV_DEBUG_H
|
||||
|
||||
@@ -2,12 +2,49 @@
|
||||
#define FIXC11_H
|
||||
|
||||
#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
|
||||
|
||||
5
qml.qrc
5
qml.qrc
@@ -1,6 +1,3 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
<file>MainForm.ui.qml</file>
|
||||
</qresource>
|
||||
<qresource prefix="/"/>
|
||||
</RCC>
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
/** get the Accelerometer sensor */
|
||||
static AccelerometerSensor& getAccelerometer() {
|
||||
#ifdef ANDROID
|
||||
return AccelerometerSensor::get();
|
||||
return AccelerometerSensorAndroid::get();
|
||||
#else
|
||||
return AccelerometerSensorDummy::get();
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef ACCELEROMETERSENSOR_H
|
||||
#define ACCELEROMETERSENSOR_H
|
||||
#ifndef ACCELEROMETERSENSORANDROID_H
|
||||
#define ACCELEROMETERSENSORANDROID_H
|
||||
|
||||
|
||||
#ifdef ANDROID
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <QtSensors/QAccelerometer>
|
||||
|
||||
|
||||
#include "../AccelerometerSensor.h"
|
||||
|
||||
class AccelerometerSensorAndroid : public AccelerometerSensor {
|
||||
|
||||
@@ -26,8 +26,8 @@ private:
|
||||
public:
|
||||
|
||||
/** singleton access */
|
||||
static AccelerometerSensor& get() {
|
||||
static AccelerometerSensor acc;
|
||||
static AccelerometerSensorAndroid& get() {
|
||||
static AccelerometerSensorAndroid acc;
|
||||
return acc;
|
||||
}
|
||||
|
||||
@@ -44,12 +44,13 @@ public:
|
||||
}
|
||||
|
||||
void stop() override {
|
||||
throw "todo";
|
||||
throw "TODO";
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif ANDROID
|
||||
|
||||
#endif // ACCELEROMETERSENSOR_H
|
||||
#endif // ACCELEROMETERSENSORANDROID_H
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include <QAndroidJniObject>
|
||||
|
||||
#include "Debug.h"
|
||||
#include "WiFiSensor.h"
|
||||
#include "../../misc/Debug.h"
|
||||
#include "../WiFiSensor.h"
|
||||
|
||||
class WiFiSensorAndroid : public WiFiSensor {
|
||||
|
||||
@@ -27,11 +27,15 @@ public:
|
||||
void start() override {
|
||||
|
||||
// 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 stop() override {
|
||||
throw "todo";
|
||||
}
|
||||
|
||||
/** called from java. handle the given incoming scan result */
|
||||
void handle(const std::string& data) {
|
||||
|
||||
@@ -59,7 +63,7 @@ public:
|
||||
extern "C" {
|
||||
|
||||
/** 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;
|
||||
jsize length = env->GetArrayLength(arrayID);
|
||||
jboolean isCopy;
|
||||
|
||||
@@ -3,8 +3,8 @@ TEMPLATE = app
|
||||
QT += qml opengl
|
||||
|
||||
# android?
|
||||
#QT += androidextras sensors
|
||||
#DEFINES += ANDROID
|
||||
QT += androidextras sensors
|
||||
DEFINES += ANDROID
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
@@ -16,6 +16,7 @@ INCLUDEPATH += \
|
||||
|
||||
OTHER_FILES += \
|
||||
_android/src/WiFi.java \
|
||||
_android/src/MyActivity.java \
|
||||
_android/AndroidManifest.xml
|
||||
|
||||
SOURCES += \
|
||||
|
||||
Reference in New Issue
Block a user