protected NotificationCompat.Builder createBigTextStyleNotification(Account account, NotificationHolder holder, int notificationId) { String accountName = controller.getAccountName(account); NotificationContent content = holder.content; String groupKey = NotificationGroupKeys.getGroupKey(account); NotificationCompat.Builder builder = createAndInitializeNotificationBuilder(account) .setTicker(content.summary) .setGroup(groupKey) .setContentTitle(content.sender) .setContentText(content.subject) .setSubText(accountName); NotificationCompat.BigTextStyle style = createBigTextStyle(builder); style.bigText(content.preview); builder.setStyle(style); PendingIntent contentIntent = actionCreator.createViewMessagePendingIntent( content.messageReference, notificationId); builder.setContentIntent(contentIntent); return builder; }
public void showAuthenticationErrorNotification(Account account, boolean incoming) { int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming); Context context = controller.getContext(); PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming); String title = context.getString(R.string.notification_authentication_error_title); String text = context.getString(R.string.notification_authentication_error_text, account.getDescription()); NotificationCompat.Builder builder = controller.createNotificationBuilder() .setSmallIcon(R.drawable.notification_icon_warning) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setTicker(title) .setContentTitle(title) .setContentText(text) .setContentIntent(editServerSettingsPendingIntent) .setStyle(new BigTextStyle().bigText(text)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_ERROR); controller.configureNotification(builder, null, null, NOTIFICATION_LED_FAILURE_COLOR, NOTIFICATION_LED_BLINK_FAST, true); getNotificationManager().notify(notificationId, builder.build()); }
@Test public void testCreateBigTextStyleNotification() throws Exception { Account account = createFakeAccount(); int notificationId = 23; NotificationHolder holder = createNotificationHolder(notificationId); Builder builder = notifications.createBigTextStyleNotification(account, holder, notificationId); verify(builder).setTicker(NOTIFICATION_SUMMARY); verify(builder).setGroup("newMailNotifications-" + ACCOUNT_NUMBER); verify(builder).setContentTitle(SENDER); verify(builder).setContentText(SUBJECT); verify(builder).setSubText(ACCOUNT_NAME); BigTextStyle bigTextStyle = notifications.bigTextStyle; verify(bigTextStyle).bigText(NOTIFICATION_PREVIEW); verify(builder).setStyle(bigTextStyle); }
/** * Updated the notification data copy and also updates the notification in the notification * shade. * <br /> * All the extension data is consumed and used for building the notification. The title of the * extension data becomes the notification's title, the body of the extension data becomes the * notification's content, the click intent of the extension data becomes the notification's * click intent, the icon of the extension data becomes the notification's icon and the status * of the extension data becomes the notifications info only if the status does not match the * title or the body (to prevent redundant information cluttering up the notification.) * * @param component the component name of the extension * @param data the data passed from the extension */ @SuppressWarnings("deprecation") private void update(ComponentName component, ExtensionData data) { if (data != null && data.visible()) { int colour = getResources().getColor(R.color.notification_color); NotificationCompat.Builder notification = new NotificationCompat.Builder(this); notification.setColor(colour); notification.setCategory(NotificationCompat.CATEGORY_SERVICE); notification.setPriority(Integer.MIN_VALUE); notification.setOnlyAlertOnce(true); notification.setOngoing(true); notification.setShowWhen(true); PendingIntent click = PendingIntent.getActivity(getApplicationContext(), 0, data.clickIntent(), 0); Bitmap icon = Utils.loadExtensionIcon(getApplicationContext(), component, data.icon(), null, colour); notification.setStyle(new BigTextStyle().bigText(data.expandedBody())); notification.setSmallIcon(R.drawable.ic_notification); notification.setContentTitle(data.expandedTitle()); notification.setContentText(data.expandedBody()); notification.setGroup("dashbar"); if (data.status() != null && !data.status().equalsIgnoreCase(data.expandedBody()) && !data.status().equalsIgnoreCase(data.expandedTitle())) { notification.setContentInfo(data.status()); } notification.setContentIntent(click); notification.setLargeIcon(icon); mNotifier.notify(component.getPackageName(), 1, notification.build()); } }
private static void generateStyle(NotificationCompat.Builder builder) { Integer styleValue = STYLE.getValueInt(); if (STYLE_BIG_PICTURE.equals(styleValue)) { BigPictureStyle bigPicture = new NotificationCompat.BigPictureStyle(); if (PICTURE.hasValue()) bigPicture.bigPicture(PICTURE.getValueBitmap()); if (BIG_CONTENT_TITLE.hasValue()) bigPicture.setBigContentTitle(BIG_CONTENT_TITLE.getValueString()); if (SUMMARY_TEXT.hasValue()) bigPicture.setSummaryText(SUMMARY_TEXT.getValueString()); builder.setStyle(bigPicture); } else if (STYLE_BIG_TEXT.equals(styleValue)) { BigTextStyle bigText = new NotificationCompat.BigTextStyle(); if (BIG_TEXT.hasValue()) bigText.bigText(BIG_TEXT.getValueString()); if (BIG_CONTENT_TITLE.hasValue()) bigText.setBigContentTitle(BIG_CONTENT_TITLE.getValueString()); if (SUMMARY_TEXT.hasValue()) bigText.setSummaryText(SUMMARY_TEXT.getValueString()); builder.setStyle(bigText); } else if (STYLE_INBOX.equals(styleValue)) { InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); if (LINES.hasValue()) { for (String line : LINES.getValueString().split("\\n")) { inboxStyle.addLine(line); } } if (BIG_CONTENT_TITLE.hasValue()) inboxStyle.setBigContentTitle(BIG_CONTENT_TITLE.getValueString()); if (SUMMARY_TEXT.hasValue()) inboxStyle.setSummaryText(SUMMARY_TEXT.getValueString()); builder.setStyle(inboxStyle); } }
private void fallbackNotify( long id, String title, String desc, PendingIntent contentIntent, PendingIntent sharePi, PendingIntent facebookPi ) { mNotifyBuilder = new NotificationCompat.Builder( this ).setWhen( id ).setSmallIcon( R.drawable.ic_push_notify ).setTicker( title ) .setContentTitle( title ).setContentText( desc ).setStyle( new BigTextStyle().bigText( desc ).setBigContentTitle( title ) ) .setAutoCancel( true ).addAction( R.drawable.ic_action_social_share, getString( R.string.action_share ), sharePi ).addAction( R.drawable.ic_stat_f, getString( R.string.action_fb ), facebookPi ); mNotifyBuilder.setContentIntent( contentIntent ); mNotificationManager.notify( Utils.randInt( 1, 9999 ), mNotifyBuilder.build() ); }
private void MorePagesWearNotificationView() { // Create builder for the main notification Intent viewIntent = new Intent(this, SpecialActivity.class); PendingIntent viewPendingIntent = PendingIntent.getActivity(this, 0, 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); }
private void BigWearNotificationView() { Intent mapIntent = new Intent(Intent.ACTION_VIEW); // 添加一个在地图上查看事件位置的action String location = "Beijing"; Uri geoUri = Uri.parse("geo:0,0?q=" + Uri.encode(location)); mapIntent.setData(geoUri); PendingIntent mapPendingIntent = PendingIntent.getActivity(this, 0, mapIntent, 0); BigTextStyle bigStyle = new NotificationCompat.BigTextStyle(); bigStyle.bigText("这是一个很长的text,用来做测试用!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)) .setContentTitle("消息标题").setContentText("消息正文").setContentIntent(mapPendingIntent) .addAction(R.drawable.ic_launcher, getString(R.string.map), mapPendingIntent) .setStyle(bigStyle); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notificationManager.notify(NOTIFICATION_ID_4, notificationBuilder.build()); manager.cancel(NOTIFICATION_ID_3); manager.cancel(NOTIFICATION_ID_5); manager.cancel(NOTIFICATION_ID_6); manager.cancel(NOTIFICATION_ID_2); manager.cancel(NOTIFICATION_ID_1); }
/** * Get the {@link android.support.v4.app.NotificationCompat.Builder} of {@link android.app.Notification}. * * @param cxt * {@link android.content.Context}. * @param ticker * Text shows on notification. * @param smallIcon * Icon for the notification. * @param contentTitle * Text shows above the content. * @param content * Text shows when expand notification. * @param id * The id of this notification. * @param bigText * Some more information. * * @return A {@link android.support.v4.app.NotificationCompat.Builder}. */ private static NotificationCompat.Builder buildNotificationCommon(Context cxt, String ticker, @DrawableRes int smallIcon, String contentTitle, String content, int id, String bigText) { NotificationCompat.Builder builder = new NotificationCompat.Builder(cxt).setWhen(System.currentTimeMillis()) .setTicker(ticker).setAutoCancel(true).setSmallIcon(smallIcon).setLargeIcon( BitmapFactory.decodeResource(cxt.getResources(), R.drawable.ic_action_logo)).setContentIntent( createMainPendingIntent(cxt, id)).setContentTitle(contentTitle).setContentText(content); AudioManager audioManager = (AudioManager) cxt.getSystemService(Context.AUDIO_SERVICE); if (audioManager.getRingerMode() == RINGER_MODE_VIBRATE) { builder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000, 1000, 1000 }); } if (audioManager.getRingerMode() == RINGER_MODE_NORMAL) { builder.setSound(Uri.parse(String.format("android.resource://%s/%s", cxt.getPackageName(), R.raw.sound_bell))); } builder.setLights(Color.BLUE, 3000, 3000); if (!TextUtils.isEmpty(bigText)) { BigTextStyle inboxStyle = new NotificationCompat.BigTextStyle(); inboxStyle.setBigContentTitle(contentTitle); inboxStyle.bigText(bigText); inboxStyle.setSummaryText(content); builder.setStyle(inboxStyle); } return builder; }
void bigTextNoti() { //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, viewIntent, 0); BigTextStyle bigStyle = new NotificationCompat.BigTextStyle(); bigStyle.bigText("Big text style.\n" + "We should have more room to add text for the user to read, instead of a short message."); //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("Simple Noti") .setContentText("This is a simple notification") .setContentIntent(viewPendingIntent) .setStyle(bigStyle); // 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 bigTextNoti() { //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, viewIntent, 0); BigTextStyle bigStyle = new NotificationCompat.BigTextStyle(); bigStyle.bigText("Big text style.\n" + "We should have more room to add text for the user to read, instead of a short message."); //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("Simple Noti") .setContentText("This is a simple notification") .setContentIntent(viewPendingIntent) .setChannelId(id) .setStyle(bigStyle); // 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++; }
protected BigTextStyle createBigTextStyle(Builder builder) { return new BigTextStyle(builder); }
@Override protected BigTextStyle createBigTextStyle(Builder builder) { return bigTextStyle; }
protected TestNotifications(NotificationController controller, NotificationActionCreator actionCreator) { super(controller, actionCreator); bigTextStyle = mock(BigTextStyle.class); }
private static void sendSingleThreadNotification(Context context, MasterSecret masterSecret, NotificationState notificationState, boolean signal) { if (notificationState.getNotifications().isEmpty()) { ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE)) .cancel(NOTIFICATION_ID); return; } List<NotificationItem>notifications = notificationState.getNotifications(); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); Recipient recipient = notifications.get(0).getIndividualRecipient(); builder.setSmallIcon(R.drawable.icon_notification); builder.setLargeIcon(recipient.getContactPhoto()); builder.setContentTitle(recipient.toShortString()); builder.setContentText(notifications.get(0).getText()); builder.setContentIntent(notifications.get(0).getPendingIntent(context)); builder.setContentInfo(String.valueOf(notificationState.getMessageCount())); builder.setNumber(notificationState.getMessageCount()); builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(DeleteReceiver.DELETE_REMINDER_ACTION), 0)); if (masterSecret != null) { builder.addAction(R.drawable.check, context.getString(R.string.MessageNotifier_mark_as_read), notificationState.getMarkAsReadIntent(context, masterSecret)); } SpannableStringBuilder content = new SpannableStringBuilder(); ListIterator<NotificationItem> iterator = notifications.listIterator(notifications.size()); while(iterator.hasPrevious()) { NotificationItem item = iterator.previous(); content.append(item.getBigStyleSummary()); content.append('\n'); } builder.setStyle(new BigTextStyle().bigText(content)); setNotificationAlarms(context, builder, signal); if (signal) { builder.setTicker(notifications.get(0).getTickerText()); } ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE)) .notify(NOTIFICATION_ID, builder.build()); }
private void showNewNotification(final String paramString1, String paramString2, final String paramString3, final String paramString4, String paramString5, int paramInt1, Bitmap paramBitmap, int paramInt2, final Intent paramIntent1, boolean paramBoolean1, Intent paramIntent2, boolean paramBoolean2, String paramString6, Intent paramIntent3, String paramString7, int paramInt3, int paramInt4, NotificationCompat.Action paramAction) { final NotificationCompat.Builder localBuilder = new NotificationCompat.Builder(this.mContext).setTicker(paramString2).setContentTitle(paramString3).setContentText(paramString4); localBuilder.mCategory = paramString6; localBuilder.mVisibility = 0; localBuilder.mLocalOnly = true; if (!TextUtils.isEmpty(paramString5)) { localBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(paramString5)); } localBuilder.setSmallIcon(paramInt1); if (paramBitmap != null) { localBuilder.mLargeIcon = paramBitmap; } if (paramInt2 > 0) { localBuilder.mNumber = paramInt2; } localBuilder.mColor = paramInt3; localBuilder.mPriority = paramInt4; if (paramAction != null) { localBuilder.mActions.add(paramAction); } final int i = getNotificationId(paramString1); PendingIntent localPendingIntent1; if (!paramBoolean1) { localPendingIntent1 = PendingIntent.getActivity(this.mContext, i, paramIntent1, 1342177280); localBuilder.mContentIntent = localPendingIntent1; if (paramIntent2 != null) { PendingIntent localPendingIntent3 = PendingIntent.getBroadcast(this.mContext, i, paramIntent2, 1342177280); localBuilder.mNotification.deleteIntent = localPendingIntent3; } if ((paramIntent3 != null) && (!TextUtils.isEmpty(paramString7))) { PendingIntent localPendingIntent2 = PendingIntent.getBroadcast(this.mContext, i, paramIntent3, 1342177280); localBuilder.mActions.add(new NotificationCompat.Action(2130838134, paramString7, localPendingIntent2)); } if (!paramBoolean2) { break label316; } localBuilder.setFlag(2, true); } for (;;) { RestrictedDeviceHelper.isLimitedOrSchoolEduUser(new RestrictedDeviceHelper.OnCompleteListener() { public final void onComplete(boolean paramAnonymousBoolean) { if (!paramAnonymousBoolean) { this.val$mgr.notify(i, localBuilder.build()); } if (!paramAnonymousBoolean) {} for (boolean bool = true;; bool = false) { NotificationManager.access$100(bool, paramString1, paramString3, paramString4, paramIntent1); return; } } }); return; localPendingIntent1 = PendingIntent.getBroadcast(this.mContext, i, paramIntent1, 1342177280); break; label316: localBuilder.setAutoCancel$7abcb88d(); } }
private static void sendSingleThreadNotification(Context context, MasterSecret masterSecret, NotificationState notificationState, boolean signal) { if (notificationState.getNotifications().isEmpty()) { ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE)) .cancel(NOTIFICATION_ID); return; } List<NotificationItem> notifications = notificationState.getNotifications(); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); Recipient recipient = notifications.get(0).getIndividualRecipient(); Drawable recipientPhoto = recipient.getContactPhoto(); int largeIconTargetSize = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size); if (recipientPhoto != null) { Bitmap recipientPhotoBitmap = BitmapUtil.createFromDrawable(recipientPhoto, largeIconTargetSize, largeIconTargetSize); if (recipientPhotoBitmap != null) builder.setLargeIcon(recipientPhotoBitmap); } builder.setSmallIcon(R.drawable.icon_notification); builder.setColor(context.getResources().getColor(R.color.textsecure_primary)); builder.setContentTitle(recipient.toShortString()); builder.setContentText(notifications.get(0).getText()); builder.setContentIntent(notifications.get(0).getPendingIntent(context)); builder.setContentInfo(String.valueOf(notificationState.getMessageCount())); builder.setPriority(NotificationCompat.PRIORITY_HIGH); builder.setNumber(notificationState.getMessageCount()); builder.setCategory(NotificationCompat.CATEGORY_MESSAGE); builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(DeleteReceiver.DELETE_REMINDER_ACTION), 0)); if (recipient.getContactUri() != null) builder.addPerson(recipient.getContactUri().toString()); long timestamp = notifications.get(0).getTimestamp(); if (timestamp != 0) builder.setWhen(timestamp); if (masterSecret != null) { Action markAsReadAction = new Action(R.drawable.check, context.getString(R.string.MessageNotifier_mark_as_read), notificationState.getMarkAsReadIntent(context, masterSecret)); builder.addAction(markAsReadAction); builder.extend(new NotificationCompat.WearableExtender().addAction(markAsReadAction)); } SpannableStringBuilder content = new SpannableStringBuilder(); ListIterator<NotificationItem> iterator = notifications.listIterator(notifications.size()); while(iterator.hasPrevious()) { NotificationItem item = iterator.previous(); content.append(item.getBigStyleSummary()); content.append('\n'); } builder.setStyle(new BigTextStyle().bigText(content)); setNotificationAlarms(context, builder, signal, notificationState.getRingtone(), notificationState.getVibrate()); if (signal) { builder.setTicker(notifications.get(0).getTickerText()); } ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE)) .notify(NOTIFICATION_ID, builder.build()); }
public BigTextStyleProxy() { super(); style = new BigTextStyle(); }
@Kroll.method @Kroll.setProperty public void setBigText(String cs) { ((BigTextStyle)style).bigText(cs); setProperty(NotificationfactoryModule.PROPERTY_BIG_TEXT, cs); }
@Kroll.method @Kroll.setProperty public void setBigContentTitle(String title) { ((BigTextStyle)style).setBigContentTitle(title); setProperty(NotificationfactoryModule.PROPERTY_BIG_CONTENT_TITLE, title); }
@Kroll.method @Kroll.setProperty public void setSummaryText(String cs) { ((BigTextStyle)style).setSummaryText(cs); setProperty(NotificationfactoryModule.PROPERTY_SUMMARY_TEXT, cs); }
private static void sendSingleThreadNotification(Context context, MasterSecret masterSecret, NotificationState notificationState, boolean signal) { if (notificationState.getNotifications().isEmpty()) { ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE)) .cancel(NOTIFICATION_ID); return; } List<NotificationItem>notifications = notificationState.getNotifications(); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); Recipient recipient = notifications.get(0).getIndividualRecipient(); builder.setSmallIcon(R.drawable.icon_notification); builder.setLargeIcon(recipient.getContactPhoto()); builder.setContentTitle(recipient.toShortString()); builder.setContentText(notifications.get(0).getText()); builder.setContentIntent(notifications.get(0).getPendingIntent(context)); builder.setContentInfo(String.valueOf(notificationState.getMessageCount())); builder.setNumber(notificationState.getMessageCount()); if (masterSecret != null) { builder.addAction(R.drawable.check, context.getString(R.string.MessageNotifier_mark_as_read), notificationState.getMarkAsReadIntent(context, masterSecret)); } SpannableStringBuilder content = new SpannableStringBuilder(); for (NotificationItem item : notifications) { content.append(item.getBigStyleSummary()); content.append('\n'); } builder.setStyle(new BigTextStyle().bigText(content)); setNotificationAlarms(context, builder, signal); if (signal) { builder.setTicker(notifications.get(0).getTickerText()); } ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE)) .notify(NOTIFICATION_ID, builder.build()); }
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); setContentView(R.layout.activity_recipients); getActionBar().setHomeButtonEnabled(true); //mSearch = (EditText)findViewById(R.id.etsearch); //mSearch.setVisibility(View.GONE); Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);; Intent resultIntent = new Intent(this, ChatsActivity.class); PendingIntent resultPendingIntent = PendingIntent.getActivity( this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT ); Calendar cal = Calendar.getInstance(); Intent intent = new Intent(Intent.ACTION_EDIT); intent.setType("vnd.android.cursor.item/event"); intent.putExtra("beginTime", cal.getTimeInMillis()+60*60*1000); intent.putExtra("allDay", false); intent.putExtra("rrule", "FREQ=DAILY"); intent.putExtra("endTime", cal.getTimeInMillis()+2*60*60*1000); intent.putExtra("title", "Remember to check your inbox !"); //startActivity(intent); PendingIntent actionPendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.notifications, getString(R.string.remind_me), actionPendingIntent) .build(); BigTextStyle bigStyle = new NotificationCompat.BigTextStyle(); bigStyle.bigText("New chit !"); mNotifBuilder = new NotificationCompat.Builder( this).setSmallIcon(R.drawable.ic_stat_ic_action_send_now) .setContentTitle("ChitChat").setContentText("Your message has been sent !").extend(new WearableExtender().addAction(action)).setSound(soundUri).setStyle(bigStyle).setAutoCancel(true);; mNotifBuilder.setContentIntent(resultPendingIntent); mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mRecipientsList = (ListView)findViewById(R.id.recipient_list); mRecipientsList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); //mRecipientsGrid = (GridView) findViewById(R.id.friends_grid); mEmptyText = (TextView) findViewById(R.id.empty_state_text); mEmptyImage = (ImageView) findViewById(R.id.empty_state_image); //mRecipientsGrid.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE); mMediaUri = getIntent().getData(); mFileType = getIntent().getExtras().getString(Constants.FILE_TYPE); /*mRecipientsGrid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub ImageView mCheckImage = (ImageView)findViewById(R.id.user_image_check); if (mRecipientsGrid.getCheckedItemCount() > 0) { mSend.setVisible(true); mCheckImage.setVisibility(View.VISIBLE); } else { mSend.setVisible(false); mCheckImage.setVisibility(View.INVISIBLE); } } });*/ mRecipientsList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub if (mRecipientsList.getCheckedItemCount() > 0) { mSend.setVisible(true); } else { mSend.setVisible(false); } } }); }
@Override public void onLyricsDownloaded(Lyrics lyrics) { if (lyrics.isLRC()) { LrcView lrcView = new LrcView(mContext, null); lrcView.setOriginalLyrics(lyrics); lrcView.setSourceLrc(lyrics.getText()); lyrics.setText(lrcView.getStaticLyrics().getText()); } NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(mContext, NotificationUtil.TRACK_NOTIF_CHANNEL); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mContext); Intent activityIntent = new Intent("com.geecko.QuickLyric.getLyrics") .putExtra("TAGS", new String[]{lyrics.getArtist(), lyrics.getTitle()}); PendingIntent openAction = PendingIntent.getActivity(mContext, 0, activityIntent, PendingIntent.FLAG_CANCEL_CURRENT); BigTextStyle bigStyle = new BigTextStyle(); bigStyle.bigText(lyrics.getText() != null ? Html.fromHtml(lyrics.getText()) : ""); int[] themes = new int[]{R.style.Theme_QuickLyric, R.style.Theme_QuickLyric_Red, R.style.Theme_QuickLyric_Purple, R.style.Theme_QuickLyric_Indigo, R.style.Theme_QuickLyric_Green, R.style.Theme_QuickLyric_Lime, R.style.Theme_QuickLyric_Brown, R.style.Theme_QuickLyric_Dark}; int themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0")); int notificationPref = Integer.valueOf(sharedPref.getString("pref_notifications", "0")); mContext.setTheme(themes[themeNum]); notifBuilder.setSmallIcon(R.drawable.ic_notif) .setContentTitle(mContext.getString(R.string.app_name)) .setContentText(String.format("%s - %s", lyrics.getArtist(), lyrics.getTitle())) .setStyle(bigStyle) .setGroup("Lyrics_Notification") .setOngoing(false) .setColor(ColorUtils.getPrimaryColor(mContext)) .setGroupSummary(false) .setContentIntent(openAction) .setVisibility(-1); // Notification.VISIBILITY_SECRET if (notificationPref == 2) notifBuilder.setPriority(-2); if (lyrics.getFlag() < 0) notifBuilder.extend(new NotificationCompat.WearableExtender() .setContentIntentAvailableOffline(false)); Notification notif = notifBuilder.build(); NotificationManagerCompat.from(mContext).notify(8, notif); }