new notification status stuff seems to work

1.2-legacy
Kevin Hester 2020-02-28 20:09:00 -08:00
rodzic 42439c4b26
commit a0db3e0ccd
4 zmienionych plików z 29 dodań i 13 usunięć

Wyświetl plik

@ -1,9 +1,7 @@
# High priority
Work items for soon alpha builds
* fix notification setSmallIcon parameter
* have the foreground service's notification show a summary of network status "connected/disconnected, 5 of 6 nodes, nearest: kevin 5km",
* have notification (individually maskable) notifications for received texts - use file:///home/kevinh/packages/android-sdk-linux/docs/reference/android/support/v4/app/NotificationCompat.BigTextStyle.html
* run services in sim mode on emulator
* show offline nodes as greyed out
* show time since last contact on the node info card
* show pointer arrow on the outside of the user icons, always pointing towoards them
@ -21,6 +19,7 @@ Work items for soon alpha builds
# Medium priority
Features for future builds
* fix notification setSmallIcon parameter - change it to use the meshtastic icon
* ditch compose and use https://github.com/zsmb13/MaterialDrawerKt + https://github.com/Kotlin/anko/wiki/Anko-Layouts?
* describe user experience: devices always point to each other and show distance, you can send texts between nodes
the channel is encrypted, you can share the the channel key with others by qr code or by sharing a special link
@ -158,3 +157,5 @@ Don't leave device discoverable. Don't let unpaired users do things with device
* connect to bluetooth device automatically using minimum power - start looking at phone boot
* tell various vendors & post in forums
* change info() log strings to debug()
* have the foreground service's notification show a summary of network status "connected/disconnected, 5 of 6 nodes, nearest: kevin 5km",
* have notification (individually maskable) notifications for received texts - use file:///home/kevinh/packages/android-sdk-linux/docs/reference/android/support/v4/app/NotificationCompat.BigTextStyle.html

Wyświetl plik

@ -268,8 +268,7 @@ class MeshService : Service(), Logging {
chan.lightColor = Color.BLUE
chan.importance = NotificationManager.IMPORTANCE_NONE
chan.lockscreenVisibility = Notification.VISIBILITY_PRIVATE
val service = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
service.createNotificationChannel(chan)
notificationManager.createNotificationChannel(chan)
return channelId
}
@ -278,7 +277,8 @@ class MeshService : Service(), Logging {
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
}
val channelId =
/// This must be lazy because we use Context
private val channelId: String by lazy() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createNotificationChannel()
} else {
@ -286,10 +286,11 @@ class MeshService : Service(), Logging {
// https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#NotificationCompat.Builder(android.content.Context)
""
}
}
private val mainAppIntent = Intent(this, MainActivity::class.java)
private val openAppIntent = PendingIntent.getActivity(this, 0, mainAppIntent, 0)
private val notificationBuilder = NotificationCompat.Builder(this, channelId)
private val openAppIntent: PendingIntent by lazy() {
PendingIntent.getActivity(this, 0, Intent(this, MainActivity::class.java), 0)
}
/// A text message that has a arrived since the last notification update
private var recentReceivedText: TextMessage? = null
@ -298,7 +299,7 @@ class MeshService : Service(), Logging {
get() = if (!isConnected)
"No radio connected"
else
"Connected $numOnlineNodes / $numNodes online"
"Connected: $numOnlineNodes of $numNodes online"
override fun toString() = summaryString
@ -307,11 +308,13 @@ class MeshService : Service(), Logging {
*/
private fun createNotification(): Notification {
val notificationBuilder = NotificationCompat.Builder(this, channelId)
val builder = notificationBuilder.setOngoing(true)
.setPriority(PRIORITY_MIN)
.setCategory(if (recentReceivedText != null) Notification.CATEGORY_SERVICE else Notification.CATEGORY_MESSAGE)
.setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
.setContentTitle("Meshtastic: $summaryString") // leave this off for now so our notification looks smaller
.setContentTitle(summaryString) // leave this off for now so our notification looks smaller
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentIntent(openAppIntent)
@ -643,7 +646,7 @@ class MeshService : Service(), Logging {
/// If we just changed our nodedb, we might want to do somethings
private fun onNodeDBChanged() {
updateNotification()
// we don't ask for GPS locations from android if our device has a built in GPS
if (!myNodeInfo!!.hasGPS) {
// If we have at least one other person in the mesh, send our GPS position otherwise stop listening to GPS

Wyświetl plik

@ -7,8 +7,10 @@ import android.os.ParcelUuid
import androidx.compose.*
import androidx.compose.frames.modelMapOf
import androidx.ui.core.ContextAmbient
import androidx.ui.core.LayoutModifier
import androidx.ui.core.Text
import androidx.ui.layout.Column
import androidx.ui.layout.LayoutGravity
import androidx.ui.material.CircularProgressIndicator
import androidx.ui.material.EmphasisLevels
import androidx.ui.material.ProvideEmphasis
@ -136,7 +138,7 @@ fun BTScanScreen() {
Text("An unexpected error was encountered. Please file a bug on our github: ${ScanUIState.errorText}")
} else {
if (ScanUIState.devices.isEmpty()) {
Text("Looking for Meshtastic devices... (zero found)")
Text(text = "Looking for Meshtastic devices... (zero found)", modifier = LayoutGravity.Center)
CircularProgressIndicator() // Show that we are searching still
} else {

Wyświetl plik

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,5c-3.87,0 -7,3.13 -7,7h2c0,-2.76 2.24,-5 5,-5s5,2.24 5,5h2c0,-3.87 -3.13,-7 -7,-7zM13,14.29c0.88,-0.39 1.5,-1.26 1.5,-2.29 0,-1.38 -1.12,-2.5 -2.5,-2.5S9.5,10.62 9.5,12c0,1.02 0.62,1.9 1.5,2.29v3.3L7.59,21 9,22.41l3,-3 3,3L16.41,21 13,17.59v-3.3zM12,1C5.93,1 1,5.93 1,12h2c0,-4.97 4.03,-9 9,-9s9,4.03 9,9h2c0,-6.07 -4.93,-11 -11,-11z"/>
</vector>