Search in sources :

Example 76 with PendingIntent

use of android.app.PendingIntent in project Signal-Android by WhisperSystems.

the class GcmRefreshJob method notifyGcmFailure.

private void notifyGcmFailure() {
    Intent intent = new Intent(context, PlayServicesProblemActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 1122, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setSmallIcon(R.drawable.icon_notification);
    builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_action_warning_red));
    builder.setContentTitle(context.getString(R.string.GcmRefreshJob_Permanent_Signal_communication_failure));
    builder.setContentText(context.getString(R.string.GcmRefreshJob_Signal_was_unable_to_register_with_Google_Play_Services));
    builder.setTicker(context.getString(R.string.GcmRefreshJob_Permanent_Signal_communication_failure));
    builder.setVibrate(new long[] { 0, 1000 });
    builder.setContentIntent(pendingIntent);
    ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(12, builder.build());
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 77 with PendingIntent

use of android.app.PendingIntent in project Signal-Android by WhisperSystems.

the class NotificationState method getDeleteIntent.

public PendingIntent getDeleteIntent(Context context) {
    int index = 0;
    long[] ids = new long[notifications.size()];
    boolean[] mms = new boolean[ids.length];
    for (NotificationItem notificationItem : notifications) {
        ids[index] = notificationItem.getId();
        mms[index++] = notificationItem.isMms();
    }
    Intent intent = new Intent(context, DeleteNotificationReceiver.class);
    intent.setAction(DeleteNotificationReceiver.DELETE_NOTIFICATION_ACTION);
    intent.putExtra(DeleteNotificationReceiver.EXTRA_IDS, ids);
    intent.putExtra(DeleteNotificationReceiver.EXTRA_MMS, mms);
    intent.setData((Uri.parse("custom://" + System.currentTimeMillis())));
    return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 78 with PendingIntent

use of android.app.PendingIntent in project Signal-Android by WhisperSystems.

the class NotificationState method getQuickReplyIntent.

public PendingIntent getQuickReplyIntent(Context context, Recipients recipients) {
    if (threads.size() != 1)
        throw new AssertionError("We only support replies to single thread notifications! " + threads.size());
    Intent intent = new Intent(context, ConversationPopupActivity.class);
    intent.putExtra(ConversationActivity.RECIPIENTS_EXTRA, recipients.getIds());
    intent.putExtra(ConversationActivity.THREAD_ID_EXTRA, (long) threads.toArray()[0]);
    intent.setData((Uri.parse("custom://" + System.currentTimeMillis())));
    return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 79 with PendingIntent

use of android.app.PendingIntent in project Signal-Android by WhisperSystems.

the class NotificationState method getAndroidAutoHeardIntent.

public PendingIntent getAndroidAutoHeardIntent(Context context, int notificationId) {
    long[] threadArray = new long[threads.size()];
    int index = 0;
    for (long thread : threads) {
        Log.w("NotificationState", "getAndroidAutoHeardIntent Added thread: " + thread);
        threadArray[index++] = thread;
    }
    Intent intent = new Intent(AndroidAutoHeardReceiver.HEARD_ACTION);
    intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
    intent.setClass(context, AndroidAutoHeardReceiver.class);
    intent.setData((Uri.parse("custom://" + System.currentTimeMillis())));
    intent.putExtra(AndroidAutoHeardReceiver.THREAD_IDS_EXTRA, threadArray);
    intent.putExtra(AndroidAutoHeardReceiver.NOTIFICATION_ID_EXTRA, notificationId);
    intent.setPackage(context.getPackageName());
    return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 80 with PendingIntent

use of android.app.PendingIntent in project Signal-Android by WhisperSystems.

the class NotificationState method getMarkAsReadIntent.

public PendingIntent getMarkAsReadIntent(Context context, int notificationId) {
    long[] threadArray = new long[threads.size()];
    int index = 0;
    for (long thread : threads) {
        Log.w("NotificationState", "Added thread: " + thread);
        threadArray[index++] = thread;
    }
    Intent intent = new Intent(MarkReadReceiver.CLEAR_ACTION);
    intent.setClass(context, MarkReadReceiver.class);
    intent.setData((Uri.parse("custom://" + System.currentTimeMillis())));
    intent.putExtra(MarkReadReceiver.THREAD_IDS_EXTRA, threadArray);
    intent.putExtra(MarkReadReceiver.NOTIFICATION_ID_EXTRA, notificationId);
    return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Aggregations

PendingIntent (android.app.PendingIntent)1208 Intent (android.content.Intent)1010 Notification (android.app.Notification)222 NotificationCompat (android.support.v4.app.NotificationCompat)167 AlarmManager (android.app.AlarmManager)149 NotificationManager (android.app.NotificationManager)148 Bundle (android.os.Bundle)75 RemoteViews (android.widget.RemoteViews)67 RemoteException (android.os.RemoteException)64 Resources (android.content.res.Resources)62 Bitmap (android.graphics.Bitmap)61 Context (android.content.Context)60 ComponentName (android.content.ComponentName)55 Test (org.junit.Test)44 Uri (android.net.Uri)42 IntentFilter (android.content.IntentFilter)41 SharedPreferences (android.content.SharedPreferences)36 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)33 UserHandle (android.os.UserHandle)31 ArrayList (java.util.ArrayList)30