Skip to content

Commit

Permalink
Improve permissions handling and display
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed Jan 6, 2024
1 parent c425afb commit de5a7ad
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 20 deletions.
159 changes: 141 additions & 18 deletions qml/MobilePermissions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Item {
function loadScreen() {
// refresh permissions
deviceManager.checkBluetoothPermissions()
notifButton.validperm = utilsApp.checkMobileNotificationPermission()

// change screen
appContent.state = "AboutPermissions"
Expand Down Expand Up @@ -55,8 +56,64 @@ Item {
spacing: 8

////////
/*
Item { // Network access
anchors.left: parent.left
anchors.right: parent.right
height: 24
Item { // Bluetooth
RoundButtonIcon {
anchors.left: parent.left
anchors.leftMargin: 16
anchors.verticalCenter: parent.verticalCenter
width: 32
height: 32
z: 1
property bool validperm: true
source: (validperm) ? "qrc:/assets/icons_material/baseline-check-24px.svg" : "qrc:/assets/icons_material/baseline-close-24px.svg"
iconColor: (validperm) ? "white" : "white"
backgroundColor: (validperm) ? Theme.colorSuccess : Theme.colorSubText
backgroundVisible: true
}
Text {
anchors.left: parent.left
anchors.leftMargin: 64
anchors.right: parent.right
anchors.rightMargin: 16
anchors.verticalCenter: parent.verticalCenter
height: 16
text: qsTr("Network access")
textFormat: Text.PlainText
wrapMode: Text.WordWrap
font.pixelSize: 18
color: Theme.colorText
verticalAlignment: Text.AlignVCenter
}
}
Text { // Network access legend
anchors.left: parent.left
anchors.leftMargin: 64
anchors.right: parent.right
anchors.rightMargin: 16
text: qsTr("Network state and Internet permissions are used to connect to MQTT brokers.")
textFormat: Text.PlainText
wrapMode: Text.WordWrap
color: Theme.colorSubText
font.pixelSize: Theme.fontSizeContentSmall
}
////////
ListSeparatorPadded { height: 16+1 }
*/
////////

Item { // Bluetooth control
anchors.left: parent.left
anchors.right: parent.right
height: 24
Expand All @@ -68,18 +125,12 @@ Item {
width: 32
height: 32

property bool validperm: deviceManager.permissionOS
property bool validperm: true

source: (validperm) ? "qrc:/assets/icons_material/baseline-check-24px.svg" : "qrc:/assets/icons_material/baseline-close-24px.svg"
iconColor: (validperm) ? "white" : "white"
backgroundColor: (validperm) ? Theme.colorSuccess : Theme.colorSubText
backgroundVisible: true

onClicked: {
utilsApp.vibrate(25)
utilsApp.getMobileBluetoothPermission()
refreshPermissions.start()
}
}

Text {
Expand All @@ -90,22 +141,22 @@ Item {
anchors.verticalCenter: parent.verticalCenter
height: 16

text: qsTr("Bluetooth")
text: qsTr("Bluetooth control")
textFormat: Text.PlainText
wrapMode: Text.WordWrap
font.pixelSize: 17
color: Theme.colorText
verticalAlignment: Text.AlignVCenter
}
}
Text { // Bluetooth legend
Text { // Bluetooth control legend
anchors.left: parent.left
anchors.leftMargin: appHeader.headerPosition
anchors.right: parent.right
anchors.rightMargin: Theme.componentMargin

text: qsTr("The Android operating system requires permission to scan for nearby Bluetooth Low Energy sensors.")
textFormat: Text.StyledText
text: qsTr("WatchFlower can activate your device's Bluetooth in order to operate.")
textFormat: Text.PlainText
wrapMode: Text.WordWrap
color: Theme.colorSubText
font.pixelSize: Theme.fontSizeContentSmall
Expand All @@ -117,7 +168,7 @@ Item {

////////

Item { // Bluetooth control
Item { // Bluetooth
anchors.left: parent.left
anchors.right: parent.right
height: 24
Expand All @@ -129,12 +180,18 @@ Item {
width: 32
height: 32

property bool validperm: true
property bool validperm: deviceManager.permissionOS

source: (validperm) ? "qrc:/assets/icons_material/baseline-check-24px.svg" : "qrc:/assets/icons_material/baseline-close-24px.svg"
iconColor: (validperm) ? "white" : "white"
backgroundColor: (validperm) ? Theme.colorSuccess : Theme.colorSubText
backgroundVisible: true

onClicked: {
utilsApp.vibrate(25)
utilsApp.getMobileBluetoothPermission()
refreshPermissions.start()
}
}

Text {
Expand All @@ -145,22 +202,22 @@ Item {
anchors.verticalCenter: parent.verticalCenter
height: 16

text: qsTr("Bluetooth control")
text: qsTr("Bluetooth")
textFormat: Text.PlainText
wrapMode: Text.WordWrap
font.pixelSize: 17
color: Theme.colorText
verticalAlignment: Text.AlignVCenter
}
}
Text { // Bluetooth control legend
Text { // Bluetooth legend
anchors.left: parent.left
anchors.leftMargin: appHeader.headerPosition
anchors.right: parent.right
anchors.rightMargin: Theme.componentMargin

text: qsTr("WatchFlower can activate your device's Bluetooth in order to operate.")
textFormat: Text.PlainText
text: qsTr("The Android operating system requires permission to scan for nearby Bluetooth Low Energy sensors.")
textFormat: Text.StyledText
wrapMode: Text.WordWrap
color: Theme.colorSubText
font.pixelSize: Theme.fontSizeContentSmall
Expand Down Expand Up @@ -389,6 +446,72 @@ Item {

////////

Item { // Notifications
height: 24
anchors.left: parent.left
anchors.right: parent.right

visible: (utilsApp.getAndroidSdkVersion() >= 13)

RoundButtonIcon {
id: notifButton
width: 32
height: 32
anchors.left: parent.left
anchors.leftMargin: Theme.componentMargin
anchors.verticalCenter: parent.verticalCenter

property bool validperm: false

source: (validperm) ? "qrc:/assets/icons_material/baseline-check-24px.svg" : "qrc:/assets/icons_material/baseline-close-24px.svg"
iconColor: (validperm) ? "white" : "white"
backgroundColor: (validperm) ? Theme.colorSuccess : Theme.colorSubText
backgroundVisible: true

onClicked: {
utilsApp.vibrate(25)
validperm = utilsApp.getMobileNotificationPermission()
refreshPermissions.start()
}
}

Text {
height: 16
anchors.left: parent.left
anchors.leftMargin: appHeader.headerPosition
anchors.right: parent.right
anchors.rightMargin: Theme.componentMargin
anchors.verticalCenter: parent.verticalCenter

text: qsTr("Notifications")
textFormat: Text.PlainText
wrapMode: Text.WordWrap
font.pixelSize: 17
color: Theme.colorText
verticalAlignment: Text.AlignVCenter
}
}
Text { // Notifications legend
anchors.left: parent.left
anchors.leftMargin: appHeader.headerPosition
anchors.right: parent.right
anchors.rightMargin: 12

visible: (utilsApp.getAndroidSdkVersion() >= 13)

text: qsTr("The Android operating system requires permission to send notifications.")
textFormat: Text.StyledText
wrapMode: Text.WordWrap
color: Theme.colorSubText
font.pixelSize: Theme.fontSizeContentSmall
}

////////

ListSeparatorPadded { height: 16+1 }

////////

Item {
id: element_infos
anchors.left: parent.left
Expand Down
7 changes: 6 additions & 1 deletion qml/Settings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,12 @@ Loader {
z: 1

checked: settingsManager.notifications
onClicked: settingsManager.notifications = checked
onClicked: {
settingsManager.notifications = checked
if (settingsManager.notifications) {
utilsApp.getMobileNotificationPermission()
}
}
}
}
Text {
Expand Down
2 changes: 1 addition & 1 deletion qml/components/ItemNoPermissions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Item {
width: singleColumn ? (itemNoPermissions.width*0.85) : undefined
spacing: Theme.componentMargin

visible: (Qt.platform.os === "android" || Qt.platform.os === "ios" || Qt.platform.os === "osx")
visible: false // (Qt.platform.os === "android" || Qt.platform.os === "ios" || Qt.platform.os === "osx")

IconSvg {
Layout.preferredWidth: 20
Expand Down

0 comments on commit de5a7ad

Please sign in to comment.