forked from MaikuB/flutter_local_notifications
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from Innim/feature/2248.analytics-for-notify
Feature/2248.analytics for notify
- Loading branch information
Showing
11 changed files
with
187 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
.../src/main/java/com/dexterous/flutterlocalnotifications/ShownNotificationsPreferences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.dexterous.flutterlocalnotifications; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
public class ShownNotificationsPreferences { | ||
private static final String SHARED_PREFS_FILE_NAME = | ||
"flutter_local_notifications_plugin_shown_info"; | ||
private final String SHOWN_NOTIFICATIONS_INFO_KEY = | ||
"com.dexterous.flutterlocalnotifications.SHOWN_NOTIFICATIONS_INFO_KEY"; | ||
private final String SHOWN_NOTIFICATIONS_INFO_DIVIDER = "/"; | ||
|
||
private final Context context; | ||
|
||
public ShownNotificationsPreferences(Context context) { | ||
|
||
this.context = context; | ||
} | ||
|
||
public void saveShownNotificationInfo(String info) { | ||
final SharedPreferences pref = get(); | ||
final SharedPreferences.Editor editor = pref.edit(); | ||
String currentInfo = pref.getString(SHOWN_NOTIFICATIONS_INFO_KEY, ""); | ||
if (!currentInfo.isEmpty()) { | ||
currentInfo = currentInfo + SHOWN_NOTIFICATIONS_INFO_DIVIDER + info; | ||
} else { | ||
currentInfo = info; | ||
} | ||
editor.putString(SHOWN_NOTIFICATIONS_INFO_KEY, currentInfo); | ||
editor.apply(); | ||
} | ||
|
||
public ArrayList<String> getShownNotificationsInfo() { | ||
final SharedPreferences pref = get(); | ||
final String currentInfo = pref.getString(SHOWN_NOTIFICATIONS_INFO_KEY, ""); | ||
if (currentInfo.isEmpty()) { | ||
return new ArrayList<>(); | ||
} | ||
final String[] list = currentInfo.split(SHOWN_NOTIFICATIONS_INFO_DIVIDER); | ||
return new ArrayList<>(Arrays.asList(list)); | ||
} | ||
|
||
public void clearShownNotificationsInfo() { | ||
final SharedPreferences pref = get(); | ||
final SharedPreferences.Editor editor = pref.edit(); | ||
editor.remove(SHOWN_NOTIFICATIONS_INFO_KEY); | ||
editor.apply(); | ||
} | ||
|
||
private SharedPreferences get() { | ||
return context.getSharedPreferences(SHARED_PREFS_FILE_NAME, Context.MODE_PRIVATE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters