Display a different notification icon, when disconnected
Better icons welcome :-)
This commit is contained in:
parent
fe310a9df8
commit
98d7237ec3
|
@ -117,7 +117,7 @@ public class DeviceCommunicationService extends Service {
|
||||||
mGBDevice = device;
|
mGBDevice = device;
|
||||||
boolean enableReceivers = mDeviceSupport != null && (mDeviceSupport.useAutoConnect() || mGBDevice.isInitialized());
|
boolean enableReceivers = mDeviceSupport != null && (mDeviceSupport.useAutoConnect() || mGBDevice.isInitialized());
|
||||||
setReceiversEnableState(enableReceivers);
|
setReceiversEnableState(enableReceivers);
|
||||||
GB.updateNotification(mGBDevice.getName() + " " + mGBDevice.getStateString(), context);
|
GB.updateNotification(mGBDevice.getName() + " " + mGBDevice.getStateString(), mGBDevice.isInitialized(), context);
|
||||||
} else {
|
} else {
|
||||||
LOG.error("Got ACTION_DEVICE_CHANGED from unexpected device: " + mGBDevice);
|
LOG.error("Got ACTION_DEVICE_CHANGED from unexpected device: " + mGBDevice);
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,7 @@ public class DeviceCommunicationService extends Service {
|
||||||
|
|
||||||
private void start() {
|
private void start() {
|
||||||
if (!mStarted) {
|
if (!mStarted) {
|
||||||
startForeground(GB.NOTIFICATION_ID, GB.createNotification(getString(R.string.gadgetbridge_running), this));
|
startForeground(GB.NOTIFICATION_ID, GB.createNotification(getString(R.string.gadgetbridge_running), false, this));
|
||||||
mStarted = true;
|
mStarted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class GB {
|
||||||
public static final String DISPLAY_MESSAGE_SEVERITY = "severity";
|
public static final String DISPLAY_MESSAGE_SEVERITY = "severity";
|
||||||
public static GBEnvironment environment;
|
public static GBEnvironment environment;
|
||||||
|
|
||||||
public static Notification createNotification(String text, Context context) {
|
public static Notification createNotification(String text, boolean connected, Context context) {
|
||||||
if (env().isLocalTest()) {
|
if (env().isLocalTest()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public class GB {
|
||||||
builder.setContentTitle(context.getString(R.string.app_name))
|
builder.setContentTitle(context.getString(R.string.app_name))
|
||||||
.setTicker(text)
|
.setTicker(text)
|
||||||
.setContentText(text)
|
.setContentText(text)
|
||||||
.setSmallIcon(R.drawable.ic_notification)
|
.setSmallIcon(connected ? R.drawable.ic_notification : R.drawable.ic_notification_disconnected)
|
||||||
.setContentIntent(pendingIntent)
|
.setContentIntent(pendingIntent)
|
||||||
.setOngoing(true);
|
.setOngoing(true);
|
||||||
if (GBApplication.isRunningLollipopOrLater()) {
|
if (GBApplication.isRunningLollipopOrLater()) {
|
||||||
|
@ -68,8 +68,8 @@ public class GB {
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateNotification(String text, Context context) {
|
public static void updateNotification(String text, boolean connected, Context context) {
|
||||||
Notification notification = createNotification(text, context);
|
Notification notification = createNotification(text, connected, context);
|
||||||
updateNotification(notification, NOTIFICATION_ID, context);
|
updateNotification(notification, NOTIFICATION_ID, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Loading…
Reference in New Issue