Move default values to constants
This commit is contained in:
parent
009854bb22
commit
e4ae47505b
@ -25,6 +25,7 @@
|
||||
- __Changes__
|
||||
- Deprecate event callbacks
|
||||
- Notification not visible anymore on lock screen
|
||||
- Remove ticker property on Android
|
||||
- Remove unexpected back button handler
|
||||
- Remove support for wp8 platform
|
||||
|
||||
|
@ -98,11 +98,13 @@ More informations can be found [here][PGB_plugin].
|
||||
- __Changes__
|
||||
- Deprecate event callbacks
|
||||
- Notification not visible anymore on lock screen
|
||||
- Remove ticker property on Android
|
||||
- Remove unexpected back button handler
|
||||
- Remove support for wp8 platform
|
||||
|
||||
#### Further informations
|
||||
- See [CHANGELOG.md][changelog] to get the full changelog for the plugin.
|
||||
- Master branch contains experimental support for the windows platform. See #222
|
||||
|
||||
#### Known issues
|
||||
- README is out of date !!!
|
||||
|
@ -47,6 +47,17 @@ public class ForegroundService extends Service {
|
||||
// Fixed ID for the 'foreground' notification
|
||||
public static final int NOTIFICATION_ID = -574543954;
|
||||
|
||||
// Default title of the background notification
|
||||
private static final String NOTIFICATION_TITLE =
|
||||
"App is running in background";
|
||||
|
||||
// Default text of the background notification
|
||||
private static final String NOTIFICATION_TEXT =
|
||||
"Doing heavy tasks.";
|
||||
|
||||
// Default icon of the background notification
|
||||
private static final String NOTIFICATION_ICON = "icon";
|
||||
|
||||
// Binder given to clients
|
||||
private final IBinder mBinder = new ForegroundBinder();
|
||||
|
||||
@ -141,7 +152,8 @@ public class ForegroundService extends Service {
|
||||
* @param settings The config settings
|
||||
*/
|
||||
private Notification makeNotification(JSONObject settings) {
|
||||
String text = settings.optString("text", "");
|
||||
String title = settings.optString("title", NOTIFICATION_TITLE);
|
||||
String text = settings.optString("text", NOTIFICATION_TEXT);
|
||||
boolean bigText = settings.optBoolean("bigText", false);
|
||||
|
||||
Context context = getApplicationContext();
|
||||
@ -150,9 +162,8 @@ public class ForegroundService extends Service {
|
||||
.getLaunchIntentForPackage(pkgName);
|
||||
|
||||
Notification.Builder notification = new Notification.Builder(context)
|
||||
.setContentTitle(settings.optString("title", ""))
|
||||
.setContentTitle(title)
|
||||
.setContentText(text)
|
||||
.setTicker(settings.optString("ticker", ""))
|
||||
.setOngoing(true)
|
||||
.setPriority(Notification.PRIORITY_MIN)
|
||||
.setSmallIcon(getIconResId(settings));
|
||||
@ -203,7 +214,7 @@ public class ForegroundService extends Service {
|
||||
Context context = getApplicationContext();
|
||||
Resources res = context.getResources();
|
||||
String pkgName = context.getPackageName();
|
||||
String icon = settings.optString("icon", "icon");
|
||||
String icon = settings.optString("icon", NOTIFICATION_ICON);
|
||||
|
||||
// cordova-android 6 uses mipmaps
|
||||
int resId = getIconResId(res, icon, "mipmap", pkgName);
|
||||
|
Loading…
Reference in New Issue
Block a user