Refactor Notification classes to remove Pebble-isms

Move pebble icons and color to a new class, keeping the original NotificationType enum
This commit is contained in:
Daniele Gobbetti
2025-07-11 09:27:02 +02:00
parent 0b42950ac9
commit cd651ce140
11 changed files with 202 additions and 143 deletions
@@ -129,7 +129,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.PendingIntentUtils;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
import nodomain.freeyourgadget.gadgetbridge.util.WidgetPreferenceStorage;
public class DebugActivity extends AbstractGBActivity {
@@ -215,7 +214,6 @@ public class DebugActivity extends AbstractGBActivity {
.loadLabel(getApplicationContext().getPackageManager())
.toString();
notificationSpec.type = NotificationType.sortedValues()[sendTypeSpinner.getSelectedItemPosition()];
notificationSpec.pebbleColor = notificationSpec.type.color;
notificationSpec.attachedActions = new ArrayList<>();
// DISMISS action
@@ -230,7 +228,7 @@ public class DebugActivity extends AbstractGBActivity {
replyAction.title = getString(R.string._pebble_watch_reply);
replyAction.type = NotificationSpec.Action.TYPE_SYNTECTIC_REPLY_PHONENR;
notificationSpec.attachedActions.add(replyAction);
} else if (notificationSpec.type == NotificationType.CONVERSATIONS) {
} else if ("generic_chat".equals(notificationSpec.type.getGenericType())) {
// REPLY action
NotificationSpec.Action replyAction = new NotificationSpec.Action();
replyAction.title = getString(R.string._pebble_watch_reply);
@@ -72,7 +72,6 @@ public class TextReceiverActivity extends AbstractGBActivity {
notificationSpec.sourceAppId = BuildConfig.APPLICATION_ID;
notificationSpec.sourceName = appName;
notificationSpec.type = NotificationType.UNKNOWN;
notificationSpec.pebbleColor = notificationSpec.type.color;
GBApplication.deviceService().onNotification(notificationSpec);
finish();
@@ -0,0 +1,145 @@
package nodomain.freeyourgadget.gadgetbridge.devices.pebble;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import androidx.palette.graphics.Palette;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Objects;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
import nodomain.freeyourgadget.gadgetbridge.util.BitmapUtil;
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
import nodomain.freeyourgadget.gadgetbridge.util.PebbleUtils;
public class PebbleNotification {
private static final Logger LOG = LoggerFactory.getLogger(PebbleNotification.class);
private final int icon;
private final byte color;
private final NotificationType notificationType;
public PebbleNotification(NotificationSpec notificationSpec) {
this.notificationType = notificationSpec.type;
this.icon = setIcon(notificationSpec.type);
this.color = setColor(notificationSpec);
}
public int getIcon() {
return icon;
}
public byte getColor() {
return color;
}
private byte setColor(NotificationType notificationType) {
return switch (notificationType) {
case UNKNOWN -> PebbleColor.DarkCandyAppleRed;
case AMAZON -> PebbleColor.ChromeYellow;
case BBM -> PebbleColor.DarkGray;
case CONVERSATIONS -> PebbleColor.Inchworm;
case FACEBOOK, HIPCHAT, INSTAGRAM, LINKEDIN -> PebbleColor.CobaltBlue;
case FACEBOOK_MESSENGER, GENERIC_CALENDAR, GOOGLE_INBOX, GOOGLE_MAPS,
GOOGLE_PHOTOS, OUTLOOK, BUSINESS_CALENDAR, SIGNAL, WIRE, TWITTER,
DELTACHAT -> PebbleColor.BlueMoon;
case GENERIC_ALARM_CLOCK, GMAIL -> PebbleColor.Red;
case GENERIC_EMAIL, GENERIC_NAVIGATION -> PebbleColor.Orange;
case GENERIC_PHONE, GOOGLE_HANGOUTS, THREEMA, KONTALK, ANTOX, TRANSIT ->
PebbleColor.JaegerGreen;
case GENERIC_SMS, VIBER -> PebbleColor.VividViolet;
case GOOGLE_MESSENGER, MAILBOX, SKYPE, TELEGRAM -> PebbleColor.VividCerulean;
case KAKAO_TALK -> PebbleColor.Yellow;
case KIK, LINE, WHATSAPP, COL_REMINDER -> PebbleColor.IslamicGreen;
case LIGHTHOUSE -> PebbleColor.PictonBlue;
case RIOT, MOLLY -> PebbleColor.LavenderIndigo;
case SLACK -> PebbleColor.Folly;
case SNAPCHAT -> PebbleColor.Icterine;
case DISCORD -> PebbleColor.Purpureus;
case WECHAT -> PebbleColor.KellyGreen;
case YAHOO_MAIL -> PebbleColor.Indigo;
case ELEMENT, ELEMENTX -> PebbleColor.Malachite;
};
}
private int setIcon(NotificationType notificationType) {
return switch (notificationType) {
case UNKNOWN -> PebbleIconID.NOTIFICATION_GENERIC;
case AMAZON -> PebbleIconID.NOTIFICATION_AMAZON;
case BBM -> PebbleIconID.NOTIFICATION_BLACKBERRY_MESSENGER;
case CONVERSATIONS, HIPCHAT, RIOT, SIGNAL, WIRE, THREEMA, KONTALK,
ANTOX, DISCORD, DELTACHAT, ELEMENT, ELEMENTX, MOLLY ->
PebbleIconID.NOTIFICATION_HIPCHAT;
case FACEBOOK -> PebbleIconID.NOTIFICATION_FACEBOOK;
case FACEBOOK_MESSENGER -> PebbleIconID.NOTIFICATION_FACEBOOK_MESSENGER;
case GENERIC_ALARM_CLOCK -> PebbleIconID.ALARM_CLOCK;
case GENERIC_CALENDAR, BUSINESS_CALENDAR -> PebbleIconID.TIMELINE_CALENDAR;
case GENERIC_EMAIL -> PebbleIconID.GENERIC_EMAIL;
case GENERIC_NAVIGATION, TRANSIT -> PebbleIconID.LOCATION;
case GENERIC_PHONE -> PebbleIconID.DURING_PHONE_CALL;
case GENERIC_SMS -> PebbleIconID.GENERIC_SMS;
case GMAIL -> PebbleIconID.NOTIFICATION_GMAIL;
case GOOGLE_HANGOUTS -> PebbleIconID.NOTIFICATION_GOOGLE_HANGOUTS;
case GOOGLE_INBOX -> PebbleIconID.NOTIFICATION_GOOGLE_INBOX;
case GOOGLE_MAPS -> PebbleIconID.NOTIFICATION_GOOGLE_MAPS;
case GOOGLE_MESSENGER -> PebbleIconID.NOTIFICATION_GOOGLE_MESSENGER;
case GOOGLE_PHOTOS -> PebbleIconID.NOTIFICATION_GOOGLE_PHOTOS;
case INSTAGRAM -> PebbleIconID.NOTIFICATION_INSTAGRAM;
case KAKAO_TALK -> PebbleIconID.NOTIFICATION_KAKAOTALK;
case KIK -> PebbleIconID.NOTIFICATION_KIK;
case LIGHTHOUSE -> PebbleIconID.NOTIFICATION_LIGHTHOUSE;
case LINE -> PebbleIconID.NOTIFICATION_LINE;
case LINKEDIN -> PebbleIconID.NOTIFICATION_LINKEDIN;
case MAILBOX -> PebbleIconID.NOTIFICATION_MAILBOX;
case OUTLOOK -> PebbleIconID.NOTIFICATION_OUTLOOK;
case SKYPE -> PebbleIconID.NOTIFICATION_SKYPE;
case SLACK -> PebbleIconID.NOTIFICATION_SLACK;
case SNAPCHAT -> PebbleIconID.NOTIFICATION_SNAPCHAT;
case TELEGRAM -> PebbleIconID.NOTIFICATION_TELEGRAM;
case TWITTER -> PebbleIconID.NOTIFICATION_TWITTER;
case VIBER -> PebbleIconID.NOTIFICATION_VIBER;
case WECHAT -> PebbleIconID.NOTIFICATION_WECHAT;
case WHATSAPP -> PebbleIconID.NOTIFICATION_WHATSAPP;
case YAHOO_MAIL -> PebbleIconID.NOTIFICATION_YAHOO_MAIL;
case COL_REMINDER -> PebbleIconID.NOTIFICATION_REMINDER;
};
}
/**
* @param notificationSpec The NotificationSpec to read from.
* @return Returns a PebbleColor that best represents this notification.
*/
private byte setColor(NotificationSpec notificationSpec) {
String appId = notificationSpec.sourceAppId;
NotificationType existingType = notificationSpec.type;
// If the notification type is known, return the associated color.
if (existingType != NotificationType.UNKNOWN) {
return setColor(existingType);
}
// Otherwise, we go and attempt to find the color from the app icon.
Drawable icon;
try {
icon = NotificationUtils.getAppIcon(GBApplication.getContext(), appId);
Objects.requireNonNull(icon);
} catch (Exception ex) {
// If we can't get the icon, we go with the default defined above.
LOG.warn("Could not get icon for AppID " + appId, ex);
return PebbleColor.IslamicGreen;
}
Bitmap bitmapIcon = BitmapUtil.convertDrawableToBitmap(icon);
int iconPrimaryColor = new Palette.Builder(bitmapIcon)
.generate()
.getVibrantColor(Color.parseColor("#aa0000"));
return PebbleUtils.getPebbleColor(iconPrimaryColor);
}
}
@@ -146,7 +146,6 @@ public class IntentApiReceiver extends BroadcastReceiver {
notificationSpec.sourceName = context.getApplicationInfo()
.loadLabel(context.getPackageManager())
.toString();
notificationSpec.pebbleColor = notificationSpec.type.color;
notificationSpec.attachedActions = new ArrayList<>();
if (notificationSpec.type == NotificationType.GENERIC_SMS) {
// REPLY action
@@ -429,9 +429,6 @@ public class NotificationListener extends NotificationListenerService {
notificationSpec.type = NotificationType.UNKNOWN;
}
// Get color
notificationSpec.pebbleColor = getPebbleColorForNotification(notificationSpec);
LOG.info(
"Processing notification {}, age: {}, source: {}, flags: {}",
notificationSpec.getId(),
@@ -1165,45 +1162,6 @@ public class NotificationListener extends NotificationListenerService {
}
/**
* Get the notification color that should be used for this Pebble notification.
* <p>
* Note that this method will *not* edit the NotificationSpec passed in. It will only evaluate the PebbleColor.
* <p>
* See Issue #815 on GitHub to see how notification colors are set.
*
* @param notificationSpec The NotificationSpec to read from.
* @return Returns a PebbleColor that best represents this notification.
*/
private byte getPebbleColorForNotification(NotificationSpec notificationSpec) {
String appId = notificationSpec.sourceAppId;
NotificationType existingType = notificationSpec.type;
// If the notification type is known, return the associated color.
if (existingType != NotificationType.UNKNOWN) {
return existingType.color;
}
// Otherwise, we go and attempt to find the color from the app icon.
Drawable icon;
try {
icon = NotificationUtils.getAppIcon(getApplicationContext(), appId);
Objects.requireNonNull(icon);
} catch (Exception ex) {
// If we can't get the icon, we go with the default defined above.
LOG.warn("Could not get icon for AppID " + appId, ex);
return PebbleColor.IslamicGreen;
}
Bitmap bitmapIcon = BitmapUtil.convertDrawableToBitmap(icon);
int iconPrimaryColor = new Palette.Builder(bitmapIcon)
.generate()
.getVibrantColor(Color.parseColor("#aa0000"));
return PebbleUtils.getPebbleColor(iconPrimaryColor);
}
private static class NotificationAction {
private final PendingIntent intent;
@Nullable
@@ -176,7 +176,6 @@ public class GBDeviceService implements DeviceService {
.putExtra(EXTRA_NOTIFICATION_TYPE, notificationSpec.type)
.putExtra(EXTRA_NOTIFICATION_ACTIONS, notificationSpec.attachedActions)
.putExtra(EXTRA_NOTIFICATION_SOURCENAME, notificationSpec.sourceName)
.putExtra(EXTRA_NOTIFICATION_PEBBLE_COLOR, notificationSpec.pebbleColor)
.putExtra(EXTRA_NOTIFICATION_SOURCEAPPID, notificationSpec.sourceAppId)
.putExtra(EXTRA_NOTIFICATION_ICONID, notificationSpec.iconId)
.putExtra(NOTIFICATION_PICTURE_PATH, notificationSpec.picturePath)
@@ -97,7 +97,6 @@ public interface DeviceService extends EventHandler {
String EXTRA_NOTIFICATION_TITLE = "notification_title";
String EXTRA_NOTIFICATION_TYPE = "notification_type";
String EXTRA_NOTIFICATION_ACTIONS = "notification_actions";
String EXTRA_NOTIFICATION_PEBBLE_COLOR = "notification_pebble_color";
String EXTRA_NOTIFICATION_ICONID = "notification_iconid";
String NOTIFICATION_PICTURE_PATH = "notification_picture_path";
String EXTRA_NOTIFICATION_DNDSUPPRESSED = "notification_dndsuppressed";
@@ -51,10 +51,6 @@ public class NotificationSpec {
public int iconId;
public String picturePath;
/**
* The color that should be assigned to this notification when displayed on a Pebble
*/
public byte pebbleColor;
public int dndSuppressed;
@@ -1,93 +1,61 @@
/* Copyright (C) 2015-2024 Andreas Shimokawa, AnthonyDiGirolamo, Carsten
Pfeiffer, Daniele Gobbetti, Davis Mosenkovs, Frank Slezak, José Rebelo,
Kaz Wolfe, Kevin Richter, Lukas Veneziano, Maxim Baz, musover
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 <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.model;
import java.util.Arrays;
import java.util.Comparator;
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleColor;
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleIconID;
public enum NotificationType {
UNKNOWN,
// TODO: this this pebbleism needs to be moved somewhere else
UNKNOWN(PebbleIconID.NOTIFICATION_GENERIC, PebbleColor.DarkCandyAppleRed),
AMAZON,
BBM,
CONVERSATIONS,
FACEBOOK,
FACEBOOK_MESSENGER,
GENERIC_ALARM_CLOCK,
GENERIC_CALENDAR,
GENERIC_EMAIL,
GENERIC_NAVIGATION,
GENERIC_PHONE,
GENERIC_SMS,
GMAIL,
GOOGLE_HANGOUTS,
GOOGLE_INBOX,
GOOGLE_MAPS,
GOOGLE_MESSENGER,
GOOGLE_PHOTOS,
HIPCHAT,
INSTAGRAM,
KAKAO_TALK,
KIK,
LIGHTHOUSE, // ??? - No idea what this is, but it works.
LINE,
LINKEDIN,
MAILBOX,
OUTLOOK,
BUSINESS_CALENDAR,
RIOT,
SIGNAL,
WIRE,
SKYPE,
SLACK,
SNAPCHAT,
TELEGRAM,
THREEMA,
KONTALK,
ANTOX,
DISCORD,
TRANSIT,
TWITTER,
VIBER,
WECHAT,
WHATSAPP,
YAHOO_MAIL,
COL_REMINDER,
DELTACHAT,
ELEMENT,
ELEMENTX,
MOLLY;
AMAZON(PebbleIconID.NOTIFICATION_AMAZON, PebbleColor.ChromeYellow),
BBM(PebbleIconID.NOTIFICATION_BLACKBERRY_MESSENGER, PebbleColor.DarkGray),
CONVERSATIONS(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.Inchworm),
FACEBOOK(PebbleIconID.NOTIFICATION_FACEBOOK, PebbleColor.CobaltBlue),
FACEBOOK_MESSENGER(PebbleIconID.NOTIFICATION_FACEBOOK_MESSENGER, PebbleColor.BlueMoon),
GENERIC_ALARM_CLOCK(PebbleIconID.ALARM_CLOCK, PebbleColor.Red),
GENERIC_CALENDAR(PebbleIconID.TIMELINE_CALENDAR, PebbleColor.BlueMoon),
GENERIC_EMAIL(PebbleIconID.GENERIC_EMAIL, PebbleColor.Orange),
GENERIC_NAVIGATION(PebbleIconID.LOCATION, PebbleColor.Orange),
GENERIC_PHONE(PebbleIconID.DURING_PHONE_CALL, PebbleColor.JaegerGreen),
GENERIC_SMS(PebbleIconID.GENERIC_SMS, PebbleColor.VividViolet),
GMAIL(PebbleIconID.NOTIFICATION_GMAIL, PebbleColor.Red),
GOOGLE_HANGOUTS(PebbleIconID.NOTIFICATION_GOOGLE_HANGOUTS, PebbleColor.JaegerGreen),
GOOGLE_INBOX(PebbleIconID.NOTIFICATION_GOOGLE_INBOX, PebbleColor.BlueMoon),
GOOGLE_MAPS(PebbleIconID.NOTIFICATION_GOOGLE_MAPS, PebbleColor.BlueMoon),
GOOGLE_MESSENGER(PebbleIconID.NOTIFICATION_GOOGLE_MESSENGER, PebbleColor.VividCerulean),
GOOGLE_PHOTOS(PebbleIconID.NOTIFICATION_GOOGLE_PHOTOS, PebbleColor.BlueMoon),
HIPCHAT(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.CobaltBlue),
INSTAGRAM(PebbleIconID.NOTIFICATION_INSTAGRAM, PebbleColor.CobaltBlue),
KAKAO_TALK(PebbleIconID.NOTIFICATION_KAKAOTALK, PebbleColor.Yellow),
KIK(PebbleIconID.NOTIFICATION_KIK, PebbleColor.IslamicGreen),
LIGHTHOUSE(PebbleIconID.NOTIFICATION_LIGHTHOUSE, PebbleColor.PictonBlue), // ??? - No idea what this is, but it works.
LINE(PebbleIconID.NOTIFICATION_LINE, PebbleColor.IslamicGreen),
LINKEDIN(PebbleIconID.NOTIFICATION_LINKEDIN, PebbleColor.CobaltBlue),
MAILBOX(PebbleIconID.NOTIFICATION_MAILBOX, PebbleColor.VividCerulean),
OUTLOOK(PebbleIconID.NOTIFICATION_OUTLOOK, PebbleColor.BlueMoon),
BUSINESS_CALENDAR(PebbleIconID.TIMELINE_CALENDAR, PebbleColor.BlueMoon),
RIOT(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.LavenderIndigo),
SIGNAL(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.BlueMoon),
WIRE(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.BlueMoon),
SKYPE(PebbleIconID.NOTIFICATION_SKYPE, PebbleColor.VividCerulean),
SLACK(PebbleIconID.NOTIFICATION_SLACK, PebbleColor.Folly),
SNAPCHAT(PebbleIconID.NOTIFICATION_SNAPCHAT, PebbleColor.Icterine),
TELEGRAM(PebbleIconID.NOTIFICATION_TELEGRAM, PebbleColor.VividCerulean),
THREEMA(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.JaegerGreen),
KONTALK(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.JaegerGreen),
ANTOX(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.JaegerGreen),
DISCORD(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.Purpureus),
TRANSIT(PebbleIconID.LOCATION, PebbleColor.JaegerGreen),
TWITTER(PebbleIconID.NOTIFICATION_TWITTER, PebbleColor.BlueMoon),
VIBER(PebbleIconID.NOTIFICATION_VIBER, PebbleColor.VividViolet),
WECHAT(PebbleIconID.NOTIFICATION_WECHAT, PebbleColor.KellyGreen),
WHATSAPP(PebbleIconID.NOTIFICATION_WHATSAPP, PebbleColor.IslamicGreen),
YAHOO_MAIL(PebbleIconID.NOTIFICATION_YAHOO_MAIL, PebbleColor.Indigo),
COL_REMINDER(PebbleIconID.NOTIFICATION_REMINDER, PebbleColor.IslamicGreen),
DELTACHAT(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.BlueMoon),
ELEMENT(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.Malachite),
ELEMENTX(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.Malachite),
MOLLY(PebbleIconID.NOTIFICATION_HIPCHAT, PebbleColor.LavenderIndigo);
// Note: if you add any more constants, update all clients as well
public final int icon;
public final byte color;
NotificationType(int icon, byte color) {
this.icon = icon;
this.color = color;
}
/**
* Returns the enum constant as a fixed String value, e.g. to be used
@@ -915,7 +915,6 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
notificationSpec.sourceName = intentCopy.getStringExtra(EXTRA_NOTIFICATION_SOURCENAME);
notificationSpec.type = (NotificationType) intentCopy.getSerializableExtra(EXTRA_NOTIFICATION_TYPE);
notificationSpec.attachedActions = (ArrayList<NotificationSpec.Action>) intentCopy.getSerializableExtra(EXTRA_NOTIFICATION_ACTIONS);
notificationSpec.pebbleColor = (byte) intentCopy.getSerializableExtra(EXTRA_NOTIFICATION_PEBBLE_COLOR);
notificationSpec.flags = intentCopy.getIntExtra(EXTRA_NOTIFICATION_FLAGS, 0);
notificationSpec.sourceAppId = intentCopy.getStringExtra(EXTRA_NOTIFICATION_SOURCEAPPID);
notificationSpec.iconId = intentCopy.getIntExtra(EXTRA_NOTIFICATION_ICONID, 0);
@@ -64,6 +64,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec.Action;
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleNotification;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
import nodomain.freeyourgadget.gadgetbridge.model.Weather;
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
@@ -501,6 +502,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
@Override
public byte[] encodeNotification(NotificationSpec notificationSpec) {
final PebbleNotification pebbleNotification = new PebbleNotification(notificationSpec);
int id = notificationSpec.getId() != -1 ? notificationSpec.getId() : mRandom.nextInt();
String title;
String subtitle = null;
@@ -522,7 +524,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
if (mFwMajor >= 3 || mForceProtocol || notificationSpec.type != NotificationType.GENERIC_EMAIL) {
// 3.x notification
return encodeNotification(id, (int) (ts & 0xffffffffL), title, subtitle, notificationSpec.body,
notificationSpec.type, notificationSpec.pebbleColor,
pebbleNotification,
notificationSpec.cannedReplies, notificationSpec.attachedActions);
} else {
// 1.x notification on FW 2.X
@@ -820,17 +822,14 @@ public class PebbleProtocol extends GBDeviceProtocol {
}
private byte[] encodeNotification(int id, int timestamp, String title, String subtitle, String body,
NotificationType notificationType, byte backgroundColor, String[] cannedReplies, ArrayList<Action> attachedActions) {
PebbleNotification pebbleNotification, String[] cannedReplies, ArrayList<Action> attachedActions) {
final short NOTIFICATION_PIN_LENGTH = 46;
final short ACTION_LENGTH_MIN = 6;
String[] parts = {title, subtitle, body};
if(notificationType == null) {
notificationType = NotificationType.UNKNOWN;
}
int icon_id = notificationType.icon;
final int icon_id = pebbleNotification.getIcon();
final byte backgroundColor = pebbleNotification.getColor();
// Calculate length first
int actions_count = 0;