Search in sources :

Example 26 with NotificationManager

use of android.app.NotificationManager in project XPrivacy by M66B.

the class PrivacyService method notifyException.

private void notifyException(Throwable ex) {
    Util.bug(null, ex);
    if (mNotified)
        return;
    Context context = getContext();
    if (context == null)
        return;
    try {
        Intent intent = new Intent("biz.bokhorst.xprivacy.action.EXCEPTION");
        intent.putExtra("Message", ex.toString());
        context.sendBroadcast(intent);
        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        // Build notification
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
        notificationBuilder.setSmallIcon(R.drawable.ic_launcher);
        notificationBuilder.setContentTitle(context.getString(R.string.app_name));
        notificationBuilder.setContentText(ex.toString());
        notificationBuilder.setWhen(System.currentTimeMillis());
        notificationBuilder.setAutoCancel(true);
        Notification notification = notificationBuilder.build();
        // Display notification
        notificationManager.notify(Util.NOTIFY_CORRUPT, notification);
        mNotified = true;
    } catch (Throwable exex) {
        Util.bug(null, exex);
    }
}
Also used : Context(android.content.Context) NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) Notification(android.app.Notification)

Example 27 with NotificationManager

use of android.app.NotificationManager in project XPrivacy by M66B.

the class BootReceiver method onReceive.

@Override
public void onReceive(final Context context, Intent bootIntent) {
    // Start boot update
    Intent changeIntent = new Intent();
    changeIntent.setClass(context, UpdateService.class);
    changeIntent.putExtra(UpdateService.cAction, UpdateService.cActionBoot);
    context.startService(changeIntent);
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    // Check if Xposed enabled
    if (Util.isXposedEnabled() && PrivacyService.checkClient())
        try {
            if (PrivacyService.getClient().databaseCorrupt()) {
                // Build notification
                NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
                notificationBuilder.setSmallIcon(R.drawable.ic_launcher);
                notificationBuilder.setContentTitle(context.getString(R.string.app_name));
                notificationBuilder.setContentText(context.getString(R.string.msg_corrupt));
                notificationBuilder.setWhen(System.currentTimeMillis());
                notificationBuilder.setAutoCancel(true);
                Notification notification = notificationBuilder.build();
                // Display notification
                notificationManager.notify(Util.NOTIFY_CORRUPT, notification);
            } else
                context.sendBroadcast(new Intent("biz.bokhorst.xprivacy.action.ACTIVE"));
        } catch (Throwable ex) {
            Util.bug(null, ex);
        }
    else {
        // Create Xposed installer intent
        // @formatter:off
        Intent xInstallerIntent = new Intent("de.robv.android.xposed.installer.OPEN_SECTION").setPackage("de.robv.android.xposed.installer").putExtra("section", "modules").putExtra("module", context.getPackageName()).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        // @formatter:on
        PendingIntent pi = (xInstallerIntent == null ? null : PendingIntent.getActivity(context, 0, xInstallerIntent, PendingIntent.FLAG_UPDATE_CURRENT));
        // Build notification
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
        notificationBuilder.setSmallIcon(R.drawable.ic_launcher);
        notificationBuilder.setContentTitle(context.getString(R.string.app_name));
        notificationBuilder.setContentText(context.getString(R.string.app_notenabled));
        notificationBuilder.setWhen(System.currentTimeMillis());
        notificationBuilder.setAutoCancel(true);
        if (pi != null)
            notificationBuilder.setContentIntent(pi);
        Notification notification = notificationBuilder.build();
        // Display notification
        notificationManager.notify(Util.NOTIFY_NOTXPOSED, notification);
    }
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 28 with NotificationManager

use of android.app.NotificationManager in project Xposed-Tinted-Status-Bar by MohammadAG.

the class OnWindowFocusedHook method afterHookedMethod.

@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
    mSettingsHelper.reload();
    if (!mSettingsHelper.getBoolean(SettingsKeys.ENABLE_AWESOME_AB_COLOR_PICKER, false))
        return;
    Activity activity = (Activity) param.thisObject;
    String packageName = activity.getPackageName();
    String activityName = activity.getLocalClassName();
    final TypedArray typedArray = activity.obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    int actionBarSize = (int) typedArray.getDimension(0, 0);
    typedArray.recycle();
    // Get the top of the window, so we can crop the status bar out.
    Rect rect = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
    int top = rect.top;
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);
    Bitmap bitmap1 = view.getDrawingCache();
    if (bitmap1 == null)
        return;
    // Crop and compress the image so that we don't get a TransactionTooLargeException.
    Bitmap bitmap = Bitmap.createBitmap(bitmap1, 0, top, bitmap1.getWidth(), actionBarSize);
    ByteArrayOutputStream compressedBitmap = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 80, compressedBitmap);
    ComponentName cn = new ComponentName("com.mohammadag.colouredstatusbar", "com.mohammadag.colouredstatusbar.activities.ScreenColorPickerActivity");
    Intent colorPickerIntent = new Intent().setComponent(cn);
    colorPickerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    colorPickerIntent.putExtra("bitmap", compressedBitmap.toByteArray());
    colorPickerIntent.putExtra("pkg", packageName);
    PendingIntent colorActivityPendingIntent = PendingIntent.getActivity(activity, 0, colorPickerIntent.putExtra("title", activityName), PendingIntent.FLAG_UPDATE_CURRENT);
    PendingIntent colorAllPendingIntent = PendingIntent.getActivity(activity, 1, colorPickerIntent.putExtra("title", packageName), PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationManager nm = (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new NotificationCompat.Builder(activity).setContentTitle(packageName).setContentText(activityName).setSmallIcon(android.R.drawable.sym_def_app_icon).setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bitmap)).addAction(android.R.drawable.ic_menu_add, mResources.getString(R.string.notification_add_activity), colorActivityPendingIntent).addAction(android.R.drawable.ic_menu_add, mResources.getString(R.string.notification_add_app), colorAllPendingIntent).build();
    nm.notify(1240, notification);
    view.setDrawingCacheEnabled(false);
}
Also used : Rect(android.graphics.Rect) NotificationManager(android.app.NotificationManager) Activity(android.app.Activity) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) View(android.view.View) Notification(android.app.Notification) Bitmap(android.graphics.Bitmap) TypedArray(android.content.res.TypedArray) NotificationCompat(android.support.v4.app.NotificationCompat) ComponentName(android.content.ComponentName) PendingIntent(android.app.PendingIntent)

Example 29 with NotificationManager

use of android.app.NotificationManager 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 30 with NotificationManager

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

the class RegistrationNotifier method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setSmallIcon(R.drawable.icon_notification);
    builder.setContentTitle(intent.getStringExtra(RegistrationService.NOTIFICATION_TITLE));
    builder.setContentText(intent.getStringExtra(RegistrationService.NOTIFICATION_TEXT));
    builder.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, ConversationListActivity.class), 0));
    builder.setWhen(System.currentTimeMillis());
    builder.setDefaults(Notification.DEFAULT_VIBRATE);
    builder.setAutoCancel(true);
    Notification notification = builder.build();
    ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(31337, notification);
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Aggregations

NotificationManager (android.app.NotificationManager)374 Intent (android.content.Intent)187 PendingIntent (android.app.PendingIntent)184 Notification (android.app.Notification)147 NotificationCompat (android.support.v4.app.NotificationCompat)107 Context (android.content.Context)32 Bitmap (android.graphics.Bitmap)24 Uri (android.net.Uri)23 Resources (android.content.res.Resources)22 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)20 TaskStackBuilder (android.app.TaskStackBuilder)15 Bundle (android.os.Bundle)15 StatusBarNotification (android.service.notification.StatusBarNotification)15 Random (java.util.Random)14 BitmapFactory (android.graphics.BitmapFactory)13 SharedPreferences (android.content.SharedPreferences)12 ComponentName (android.content.ComponentName)10 IntentFilter (android.content.IntentFilter)9 ArrayList (java.util.ArrayList)9 Date (java.util.Date)9