Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Show only one time notification #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Show only one time notification #30

wants to merge 2 commits into from

Conversation

ploufs
Copy link

@ploufs ploufs commented Dec 1, 2013

issue #28

Add checkbox in setting
Log last notification by package name.
Only create hashMap when need.
@Daniel15
Copy link

The formatting changes make it hard to see what you've changed - I'd suggest pulling those into a separate pull request.

@ploufs
Copy link
Author

ploufs commented Dec 23, 2013

res/values/strings.xml
add line 86 :
Don't repeat notification

res/xml/preferences.xml
Add line 21-23

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));

@Daniel15
Copy link

I suggest editing your branch to only have the changes you mentioned in the comment above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants