From 98d7237ec3aef774a8ceab919d0d97f5a1be9bef Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Fri, 15 Apr 2016 22:56:37 +0200 Subject: [PATCH] Display a different notification icon, when disconnected Better icons welcome :-) --- .../service/DeviceCommunicationService.java | 4 ++-- .../freeyourgadget/gadgetbridge/util/GB.java | 8 ++++---- .../ic_notification_disconnected.png | Bin 0 -> 1202 bytes .../ic_notification_disconnected.png | Bin 0 -> 1033 bytes .../ic_notification_disconnected.png | Bin 0 -> 1469 bytes .../ic_notification_disconnected.png | Bin 0 -> 2314 bytes 6 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_notification_disconnected.png create mode 100644 app/src/main/res/drawable-mdpi/ic_notification_disconnected.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_notification_disconnected.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_notification_disconnected.png diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java index 85e3ceb7..c26cb1b8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java @@ -117,7 +117,7 @@ public class DeviceCommunicationService extends Service { mGBDevice = device; boolean enableReceivers = mDeviceSupport != null && (mDeviceSupport.useAutoConnect() || mGBDevice.isInitialized()); setReceiversEnableState(enableReceivers); - GB.updateNotification(mGBDevice.getName() + " " + mGBDevice.getStateString(), context); + GB.updateNotification(mGBDevice.getName() + " " + mGBDevice.getStateString(), mGBDevice.isInitialized(), context); } else { LOG.error("Got ACTION_DEVICE_CHANGED from unexpected device: " + mGBDevice); } @@ -387,7 +387,7 @@ public class DeviceCommunicationService extends Service { private void start() { 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; } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GB.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GB.java index a20e0f2e..07a7d593 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GB.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GB.java @@ -45,7 +45,7 @@ public class GB { public static final String DISPLAY_MESSAGE_SEVERITY = "severity"; 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()) { return null; } @@ -59,7 +59,7 @@ public class GB { builder.setContentTitle(context.getString(R.string.app_name)) .setTicker(text) .setContentText(text) - .setSmallIcon(R.drawable.ic_notification) + .setSmallIcon(connected ? R.drawable.ic_notification : R.drawable.ic_notification_disconnected) .setContentIntent(pendingIntent) .setOngoing(true); if (GBApplication.isRunningLollipopOrLater()) { @@ -68,8 +68,8 @@ public class GB { return builder.build(); } - public static void updateNotification(String text, Context context) { - Notification notification = createNotification(text, context); + public static void updateNotification(String text, boolean connected, Context context) { + Notification notification = createNotification(text, connected, context); updateNotification(notification, NOTIFICATION_ID, context); } diff --git a/app/src/main/res/drawable-hdpi/ic_notification_disconnected.png b/app/src/main/res/drawable-hdpi/ic_notification_disconnected.png new file mode 100644 index 0000000000000000000000000000000000000000..5d510a7a96b83e9ab703d00d19477c6338e13f18 GIT binary patch literal 1202 zcmV;j1Wo&iP)M?s9>M``&~-il000McNliru-~qKI*!OK{`D0nv@R z5Lp;C21(S!g;5m67_>nVi8c}k8~~fN+Ko*?cYQ86m3|gAys9P|PjZvWedpcxzcc*j zf0f8#YV}qDm|eoJ)pj-E@}o!ouxjkKC4b{2hcQit-4O# ztp2Eu2B1&Wof&}J)vF>3)n|36J?cy9Dz&Hjc`0Xi-2*%o{(Zn#KsPW4I1JnX6f?Je z58MfS3>;4>p-u-D1D67q0jp9<{kZ{Uz?=`f4xE{}JPP~*YzIofQeYv_71y@{2Z8;- z6F?bQ7rqYwqba37+ey__^)(w?zq&0bU_jlkKBo>wT6e3x>MQD;@$${RYRP=|zS^g5 zRKKaZwp(3R)gaU={z8LPT?jmwNkhfTu_|^P_!Srez77UoTy;+oxC2-XOllO2Vx9eN z;343Q8rS-P4}c}W0pNF_GYb3waDA2kAz%-%JkDJLtPS6jMov9I=K|N(*e?UyfNz1* zfOCM^0qEW6pze(SQ21X0OpCp{BdV*bBHa+syvzYv8;q8}CQ>>v_TLGB^Quz$UZgL( zzX#Y<3rx+nj~Y4~crzkZZAXB;Q8!b90)7B)jA$jmh*%eJW#-<`fk%TzMrtX9)S#&E z0-gaT)QRG;0961c$D0>{9^ljPSq^l>@8008!@!#0B5LWHedKLIPE$VclPnwqfmMG@WwEmGN$05vVTa0+k%a1^)+_^6(sE7U|e z=G+TB9dF%=O^$i>2QU@5IMTTv*f(AcG*f-sQ)8Re&PLLtkOS91bjHC`AUbyi9kd51 zle!Oq4bjf++6eGPvk!u%5sI5Tqac492cVyWR8NVxpRI0HSA@i9)dtm-wNzv~U}mT< zsF$k~)b%ZbIi{{@R?N9l7Mk~VU`MP{ux+`8ciIR%UXikG15)P#>w`Zw0>hcXYjjJa zH4;+gd0;5-mu;~IkS<^b@MO%S4Kd}X1GmJ$?TrT>t#qDHNMp=jj7B&HTn&7u_U8eW zYJgc8x~2%+ms0A_D1a@%=>eiw*p#447%WQ(m{dqiOebdCikNo;A=-B20aUC3a3rSu z-jvcngBK~K6S8Abg07ClaEy$f8+4M=;NO literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_notification_disconnected.png b/app/src/main/res/drawable-mdpi/ic_notification_disconnected.png new file mode 100644 index 0000000000000000000000000000000000000000..f1587ca34dd657c095b5befaa149ade288552268 GIT binary patch literal 1033 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM3?#3wJbQ|PfvG9LC&cytC>W+8@bCYBAi@Li z%i_^UU8z$2z8%0s$ygHP7tG-B>_!@hljQC0!qCAg>jC6&7I;J!Gcd><0%69y3#E2I zLG}_)Usv`AEc_z6`p=hVuLJ5~@N{tu(Kw%+puiDvb3=D=?A}wnsYXUh-W(iUoZTHx zM<%MMs4QKQnzBA_sFiteor?Qn-3``1+{ZH*Vc* zJ~DTXpio};`d!r(Rh7+0{{C6dc0jdheH@XY zn^h*(f7LoMqv_D1N0TlYrMwSqI?{M+)vD}u*Oa^+jyf(7^!=m7vt?12amfJ{tH7g@ zRSO>N&3MG~S6Iz&mQCs_6Om?zCu?pNKRY*je}ZC_jqcuEJT7bZ?PBvy`rFp4kahc; z?2D+f_cwRv|8Hz=H+b~t#z$dw|9MumZ3&AQ8NMD#b$+*Iy%8{Y7(8A5T-G@yGywoG CTp48m literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_notification_disconnected.png b/app/src/main/res/drawable-xhdpi/ic_notification_disconnected.png new file mode 100644 index 0000000000000000000000000000000000000000..b382a8f75b78051d9c8ee4cf775b8f675d27e75b GIT binary patch literal 1469 zcmV;u1w#6XP)M?s9>M``&~-il000McNliru-~=v**d9@|FSI}u`K2%-3bLqdMJS5U zs6a^3NGgdDr4I&?l9?lExQ*jjlMaMwjydBpcm932&&`+9+3q>#Mt>M)?m6c^_xV5X zv)^%KfTXBf4iJEIjz&SA0;MbhoOA#Dc(@w)7`JN;)iQrJX<+j!1g87TjS( z>Tw%ar}fVO76Z2jZv*>*4Ztp-AD9b_4-s`7co#SZEC+V@g|Cs8N79oqK3~HjJBg1Z zbx7*-;y{u2P7Wv7%X#k&LoEx;$hT`@9-f%k#)fzhVu zL3{5+U<&Y!S^lyZIUBvx`2%v2ZlG+@4@$oV3Pz$NCtQRoNe12+SAM!3T+;K3LfOM!bLWbetFKJT}tEDD2? zzOuaDA*t8q0a>b?laOlPlhhw_eV?SeC6$tbIVlDv0AHGG#9_dKb(^`(SYQkAOw4=U z0v<4T^R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