Skip to content

Commit

Permalink
Multiple changes for android (#62)
Browse files Browse the repository at this point in the history
* Add android status/nav bar color, relayout settings page, fix banner, change mic icon

* fix as per review
  • Loading branch information
AIIX authored Jul 17, 2020
1 parent 19c364f commit f57e0c6
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 24 deletions.
2 changes: 1 addition & 1 deletion application/HintsDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ Kirigami.AbstractCard {
}
}
}
}
}
108 changes: 87 additions & 21 deletions application/SettingsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,104 @@ Kirigami.ScrollablePage {
title: "Settings"
objectName: "Settings"


ColumnLayout {
id: settingsLayout
anchors.fill: parent
Layout.fillWidth: true
width: parent.width
implicitHeight: childrenRect.height
spacing: Kirigami.Units.largeSpacing

Controls.Label {
id: websocketLabel
text: "<h1>Websocket Address</h1> Example: <tt>ws://192.168.1.1</tt>"
Kirigami.Heading {
id: websocketLabel
level: 2
font.bold: true
color: Kirigami.Theme.textColor;
Layout.fillWidth: true
text: "Websocket Address"
}

Controls.TextField {
id: webSocketAddressField
width: parent.width
Controls.Label {
id: exampleLabel
text: "Example: <tt>ws://192.168.1.1</tt>"
Layout.fillWidth: true
Layout.columnSpan: 2
Component.onCompleted:{
webSocketAddressField.text = Mycroft.GlobalSettings.webSocketAddress
}
}

Controls.Button{
id: applySettings

Controls.Control{
Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
text: "Apply"
Layout.preferredHeight: Kirigami.Units.gridUnit * 3
leftPadding: Kirigami.Units.largeSpacing
rightPadding: Kirigami.Units.largeSpacing

onClicked:{
Mycroft.GlobalSettings.webSocketAddress = webSocketAddressField.text
Mycroft.MycroftController.reconnect()
background: Rectangle {
Kirigami.Theme.colorSet: Kirigami.Theme.Button
color: Kirigami.Theme.backgroundColor
radius: 5
}

contentItem: Controls.TextField {
id: webSocketAddressField

Component.onCompleted:{
webSocketAddressField.text = Mycroft.GlobalSettings.webSocketAddress
}
}
}

RowLayout {
Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.gridUnit * 4

Controls.Button {
id: applySettings
Kirigami.Theme.colorSet: Kirigami.Theme.Button
Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.gridUnit * 3
text: "Apply"

onClicked:{
Mycroft.GlobalSettings.webSocketAddress = webSocketAddressField.text
Mycroft.MycroftController.reconnect()
}
}

Controls.Button{
id: reverSettings
Kirigami.Theme.colorSet: Kirigami.Theme.Button
Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.gridUnit * 3
text: "Revert"

onClicked: {
webSocketAddressField.text = "ws://0.0.0.0"
Mycroft.GlobalSettings.webSocketAddress = webSocketAddressField.text
Mycroft.MycroftController.reconnect()
}
}
}

Item {
Layout.preferredHeight: Kirigami.Units.largeSpacing * 2
}

Kirigami.Heading {
level: 2
text: "About Application"
font.bold: true
Layout.fillWidth: true
color: Kirigami.Theme.textColor
}

Controls.Label {
id: mycroftAndroidAppVersionLabel
text: "Application Version: 0.80"
Layout.fillWidth: true
color: Kirigami.Theme.textColor;
}

Controls.Label {
id: mycroftGuiVersionLabel
text: "GUI Version: 1.0"
Layout.fillWidth: true
color: Kirigami.Theme.textColor;
}
}
}
Binary file modified application/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

#ifdef Q_OS_ANDROID
#include <QGuiApplication>
#include <QtAndroid>
#define FLAG_TRANSLUCENT_STATUS 0x04000000
#define FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS 0x80000000
#else
#include <QApplication>
#include <KDBusService>
Expand Down Expand Up @@ -120,5 +123,15 @@ int main(int argc, char *argv[])

engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

#ifdef Q_OS_ANDROID
QtAndroid::runOnAndroidThread([=]() {
QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;");
window.callMethod<void>("addFlags", "(I)V", FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.callMethod<void>("clearFlags", "(I)V", FLAG_TRANSLUCENT_STATUS);
window.callMethod<void>("setStatusBarColor", "(I)V", QColor("#31363b").rgba());
window.callMethod<void>("setNavigationBarColor", "(I)V", QColor("#31363b").rgba());
});
#endif

return app.exec();
}
14 changes: 12 additions & 2 deletions application/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,18 @@ Kirigami.ApplicationWindow {
}
}
}
Button {
text: "Speak" // TODO generic microphone icon

ToolButton {
Kirigami.Theme.colorSet: Kirigami.Theme.Button
Layout.preferredWidth: handleAnchor.width
Layout.fillHeight: true
Layout.rightMargin: Kirigami.Units.smallSpacing

contentItem: Kirigami.Icon {
anchors.centerIn: parent
source: "audio-input-microphone"
}

onClicked: {
if(applicationSettings.usesRemoteSTT){
audioRecorder.open()
Expand Down

0 comments on commit f57e0c6

Please sign in to comment.