Commit 46d71294 by Sebastián Katzer

Support for Android system colors e.g. color: "RED"

parent 52623f11
...@@ -23,6 +23,7 @@ package de.appplant.cordova.plugin.notification; ...@@ -23,6 +23,7 @@ package de.appplant.cordova.plugin.notification;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
...@@ -239,11 +240,21 @@ public class Options { ...@@ -239,11 +240,21 @@ public class Options {
try { try {
hex = stripHex(hex); hex = stripHex(hex);
int aRGB = Integer.parseInt(hex, 16);
if (hex.matches("[^0-9]*")) {
return Color.class
.getDeclaredField(hex.toUpperCase())
.getInt(null);
}
int aRGB = Integer.parseInt(hex, 16);
return aRGB + 0xFF000000; return aRGB + 0xFF000000;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
e.printStackTrace(); e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} }
return NotificationCompat.COLOR_DEFAULT; return NotificationCompat.COLOR_DEFAULT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment