项目:q-mail
文件:WearNotifications.java
public void addSummaryActions(Builder builder,NotificationData notificationData) {
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();
addMarkAllAsReadAction(wearableExtender,notificationData);
if (isDeleteActionAvailableForWear()) {
addDeleteallAction(wearableExtender,notificationData);
}
Account account = notificationData.getAccount();
if (isArchiveActionAvailableForWear(account)) {
addArchiveAllAction(wearableExtender,notificationData);
}
builder.extend(wearableExtender);
}
项目:q-mail
文件:WearNotifications.java
private void addWearactions(Builder builder,Account account,NotificationHolder holder) {
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();
addReplyAction(wearableExtender,holder);
addMarkAsReadAction(wearableExtender,holder);
if (isDeleteActionAvailableForWear()) {
addDeleteAction(wearableExtender,holder);
}
if (isArchiveActionAvailableForWear(account)) {
addArchiveAction(wearableExtender,holder);
}
if (isspamActionAvailableForWear(account)) {
addMarkAsspamAction(wearableExtender,holder);
}
builder.extend(wearableExtender);
}
项目:K9-MailClient
文件:WearNotifications.java
public void addSummaryActions(Builder builder,notificationData);
}
builder.extend(wearableExtender);
}
项目:K9-MailClient
文件:WearNotifications.java
项目:AndroidWearNotifications
文件:NotificationPresets.java
@Override
public Notification[] buildNotifications(Context context,BuildOptions options) {
Notification secondPage = new NotificationCompat.Builder(context)
.setContentTitle(context.getString(R.string.second_page_content_title))
.setContentText(context.getString(R.string.second_page_content_text))
.build();
Builder notificationBuilder = buildBasicNotification(context,options);
Notification twoPageNotification = new WearableExtender()
.addPage(secondPage)
.extend(notificationBuilder)
.build();
return new Notification[] { twoPageNotification };
}
项目:wear
文件:NotificationUtils.java
public static void showNotificationWithPages(Context context) {
NotificationCompat.Builder builder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(context.getString(R.string.page1_title))
.setContentText(context.getString(R.string.page1_text));
Notification second = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(context.getString(R.string.page2_title))
.setContentText(context.getString(R.string.page2_text))
.build();
notificationmanagerCompat.from(context).notify(getNewID(),new WearableExtender()
.addPage(second)
.extend(builder)
.build());
}
项目:wear
文件:NotificationUtils.java
public static void showNotificationWithInputForPrimaryAction(Context context) {
Intent intent = new Intent(ACTION_TEST);
PendingIntent pendingIntent =
PendingIntent.getActivity(context,intent,0);
RemoteInput remoteInput = new RemoteInput.Builder(ACTION_EXTRA)
.setLabel(context.getString(R.string.action_label))
.setChoices(context.getResources().getStringArray(R.array.input_choices))
.build();
NotificationCompat.Action action =
new NotificationCompat.Action.Builder(R.drawable.ic_launcher,"Action",pendingIntent)
.addRemoteInput(remoteInput)
.build();
notificationmanagerCompat.from(context).notify(getNewID(),new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(context.getString(R.string.action_title))
.setContentText(context.getString(R.string.action_text))
.setContentIntent(pendingIntent)
.extend(new WearableExtender().addAction(action))
.build());
}
项目:wear
文件:NotificationUtils.java
public static void showNotificationWithInputForSecondaryAction(Context context) {
Intent intent = new Intent(ACTION_TEST);
PendingIntent pendingIntent =
PendingIntent.getActivity(context,0);
RemoteInput remoteInput = new RemoteInput.Builder(ACTION_EXTRA)
.setLabel(context.getString(R.string.action_label))
.build();
NotificationCompat.Action action =
new NotificationCompat.Action.Builder(R.drawable.ic_launcher,new NotificationCompat.Builder(context)
.setContentTitle(context.getString(R.string.action_title))
.extend(new WearableExtender().addAction(action))
.build());
}
项目:q-mail
文件:WearNotifications.java
private void addMarkAllAsReadAction(WearableExtender wearableExtender,NotificationData notificationData) {
int icon = R.drawable.ic_action_mark_as_read_dark;
String title = context.getString(R.string.notification_action_mark_all_as_read);
Account account = notificationData.getAccount();
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
PendingIntent action = actionCreator.getMarkAllAsReadPendingIntent(account,messageReferences,notificationId);
NotificationCompat.Action markAsReadAction = new NotificationCompat.Action.Builder(icon,title,action).build();
wearableExtender.addAction(markAsReadAction);
}
项目:q-mail
文件:WearNotifications.java
private void addDeleteallAction(WearableExtender wearableExtender,NotificationData notificationData) {
int icon = R.drawable.ic_action_delete_dark;
String title = context.getString(R.string.notification_action_delete_all);
Account account = notificationData.getAccount();
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
PendingIntent action = actionCreator.getDeleteallPendingIntent(account,notificationId);
NotificationCompat.Action deleteAction = new NotificationCompat.Action.Builder(icon,action).build();
wearableExtender.addAction(deleteAction);
}
项目:q-mail
文件:WearNotifications.java
private void addArchiveAllAction(WearableExtender wearableExtender,NotificationData notificationData) {
int icon = R.drawable.ic_action_archive_dark;
String title = context.getString(R.string.notification_action_archive_all);
Account account = notificationData.getAccount();
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
PendingIntent action = actionCreator.createArchiveAllPendingIntent(account,notificationId);
NotificationCompat.Action archiveAction = new NotificationCompat.Action.Builder(icon,action).build();
wearableExtender.addAction(archiveAction);
}
项目:q-mail
文件:WearNotifications.java
private void addReplyAction(WearableExtender wearableExtender,NotificationHolder holder) {
int icon = R.drawable.ic_action_single_message_options_dark;
String title = context.getString(R.string.notification_action_reply);
MessageReference messageReference = holder.content.messageReference;
int notificationId = holder.notificationId;
PendingIntent action = actionCreator.createReplyPendingIntent(messageReference,notificationId);
NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(icon,action).build();
wearableExtender.addAction(replyAction);
}
项目:q-mail
文件:WearNotifications.java
private void addMarkAsReadAction(WearableExtender wearableExtender,NotificationHolder holder) {
int icon = R.drawable.ic_action_mark_as_read_dark;
String title = context.getString(R.string.notification_action_mark_as_read);
MessageReference messageReference = holder.content.messageReference;
int notificationId = holder.notificationId;
PendingIntent action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference,action).build();
wearableExtender.addAction(markAsReadAction);
}
项目:q-mail
文件:WearNotifications.java
private void addDeleteAction(WearableExtender wearableExtender,NotificationHolder holder) {
int icon = R.drawable.ic_action_delete_dark;
String title = context.getString(R.string.notification_action_delete);
MessageReference messageReference = holder.content.messageReference;
int notificationId = holder.notificationId;
PendingIntent action = actionCreator.createDeleteMessagePendingIntent(messageReference,action).build();
wearableExtender.addAction(deleteAction);
}
项目:q-mail
文件:WearNotifications.java
private void addArchiveAction(WearableExtender wearableExtender,NotificationHolder holder) {
int icon = R.drawable.ic_action_archive_dark;
String title = context.getString(R.string.notification_action_archive);
MessageReference messageReference = holder.content.messageReference;
int notificationId = holder.notificationId;
PendingIntent action = actionCreator.createArchiveMessagePendingIntent(messageReference,action).build();
wearableExtender.addAction(archiveAction);
}
项目:q-mail
文件:WearNotifications.java
private void addMarkAsspamAction(WearableExtender wearableExtender,NotificationHolder holder) {
int icon = R.drawable.ic_action_spam_dark;
String title = context.getString(R.string.notification_action_spam);
MessageReference messageReference = holder.content.messageReference;
int notificationId = holder.notificationId;
PendingIntent action = actionCreator.createMarkMessageAsspamPendingIntent(messageReference,notificationId);
NotificationCompat.Action spamAction = new NotificationCompat.Action.Builder(icon,action).build();
wearableExtender.addAction(spamAction);
}
项目:q-mail
文件:WearNotificationsTest.java
@Override
public boolean matches(Object argument) {
if (!(argument instanceof WearableExtender)) {
return false;
}
WearableExtender wearableExtender = (WearableExtender) argument;
for (Action action : wearableExtender.getActions()) {
if (action.icon == icon && action.title.equals(title) && action.actionIntent == pendingIntent) {
return true;
}
}
return false;
}
项目:q-mail
文件:WearNotificationsTest.java
/**
* This method is just like a wrapper class method for usual notification class which add voice actions
* for wearable devices
*
* @throws RuntimeException
*/
public void sendNotification() throws Exception {
if (pendingIntent == null && notificationHandler == null) {
throw new RuntimeException("Either pendingIntent or handler class requires.");
}
//Action action = buildWearableAction(); removed remote input action for Now
Notification notification = notificationBuilder.extend(new WearableExtender()).build();
if (Applozicclient.getInstance(mContext).isNotificationSmallIconHidden() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
int smallIconViewId = mContext.getResources().getIdentifier("right_icon","id",android.R.class.getPackage().getName());
if (smallIconViewId != 0) {
if (notification.contentIntent != null) {
notification.contentView.setViewVisibility(smallIconViewId,View.INVISIBLE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (notification.headsUpContentView != null) {
notification.headsUpContentView.setViewVisibility(smallIconViewId,View.INVISIBLE);
}
if (notification.bigContentView != null) {
notification.bigContentView.setViewVisibility(smallIconViewId,View.INVISIBLE);
}
}
}
}
notificationmanagerCompat notificationmanager = notificationmanagerCompat.from(mContext);
notificationmanager.notify(notificationId,notification);
}
/**
* This method is just like a wrapper class method for usual notification class which add voice actions
* for wearable devices
*
* @throws RuntimeException
*/
public void sendNotification() throws Exception {
if (pendingIntent == null && notificationHandler == null) {
throw new RuntimeException("Either pendingIntent or handler class requires.");
}
//Action action = buildWearableAction(); removed remote input action for Now
Notification notification = notificationBuilder.extend(new WearableExtender()).build();
if (Applozicclient.getInstance(mContext).isNotificationSmallIconHidden() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
int smallIconViewId = mContext.getResources().getIdentifier("right_icon",android.R.class.getPackage().getName());
if (smallIconViewId != 0) {
if (notification.contentIntent != null && notification.contentView != null) {
notification.contentView.setViewVisibility(smallIconViewId,notification);
}
项目:K9-MailClient
文件:WearNotifications.java
项目:K9-MailClient
文件:WearNotifications.java
项目:K9-MailClient
文件:WearNotifications.java
项目:K9-MailClient
文件:WearNotifications.java
项目:K9-MailClient
文件:WearNotifications.java
项目:K9-MailClient
文件:WearNotifications.java
项目:K9-MailClient
文件:WearNotifications.java
项目:K9-MailClient
文件:WearNotifications.java
项目:K9-MailClient
文件:WearNotificationsTest.java
@Override
public boolean matches(Object argument) {
if (!(argument instanceof WearableExtender)) {
return false;
}
WearableExtender wearableExtender = (WearableExtender) argument;
for (Action action : wearableExtender.getActions()) {
if (action.icon == icon && action.title.equals(title) && action.actionIntent == pendingIntent) {
return true;
}
}
return false;
}
项目:K9-MailClient
文件:WearNotificationsTest.java
/**
* This method is just like a wrapper class method for usual notification class which add voice actions
* for wearable devices
*
* @throws RuntimeException
*/
public void sendNotification() throws Exception {
if (pendingIntent == null && notificationHandler == null) {
throw new RuntimeException("Either pendingIntent or handler class requires.");
}
//Action action = buildWearableAction(); removed remote input action for Now
Notification notification = notificationBuilder.extend(new WearableExtender()).build();
if (Applozicclient.getInstance(mContext).isNotificationSmallIconHidden() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
int smallIconViewId = mContext.getResources().getIdentifier("right_icon",notification);
}
项目:AndroidWearNotification
文件:MainActivity.java
private void VoicePrintWearNotificationView() {
// Key for the string that's delivered in the action's intent
String replyLabel = getResources().getString(R.string.reply_choices);
RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel(replyLabel)
.build();
// Create an intent for the reply action
Intent replyIntent = new Intent(this,OtherActivity.class);
PendingIntent replyPendingIntent = PendingIntent.getActivity(this,replyIntent,PendingIntent.FLAG_UPDATE_CURRENT);
// Create the reply action and add the remote input
NotificationCompat.Action action = new NotificationCompat.Action.Builder(
R.drawable.ic_launcher,getString(R.string.label,replyPendingIntent),replyPendingIntent).addRemoteInput(remoteInput).build();
// Build the notification and add the action via WearableExtender
Notification notification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher).setContentTitle("消息标题")
.setContentText("消息正文").extend(new WearableExtender().addAction(action)).build();
// Issue the notification
notificationmanagerCompat notificationmanager = notificationmanagerCompat.from(this);
notificationmanager.notify(NOTIFICATION_ID_6,notification);
manager.cancel(NOTIFICATION_ID_5);
manager.cancel(NOTIFICATION_ID_4);
manager.cancel(NOTIFICATION_ID_3);
manager.cancel(NOTIFICATION_ID_2);
manager.cancel(NOTIFICATION_ID_1);
}
项目:AndroidWearNotification
文件:MainActivity.java
private void MorePagesWearNotificationView() {
// Create builder for the main notification
Intent viewIntent = new Intent(this,SpecialActivity.class);
PendingIntent viewPendingIntent = PendingIntent.getActivity(this,viewIntent,0);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher).setContentTitle("第一页")
.setContentText("亲,还有第二页噢").setContentIntent(viewPendingIntent);
// Create a big text style for the second page
BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();
secondPageStyle.setBigContentTitle("第二页").bigText(
"这是一段很长的Text,用来测试用!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
// Create second page notification
Notification secondPageNotification = new NotificationCompat.Builder(this).setStyle(
secondPageStyle).build();
// Add second page with wearable extender and extend the main
// notification
Notification twoPageNotification = new WearableExtender().addPage(secondPageNotification)
.extend(notificationBuilder).build();
// Issue the notification
notificationmanagerCompat notificationmanager = notificationmanagerCompat.from(this);
notificationmanager.notify(NOTIFICATION_ID_5,twoPageNotification);
manager.cancel(NOTIFICATION_ID_4);
manager.cancel(NOTIFICATION_ID_6);
manager.cancel(NOTIFICATION_ID_3);
manager.cancel(NOTIFICATION_ID_2);
manager.cancel(NOTIFICATION_ID_1);
}
项目:AndroidWearNotification
文件:MainActivity.java
private void ReplyWearNotificationView() {
// Create an intent for the reply action
Intent actionIntent = new Intent(this,SpecialActivity.class);
PendingIntent actionPendingIntent = PendingIntent.getActivity(this,actionIntent,PendingIntent.FLAG_UPDATE_CURRENT);
// Create the action
NotificationCompat.Action action = new NotificationCompat.Action.Builder(
R.drawable.ic_launcher,actionPendingIntent),actionPendingIntent).build();
// Build the notification and add the action via WearableExtender
Notification notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.hello_world))
.extend(new NotificationCompat.WearableExtender()
.setContentIcon(R.drawable.ic_launcher))
/* .extend(new WearableExtender().addAction(action)) */
.setDefaults(NotificationCompat.DEFAULT_VIBRATE)//增加震动
.build();
// Get an instance of the notificationmanager service
notificationmanagerCompat notificationmanager = notificationmanagerCompat.from(this);
notificationmanager.notify(NOTIFICATION_ID_3,notificationBuilder);
manager.cancel(NOTIFICATION_ID_2);
manager.cancel(NOTIFICATION_ID_5);
manager.cancel(NOTIFICATION_ID_4);
manager.cancel(NOTIFICATION_ID_6);
manager.cancel(NOTIFICATION_ID_1);
}
void onlywearableNoti() {
//create the intent to launch the notiactivity,then the pentingintent.
Intent viewIntent = new Intent(this,NotiActivity.class);
viewIntent.putExtra("NotiID","Notification ID is " + notificationID);
PendingIntent viewPendingIntent =
PendingIntent.getActivity(this,0);
// we are going to add an intent to open the camera here.
Intent cameraIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
PendingIntent cameraPendingIntent =
PendingIntent.getActivity(this,cameraIntent,0);
// Create the action
NotificationCompat.Action action =
new NotificationCompat.Action.Builder(R.drawable.ic_action_time,"take a Picutre",cameraPendingIntent)
.build();
//Now create the notification. We must use the NotificationCompat or it will not work on the wearable.
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("add button Noti")
.setContentText("swipe left to open camera.")
.setContentIntent(viewPendingIntent)
.extend(new WearableExtender().addAction(action));
// Get an instance of the notificationmanager service
notificationmanagerCompat notificationmanager =
notificationmanagerCompat.from(this);
// Build the notification and issues it with notification manager.
notificationmanager.notify(notificationID,notificationBuilder.build());
notificationID++;
}
void onlywearableNoti() {
//create the intent to launch the notiactivity,"Notification ID is " + notificationID);
PendingIntent viewPendingIntent =
PendingIntent.getActivity(this,0);
// we are going to add an intent to open the camera here.
Intent cameraIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
PendingIntent cameraPendingIntent =
PendingIntent.getActivity(this,0);
// Create the action
NotificationCompat.Action action =
new NotificationCompat.Action.Builder(R.drawable.ic_action_time,"Open Camera",cameraPendingIntent)
.build();
//Now create the notification. We must use the NotificationCompat or it will not work on the wearable.
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this,id)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Button on Wear Only")
.setContentText("tap to open message")
.setContentIntent(viewPendingIntent)
.setChannelId(id)
.extend(new WearableExtender().addAction(action));
// Get an instance of the notificationmanager service
notificationmanagerCompat notificationmanager =
notificationmanagerCompat.from(this);
// Build the notification and issues it with notification manager.
notificationmanager.notify(notificationID,notificationBuilder.build());
notificationID++;
}
项目:q-mail
文件:WearNotificationsTest.java
private WearableExtender action(int icon,String title,PendingIntent pendingIntent) {
return argThat(new ActionMatcher(icon,pendingIntent));
}
项目:q-mail
文件:WearNotificationsTest.java
项目:K9-MailClient
文件:WearNotificationsTest.java
private WearableExtender action(int icon,pendingIntent));
}
项目:K9-MailClient
文件:WearNotificationsTest.java
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。