Java Code Examples for android.app.Notification#VISIBILITY_SECRET

The following examples show how to use android.app.Notification#VISIBILITY_SECRET . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OversecIntentService.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
public static Notification buildAcsNotRunningNotification(Context ctx) {
    Intent mainIntent = new Intent(ctx, OversecIntentService.class);
    mainIntent.setAction(ACTION_SHOW_ACCESSIBILITY_SETTINGS);
    PendingIntent pendingMainIntent = PendingIntent.getService(ctx, 0,
            mainIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(
            ctx)
            .setSmallIcon(R.drawable.ic_info_black_24dp)
            // .setLargeIcon(largeIcon)
            .setColor(ContextCompat.getColor(ctx, io.oversec.one.crypto.R.color.colorPrimary))
            .setContentTitle(ctx.getString(R.string.notification_acsnotrunning_title))
            .setContentText(ctx.getString(R.string.notification_acsnotrunning_body))
            .setContentIntent(pendingMainIntent);
    Notification n = builder.build();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        n.visibility = Notification.VISIBILITY_SECRET;
    }
    return n;
}
 
Example 2
Source File: NotificationUsageStats.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public void countApiUse(NotificationRecord record) {
    final Notification n = record.getNotification();
    if (n.actions != null) {
        numWithActions++;
    }

    if ((n.flags & Notification.FLAG_FOREGROUND_SERVICE) != 0) {
        numForegroundService++;
    }

    if ((n.flags & Notification.FLAG_ONGOING_EVENT) != 0) {
        numOngoing++;
    }

    if ((n.flags & Notification.FLAG_AUTO_CANCEL) != 0) {
        numAutoCancel++;
    }

    if ((n.defaults & Notification.DEFAULT_SOUND) != 0 ||
            (n.defaults & Notification.DEFAULT_VIBRATE) != 0 ||
            n.sound != null || n.vibrate != null) {
        numInterrupt++;
    }

    switch (n.visibility) {
        case Notification.VISIBILITY_PRIVATE:
            numPrivate++;
            break;
        case Notification.VISIBILITY_SECRET:
            numSecret++;
            break;
    }

    if (record.stats.isNoisy) {
        noisyImportance.increment(record.stats.requestedImportance);
    } else {
        quietImportance.increment(record.stats.requestedImportance);
    }
    finalImportance.increment(record.getImportance());

    final Set<String> names = n.extras.keySet();
    if (names.contains(Notification.EXTRA_BIG_TEXT)) {
        numWithBigText++;
    }
    if (names.contains(Notification.EXTRA_PICTURE)) {
        numWithBigPicture++;
    }
    if (names.contains(Notification.EXTRA_LARGE_ICON)) {
        numWithLargeIcon++;
    }
    if (names.contains(Notification.EXTRA_TEXT_LINES)) {
        numWithInbox++;
    }
    if (names.contains(Notification.EXTRA_MEDIA_SESSION)) {
        numWithMediaSession++;
    }
    if (names.contains(Notification.EXTRA_TITLE) &&
            !TextUtils.isEmpty(n.extras.getCharSequence(Notification.EXTRA_TITLE))) {
        numWithTitle++;
    }
    if (names.contains(Notification.EXTRA_TEXT) &&
            !TextUtils.isEmpty(n.extras.getCharSequence(Notification.EXTRA_TEXT))) {
        numWithText++;
    }
    if (names.contains(Notification.EXTRA_SUB_TEXT) &&
            !TextUtils.isEmpty(n.extras.getCharSequence(Notification.EXTRA_SUB_TEXT))) {
        numWithSubText++;
    }
    if (names.contains(Notification.EXTRA_INFO_TEXT) &&
            !TextUtils.isEmpty(n.extras.getCharSequence(Notification.EXTRA_INFO_TEXT))) {
        numWithInfoText++;
    }
}
 
Example 3
Source File: OversecIntentService.java    From oversec with GNU General Public License v3.0 4 votes vote down vote up
public static Notification buildNotification(Context ctx, String packagename, boolean decryptOverlayIsShowing, boolean infoMode, boolean temporaryHidden) {

        Intent mainIntent = new Intent(ctx, OversecIntentService.class);
        mainIntent.setAction(temporaryHidden ? ACTION_TEMP_SHOW : ACTION_SHOW_CONFIG);
        mainIntent.putExtra(EXTRA_PACKAGE_NAME, packagename);

        PendingIntent pendingMainIntent = PendingIntent.getService(ctx, 0,
                mainIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        Intent tempHideIntent = new Intent(ctx, OversecIntentService.class);
        tempHideIntent.setAction(ACTION_TEMP_HIDE);
        tempHideIntent.putExtra(EXTRA_PACKAGE_NAME, packagename);
        PendingIntent pendingTempHideIntent = PendingIntent.getService(ctx, 0,
                tempHideIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        Intent tempShowIntent = new Intent(ctx, OversecIntentService.class);
        tempShowIntent.setAction(ACTION_TEMP_SHOW);
        tempShowIntent.putExtra(EXTRA_PACKAGE_NAME, packagename);
        PendingIntent pendingTempShowIntent = PendingIntent.getService(ctx, 0,
                tempShowIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        Intent infoOnIntent = new Intent(ctx, OversecIntentService.class);
        infoOnIntent.setAction(ACTION_INFO_ON);
        PendingIntent pendingInfoOnIntent = PendingIntent.getService(ctx, 0,
                infoOnIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        Intent infoOffIntent = new Intent(ctx, OversecIntentService.class);
        infoOffIntent.setAction(ACTION_INFO_OFF);
        PendingIntent pendingInfoOffIntent = PendingIntent.getService(ctx, 0,
                infoOffIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        Intent stopIntent = new Intent(ctx, OversecIntentService.class);
        stopIntent.setAction(ACTION_STOPBOSS);
        PendingIntent pendingStopIntent = PendingIntent.getService(ctx, 0,
                stopIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(
                ctx)
                .setSmallIcon(R.drawable.ic_shutup_black_24dp)
                //  .setLargeIcon(largeIcon)
                .setColor(ContextCompat.getColor(ctx, io.oversec.one.crypto.R.color.colorPrimary))
                .setContentTitle(ctx.getString(temporaryHidden ? R.string.notification_title__hidden : R.string.notification_title__active))
                .setContentText(ctx.getString(temporaryHidden ? R.string.notification_body__hidden : R.string.notification_body__active))
                .setContentIntent(pendingMainIntent)

                .addAction(
                        Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
                                R.drawable.ic_cancel_black_24dp : R.drawable.ic_cancel_white_24dp,
                        ctx.getString(R.string.notification_action_boss),
                        pendingStopIntent);
        if (!temporaryHidden) {
            builder.addAction(
                    Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
                            R.drawable.ic_not_interested_black_24dp : R.drawable.ic_not_interested_white_24dp,
                    ctx.getString(decryptOverlayIsShowing ? R.string.notification_action_hide
                            : R.string.notification_action_show),
                    decryptOverlayIsShowing ? pendingTempHideIntent : pendingTempShowIntent);
        }
        if (decryptOverlayIsShowing && !temporaryHidden) {
            builder.addAction(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
                            R.drawable.ic_info_outline_black_24dp : R.drawable.ic_info_outline_white_24dp,
                    ctx.getString(infoMode ? R.string.notification_action_unexplore
                            : R.string.notification_action_explore),
                    infoMode ? pendingInfoOffIntent : pendingInfoOnIntent);

        }

        Notification n = builder.build();
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            n.visibility = Notification.VISIBILITY_SECRET;
        }
        n.priority = Notification.PRIORITY_MIN; //TODO: maybe make configurable
        return n;
    }
 
Example 4
Source File: LeanplumNotificationChannel.java    From Leanplum-Android-SDK with Apache License 2.0 4 votes vote down vote up
NotificationChannelData(Map<String, Object> channel) {
  id = (String) channel.get("id");
  name = (String) channel.get("name");
  description = (String) channel.get("description");
  groupId = (String) channel.get("groupId");

  importance = (int) CollectionUtil.getOrDefault(channel, "importance",
      importance);
  enableLights = (boolean) CollectionUtil.getOrDefault(channel, "enable_lights",
      enableLights);
  lightColor = (int) CollectionUtil.getOrDefault(channel, "light_color", lightColor);
  enableVibration = (boolean) CollectionUtil.getOrDefault(channel, "enable_vibration",
      enableVibration);
  lockscreenVisibility = (int) CollectionUtil.getOrDefault(channel, "lockscreen_visibility",
      lockscreenVisibility);
  bypassDnd = (boolean) CollectionUtil.getOrDefault(channel, "bypass_dnd", bypassDnd);
  showBadge = (boolean) CollectionUtil.getOrDefault(channel, "show_badge", showBadge);

  try {
    List<Number> pattern = CollectionUtil.uncheckedCast(
        CollectionUtil.getOrDefault(channel, "vibration_pattern", null));
    if (pattern != null) {
      vibrationPattern = new long[pattern.size()];
      Iterator<Number> iterator = pattern.iterator();
      for (int i = 0; i < vibrationPattern.length; i++) {
        Number next = iterator.next();
        if (next != null) {
          vibrationPattern[i] = next.longValue();
        }
      }
    }
  } catch (Exception e) {
    Log.w("Failed to parse vibration pattern.");
  }

  // Sanity checks.
  if (importance < NotificationManager.IMPORTANCE_NONE &&
      importance > NotificationManager.IMPORTANCE_MAX) {
    importance = NotificationManager.IMPORTANCE_DEFAULT;
  }
  if (lockscreenVisibility < Notification.VISIBILITY_SECRET &&
      lockscreenVisibility > Notification.VISIBILITY_PUBLIC) {
    lockscreenVisibility = Notification.VISIBILITY_PUBLIC;
  }
}