diff --git a/OmobiDisplayApp/OmobiDisplayApp.pro b/OmobiDisplayApp/OmobiDisplayApp.pro
index 0ec8ca4..c436c0b 100644
--- a/OmobiDisplayApp/OmobiDisplayApp.pro
+++ b/OmobiDisplayApp/OmobiDisplayApp.pro
@@ -1,7 +1,8 @@
QT += quick bluetooth quickcontrols2
CONFIG += c++11
-TARGET = OmobiDisplayApp
+TARGET = ItsblueLedDisplayController
+VERSION = 1.0.0
TEMPLATE = app
@@ -41,18 +42,24 @@ CONFIG += QBluetoothLeUart_QML
include($$PWD/QBluetoothLeUart/QBluetoothLeUart.pri)
DISTFILES += \
- test.qmodel
+ android/AndroidManifest.xml
-STATECHARTS +=
-
-contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
- ANDROID_ABIS = \
- armeabi-v7a
-}
-
-ANDROID_ABIS = armeabi-v7a
+android {
+QT += androidextras
+ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
contains(ANDROID_TARGET_ARCH,) {
ANDROID_ABIS = \
armeabi-v7a
}
+
+contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
+ ANDROID_ABIS = \
+ armeabi-v7a
+}
+}
+
+contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
+ ANDROID_ABIS = \
+ armeabi-v7a
+}
diff --git a/OmobiDisplayApp/android/AndroidManifest.xml b/OmobiDisplayApp/android/AndroidManifest.xml
new file mode 100644
index 0000000..f91454a
--- /dev/null
+++ b/OmobiDisplayApp/android/AndroidManifest.xml
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OmobiDisplayApp/main.cpp b/OmobiDisplayApp/main.cpp
index 043d5b7..bdef8bc 100644
--- a/OmobiDisplayApp/main.cpp
+++ b/OmobiDisplayApp/main.cpp
@@ -5,9 +5,19 @@
#include
#include
+#ifdef Q_OS_ANDROID
+#include
+#endif
+
#include "omobidisplaybackend.h"
#include "omobidisplaytextmodel.h"
+/*void permissionCallback(const QtAndroid::PermissionResultMap& results) {
+ for(QtAndroid::PermissionResult result : results) {
+ qWarning() << "Permission Callback Result:" << (result == QtAndroid::PermissionResult::Granted);
+ }
+}*/
+
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
diff --git a/OmobiDisplayApp/omobidisplaybackend.cpp b/OmobiDisplayApp/omobidisplaybackend.cpp
index 7a689ba..cc96875 100644
--- a/OmobiDisplayApp/omobidisplaybackend.cpp
+++ b/OmobiDisplayApp/omobidisplaybackend.cpp
@@ -47,12 +47,29 @@ void OmobiDisplayBackend::authenticate(QString code) {
this->sendBluetoothCommand(AuthenticateCommand, QVariantMap{{"secret", this->lastDisplaySecret}});
}
+void OmobiDisplayBackend::handleBluetoothScanningError(QBluetoothLeUartClient::BluetoothScanError error) {
+ if(error == QBluetoothLeUartClient::LocationPermissionDeniedError) {
+#ifdef Q_OS_ANDROID
+ // try to get permission
+ //QtAndroid::requestPermissions({"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"}, NULL);
+#endif
+ }
+}
+
void OmobiDisplayBackend::handleBluetoothStateChange(QBluetoothLeUartClient::BluetoothLeUartClientState state){
switch(state){
case QBluetoothLeUartClient::Idle: {
this->setState(Idle);
break;
}
+ case QBluetoothLeUartClient::AdapterTurnedOff: {
+ this->setState(BluetoothOff);
+ break;
+ }
+ case QBluetoothLeUartClient::LocationPermissionDenied: {
+ this->setState(LocationPermissionDenied);
+ break;
+ }
case QBluetoothLeUartClient::Scanning: {
this->setState(Scanning);
break;
diff --git a/OmobiDisplayApp/omobidisplaybackend.h b/OmobiDisplayApp/omobidisplaybackend.h
index 350aba4..22692be 100644
--- a/OmobiDisplayApp/omobidisplaybackend.h
+++ b/OmobiDisplayApp/omobidisplaybackend.h
@@ -23,6 +23,8 @@ public:
enum OmobiDisplayAppState {
Idle,
+ BluetoothOff,
+ LocationPermissionDenied,
Scanning,
ReadyToConnect,
Connecting,
@@ -78,6 +80,7 @@ private slots:
void handleBluetoothStateChange(QBluetoothLeUartClient::BluetoothLeUartClientState state);
void handleFoundNewDevice(QBluetoothLeUartDevice* device);
void handleBluetoothDeviceConected();
+ void handleBluetoothScanningError(QBluetoothLeUartClient::BluetoothScanError error);
void handleDisplayTextModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles = QVector());
void handleDisplayTextModelRowsInserted(const QModelIndex &parent, int first, int last);
diff --git a/OmobiDisplayApp/ressources/qml/ConnectPage.qml b/OmobiDisplayApp/ressources/qml/ConnectPage.qml
index 991d307..7a8b9f7 100644
--- a/OmobiDisplayApp/ressources/qml/ConnectPage.qml
+++ b/OmobiDisplayApp/ressources/qml/ConnectPage.qml
@@ -173,6 +173,123 @@ Page {
text: parseInt(root.state) === OmobiDisplayBackend.Scanning ? qsTr("Still scanning"):qsTr("No displays found")
}
}
+
+
+ Item {
+ id: bluetoothOffItem
+ anchors.centerIn: parent
+
+ width: Math.min(parent.height, parent.width)
+ height: Math.min(parent.height, parent.width)
+
+ opacity: 0
+
+ Behavior on opacity {
+ NumberAnimation {}
+ }
+
+
+ Text {
+ id: bluetoothOffIcon
+ anchors {
+ top: parent.top
+ topMargin: parent.height * 0.1
+ horizontalCenter: parent.horizontalCenter
+ }
+ anchors.verticalCenterOffset: text === "..." ? -height * 0.25:0
+ color: "lightgrey"
+ font.pixelSize: parent.height * 0.4
+ font.family: fontAwesomeBrands.name
+ text: "\uf294"
+ }
+
+
+ Text {
+ id: bluetoothOffText
+ anchors {
+ top: bluetoothOffIcon.bottom
+ topMargin: bluetoothOffIcon.height * 0.15
+ horizontalCenter: parent.horizontalCenter
+ }
+
+ font.bold: true
+ font.pixelSize: bluetoothOffIcon.height * 0.15
+
+ color: Qt.darker("lightgrey", 1.1)
+ text: qsTr("Bluetooth is turned off")
+ }
+ }
+
+ Item {
+ id: noPermissionItem
+ anchors.centerIn: parent
+
+ width: Math.min(parent.height, parent.width)
+ height: Math.min(parent.height, parent.width)
+
+ opacity: 0
+
+ Behavior on opacity {
+ NumberAnimation {}
+ }
+
+
+ Text {
+ id: noPermissionIcon
+ anchors {
+ top: parent.top
+ topMargin: parent.height * 0
+ horizontalCenter: parent.horizontalCenter
+ }
+ anchors.verticalCenterOffset: text === "..." ? -height * 0.25:0
+ color: "lightgrey"
+ font.pixelSize: parent.height * 0.4
+ font.family: fontAwesome.name
+ text: "\uf3ed"
+ }
+ Text {
+ id: noPermissionText
+ anchors {
+ top: noPermissionIcon.bottom
+ topMargin: noPermissionIcon.height * 0.15
+ horizontalCenter: parent.horizontalCenter
+ }
+
+ width: parent.width * 0.9
+
+ font.bold: true
+ font.pixelSize: noPermissionIcon.height * 0.15
+
+ horizontalAlignment: Text.AlignHCenter
+
+ wrapMode: Text.Wrap
+
+ color: Qt.darker("lightgrey", 1.1)
+ text: qsTr("Error:\nLocation permission denied!")
+ }
+
+ Text {
+ id: noPermissionDetailText
+ anchors {
+ top: noPermissionText.bottom
+ topMargin: noPermissionText.height * 0.15
+ horizontalCenter: parent.horizontalCenter
+ }
+
+ width: parent.width * 0.9
+
+ font.bold: true
+ font.pixelSize: noPermissionText.font.pixelSize * 0.7
+
+ horizontalAlignment: Text.AlignHCenter
+
+ wrapMode: Text.Wrap
+
+ color: Qt.darker("lightgrey", 1.1)
+ text: qsTr("This app requires location permission in order for Bluetooth to work, it will not actually access your location.")
+ }
+ }
+
}
}
@@ -224,6 +341,44 @@ Page {
statusText: qsTr("Tap here to scan")
working: false
}
+
+ PropertyChanges {
+ target: noPermissionItem
+ opacity: 0
+ }
+ },
+ State {
+ name: OmobiDisplayBackend.BluetoothOff
+ PropertyChanges {
+ target: bluetoothOffItem
+ opacity: 1
+ }
+ PropertyChanges {
+ target: root
+ statusText: qsTr("Bluetooth is turned off")
+ working: false
+ }
+ PropertyChanges {
+ target: noDisplaysItem
+ opacity: 0
+ }
+ },
+ State {
+ name: OmobiDisplayBackend.LocationPermissionDenied
+
+ PropertyChanges {
+ target: noPermissionItem
+ opacity: 1
+ }
+ PropertyChanges {
+ target: root
+ statusText: qsTr("Tap here to continue")
+ working: false
+ }
+ PropertyChanges {
+ target: noDisplaysItem
+ opacity: 0
+ }
},
State {
name: OmobiDisplayBackend.Scanning
@@ -233,6 +388,14 @@ Page {
statusText: qsTr("Scanning...")
working: true
}
+ PropertyChanges {
+ target: bluetoothOffItem
+ opacity: 0
+ }
+ PropertyChanges {
+ target: noPermissionItem
+ opacity: 0
+ }
},
State {
name: OmobiDisplayBackend.ReadyToConnect
diff --git a/OmobiDisplayApp/ressources/qml/ConnectedPage.qml b/OmobiDisplayApp/ressources/qml/ConnectedPage.qml
index f3399da..ebd217d 100644
--- a/OmobiDisplayApp/ressources/qml/ConnectedPage.qml
+++ b/OmobiDisplayApp/ressources/qml/ConnectedPage.qml
@@ -75,7 +75,7 @@ Page {
ToolTip {
parent: brightnessSlider.handle
visible: brightnessSlider.pressed
- text: brightnessSlider.value.toFixed(1)
+ text: brightnessSlider.value
}
}
diff --git a/OmobiDisplayApp/ressources/qml/main.qml b/OmobiDisplayApp/ressources/qml/main.qml
index 24366e1..a9d6b27 100644
--- a/OmobiDisplayApp/ressources/qml/main.qml
+++ b/OmobiDisplayApp/ressources/qml/main.qml
@@ -110,6 +110,15 @@ ApplicationWindow {
}
}
+ FontLoader {
+ id: fontAwesomeBrands
+ source: "qrc:/fa5brands.woff"
+
+ Component.onCompleted: {
+ console.log("Font name: " + fontAwesome.name)
+ }
+ }
+
StackView {
id: mainStack
@@ -169,6 +178,22 @@ ApplicationWindow {
}
},
+ State {
+ name: OmobiDisplayBackend.BluetoothOff
+ PropertyChanges {
+ target: mainStack
+ currentComponent: connectPageComp
+ }
+ },
+
+ State {
+ name: OmobiDisplayBackend.LocationPermissionDenied
+ PropertyChanges {
+ target: mainStack
+ currentComponent: connectPageComp
+ }
+ },
+
State {
name: OmobiDisplayBackend.Scanning
PropertyChanges {
diff --git a/OmobiDisplayApp/ressources/shared/fa5brands.woff b/OmobiDisplayApp/ressources/shared/fa5brands.woff
new file mode 100644
index 0000000..e6bccbc
Binary files /dev/null and b/OmobiDisplayApp/ressources/shared/fa5brands.woff differ
diff --git a/OmobiDisplayApp/ressources/shared/fa5solid.woff b/OmobiDisplayApp/ressources/shared/fa5solid.woff
index beec791..105028f 100644
Binary files a/OmobiDisplayApp/ressources/shared/fa5solid.woff and b/OmobiDisplayApp/ressources/shared/fa5solid.woff differ
diff --git a/OmobiDisplayApp/ressources/shared/shared.qrc b/OmobiDisplayApp/ressources/shared/shared.qrc
index ca7d0d2..d1d683c 100644
--- a/OmobiDisplayApp/ressources/shared/shared.qrc
+++ b/OmobiDisplayApp/ressources/shared/shared.qrc
@@ -3,5 +3,6 @@
omobi.png
itsblue.png
fa5solid.woff
+ fa5brands.woff