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-24503] Android: Implement notification quick actions #9278

Merged
merged 2 commits into from Aug 21, 2017

Conversation

garymathews
Copy link
Contributor

Requires support library 26.0.0 #9274
  • Implement notification quick actions
  • Expose support library 26.0.0 feature setGroupAlertBehavior()
TEST CASE
var win = Ti.UI.createWindow({title: 'TIMOB-24503', layout: 'vertical'}),
    btn = Ti.UI.createButton({title: 'CREATE NOTIFICATION', height: 50, width: Ti.UI.FILL}),
    id = 100;

function createNotification() {
        var n = Ti.Android.createNotification({
                icon: Ti.Android.R.drawable.ic_dialog_info,
                contentTitle: 'APPCELERATOR',
                contentText : 'Open Appcelerator web-page.'
            }),
            p = Ti.Android.createPendingIntent({
                intent: Ti.Android.createIntent({
                    action: Ti.Android.ACTION_VIEW,
                    data: 'https://www.appcelerator.com'
                })
            });
        n.addAction(Ti.Android.R.drawable.ic_dialog_email, "OPEN", p);
        Ti.Android.NotificationManager.notify(id, n);
}

btn.addEventListener('click', function() {
    createNotification();
});

win.add([btn]);
win.open();

JIRA Ticket

parameters:
- name: icon
summary: Icon of the action button as URL or resource ID
type: [Number, String]
Copy link
Contributor

Choose a reason for hiding this comment

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

We should indicate that the icon must be 32x32 dp (ie: 32x32 pixels for mdpi).

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the icons have to use a holo dark theme on Android 4.x and a light material theme on Android 5.0 and above. Which means developers need to provide versioned drawable resources (ie: "drawable-mdpi-v21" for material). Or perhaps those details should go into the notification guide?

@@ -154,6 +154,22 @@ methods:
summary: Allows to enable the indeterminate mode.
type: Boolean

- name: addAction
summary: Add an action button to the notification
Copy link
Contributor

Choose a reason for hiding this comment

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

We should document that a notification can have up to 3 action buttons. Additional actions added will be ignored.


- name: title
summary: Title of the action button
type: Number
Copy link
Contributor

Choose a reason for hiding this comment

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

"title" type should be "String", not "Number".

String iconFullUrl = resolveUrl(null, iconUrl);
iconId = TiUIHelper.getResourceId(iconFullUrl);
}
notificationBuilder.addAction(iconId, title, pendingIntent.getPendingIntent());
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should do the following if title is null. (I'm thinking icon-only action buttons.)

if (title == null) {
    title = "";
}

Copy link
Contributor

Choose a reason for hiding this comment

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

And if "pendingIntent" is null, we should log an error or throw an exception indicating that this argument cannot be null.

@garymathews
Copy link
Contributor Author

@jquick-axway Updated PR, title can be null for icon only buttons

Copy link
Contributor

@jquick-axway jquick-axway left a comment

Choose a reason for hiding this comment

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

CR: Pass

@lokeshchdhry
Copy link
Contributor

FR Passed.

  1. Checked with code above.
  2. Checked with data: 'http://maps.google.com/maps?q=loc:37.3906238,-122.0499305,19' which opens up the maps app.
  3. Checked with :
intent : Ti.Android.createIntent({
	action: Ti.Android.ACTION_VIEW,
	className: 'com.app.zxyz.ZxyzActivity',
	packageName: 'com.app.zxyx
})
  1. Checked with null argument's for title & pending intent`.

Studio Ver: 4.9.1.201707200100
SDK Ver: 7.0.0 local build
OS Ver: 10.12.3
Xcode Ver: Xcode 8.3.3
Appc NPM: 4.2.9
Appc CLI: 6.2.3
Ti CLI Ver: 5.0.14
Alloy Ver: 1.9.13
Node Ver: 6.10.1
Java Ver: 1.8.0_101
Devices: ⇨ google Nexus 5 --- Android 6.0.1
⇨ google Pixel --- Android 7.1.1

@lokeshchdhry lokeshchdhry merged commit c803e2d into tidev:master Aug 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants