Add title customizable sendPebbleNotification method

This commit is contained in:
Minori Hiraoka 2016-06-12 11:36:06 +09:00
parent 237a758425
commit 3a23182434
1 changed files with 24 additions and 2 deletions

View File

@ -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<PebbleMessage> messages = new ArrayList<>();
messages.add(new PebbleMessage(appName, message));
@ -2268,6 +2289,7 @@ public final class Utils implements Constants {
context.getApplicationContext().sendBroadcast(intent);
}
}
@Nullable