1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-01 22:43:00 +01:00

Merge pull request #122 from roidelapluie/colors

Pebble: Support Colors in notifications
This commit is contained in:
Andreas Shimokawa 2015-09-13 14:58:05 +02:00
commit 04086a3b4c
2 changed files with 91 additions and 2 deletions

View File

@ -0,0 +1,76 @@
package nodomain.freeyourgadget.gadgetbridge.devices.pebble;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class ColorConst {
private static final Logger LOG = LoggerFactory.getLogger(ColorConst.class);
public static final byte COLOR_Black = (byte) 0b11000000;
public static final byte COLOR_OxfordBlue = (byte) 0b11000001;
public static final byte COLOR_DukeBlue = (byte) 0b11000010;
public static final byte COLOR_Blue = (byte) 0b11000011;
public static final byte COLOR_DarkGreen = (byte) 0b11000100;
public static final byte COLOR_MidnightGreen = (byte) 0b11000101;
public static final byte COLOR_CobaltBlue = (byte) 0b11000110;
public static final byte COLOR_BlueMoon = (byte) 0b11000111;
public static final byte COLOR_IslamicGreen = (byte) 0b11001000;
public static final byte COLOR_JaegerGreen = (byte) 0b11001001;
public static final byte COLOR_TiffanyBlue = (byte) 0b11001010;
public static final byte COLOR_VividCerulean = (byte) 0b11001011;
public static final byte COLOR_Green = (byte) 0b11001100;
public static final byte COLOR_Malachite = (byte) 0b11001101;
public static final byte COLOR_MediumSpringGreen = (byte) 0b11001110;
public static final byte COLOR_Cyan = (byte) 0b11001111;
public static final byte COLOR_BulgarianRose = (byte) 0b11010000;
public static final byte COLOR_ImperialPurple = (byte) 0b11010001;
public static final byte COLOR_Indigo = (byte) 0b11010010;
public static final byte COLOR_ElectricUltramarine = (byte) 0b11010011;
public static final byte COLOR_ArmyGreen = (byte) 0b11010100;
public static final byte COLOR_DarkGray = (byte) 0b11010101;
public static final byte COLOR_Liberty = (byte) 0b11010110;
public static final byte COLOR_VeryLightBlue = (byte) 0b11010111;
public static final byte COLOR_KellyGreen = (byte) 0b11011000;
public static final byte COLOR_MayGreen = (byte) 0b11011001;
public static final byte COLOR_CadetBlue = (byte) 0b11011010;
public static final byte COLOR_PictonBlue = (byte) 0b11011011;
public static final byte COLOR_BrightGreen = (byte) 0b11011100;
public static final byte COLOR_ScreaminGreen = (byte) 0b11011101;
public static final byte COLOR_MediumAquamarine = (byte) 0b11011110;
public static final byte COLOR_ElectricBlue = (byte) 0b11011111;
public static final byte COLOR_DarkCandyAppleRed = (byte) 0b11100000;
public static final byte COLOR_JazzberryJam = (byte) 0b11100001;
public static final byte COLOR_Purple = (byte) 0b11100010;
public static final byte COLOR_VividViolet = (byte) 0b11100011;
public static final byte COLOR_WindsorTan = (byte) 0b11100100;
public static final byte COLOR_RoseVale = (byte) 0b11100101;
public static final byte COLOR_Purpureus = (byte) 0b11100110;
public static final byte COLOR_LavenderIndigo = (byte) 0b11100111;
public static final byte COLOR_Limerick = (byte) 0b11101000;
public static final byte COLOR_Brass = (byte) 0b11101001;
public static final byte COLOR_LightGray = (byte) 0b11101010;
public static final byte COLOR_BabyBlueEyes = (byte) 0b11101011;
public static final byte COLOR_SpringBud = (byte) 0b11101100;
public static final byte COLOR_Inchworm = (byte) 0b11101101;
public static final byte COLOR_MintGreen = (byte) 0b11101110;
public static final byte COLOR_Celeste = (byte) 0b11101111;
public static final byte COLOR_Red = (byte) 0b11110000;
public static final byte COLOR_Folly = (byte) 0b11110001;
public static final byte COLOR_FashionMagenta = (byte) 0b11110010;
public static final byte COLOR_Magenta = (byte) 0b11110011;
public static final byte COLOR_Orange = (byte) 0b11110100;
public static final byte COLOR_SunsetOrange = (byte) 0b11110101;
public static final byte COLOR_BrilliantRose = (byte) 0b11110110;
public static final byte COLOR_ShockingPink = (byte) 0b11110111;
public static final byte COLOR_ChromeYellow = (byte) 0b11111000;
public static final byte COLOR_Rajah = (byte) 0b11111001;
public static final byte COLOR_Melon = (byte) 0b11111010;
public static final byte COLOR_RichBrilliantLavender = (byte) 0b11111011;
public static final byte COLOR_Yellow = (byte) 0b11111100;
public static final byte COLOR_Icterine = (byte) 0b11111101;
public static final byte COLOR_PastelYellow = (byte) 0b11111110;
public static final byte COLOR_White = (byte) 0b11111111;
public static final byte COLOR_Clear = (byte) 0b00000000;
}

View File

@ -13,6 +13,7 @@ import java.util.Random;
import java.util.SimpleTimeZone; import java.util.SimpleTimeZone;
import java.util.UUID; import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.ColorConst;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppManagement; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppManagement;
@ -699,29 +700,37 @@ public class PebbleProtocol extends GBDeviceProtocol {
String[] parts = {title, subtitle, body}; String[] parts = {title, subtitle, body};
int icon_id; int icon_id;
byte color_id;
switch (type) { switch (type) {
case NOTIFICATION_EMAIL: case NOTIFICATION_EMAIL:
icon_id = ICON_GENERIC_EMAIL; icon_id = ICON_GENERIC_EMAIL;
color_id = ColorConst.COLOR_JaegerGreen;
break; break;
case NOTIFICATION_SMS: case NOTIFICATION_SMS:
icon_id = ICON_GENERIC_SMS; icon_id = ICON_GENERIC_SMS;
color_id = ColorConst.COLOR_VividViolet;
break; break;
default: default:
switch(notificationKind){ switch(notificationKind){
case TWITTER: case TWITTER:
icon_id = ICON_NOTIFICATION_TWITTER; icon_id = ICON_NOTIFICATION_TWITTER;
color_id = ColorConst.COLOR_BlueMoon;
break; break;
case EMAIL: case EMAIL:
icon_id = ICON_GENERIC_EMAIL; icon_id = ICON_GENERIC_EMAIL;
color_id = ColorConst.COLOR_JaegerGreen;
break; break;
case FACEBOOK: case FACEBOOK:
icon_id = ICON_NOTIFICATION_FACEBOOK; icon_id = ICON_NOTIFICATION_FACEBOOK;
color_id = ColorConst.COLOR_VeryLightBlue;
break; break;
case CHAT: case CHAT:
icon_id = ICON_NOTIFICATION_HIPCHAT; icon_id = ICON_NOTIFICATION_HIPCHAT;
color_id = ColorConst.COLOR_Inchworm;
break; break;
default: default:
icon_id = ICON_NOTIFICATION_GENERIC; icon_id = ICON_NOTIFICATION_GENERIC;
color_id = ColorConst.COLOR_Red;
break; break;
} }
break; break;
@ -744,8 +753,8 @@ public class PebbleProtocol extends GBDeviceProtocol {
actions_length = (short) (ACTION_LENGTH_MIN * actions_count + dismiss_string.length() + open_string.length()); actions_length = (short) (ACTION_LENGTH_MIN * actions_count + dismiss_string.length() + open_string.length());
} }
byte attributes_count = 1; // icon byte attributes_count = 2; // icon
short attributes_length = (short) (7 + actions_length); // icon short attributes_length = (short) (11 + actions_length);
if (parts != null) { if (parts != null) {
for (String s : parts) { for (String s : parts) {
if (s == null || s.equals("")) { if (s == null || s.equals("")) {
@ -800,6 +809,10 @@ public class PebbleProtocol extends GBDeviceProtocol {
buf.putShort((short) 4); // length of int buf.putShort((short) 4); // length of int
buf.putInt(0x80000000 | icon_id); buf.putInt(0x80000000 | icon_id);
buf.put((byte) 28); // background_color
buf.putShort((short) 1); // length of int
buf.put(color_id);
// dismiss action // dismiss action
buf.put(dismiss_action_id); buf.put(dismiss_action_id);
buf.put((byte) 0x02); // generic action, dismiss did not do anything buf.put((byte) 0x02); // generic action, dismiss did not do anything