Added extra settings for Lollipop devices

Two settings have been added:
- Notification visibility - allows the notification to be made visible on a
secure lock screen
- Color - used to set the color of the notification circle that contains the
icon
This commit is contained in:
Gearóid Moroney
2015-06-03 16:33:09 +01:00
parent f41787afe1
commit cec56db33c
3 changed files with 25 additions and 11 deletions

View File

@@ -33,6 +33,7 @@ import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
@@ -141,6 +142,20 @@ public class ForegroundService extends Service {
.setOngoing(true)
.setSmallIcon(getIconResId());
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if(settings.optBoolean("isPublic") == true) {
notification.setVisibility(Notification.VISIBILITY_PUBLIC);
}
if(!settings.optString("color").equals("")) {
try {
notification.setColor(Color.parseColor(settings.optString("color")));
} catch (Exception e) {
Log.e("BackgroundMode", settings.optString("color") + " is not a valid color");
}
}
}
if (intent != null && settings.optBoolean("resume")) {
PendingIntent contentIntent = PendingIntent.getActivity(