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