Consolidate duplicate Mi2 / Bip icon definition

Also handle some more recently added icons
master
Andreas Shimokawa 2017-09-14 10:15:14 +02:00
parent 2bc0c27b90
commit 3301194e75
6 changed files with 121 additions and 137 deletions

View File

@ -1,97 +0,0 @@
/* Copyright (C) 2017 Andreas Shimokawa
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
public class AmazfitBipIcon {
// icons which are unsure which app they are for are suffixed with _NN
public static final int CHAT = 0;
public static final int PENGUIN_1 = 1;
public static final int MI_CHAT_2 = 2;
public static final int FACEBOOK = 3;
public static final int TWITTER = 4;
public static final int MI_APP_5 = 5;
public static final int SNAPCHAT = 6;
public static final int WHATSAPP = 7;
public static final int RED_WHITE_FIRE_8 = 8;
public static final int CHINESE_9 = 9;
public static final int ALARM_CLOCK = 10;
public static final int APP_11 = 11;
public static final int CAMERA_12 = 12;
public static final int CHAT_BLUE_13 = 13;
public static final int COW_14 = 14;
public static final int CHINESE_15 = 15;
public static final int CHINESE_16 = 16;
public static final int STAR_17 = 17;
public static final int APP_18 = 18;
public static final int CHINESE_19 = 19;
public static final int CHINESE_20 = 20;
public static final int CALENDAR = 21;
public static final int FACEBOOK_MESSENGER = 22;
public static final int WHATSAPP_CALL_23 = 23;
public static final int LINE = 24;
public static final int TELEGRAM = 25;
public static final int KAKAOTALK = 26;
public static final int SKYPE = 27;
public static final int VKONTAKTE = 28;
public static final int POKEMONGO = 29;
public static final int HANGOUTS = 30;
public static final int MI_31 = 31;
public static final int CHINESE_32 = 32;
public static final int CHINESE_33 = 33;
public static final int EMAIL = 34;
public static final int WEATHER = 35;
public static final int HR_WARNING_36 = 36;
public static int mapToIconId(NotificationType type) {
switch (type) {
case UNKNOWN:
return APP_11;
case CONVERSATIONS:
return CHAT;
case GENERIC_EMAIL:
return EMAIL;
case GENERIC_NAVIGATION:
return APP_11;
case GENERIC_SMS:
return CHAT;
case GENERIC_CALENDAR:
return CALENDAR;
case FACEBOOK:
return FACEBOOK;
case FACEBOOK_MESSENGER:
return FACEBOOK_MESSENGER;
case RIOT:
return CHAT;
case SIGNAL:
return CHAT_BLUE_13;
case TWITTER:
return TWITTER;
case TELEGRAM:
return TELEGRAM;
case WHATSAPP:
return WHATSAPP;
case GENERIC_ALARM_CLOCK:
return ALARM_CLOCK;
}
return APP_11;
}
}

View File

@ -110,39 +110,6 @@ public class MiBand2Service {
public static final byte[] COMMAND_SET_FITNESS_GOAL_START = new byte[] { 0x10, 0x0, 0x0 };
public static final byte[] COMMAND_SET_FITNESS_GOAL_END = new byte[] { 0, 0 };
public static final byte ICON_CHAT = 0x00;
public static final byte ICON_PENGUIN = 0x01;
public static final byte ICON_CHAT_MI = 0x02;
public static final byte ICON_FB = 0x03;
public static final byte ICON_TWITTER = 0x04;
public static final byte ICON_MIBAND = 0x05;
public static final byte ICON_SNAPCHAT = 0x06;
public static final byte ICON_WHATSAPP = 0x07;
public static final byte ICON_MANTA = 0x08;
public static final byte ICON_XX0 = 0x09;
public static final byte ICON_ALARM = 0x10;
public static final byte ICON_SHATTERED_GLASS = 0x11;
public static final byte ICON_INSTAGRAM = 0x12;
public static final byte ICON_CHAT_GHOST = 0x13;
public static final byte ICON_COW = 0x14;
public static final byte ICON_XX2 = 0x15;
public static final byte ICON_XX3 = 0x16;
public static final byte ICON_XX4 = 0x17;
public static final byte ICON_XX5 = 0x18;
public static final byte ICON_XX6 = 0x19;
public static final byte ICON_EGALE = 0x1a;
public static final byte ICON_CALENDAR = 0x1b;
public static final byte ICON_XX7 = 0x1c;
public static final byte ICON_PHONE_CALL = 0x1d;
public static final byte ICON_CHAT_LINE = 0x1e;
public static final byte ICON_TELEGRAM = 0x1f;
public static final byte ICON_CHAT_TALK = 0x20;
public static final byte ICON_SKYPE = 0x21;
public static final byte ICON_VK = 0x22;
public static final byte ICON_CIRCLES = 0x23;
public static final byte ICON_HANGOUTS = 0x24;
public static final byte ICON_MI = 0x25;
public static final byte ICON_HIGH_PRIORITY = 0x7;
public static byte ENDPOINT_DISPLAY_ITEMS = 0x0a;

View File

@ -0,0 +1,113 @@
/* Copyright (C) 2017 Andreas Shimokawa
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.miband2;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
public class MiBand2Icon {
// icons which are unsure which app they are for are suffixed with _NN
public static final byte WECHAT = 0;
public static final byte PENGUIN_1 = 1;
public static final byte MI_CHAT_2 = 2;
public static final byte FACEBOOK = 3;
public static final byte TWITTER = 4;
public static final byte MI_APP_5 = 5;
public static final byte SNAPCHAT = 6;
public static final byte WHATSAPP = 7;
public static final byte RED_WHITE_FIRE_8 = 8;
public static final byte CHINESE_9 = 9;
public static final byte ALARM_CLOCK = 10;
public static final byte APP_11 = 11;
public static final byte INSTAGRAM = 12;
public static final byte CHAT_BLUE_13 = 13;
public static final byte COW_14 = 14;
public static final byte CHINESE_15 = 15;
public static final byte CHINESE_16 = 16;
public static final byte STAR_17 = 17;
public static final byte APP_18 = 18;
public static final byte CHINESE_19 = 19;
public static final byte CHINESE_20 = 20;
public static final byte CALENDAR = 21;
public static final byte FACEBOOK_MESSENGER = 22;
public static final byte VIBER = 23;
public static final byte LINE = 24;
public static final byte TELEGRAM = 25;
public static final byte KAKAOTALK = 26;
public static final byte SKYPE = 27;
public static final byte VKONTAKTE = 28;
public static final byte POKEMONGO = 29;
public static final byte HANGOUTS = 30;
public static final byte MI_31 = 31;
public static final byte CHINESE_32 = 32;
public static final byte CHINESE_33 = 33;
public static final byte EMAIL = 34;
public static final byte WEATHER = 35;
public static final byte HR_WARNING_36 = 36;
public static byte mapToIconId(NotificationType type) {
switch (type) {
case UNKNOWN:
return APP_11;
case CONVERSATIONS:
return WECHAT;
case GENERIC_EMAIL:
return EMAIL;
case GENERIC_NAVIGATION:
return APP_11;
case GENERIC_SMS:
return WECHAT;
case GENERIC_CALENDAR:
return CALENDAR;
case FACEBOOK:
return FACEBOOK;
case FACEBOOK_MESSENGER:
return FACEBOOK_MESSENGER;
case GOOGLE_HANGOUTS:
return HANGOUTS;
case INSTAGRAM:
return INSTAGRAM;
case KAKAO_TALK:
return KAKAOTALK;
case LINE:
return LINE;
case RIOT:
return WECHAT;
case SIGNAL:
return CHAT_BLUE_13;
case TWITTER:
return TWITTER;
case SKYPE:
return SKYPE;
case SNAPCHAT:
return SNAPCHAT;
case TELEGRAM:
return TELEGRAM;
case VIBER:
return VIBER;
case WECHAT:
return WECHAT;
case WHATSAPP:
return WHATSAPP;
case GENERIC_ALARM_CLOCK:
return ALARM_CLOCK;
}
return APP_11;
}
}

View File

@ -49,7 +49,7 @@ public class NewAlert {
private final AlertCategory category;
private final int numAlerts;
private final String message;
private int customIcon = -1;
private byte customIcon = -1;
public NewAlert(AlertCategory category, int /*uint8*/ numAlerts, String /*utf8s*/ message) {
this.category = category;
@ -57,7 +57,7 @@ public class NewAlert {
this.message = message;
}
public NewAlert(AlertCategory category, int /*uint8*/ numAlerts, String /*utf8s*/ message, int customIcon) {
public NewAlert(AlertCategory category, int /*uint8*/ numAlerts, String /*utf8s*/ message, byte customIcon) {
this.category = category;
this.numAlerts = numAlerts;
this.message = message;
@ -76,7 +76,7 @@ public class NewAlert {
return message;
}
public int getCustomIcon() {
public byte getCustomIcon() {
return customIcon;
}
}

View File

@ -32,7 +32,7 @@ import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.Logging;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
import nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.AmazfitBipIcon;
import nodomain.freeyourgadget.gadgetbridge.devices.miband2.MiBand2Icon;
import nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.AmazfitBipService;
import nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.AmazfitBipWeatherConditions;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBand2Service;
@ -82,7 +82,7 @@ public class AmazfitBipSupport extends MiBand2Support {
AlertNotificationProfile<?> profile = new AlertNotificationProfile(this);
profile.setMaxLength(230);
int customIconId = AmazfitBipIcon.mapToIconId(notificationSpec.type);
byte customIconId = MiBand2Icon.mapToIconId(notificationSpec.type);
AlertCategory alertCategory = AlertCategory.CustomMiBand2;

View File

@ -21,6 +21,7 @@ import android.support.annotation.NonNull;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBand2Service;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.VibrationProfile;
import nodomain.freeyourgadget.gadgetbridge.devices.miband2.MiBand2Icon;
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
import nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEAction;
import nodomain.freeyourgadget.gadgetbridge.service.btle.GattCharacteristic;
@ -68,9 +69,9 @@ public class Mi2TextNotificationStrategy extends Mi2NotificationStrategy {
case Email:
return new byte[] { BLETypeConversions.fromUint8(AlertCategory.Email.getId()), BLETypeConversions.fromUint8(numAlerts)};
case InstantMessage:
return new byte[] { BLETypeConversions.fromUint8(AlertCategory.CustomMiBand2.getId()), BLETypeConversions.fromUint8(numAlerts), MiBand2Service.ICON_CHAT};
return new byte[] { BLETypeConversions.fromUint8(AlertCategory.CustomMiBand2.getId()), BLETypeConversions.fromUint8(numAlerts), MiBand2Icon.WECHAT};
case News:
return new byte[] { BLETypeConversions.fromUint8(AlertCategory.CustomMiBand2.getId()), BLETypeConversions.fromUint8(numAlerts), MiBand2Service.ICON_PENGUIN};
return new byte[] { BLETypeConversions.fromUint8(AlertCategory.CustomMiBand2.getId()), BLETypeConversions.fromUint8(numAlerts), MiBand2Icon.PENGUIN_1};
}
}
return new byte[] { BLETypeConversions.fromUint8(AlertCategory.SMS.getId()), BLETypeConversions.fromUint8(numAlerts)};