List of usage examples for android.content Intent FLAG_ACTIVITY_NO_USER_ACTION
int FLAG_ACTIVITY_NO_USER_ACTION
To view the source code for android.content Intent FLAG_ACTIVITY_NO_USER_ACTION.
Click Source Link
From source file:com.ferdi2005.secondgram.NotificationsController.java
protected void forceShowPopupForReply() { notificationsQueue.postRunnable(new Runnable() { @Override//from w w w . j a va2 s. co m public void run() { final ArrayList<MessageObject> popupArray = new ArrayList<>(); for (int a = 0; a < pushMessages.size(); a++) { MessageObject messageObject = pushMessages.get(a); long dialog_id = messageObject.getDialogId(); if (messageObject.messageOwner.mentioned && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage || (int) dialog_id == 0 || messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isMegagroup()) { continue; } popupArray.add(0, messageObject); } if (!popupArray.isEmpty() && !AndroidUtilities.needShowPasscode(false)) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { popupReplyMessages = popupArray; Intent popupIntent = new Intent(ApplicationLoader.applicationContext, PopupNotificationActivity.class); popupIntent.putExtra("force", true); popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND); ApplicationLoader.applicationContext.startActivity(popupIntent); Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); ApplicationLoader.applicationContext.sendBroadcast(it); } }); } } }); }
From source file:com.androidinspain.deskclock.alarms.AlarmNotifications.java
static synchronized void showAlarmNotification(Service service, AlarmInstance instance) { LogUtils.v("Displaying alarm notification for alarm instance: " + instance.mId); Resources resources = service.getResources(); NotificationCompat.Builder notification = new NotificationCompat.Builder(service) .setContentTitle(instance.getLabelOrDefault(service)) .setContentText(AlarmUtils.getFormattedTime(service, instance.getAlarmTime())) .setColor(ContextCompat.getColor(service, com.androidinspain.deskclock.R.color.default_background)) .setSmallIcon(com.androidinspain.deskclock.R.drawable.stat_notify_alarm).setOngoing(true) .setAutoCancel(false).setDefaults(NotificationCompat.DEFAULT_LIGHTS).setWhen(0) .setCategory(NotificationCompat.CATEGORY_ALARM).setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setLocalOnly(true);//w w w.j av a 2 s .c o m // Setup Snooze Action Intent snoozeIntent = AlarmStateManager.createStateChangeIntent(service, AlarmStateManager.ALARM_SNOOZE_TAG, instance, AlarmInstance.SNOOZE_STATE); snoozeIntent.putExtra(AlarmStateManager.FROM_NOTIFICATION_EXTRA, true); PendingIntent snoozePendingIntent = PendingIntent.getService(service, ALARM_FIRING_NOTIFICATION_ID, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(com.androidinspain.deskclock.R.drawable.ic_snooze_24dp, resources.getString(com.androidinspain.deskclock.R.string.alarm_alert_snooze_text), snoozePendingIntent); // Setup Dismiss Action Intent dismissIntent = AlarmStateManager.createStateChangeIntent(service, AlarmStateManager.ALARM_DISMISS_TAG, instance, AlarmInstance.DISMISSED_STATE); dismissIntent.putExtra(AlarmStateManager.FROM_NOTIFICATION_EXTRA, true); PendingIntent dismissPendingIntent = PendingIntent.getService(service, ALARM_FIRING_NOTIFICATION_ID, dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(com.androidinspain.deskclock.R.drawable.ic_alarm_off_24dp, resources.getString(com.androidinspain.deskclock.R.string.alarm_alert_dismiss_text), dismissPendingIntent); // Setup Content Action Intent contentIntent = AlarmInstance.createIntent(service, AlarmActivity.class, instance.mId); notification.setContentIntent(PendingIntent.getActivity(service, ALARM_FIRING_NOTIFICATION_ID, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT)); // Setup fullscreen intent Intent fullScreenIntent = AlarmInstance.createIntent(service, AlarmActivity.class, instance.mId); // set action, so we can be different then content pending intent fullScreenIntent.setAction("fullscreen_activity"); fullScreenIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); notification.setFullScreenIntent(PendingIntent.getActivity(service, ALARM_FIRING_NOTIFICATION_ID, fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT), true); notification.setPriority(NotificationCompat.PRIORITY_MAX); clearNotification(service, instance); service.startForeground(ALARM_FIRING_NOTIFICATION_ID, notification.build()); }
From source file:com.goftagram.telegram.messenger.NotificationsController.java
public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast) { if (messageObjects.isEmpty()) { return;/*from w w w. ja v a 2 s . c o m*/ } final ArrayList<MessageObject> popupArray = new ArrayList<>(popupMessages); notificationsQueue.postRunnable(new Runnable() { @Override public void run() { boolean added = false; int oldCount = popupArray.size(); HashMap<Long, Boolean> settingsCache = new HashMap<>(); SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Context.MODE_PRIVATE); int popup = 0; for (int a = 0; a < messageObjects.size(); a++) { MessageObject messageObject = messageObjects.get(a); long mid = messageObject.messageOwner.id; if (messageObject.messageOwner.to_id.channel_id != 0) { mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32; } if (pushMessagesDict.containsKey(mid)) { continue; } long dialog_id = messageObject.getDialogId(); long original_dialog_id = dialog_id; if (dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) { playInChatSound(); continue; } if (messageObject.messageOwner.mentioned) { dialog_id = messageObject.messageOwner.from_id; } if (isPersonalMessage(messageObject)) { personal_count++; } added = true; Boolean value = settingsCache.get(dialog_id); boolean isChat = (int) dialog_id < 0; popup = (int) dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0); if (value == null) { int notifyOverride = getNotifyOverride(preferences, dialog_id); value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0); settingsCache.put(dialog_id, value); } if (value) { if (popup != 0) { popupArray.add(0, messageObject); } delayedPushMessages.add(messageObject); pushMessages.add(0, messageObject); pushMessagesDict.put(mid, messageObject); if (original_dialog_id != dialog_id) { pushDialogsOverrideMention.put(original_dialog_id, 1); } } } if (added) { notifyCheck = isLast; } if (!popupArray.isEmpty() && oldCount != popupArray.size() && !AndroidUtilities.needShowPasscode(false)) { final int popupFinal = popup; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { popupMessages = popupArray; if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn && !UserConfig.isWaitingForPasscodeEnter) { MessageObject messageObject = messageObjects.get(0); if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn || popupFinal == 2 && !ApplicationLoader.isScreenOn) { Intent popupIntent = new Intent(ApplicationLoader.applicationContext, PopupNotificationActivity.class); popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND); ApplicationLoader.applicationContext.startActivity(popupIntent); } } } }); } } }); }
From source file:org.cafemember.messenger.NotificationsController.java
public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast) { if (messageObjects.isEmpty()) { return;/*from w ww .j a v a 2 s. c o m*/ } final ArrayList<MessageObject> popupArray = new ArrayList<>(popupMessages); notificationsQueue.postRunnable(new Runnable() { @Override public void run() { boolean added = false; int oldCount = popupArray.size(); HashMap<Long, Boolean> settingsCache = new HashMap<>(); SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Context.MODE_PRIVATE); boolean allowPinned = preferences.getBoolean("PinnedMessages", true); int popup = 0; for (int a = 0; a < messageObjects.size(); a++) { MessageObject messageObject = messageObjects.get(a); long mid = messageObject.messageOwner.id; if (messageObject.messageOwner.to_id.channel_id != 0) { mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32; } if (pushMessagesDict.containsKey(mid)) { continue; } long dialog_id = messageObject.getDialogId(); long original_dialog_id = dialog_id; if (dialog_id == opened_dialog_id && ApplicationLoader.isScreenOn) { playInChatSound(); continue; } if (messageObject.messageOwner.mentioned) { if (!allowPinned && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { continue; } dialog_id = messageObject.messageOwner.from_id; } if (isPersonalMessage(messageObject)) { personal_count++; } added = true; Boolean value = settingsCache.get(dialog_id); boolean isChat = (int) dialog_id < 0; popup = (int) dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0); if (value == null) { int notifyOverride = getNotifyOverride(preferences, dialog_id); value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0); settingsCache.put(dialog_id, value); } if (value) { if (popup != 0) { popupArray.add(0, messageObject); } delayedPushMessages.add(messageObject); pushMessages.add(0, messageObject); pushMessagesDict.put(mid, messageObject); if (original_dialog_id != dialog_id) { pushDialogsOverrideMention.put(original_dialog_id, 1); } } } if (added) { notifyCheck = isLast; } if (!popupArray.isEmpty() && oldCount != popupArray.size() && !AndroidUtilities.needShowPasscode(false)) { final int popupFinal = popup; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { popupMessages = popupArray; if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn && !UserConfig.isWaitingForPasscodeEnter) { MessageObject messageObject = messageObjects.get(0); if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn || popupFinal == 2 && !ApplicationLoader.isScreenOn) { Intent popupIntent = new Intent(ApplicationLoader.applicationContext, PopupNotificationActivity.class); popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND); ApplicationLoader.applicationContext.startActivity(popupIntent); } } } }); } } }); }
From source file:ir.besteveryeverapp.telegram.NotificationsController.java
public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast) { if (messageObjects.isEmpty()) { return;/*from ww w .j a va2s . c o m*/ } final ArrayList<MessageObject> popupArray = new ArrayList<>(popupMessages); notificationsQueue.postRunnable(new Runnable() { @Override public void run() { boolean added = false; int oldCount = popupArray.size(); HashMap<Long, Boolean> settingsCache = new HashMap<>(); SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Context.MODE_PRIVATE); boolean allowPinned = preferences.getBoolean("PinnedMessages", true); int popup = 0; for (int a = 0; a < messageObjects.size(); a++) { MessageObject messageObject = messageObjects.get(a); long mid = messageObject.messageOwner.id; if (messageObject.messageOwner.to_id.channel_id != 0) { mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32; } if (pushMessagesDict.containsKey(mid)) { continue; } long dialog_id = messageObject.getDialogId(); long original_dialog_id = dialog_id; if (dialog_id == opened_dialog_id && ApplicationLoader.isScreenOn) { playInChatSound(); continue; } if (messageObject.messageOwner.mentioned) { if (!allowPinned && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { continue; } dialog_id = messageObject.messageOwner.from_id; } if (isPersonalMessage(messageObject)) { personal_count++; } added = true; Boolean value = settingsCache.get(dialog_id); boolean isChat = (int) dialog_id < 0; popup = (int) dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0); if (value == null) { int notifyOverride = getNotifyOverride(preferences, dialog_id); value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0); settingsCache.put(dialog_id, value); } if (popup != 0 && messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isMegagroup()) { popup = 0; } if (value) { if (popup != 0) { popupArray.add(0, messageObject); } delayedPushMessages.add(messageObject); pushMessages.add(0, messageObject); pushMessagesDict.put(mid, messageObject); if (original_dialog_id != dialog_id) { pushDialogsOverrideMention.put(original_dialog_id, 1); } } } if (added) { notifyCheck = isLast; } if (!popupArray.isEmpty() && oldCount != popupArray.size() && !AndroidUtilities.needShowPasscode(false)) { final int popupFinal = popup; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { popupMessages = popupArray; if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn && !UserConfig.isWaitingForPasscodeEnter) { MessageObject messageObject = messageObjects.get(0); if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn || popupFinal == 2 && !ApplicationLoader.isScreenOn) { Intent popupIntent = new Intent(ApplicationLoader.applicationContext, PopupNotificationActivity.class); popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND); ApplicationLoader.applicationContext.startActivity(popupIntent); } } } }); } } }); }
From source file:ir.irani.telecam.messenger.NotificationsController.java
public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast) { if (messageObjects.isEmpty()) { return;/*from w w w. j a v a 2 s . c o m*/ } final ArrayList<MessageObject> popupArray = new ArrayList<>(popupMessages); notificationsQueue.postRunnable(new Runnable() { @Override public void run() { boolean added = false; int oldCount = popupArray.size(); HashMap<Long, Boolean> settingsCache = new HashMap<>(); SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Context.MODE_PRIVATE); boolean allowPinned = preferences.getBoolean("PinnedMessages", true); int popup = 0; for (int a = 0; a < messageObjects.size(); a++) { MessageObject messageObject = messageObjects.get(a); long mid = messageObject.messageOwner.id; if (messageObject.messageOwner.to_id.channel_id != 0) { mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32; } if (pushMessagesDict.containsKey(mid)) { continue; } long dialog_id = messageObject.getDialogId(); long original_dialog_id = dialog_id; if (dialog_id == opened_dialog_id && ApplicationLoader.isScreenOn) { playInChatSound(); continue; } if (messageObject.messageOwner.mentioned) { if (!allowPinned && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { continue; } dialog_id = messageObject.messageOwner.from_id; } if (isPersonalMessage(messageObject)) { personal_count++; } added = true; Boolean value = settingsCache.get(dialog_id); boolean isChat = (int) dialog_id < 0; //if(HiddenController.IsHidden(dialog_id))continue; popup = (int) dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0); if (value == null) { int notifyOverride = getNotifyOverride(preferences, dialog_id); value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0); settingsCache.put(dialog_id, value); } if (popup != 0 && messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isMegagroup()) { popup = 0; } if (value) { if (popup != 0) { popupArray.add(0, messageObject); } delayedPushMessages.add(messageObject); pushMessages.add(0, messageObject); pushMessagesDict.put(mid, messageObject); if (original_dialog_id != dialog_id) { pushDialogsOverrideMention.put(original_dialog_id, 1); } } } if (added) { notifyCheck = isLast; } if (!popupArray.isEmpty() && oldCount != popupArray.size() && !AndroidUtilities.needShowPasscode(false)) { final int popupFinal = popup; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { popupMessages = popupArray; if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn && !UserConfig.isWaitingForPasscodeEnter) { MessageObject messageObject = messageObjects.get(0); if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn || popupFinal == 2 && !ApplicationLoader.isScreenOn) { Intent popupIntent = new Intent(ApplicationLoader.applicationContext, PopupNotificationActivity.class); popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND); ApplicationLoader.applicationContext.startActivity(popupIntent); } } } }); } } }); }
From source file:kr.wdream.storyshop.NotificationsController.java
public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast) { if (messageObjects.isEmpty()) { return;/*from ww w.j av a 2 s . c om*/ } final ArrayList<MessageObject> popupArray = new ArrayList<>(popupMessages); notificationsQueue.postRunnable(new Runnable() { @Override public void run() { boolean added = false; int oldCount = popupArray.size(); HashMap<Long, Boolean> settingsCache = new HashMap<>(); SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Context.MODE_PRIVATE); boolean allowPinned = preferences.getBoolean("PinnedMessages", true); int popup = 0; for (int a = 0; a < messageObjects.size(); a++) { MessageObject messageObject = messageObjects.get(a); long mid = messageObject.messageOwner.id; if (messageObject.messageOwner.to_id.channel_id != 0) { mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32; } if (pushMessagesDict.containsKey(mid)) { continue; } long dialog_id = messageObject.getDialogId(); long original_dialog_id = dialog_id; if (dialog_id == opened_dialog_id && ApplicationLoader.isScreenOn) { playInChatSound(); continue; } if (messageObject.messageOwner.mentioned) { if (!allowPinned && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { continue; } dialog_id = messageObject.messageOwner.from_id; } if (isPersonalMessage(messageObject)) { personal_count++; } added = true; Boolean value = settingsCache.get(dialog_id); boolean isChat = (int) dialog_id < 0; popup = (int) dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0); if (value == null) { int notifyOverride = getNotifyOverride(preferences, dialog_id); value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0); settingsCache.put(dialog_id, value); } if (popup != 0 && messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isMegagroup()) { popup = 0; } if (value) { if (popup != 0) { popupArray.add(0, messageObject); } delayedPushMessages.add(messageObject); pushMessages.add(0, messageObject); pushMessagesDict.put(mid, messageObject); if (original_dialog_id != dialog_id) { pushDialogsOverrideMention.put(original_dialog_id, 1); } } } if (added) { notifyCheck = isLast; } if (!popupArray.isEmpty() && oldCount != popupArray.size() && !AndroidUtilities.needShowPasscode(false)) { final int popupFinal = popup; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { popupMessages = popupArray; if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn && !UserConfig.isWaitingForPasscodeEnter) { if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn || popupFinal == 2 && !ApplicationLoader.isScreenOn) { Intent popupIntent = new Intent(ApplicationLoader.applicationContext, PopupNotificationActivity.class); popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND); ApplicationLoader.applicationContext.startActivity(popupIntent); } } } }); } } }); }
From source file:com.android.deskclock.data.TimerModel.java
/** * Updates the heads-up notification controlling expired timers. This heads-up notification is * displayed whether the application is open or not. *//*from ww w .ja v a 2 s . c o m*/ private void updateHeadsUpNotification() { // Nothing can be done with the heads-up notification without a valid service reference. if (mService == null) { return; } final List<Timer> expired = getExpiredTimers(); // If no expired timers exist, stop the service (which cancels the foreground notification). if (expired.isEmpty()) { mService.stopSelf(); mService = null; return; } // Generate some descriptive text, a title, and an action name based on the timer count. final int timerId; final String contentText; final String contentTitle; final String resetActionTitle; if (expired.size() > 1) { timerId = -1; contentText = mContext.getString(R.string.timer_multi_times_up, expired.size()); contentTitle = mContext.getString(R.string.timer_notification_label); resetActionTitle = mContext.getString(R.string.timer_stop_all); } else { final Timer timer = expired.get(0); timerId = timer.getId(); resetActionTitle = mContext.getString(R.string.timer_stop); contentText = mContext.getString(R.string.timer_times_up); final String label = timer.getLabel(); if (TextUtils.isEmpty(label)) { contentTitle = mContext.getString(R.string.timer_notification_label); } else { contentTitle = label; } } // Content intent shows the timer full screen when clicked. final Intent content = new Intent(mContext, ExpiredTimersActivity.class); final PendingIntent pendingContent = PendingIntent.getActivity(mContext, 0, content, PendingIntent.FLAG_UPDATE_CURRENT); // Full screen intent has flags so it is different than the content intent. final Intent fullScreen = new Intent(mContext, ExpiredTimersActivity.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); final PendingIntent pendingFullScreen = PendingIntent.getActivity(mContext, 0, fullScreen, PendingIntent.FLAG_UPDATE_CURRENT); // First action intent is either reset single timer or reset all timers. final Intent reset = TimerService.createResetExpiredTimersIntent(mContext); final PendingIntent pendingReset = PendingIntent.getService(mContext, 0, reset, PendingIntent.FLAG_UPDATE_CURRENT); final NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext).setWhen(0) .setOngoing(true).setLocalOnly(true).setAutoCancel(false).setContentText(contentText) .setContentTitle(contentTitle).setContentIntent(pendingContent) .setSmallIcon(R.drawable.stat_notify_timer).setFullScreenIntent(pendingFullScreen, true) .setPriority(NotificationCompat.PRIORITY_MAX).setDefaults(NotificationCompat.DEFAULT_LIGHTS) .addAction(R.drawable.ic_stop_24dp, resetActionTitle, pendingReset); // Add a second action if only a single timer is expired. if (expired.size() == 1) { // Second action intent adds a minute to a single timer. final Intent addMinute = TimerService.createAddMinuteTimerIntent(mContext, timerId); final PendingIntent pendingAddMinute = PendingIntent.getService(mContext, 0, addMinute, PendingIntent.FLAG_UPDATE_CURRENT); final String addMinuteTitle = mContext.getString(R.string.timer_plus_1_min); builder.addAction(R.drawable.ic_add_24dp, addMinuteTitle, pendingAddMinute); } // Update the notification. final Notification notification = builder.build(); final int notificationId = mNotificationModel.getExpiredTimerNotificationId(); mService.startForeground(notificationId, notification); }
From source file:com.ferdi2005.secondgram.NotificationsController.java
public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast) { if (messageObjects.isEmpty()) { return;/*from ww w . j a v a 2 s . com*/ } final ArrayList<MessageObject> popupArray = new ArrayList<>(popupMessages); notificationsQueue.postRunnable(new Runnable() { @Override public void run() { boolean added = false; int oldCount = popupArray.size(); HashMap<Long, Boolean> settingsCache = new HashMap<>(); SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Context.MODE_PRIVATE); boolean allowPinned = preferences.getBoolean("PinnedMessages", true); int popup = 0; for (int a = 0; a < messageObjects.size(); a++) { MessageObject messageObject = messageObjects.get(a); long mid = messageObject.messageOwner.id; if (messageObject.messageOwner.to_id.channel_id != 0) { mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32; } if (pushMessagesDict.containsKey(mid)) { continue; } long dialog_id = messageObject.getDialogId(); long original_dialog_id = dialog_id; if (dialog_id == opened_dialog_id && ApplicationLoader.isScreenOn) { playInChatSound(); continue; } if (messageObject.messageOwner.mentioned) { if (!allowPinned && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { continue; } dialog_id = messageObject.messageOwner.from_id; } if (isPersonalMessage(messageObject)) { personal_count++; } added = true; Boolean value = settingsCache.get(dialog_id); int lower_id = (int) dialog_id; boolean isChat = lower_id < 0; if (lower_id != 0) { if (preferences.getBoolean("custom_" + dialog_id, false)) { popup = preferences.getInt("popup_" + dialog_id, 0); } else { popup = 0; } if (popup == 0) { popup = preferences.getInt((int) dialog_id < 0 ? "popupGroup" : "popupAll", 0); } else if (popup == 1) { popup = 3; } else if (popup == 2) { popup = 0; } } if (value == null) { int notifyOverride = getNotifyOverride(preferences, dialog_id); value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0); settingsCache.put(dialog_id, value); } if (popup != 0 && messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isMegagroup()) { popup = 0; } if (value) { if (popup != 0) { popupArray.add(0, messageObject); } delayedPushMessages.add(messageObject); pushMessages.add(0, messageObject); pushMessagesDict.put(mid, messageObject); if (original_dialog_id != dialog_id) { pushDialogsOverrideMention.put(original_dialog_id, 1); } } } if (added) { notifyCheck = isLast; } if (!popupArray.isEmpty() && oldCount != popupArray.size() && !AndroidUtilities.needShowPasscode(false)) { final int popupFinal = popup; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { popupMessages = popupArray; if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn && !UserConfig.isWaitingForPasscodeEnter) { if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn || popupFinal == 2 && !ApplicationLoader.isScreenOn) { Intent popupIntent = new Intent(ApplicationLoader.applicationContext, PopupNotificationActivity.class); popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND); ApplicationLoader.applicationContext.startActivity(popupIntent); } } } }); } } }); }
From source file:org.mareatlantica.android.NotificationsController.java
public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) { if (messageObjects.isEmpty()) { return;/*from www. j a v a 2 s .c o m*/ } boolean added = false; int oldCount = popupMessages.size(); HashMap<Long, Boolean> settingsCache = new HashMap<Long, Boolean>(); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); int popup = 0; for (MessageObject messageObject : messageObjects) { if (pushMessagesDict.containsKey(messageObject.messageOwner.id)) { continue; } long dialog_id = messageObject.getDialogId(); if (dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) { continue; } added = true; Boolean value = settingsCache.get(dialog_id); boolean isChat = (int) dialog_id < 0; popup = (int) dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0); if (value == null) { int notify_override = preferences.getInt("notify2_" + dialog_id, 0); value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); settingsCache.put(dialog_id, value); } if (value) { if (popup != 0) { popupMessages.add(0, messageObject); } pushMessagesDict.put(messageObject.messageOwner.id, messageObject); pushMessages.add(0, messageObject); } } if (added) { notifyCheck = isLast; } if (!popupMessages.isEmpty() && oldCount != popupMessages.size()) { if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn) { MessageObject messageObject = messageObjects.get(0); if (popup == 3 || popup == 1 && ApplicationLoader.isScreenOn || popup == 2 && !ApplicationLoader.isScreenOn) { Intent popupIntent = new Intent(ApplicationLoader.applicationContext, PopupNotificationActivity.class); popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND); ApplicationLoader.applicationContext.startActivity(popupIntent); } } } }