android.app.Notification#FLAG_GROUP_SUMMARY源码实例Demo

下面列出了android.app.Notification#FLAG_GROUP_SUMMARY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: LaunchEnr   文件: NotificationListener.java
private boolean shouldBeFilteredOut(StatusBarNotification sbn) {
    Notification notification = sbn.getNotification();

    if (AndroidVersion.isAtLeastOreo()) {
        getCurrentRanking().getRanking(sbn.getKey(), mTempRanking);
        if (!mTempRanking.canShowBadge()) {
            return true;
        }
        if (mTempRanking.getChannel().getId().equals(NotificationChannel.DEFAULT_CHANNEL_ID)) {
            // Special filtering for the default, legacy "Miscellaneous" channel.
            if ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0) {
                return true;
            }
        }
    }

    if ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0) {
        return true;
    }

    boolean isGroupHeader = (notification.flags & Notification.FLAG_GROUP_SUMMARY) != 0;
    CharSequence title = notification.extras.getCharSequence(Notification.EXTRA_TITLE);
    CharSequence text = notification.extras.getCharSequence(Notification.EXTRA_TEXT);
    boolean missingTitleAndText = TextUtils.isEmpty(title) && TextUtils.isEmpty(text);
    return (isGroupHeader || missingTitleAndText);
}
 
@Override
public CharSequence[] getTitleAndText(String appPackageName, Bundle extras, int notificationFlags) {
    DebugLog debugLog = getDebugLog();
    if (isLoggingEnabled()) {
        debugLog.writeLog("Entered 'IgnoreSummaryMessageExtractor' getTitleAndText method");
        debugLog.writeLog("NotificationFlags = " + notificationFlags);
    }

    if ((notificationFlags & Notification.FLAG_GROUP_SUMMARY) != 0) {
        if (isLoggingEnabled()) {
            debugLog.writeLog("Notification is a group summary. Ignoring.");
        }
        return null;
    }

    // TODO: GMail repeats non-summary notifications occasionally
    // some of them will be filtered out by the GenericMessageExtractor implementation
    // but sometimes they are not immediately one after another: M1 - M2 - M3 - M1
    // TODO: keep track of several previous messages hashes to ignore the duplicates?

    if (isLoggingEnabled()) {
        debugLog.writeLog("Calling method from super class");
    }
    return super.getTitleAndText(appPackageName, extras, notificationFlags);
}
 
源代码3 项目: an2linuxclient   文件: NotificationService.java
@RequiresApi(Build.VERSION_CODES.KITKAT_WATCH)
private boolean isGroupSummary(int flags) {
    return (flags & Notification.FLAG_GROUP_SUMMARY) != 0;
}
 
源代码4 项目: an2linuxclient   文件: NotificationService.java
@RequiresApi(Build.VERSION_CODES.KITKAT_WATCH)
private boolean isGroupSummary(int flags) {
    return (flags & Notification.FLAG_GROUP_SUMMARY) != 0;
}
 
源代码5 项目: json2notification   文件: NotificationConverter.java
@TargetApi(Build.VERSION_CODES.KITKAT)
@NonNull
public static SimpleNotification toSimpleNotification(@NonNull Notification notification) {
    SimpleNotification simpleNotification = new SimpleNotification();

    simpleNotification.autoCancel = (notification.flags & Notification.FLAG_AUTO_CANCEL) == Notification.FLAG_AUTO_CANCEL;
    android.util.Log.d("json2notification", "autoCancel:" + simpleNotification.autoCancel);

    //simpleNotification.bigPictureStyle // TODO

    simpleNotification.category = notification.category;
    simpleNotification.color = notification.color > 0 ? notification.color : null;
    simpleNotification.contentInfo = notification.extras.getString(Notification.EXTRA_INFO_TEXT);
    simpleNotification.contentIntent = notification.contentIntent;
    simpleNotification.contentTitle = notification.extras.getString(Notification.EXTRA_TITLE);
    simpleNotification.contentText = notification.extras.getString(Notification.EXTRA_TEXT);
    simpleNotification.defaults = notification.defaults > 0 ? notification.defaults : null;
    simpleNotification.deleteIntent = notification.deleteIntent;
    //simpleNotification.extras;
    simpleNotification.groupKey = notification.getGroup();
    if (simpleNotification.groupKey != null) {
        simpleNotification.groupSummary = (notification.flags & Notification.FLAG_GROUP_SUMMARY) == Notification.FLAG_GROUP_SUMMARY;
    }
    Bitmap bitmap = notification.extras.getParcelable(Notification.EXTRA_LARGE_ICON);
    if (bitmap != null) simpleNotification.largeIcon = Bitmaps.base64(bitmap);
    if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) == Notification.FLAG_SHOW_LIGHTS) {
        simpleNotification.lights = Arrays.asList(notification.ledARGB, notification.ledOnMS, notification.ledOffMS);
    }
    simpleNotification.localOnly = (notification.flags & Notification.FLAG_LOCAL_ONLY) == Notification.FLAG_LOCAL_ONLY;
    simpleNotification.number = notification.number > 0 ? notification.number : null;
    simpleNotification.ongoing = (notification.flags & Notification.FLAG_ONGOING_EVENT) == Notification.FLAG_ONGOING_EVENT;
    simpleNotification.onlyAlertOnce = (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) == Notification.FLAG_ONLY_ALERT_ONCE;
    String[] people = notification.extras.getStringArray(Notification.EXTRA_PEOPLE);
    if (people != null) {
        simpleNotification.people = Arrays.asList(people);
    }
    simpleNotification.priority = notification.priority > 0 ? notification.priority : null;
    //simpleNotification.progress;
    simpleNotification.publicVersion = notification.publicVersion;
    simpleNotification.showWhen = notification.extras.getBoolean(Notification.EXTRA_SHOW_WHEN);
    if (simpleNotification.showWhen) {
        simpleNotification.when = notification.when;
    }
    simpleNotification.smallIcon = String.valueOf(notification.extras.getInt(Notification.EXTRA_SMALL_ICON)); // TODO getResourceNameById()
    android.util.Log.d("json2notification", "simpleNotification.smallIcon" + simpleNotification.smallIcon);
    simpleNotification.sortKey = notification.getSortKey();
    simpleNotification.sound = notification.sound;
    simpleNotification.subText = notification.extras.getString(Notification.EXTRA_SUB_TEXT);
    simpleNotification.tickerText = notification.tickerText;
    simpleNotification.usesChronometer = notification.extras.getBoolean(Notification.EXTRA_SHOW_CHRONOMETER);
    simpleNotification.visibility = notification.visibility > 0 ? notification.visibility : null;
    return simpleNotification;
}
 
public static boolean isGroupSummary(Notification notif) {
    return (notif.flags & Notification.FLAG_GROUP_SUMMARY) != 0;
}