forked from Blendman974/faceclaw
Fix Android app and background service notification title capitalization; don't show a home screen badge on some devices
This commit is contained in:
1 parent
d41096f336
commit
b0188d8af9
2 files changed
+21
-5
No files matched your search
+14
-5
@@ -22,7 +22,12 @@ public class FaceclawForegroundService extends Service {
|
|||||||
public static final String ACTION_STOP = "com.faceclaw.app.action.STOP";
|
public static final String ACTION_STOP = "com.faceclaw.app.action.STOP";
|
||||||
public static final String EXTRA_TEXT = "text";
|
public static final String EXTRA_TEXT = "text";
|
||||||
|
|
||||||
private static final String CHANNEL_ID = "faceclaw-dashboard";
|
// Channel id was bumped from "faceclaw-dashboard" when the badge setting
|
||||||
|
// changed: Android freezes a channel's showBadge flag at creation, so the
|
||||||
|
// old channel (which let Samsung's launcher count the pinned notification
|
||||||
|
// as a red "1" badge) is deleted on upgrade rather than reused.
|
||||||
|
private static final String LEGACY_CHANNEL_ID = "faceclaw-dashboard";
|
||||||
|
private static final String CHANNEL_ID = "faceclaw-connection";
|
||||||
private static final int NOTIFICATION_ID = 4201;
|
private static final int NOTIFICATION_ID = 4201;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,7 +48,7 @@ public class FaceclawForegroundService extends Service {
|
|||||||
|
|
||||||
ensureNotificationChannel();
|
ensureNotificationChannel();
|
||||||
Notification notification = buildNotification(
|
Notification notification = buildNotification(
|
||||||
text != null && !text.trim().isEmpty() ? text : "Keeping the dashboard connected"
|
text != null && !text.trim().isEmpty() ? text : "Connected to glasses"
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
@@ -69,14 +74,18 @@ public class FaceclawForegroundService extends Service {
|
|||||||
|
|
||||||
NotificationChannel channel = new NotificationChannel(
|
NotificationChannel channel = new NotificationChannel(
|
||||||
CHANNEL_ID,
|
CHANNEL_ID,
|
||||||
"Faceclaw dashboard",
|
"Glasses connection",
|
||||||
NotificationManager.IMPORTANCE_LOW
|
NotificationManager.IMPORTANCE_LOW
|
||||||
);
|
);
|
||||||
channel.setDescription("Keeps the Faceclaw dashboard connected to the glasses.");
|
channel.setDescription("Keeps Faceclaw connected to the glasses.");
|
||||||
|
// The pinned status notification must not count toward the launcher
|
||||||
|
// icon's notification badge.
|
||||||
|
channel.setShowBadge(false);
|
||||||
|
|
||||||
NotificationManager manager = getSystemService(NotificationManager.class);
|
NotificationManager manager = getSystemService(NotificationManager.class);
|
||||||
if (manager != null) {
|
if (manager != null) {
|
||||||
manager.createNotificationChannel(channel);
|
manager.createNotificationChannel(channel);
|
||||||
|
manager.deleteNotificationChannel(LEGACY_CHANNEL_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +105,7 @@ public class FaceclawForegroundService extends Service {
|
|||||||
: new Notification.Builder(this);
|
: new Notification.Builder(this);
|
||||||
|
|
||||||
return builder
|
return builder
|
||||||
.setContentTitle("faceclaw dashboard")
|
.setContentTitle("Faceclaw")
|
||||||
.setContentText(text)
|
.setContentText(text)
|
||||||
.setSmallIcon(getApplicationInfo().icon)
|
.setSmallIcon(getApplicationInfo().icon)
|
||||||
.setContentIntent(contentIntent)
|
.setContentIntent(contentIntent)
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<!-- Overrides the CLI-generated app_name (derived from package.json's
|
||||||
|
lowercase "faceclaw") so the launcher shows a capitalized label. -->
|
||||||
|
<string name="app_name">Faceclaw</string>
|
||||||
|
<string name="title_activity_kimera">Faceclaw</string>
|
||||||
|
</resources>
|
||||||
Reference in new issue
Block a user