diff --git a/android-sources/AndroidManifest.xml b/android-sources/AndroidManifest.xml index 4e1d53a..351ded2 100644 --- a/android-sources/AndroidManifest.xml +++ b/android-sources/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/headers/serverconn.h b/headers/serverconn.h index aced1b3..4ed5e59 100644 --- a/headers/serverconn.h +++ b/headers/serverconn.h @@ -59,6 +59,8 @@ private: ReturnData_t senddata(QUrl serviceUrl, QUrlQuery postData); + QList apiVersion = {0,1,15}; + private slots: void setState(QString state); diff --git a/qml/Components/FancyButton.qml b/qml/Components/FancyButton.qml index 7df08a7..2ea10bb 100644 --- a/qml/Components/FancyButton.qml +++ b/qml/Components/FancyButton.qml @@ -26,10 +26,19 @@ Button { property string image property real imageScale: 1 + + scale: control.pressed ? 0.8:1 + + Behavior on scale { + PropertyAnimation { + duration: 100 + } + } + background: Item { id: controlBackgroundContainer - scale: control.pressed ? 0.8:1 + Behavior on scale { PropertyAnimation { @@ -68,12 +77,6 @@ Button { fillMode: Image.PreserveAspectFit scale: control.imageScale - - Behavior on scale { - PropertyAnimation { - duration: 100 - } - } } } } diff --git a/qml/Pages/LoginPage.qml b/qml/Pages/LoginPage.qml index fccebaf..78a3d2a 100644 --- a/qml/Pages/LoginPage.qml +++ b/qml/Pages/LoginPage.qml @@ -35,11 +35,15 @@ Page { Image { id: bigLogo - source: "qrc:/favicon.png" - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: window.height * 0.01 + source: "qrc:/graphics/images/FannyIcon.png" + + anchors { + top: parent.top + left: parent.left + right: parent.right + margins: window.height * 0.01 + } + height: window.height * 0.2 fillMode: Image.PreserveAspectFit mipmap: true @@ -48,7 +52,7 @@ Page { Label { id: infoText - text: "Bitte melde dich mit den Anmeldedaten an, die du für den Vertretungsplan erhalten hast. + text: "Bitte melde dich mit den Anmeldedaten der Fanny-Webseite an. Weitere Informationen" wrapMode: Text.Wrap onLinkActivated: { @@ -66,13 +70,14 @@ Page { Column { spacing: ( height - 100 ) * 0.1 + anchors { left: parent.left right: parent.right top: infoText.bottom bottom: parent.bottom - topMargin: window.height * 0.02 - bottomMargin: window.height * 0.2 + topMargin: root.height * 0.02 + bottomMargin: root.height * 0.2 } TextField { @@ -91,7 +96,6 @@ Page { TextField { id: tipasswd - echoMode: passwordHideShow.state === "visible" ? TextInput.Normal:TextInput.Password placeholderText: "Passwort" Keys.onReturnPressed: login(tiuname.text, tipasswd.text, cBperm.checked) @@ -102,8 +106,6 @@ Page { rightMargin: root.width * 0.05 } - - MouseArea { id: passwordHideShow anchors { @@ -125,19 +127,23 @@ Page { state: "invisible" states: [ - State { - name: "visible" - PropertyChanges { - target: visibleIcon - scale: 0 - } - PropertyChanges { - target: invisibleIcon - scale: 1 - } - }, State { name: "invisible" + PropertyChanges { + target: visibleIcon + scale: 0 + } + PropertyChanges { + target: invisibleIcon + scale: 1 + } + PropertyChanges { + target: tipasswd + echoMode: TextInput.Password + } + }, + State { + name: "visible" PropertyChanges { target: visibleIcon scale: 1 @@ -146,17 +152,9 @@ Page { target: invisibleIcon scale: 0 } - } - ] - - transitions: [ - Transition { - from: "*" - to: "*" - NumberAnimation { - properties: "scale,opacity" - easing.type: Easing.InOutQuad - duration: 200 + PropertyChanges { + target: tipasswd + echoMode: TextInput.Normal } } ] @@ -169,7 +167,7 @@ Page { bottom: parent.bottom right: parent.right - bottomMargin: parent.height * 0.2 + bottomMargin: parent.height * 0.25 topMargin: anchors.bottomMargin } fillMode: Image.PreserveAspectFit @@ -204,14 +202,17 @@ Page { anchors.horizontalCenter: parent.horizontalCenter } - Button { + FancyButton { id: loginButton - objectName: "loginButton" + + anchors { + horizontalCenter: parent.horizontalCenter + left: parent.left + margins: window.width * 0.05 + } + text: qsTr("Anmelden") enabled: tiuname.length > 0 & tipasswd.length > 0 - anchors.horizontalCenter: parent.horizontalCenter - anchors.left: parent.left - anchors.margins: window.width * 0.05 onClicked: login(tiuname.text, tipasswd.text, cBperm.checked) } Label { @@ -254,11 +255,7 @@ Page { app.state = "loggedIn" } else{ - // if it wasn't -> reset the stored credentinals - _cppAppSettings.writeSetting("permanent", "0") - _cppAppSettings.writeSetting("username", "") - _cppAppSettings.writeSetting("password", "") - // and set the error label to the error short description of the retuned error code + // if it wasn't -> set the error label to the error short description of the retuned error code laStatus.text = app.getErrorInfo(ret)[1] } } diff --git a/qml/main.qml b/qml/main.qml index ddcb6d5..3063458 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -95,6 +95,12 @@ ApplicationWindow { } } + FontLoader { + id: fontAwesome + name: "fontawesome" + source: "qrc:/fonts/fontawesome-webfont.ttf" + } + function getErrorInfo(errorCode) { var infoLevel @@ -141,6 +147,11 @@ ApplicationWindow { errorString = "Ungültiger Aufruf" errorDescription = "Die aufgerufene Funktion ist momentan nicht verfügbar, bitte versuche es später erneut." break + case 904: + infoLevel = 2 + errorString = "Inkompatible API" + errorDescription = "Die Version der API auf dem Server ist zu neu und kann daher nicht verarbeitet werden. Bitte aktualisiere die App auf die aktuellste Version." + break default: infoLevel = 2 errorString = "Unerwarteter Fehler ("+errorCode+")" diff --git a/shared/fonts/fontawesome-webfont.ttf b/shared/fonts/fontawesome-webfont.ttf new file mode 100644 index 0000000..5cd6cff Binary files /dev/null and b/shared/fonts/fontawesome-webfont.ttf differ diff --git a/shared/graphics/images/FannyIcon.png b/shared/graphics/images/FannyIcon.png new file mode 100644 index 0000000..ac69062 Binary files /dev/null and b/shared/graphics/images/FannyIcon.png differ diff --git a/shared/shared.qrc b/shared/shared.qrc index a0d4deb..026e559 100644 --- a/shared/shared.qrc +++ b/shared/shared.qrc @@ -20,5 +20,7 @@ sampleEventData/sample.pdf sampleEventData/sample.txt sampleEventData/sample.json + fonts/fontawesome-webfont.ttf + graphics/images/FannyIcon.png diff --git a/sources/serverconn.cpp b/sources/serverconn.cpp index a241b81..0135bdb 100644 --- a/sources/serverconn.cpp +++ b/sources/serverconn.cpp @@ -84,6 +84,10 @@ int ServerConn::login(QString username, QString password, bool permanent) else { // if not 200 was returned -> error -> return the return code this->setState("notLoggedIn"); + // -> reset the stored credentinals + pGlobalAppSettings->writeSetting("permanent", "0"); + pGlobalAppSettings->writeSetting("username", ""); + pGlobalAppSettings->writeSetting("password", ""); return(ret.status_code); } } @@ -180,9 +184,23 @@ int ServerConn::getEvents(QString day) // get the version of the json format QString version = dataArray.value("version").toString(); + QStringList versionList = version.split("."); + if(versionList.length() < 3){ + return(900); + } + + int versionMajor = version.split(".")[0].toInt(); + int versionMinor = version.split(".")[1].toInt(); + int versionRevision = version.split(".")[2].toInt(); + + if(versionMajor > this->apiVersion[0] || versionMinor > this->apiVersion[1]){ + return(904); + } + // get the header data tmpEventHeader.append(dataArray.value("targetDate").toString()); + tmpEventHeader.append(dataArray.value("refreshDate").toString()); tmpEventHeader.append(dataArray.value("stewardingClass").toString()); // expand the length of the header list to seven to prevent list out of range errors