From 3a23182434a3e0ac35454eb86054a977e5a21e17 Mon Sep 17 00:00:00 2001 From: Minori Hiraoka Date: Sun, 12 Jun 2016 11:36:06 +0900 Subject: [PATCH] Add title customizable sendPebbleNotification method --- .../org/mariotaku/twidere/util/Utils.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java b/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java index ccfc13072..f24d7fabf 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/Utils.java @@ -2251,13 +2251,34 @@ public final class Utils implements Constants { * @param message String */ public static void sendPebbleNotification(final Context context, final String message) { + sendPebbleNotification(context, null, message); + } + + /** + * Send Notifications to Pebble smartwatches + * + * @param context Context + * @param title String + * @param message String + */ + public static void sendPebbleNotification(final Context context, final String title, final String message) + { + String appName; + + if ( title == null) + { + appName = context.getString(R.string.app_name); + } + else + { + appName = context.getString(R.string.app_name) + " - " + title; + } + if (context == null || TextUtils.isEmpty(message)) return; final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); if (prefs.getBoolean(KEY_PEBBLE_NOTIFICATIONS, false)) { - final String appName = context.getString(R.string.app_name); - final List messages = new ArrayList<>(); messages.add(new PebbleMessage(appName, message)); @@ -2268,6 +2289,7 @@ public final class Utils implements Constants { context.getApplicationContext().sendBroadcast(intent); } + } @Nullable