1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-29 05:16:51 +01:00

Some refactoring:

- Put Pebble icon ID constants in its own class
- remove ICON_ and COLOR_ prefixes from constants
This commit is contained in:
Andreas Shimokawa 2015-09-13 15:21:07 +02:00
parent dfe86d681d
commit d3dbde6917
4 changed files with 186 additions and 185 deletions

View File

@ -1,76 +0,0 @@
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

@ -0,0 +1,72 @@
package nodomain.freeyourgadget.gadgetbridge.devices.pebble;
public final class PebbleColor {
public static final byte Black = (byte) 0b11000000;
public static final byte OxfordBlue = (byte) 0b11000001;
public static final byte DukeBlue = (byte) 0b11000010;
public static final byte Blue = (byte) 0b11000011;
public static final byte DarkGreen = (byte) 0b11000100;
public static final byte MidnightGreen = (byte) 0b11000101;
public static final byte CobaltBlue = (byte) 0b11000110;
public static final byte BlueMoon = (byte) 0b11000111;
public static final byte IslamicGreen = (byte) 0b11001000;
public static final byte JaegerGreen = (byte) 0b11001001;
public static final byte TiffanyBlue = (byte) 0b11001010;
public static final byte VividCerulean = (byte) 0b11001011;
public static final byte Green = (byte) 0b11001100;
public static final byte Malachite = (byte) 0b11001101;
public static final byte MediumSpringGreen = (byte) 0b11001110;
public static final byte Cyan = (byte) 0b11001111;
public static final byte BulgarianRose = (byte) 0b11010000;
public static final byte ImperialPurple = (byte) 0b11010001;
public static final byte Indigo = (byte) 0b11010010;
public static final byte ElectricUltramarine = (byte) 0b11010011;
public static final byte ArmyGreen = (byte) 0b11010100;
public static final byte DarkGray = (byte) 0b11010101;
public static final byte Liberty = (byte) 0b11010110;
public static final byte VeryLightBlue = (byte) 0b11010111;
public static final byte KellyGreen = (byte) 0b11011000;
public static final byte MayGreen = (byte) 0b11011001;
public static final byte CadetBlue = (byte) 0b11011010;
public static final byte PictonBlue = (byte) 0b11011011;
public static final byte BrightGreen = (byte) 0b11011100;
public static final byte ScreaminGreen = (byte) 0b11011101;
public static final byte MediumAquamarine = (byte) 0b11011110;
public static final byte ElectricBlue = (byte) 0b11011111;
public static final byte DarkCandyAppleRed = (byte) 0b11100000;
public static final byte JazzberryJam = (byte) 0b11100001;
public static final byte Purple = (byte) 0b11100010;
public static final byte VividViolet = (byte) 0b11100011;
public static final byte WindsorTan = (byte) 0b11100100;
public static final byte RoseVale = (byte) 0b11100101;
public static final byte Purpureus = (byte) 0b11100110;
public static final byte LavenderIndigo = (byte) 0b11100111;
public static final byte Limerick = (byte) 0b11101000;
public static final byte Brass = (byte) 0b11101001;
public static final byte LightGray = (byte) 0b11101010;
public static final byte BabyBlueEyes = (byte) 0b11101011;
public static final byte SpringBud = (byte) 0b11101100;
public static final byte Inchworm = (byte) 0b11101101;
public static final byte MintGreen = (byte) 0b11101110;
public static final byte Celeste = (byte) 0b11101111;
public static final byte Red = (byte) 0b11110000;
public static final byte Folly = (byte) 0b11110001;
public static final byte FashionMagenta = (byte) 0b11110010;
public static final byte Magenta = (byte) 0b11110011;
public static final byte Orange = (byte) 0b11110100;
public static final byte SunsetOrange = (byte) 0b11110101;
public static final byte BrilliantRose = (byte) 0b11110110;
public static final byte ShockingPink = (byte) 0b11110111;
public static final byte ChromeYellow = (byte) 0b11111000;
public static final byte Rajah = (byte) 0b11111001;
public static final byte Melon = (byte) 0b11111010;
public static final byte RichBrilliantLavender = (byte) 0b11111011;
public static final byte Yellow = (byte) 0b11111100;
public static final byte Icterine = (byte) 0b11111101;
public static final byte PastelYellow = (byte) 0b11111110;
public static final byte White = (byte) 0b11111111;
public static final byte Clear = (byte) 0b00000000;
}

View File

@ -0,0 +1,95 @@
package nodomain.freeyourgadget.gadgetbridge.devices.pebble;
public final class PebbleIconID {
public static final int NOTIFICATION_GENERIC = 1;
public static final int TIMELINE_MISSED_CALL = 2;
public static final int NOTIFICATION_REMINDER = 3;
public static final int NOTIFICATION_FLAG = 4;
public static final int NOTIFICATION_WHATSAPP = 5;
public static final int NOTIFICATION_TWITTER = 6;
public static final int NOTIFICATION_TELEGRAM = 7;
public static final int NOTIFICATION_GOOGLE_HANGOUTS = 8;
public static final int NOTIFICATION_GMAIL = 9;
public static final int NOTIFICATION_FACEBOOK_MESSENGER = 10;
public static final int NOTIFICATION_FACEBOOK = 11;
public static final int AUDIO_CASSETTE = 12;
public static final int ALARM_CLOCK = 13;
public static final int TIMELINE_WEATHER = 14;
public static final int TIMELINE_SUN = 16;
public static final int TIMELINE_SPORTS = 17;
public static final int GENERIC_EMAIL = 19;
public static final int AMERICAN_FOOTBALL = 20;
public static final int TIMELINE_CALENDAR = 21;
public static final int TIMELINE_BASEBALL = 22;
public static final int BIRTHDAY_EVENT = 23;
public static final int CAR_RENTAL = 24;
public static final int CLOUDY_DAY = 25;
public static final int CRICKET_GAME = 26;
public static final int DINNER_RESERVATION = 27;
public static final int GENERIC_WARNING = 28;
public static final int GLUCOSE_MONITOR = 29;
public static final int HOCKEY_GAME = 30;
public static final int HOTEL_RESERVATION = 31;
public static final int LIGHT_RAIN = 32;
public static final int LIGHT_SNOW = 33;
public static final int MOVIE_EVENT = 34;
public static final int MUSIC_EVENT = 35;
public static final int NEWS_EVENT = 36;
public static final int PARTLY_CLOUDY = 37;
public static final int PAY_BILL = 38;
public static final int RADIO_SHOW = 39;
public static final int SCHEDULED_EVENT = 40;
public static final int SOCCER_GAME = 41;
public static final int STOCKS_EVENT = 42;
public static final int RESULT_DELETED = 43;
public static final int CHECK_INTERNET_CONNECTION = 44;
public static final int GENERIC_SMS = 45;
public static final int RESULT_MUTE = 46;
public static final int RESULT_SENT = 47;
public static final int WATCH_DISCONNECTED = 48;
public static final int DURING_PHONE_CALL = 49;
public static final int TIDE_IS_HIGH = 50;
public static final int RESULT_DISMISSED = 51;
public static final int HEAVY_RAIN = 52;
public static final int HEAVY_SNOW = 53;
public static final int SCHEDULED_FLIGHT = 54;
public static final int GENERIC_CONFIRMATION = 55;
public static final int DAY_SEPARATOR = 56;
public static final int NO_EVENTS = 57;
public static final int NOTIFICATION_BLACKBERRY_MESSENGER = 58;
public static final int NOTIFICATION_INSTAGRAM = 59;
public static final int NOTIFICATION_MAILBOX = 60;
public static final int NOTIFICATION_GOOGLE_INBOX = 61;
public static final int RESULT_FAILED = 62;
public static final int GENERIC_QUESTION = 63;
public static final int NOTIFICATION_OUTLOOK = 64;
public static final int RAINING_AND_SNOWING = 65;
public static final int REACHED_FITNESS_GOAL = 66;
public static final int NOTIFICATION_LINE = 67;
public static final int NOTIFICATION_SKYPE = 68;
public static final int NOTIFICATION_SNAPCHAT = 69;
public static final int NOTIFICATION_VIBER = 70;
public static final int NOTIFICATION_WECHAT = 71;
public static final int NOTIFICATION_YAHOO_MAIL = 72;
public static final int TV_SHOW = 73;
public static final int BASKETBALL = 74;
public static final int DISMISSED_PHONE_CALL = 75;
public static final int NOTIFICATION_GOOGLE_MESSENGER = 76;
public static final int NOTIFICATION_HIPCHAT = 77;
public static final int INCOMING_PHONE_CALL = 78;
public static final int NOTIFICATION_KAKAOTALK = 79;
public static final int NOTIFICATION_KIK = 80;
public static final int NOTIFICATION_LIGHTHOUSE = 81;
public static final int LOCATION = 82;
public static final int SETTINGS = 83;
public static final int SUNRISE = 84;
public static final int SUNSET = 85;
public static final int FACETIME_DISMISSED = 86;
public static final int FACETIME_INCOMING = 87;
public static final int FACETIME_OUTGOING = 88;
public static final int FACETIME_MISSED = 89;
public static final int FACETIME_DURING = 90;
public static final int BLUESCREEN_OF_DEATH = 91;
public static final int START_MUSIC_PHONE = 92;
}

View File

@ -13,7 +13,8 @@ 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.devices.pebble.PebbleColor;
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleIconID;
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;
@ -80,97 +81,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
static final byte NOTIFICATION_TWITTER = 2; static final byte NOTIFICATION_TWITTER = 2;
static final byte NOTIFICATION_FACEBOOK = 3; static final byte NOTIFICATION_FACEBOOK = 3;
static final byte ICON_NOTIFICATION_GENERIC = 1;
static final byte ICON_TIMELINE_MISSED_CALL = 2;
static final byte ICON_NOTIFICATION_REMINDER = 3;
static final byte ICON_NOTIFICATION_FLAG = 4;
static final byte ICON_NOTIFICATION_WHATSAPP = 5;
static final byte ICON_NOTIFICATION_TWITTER = 6;
static final byte ICON_NOTIFICATION_TELEGRAM = 7;
static final byte ICON_NOTIFICATION_GOOGLE_HANGOUTS = 8;
static final byte ICON_NOTIFICATION_GMAIL = 9;
static final byte ICON_NOTIFICATION_FACEBOOK_MESSENGER = 10;
static final byte ICON_NOTIFICATION_FACEBOOK = 11;
static final byte ICON_AUDIO_CASSETTE = 12;
static final byte ICON_ALARM_CLOCK = 13;
static final byte ICON_TIMELINE_WEATHER = 14;
static final byte ICON_TIMELINE_SUN = 16;
static final byte ICON_TIMELINE_SPORTS = 17;
static final byte ICON_GENERIC_EMAIL = 19;
static final byte ICON_AMERICAN_FOOTBALL = 20;
static final byte ICON_TIMELINE_CALENDAR = 21;
static final byte ICON_TIMELINE_BASEBALL = 22;
static final byte ICON_BIRTHDAY_EVENT = 23;
static final byte ICON_CAR_RENTAL = 24;
static final byte ICON_CLOUDY_DAY = 25;
static final byte ICON_CRICKET_GAME = 26;
static final byte ICON_DINNER_RESERVATION = 27;
static final byte ICON_GENERIC_WARNING = 28;
static final byte ICON_GLUCOSE_MONITOR = 29;
static final byte ICON_HOCKEY_GAME = 30;
static final byte ICON_HOTEL_RESERVATION = 31;
static final byte ICON_LIGHT_RAIN = 32;
static final byte ICON_LIGHT_SNOW = 33;
static final byte ICON_MOVIE_EVENT = 34;
static final byte ICON_MUSIC_EVENT = 35;
static final byte ICON_NEWS_EVENT = 36;
static final byte ICON_PARTLY_CLOUDY = 37;
static final byte ICON_PAY_BILL = 38;
static final byte ICON_RADIO_SHOW = 39;
static final byte ICON_SCHEDULED_EVENT = 40;
static final byte ICON_SOCCER_GAME = 41;
static final byte ICON_STOCKS_EVENT = 42;
static final byte ICON_RESULT_DELETED = 43;
static final byte ICON_CHECK_INTERNET_CONNECTION = 44;
static final byte ICON_GENERIC_SMS = 45;
static final byte ICON_RESULT_MUTE = 46;
static final byte ICON_RESULT_SENT = 47;
static final byte ICON_WATCH_DISCONNECTED = 48;
static final byte ICON_DURING_PHONE_CALL = 49;
static final byte ICON_TIDE_IS_HIGH = 50;
static final byte ICON_RESULT_DISMISSED = 51;
static final byte ICON_HEAVY_RAIN = 52;
static final byte ICON_HEAVY_SNOW = 53;
static final byte ICON_SCHEDULED_FLIGHT = 54;
static final byte ICON_GENERIC_CONFIRMATION = 55;
static final byte ICON_DAY_SEPARATOR = 56;
static final byte ICON_NO_EVENTS = 57;
static final byte ICON_NOTIFICATION_BLACKBERRY_MESSENGER = 58;
static final byte ICON_NOTIFICATION_INSTAGRAM = 59;
static final byte ICON_NOTIFICATION_MAILBOX = 60;
static final byte ICON_NOTIFICATION_GOOGLE_INBOX = 61;
static final byte ICON_RESULT_FAILED = 62;
static final byte ICON_GENERIC_QUESTION = 63;
static final byte ICON_NOTIFICATION_OUTLOOK = 64;
static final byte ICON_RAINING_AND_SNOWING = 65;
static final byte ICON_REACHED_FITNESS_GOAL = 66;
static final byte ICON_NOTIFICATION_LINE = 67;
static final byte ICON_NOTIFICATION_SKYPE = 68;
static final byte ICON_NOTIFICATION_SNAPCHAT = 69;
static final byte ICON_NOTIFICATION_VIBER = 70;
static final byte ICON_NOTIFICATION_WECHAT = 71;
static final byte ICON_NOTIFICATION_YAHOO_MAIL = 72;
static final byte ICON_TV_SHOW = 73;
static final byte ICON_BASKETBALL = 74;
static final byte ICON_DISMISSED_PHONE_CALL = 75;
static final byte ICON_NOTIFICATION_GOOGLE_MESSENGER = 76;
static final byte ICON_NOTIFICATION_HIPCHAT = 77;
static final byte ICON_INCOMING_PHONE_CALL = 78;
static final byte ICON_NOTIFICATION_KAKAOTALK = 79;
static final byte ICON_NOTIFICATION_KIK = 80;
static final byte ICON_NOTIFICATION_LIGHTHOUSE = 81;
static final byte ICON_LOCATION = 82;
static final byte ICON_SETTINGS = 83;
static final byte ICON_SUNRISE = 84;
static final byte ICON_SUNSET = 85;
static final byte ICON_FACETIME_DISMISSED = 86;
static final byte ICON_FACETIME_INCOMING = 87;
static final byte ICON_FACETIME_OUTGOING = 88;
static final byte ICON_FACETIME_MISSED = 89;
static final byte ICON_FACETIME_DURING = 90;
static final byte ICON_BLUESCREEN_OF_DEATH = 91;
static final byte ICON_START_MUSIC_PHONE = 92;
static final byte PHONECONTROL_ANSWER = 1; static final byte PHONECONTROL_ANSWER = 1;
static final byte PHONECONTROL_HANGUP = 2; static final byte PHONECONTROL_HANGUP = 2;
static final byte PHONECONTROL_GETSTATE = 3; static final byte PHONECONTROL_GETSTATE = 3;
@ -703,34 +613,34 @@ public class PebbleProtocol extends GBDeviceProtocol {
byte color_id; byte color_id;
switch (type) { switch (type) {
case NOTIFICATION_EMAIL: case NOTIFICATION_EMAIL:
icon_id = ICON_GENERIC_EMAIL; icon_id = PebbleIconID.GENERIC_EMAIL;
color_id = ColorConst.COLOR_JaegerGreen; color_id = PebbleColor.JaegerGreen;
break; break;
case NOTIFICATION_SMS: case NOTIFICATION_SMS:
icon_id = ICON_GENERIC_SMS; icon_id = PebbleIconID.GENERIC_SMS;
color_id = ColorConst.COLOR_VividViolet; color_id = PebbleColor.VividViolet;
break; break;
default: default:
switch(notificationKind){ switch(notificationKind){
case TWITTER: case TWITTER:
icon_id = ICON_NOTIFICATION_TWITTER; icon_id = PebbleIconID.NOTIFICATION_TWITTER;
color_id = ColorConst.COLOR_BlueMoon; color_id = PebbleColor.BlueMoon;
break; break;
case EMAIL: case EMAIL:
icon_id = ICON_GENERIC_EMAIL; icon_id = PebbleIconID.GENERIC_EMAIL;
color_id = ColorConst.COLOR_JaegerGreen; color_id = PebbleColor.JaegerGreen;
break; break;
case FACEBOOK: case FACEBOOK:
icon_id = ICON_NOTIFICATION_FACEBOOK; icon_id = PebbleIconID.NOTIFICATION_FACEBOOK;
color_id = ColorConst.COLOR_VeryLightBlue; color_id = PebbleColor.VeryLightBlue;
break; break;
case CHAT: case CHAT:
icon_id = ICON_NOTIFICATION_HIPCHAT; icon_id = PebbleIconID.NOTIFICATION_HIPCHAT;
color_id = ColorConst.COLOR_Inchworm; color_id = PebbleColor.Inchworm;
break; break;
default: default:
icon_id = ICON_NOTIFICATION_GENERIC; icon_id = PebbleIconID.NOTIFICATION_GENERIC;
color_id = ColorConst.COLOR_Red; color_id = PebbleColor.Red;
break; break;
} }
break; break;
@ -1376,17 +1286,17 @@ public class PebbleProtocol extends GBDeviceProtocol {
case 0x01: case 0x01:
dismissNotification.event = GBDeviceEventNotificationControl.Event.OPEN; dismissNotification.event = GBDeviceEventNotificationControl.Event.OPEN;
caption = "Opened"; caption = "Opened";
icon_id = ICON_DURING_PHONE_CALL; icon_id = PebbleIconID.DURING_PHONE_CALL;
break; break;
case 0x02: case 0x02:
dismissNotification.event = GBDeviceEventNotificationControl.Event.DISMISS; dismissNotification.event = GBDeviceEventNotificationControl.Event.DISMISS;
caption = "Dismissed"; caption = "Dismissed";
icon_id = ICON_RESULT_DISMISSED; icon_id = PebbleIconID.RESULT_DISMISSED;
break; break;
case 0x03: case 0x03:
dismissNotification.event = GBDeviceEventNotificationControl.Event.DISMISS_ALL; dismissNotification.event = GBDeviceEventNotificationControl.Event.DISMISS_ALL;
caption = "All dismissed"; caption = "All dismissed";
icon_id = ICON_RESULT_DISMISSED; icon_id = PebbleIconID.RESULT_DISMISSED;
break; break;
} }
GBDeviceEventSendBytes sendBytesAck = new GBDeviceEventSendBytes(); GBDeviceEventSendBytes sendBytesAck = new GBDeviceEventSendBytes();