Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-23645] Android: Added Color to Android notification color behind icon #9444

Merged
merged 11 commits into from
Nov 10, 2017
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiUIHelper;
import org.appcelerator.titanium.util.TiColorHelper;

import ti.modules.titanium.android.AndroidModule;
import ti.modules.titanium.android.PendingIntentProxy;
Expand Down Expand Up @@ -71,6 +72,9 @@ public void handleCreationDict(KrollDict d)
if (d.containsKey(TiC.PROPERTY_LARGE_ICON)) {
setLargeIcon(d.get(TiC.PROPERTY_LARGE_ICON));
}
if (d.containsKey(TiC.PROPERTY_COLOR)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

setColor(TiConvert.toString(d, TiC.PROPERTY_COLOR));
}
if (d.containsKey(TiC.PROPERTY_TICKER_TEXT)) {
setTickerText(TiConvert.toString(d, TiC.PROPERTY_TICKER_TEXT));
}
Expand Down Expand Up @@ -183,7 +187,16 @@ public void setLargeIcon(Object icon)
}
setProperty(TiC.PROPERTY_LARGE_ICON, icon);
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove spaces from empty lines - here and on line 199.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Kroll.method @Kroll.setProperty
public void setColor(String color)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)) {
notificationBuilder.setColor(TiColorHelper.parseColor(color));
}
setProperty(TiC.PROPERTY_COLOR, color);
}

@Kroll.method @Kroll.setProperty
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the indentation. I fixed it previously but you want to check this as well - maybe for future PR's 😙.

public void setVisibility(int visibility)
{
Expand Down
12 changes: 11 additions & 1 deletion apidoc/Titanium/Android/Notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,18 @@ properties:

See <Titanium.App.Android.R> for more information on accessing
Android resources by ID.
type: [Number,String]
type: [Number, String]
since: "4.2.0"

- name: color
summary: Accent color used behind icon.
description: |
Accent color of the circle used behind icon. The Icon will be stenciled in white on top of a
cicle of the color set. For information about color values, see the "Colors" section of <Titanium.UI>.

See Android Reference for the [color](https://developer.android.com/reference/android/app/Notification.html#color) property.
type: String
since: "7.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add osver: {android: {min: "5.0"}}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@garymathews - I see this has not been approved yet?


- name: ledARGB
summary: The color for the LED to blink.
Expand Down