pebble-notifier
pebble-notifier copied to clipboard
Show only one time notification
issue #28
The formatting changes make it hard to see what you've changed - I'd suggest pulling those into a separate pull request.
res/values/strings.xml
add line 86 :
res/xml/preferences.xml Add line 21-23 <CheckBoxPreference android:defaultValue="false" android:key="pref_dont_throw_many_time" android:title="@string/pref_dont_throw_many_time"/>
src/com/dattasmoon/pebble/plugin/Constants.java Add line 53 : public static final String PREFERENCE_DONT_THROW_MANY_TIME = "pref_dont_throw_many_time";
src/com/dattasmoon/pebble/plugin/NotificationService.java Add line 81 : private HashMap<String, String> previousNotification = null;
Add line 320-335 : // validate don't throw same notification
-
try {
-
if (dontThrowManyTime) {
-
if (previousNotification == null) {
-
previousNotification = new HashMap<String, String>();
-
}
-
if (previousNotification.containsKey(eventPackageName)
-
&& previousNotification.get(eventPackageName).equalsIgnoreCase(notificationText)) {
-
Log.i(Constants.LOG_TAG, "Notification many time =" + notificationText);
-
return;
-
}
-
}
-
previousNotification.put(eventPackageName, notificationText);
-
} catch (Exception e) {
-
e.printStackTrace();
-
}
Add line 445-446 editor.putBoolean(Constants.PREFERENCE_DONT_THROW_MANY_TIME, sharedPreferences.getBoolean(Constants.LOG_TAG + ".dontThrowManyTime", false));
src/com/dattasmoon/pebble/plugin/SettingsActivity.java add line 72-73 editor.putBoolean(Constants.PREFERENCE_DONT_THROW_MANY_TIME, sharedPreferences.getBoolean(Constants.LOG_TAG + ".dontThrowManyTime", false));
I suggest editing your branch to only have the changes you mentioned in the comment above.