2021-07-24 02:37:17 +00:00
package androidx.core.app ;
import android.annotation.SuppressLint ;
import android.app.Notification ;
import android.app.PendingIntent ;
2021-09-21 07:33:49 +00:00
import android.app.Person ;
2021-07-24 02:37:17 +00:00
import android.app.RemoteInput ;
import android.content.Context ;
2021-09-21 07:33:49 +00:00
import android.content.LocusId ;
2021-07-24 02:37:17 +00:00
import android.content.res.ColorStateList ;
import android.content.res.Resources ;
import android.graphics.Bitmap ;
import android.graphics.Canvas ;
import android.graphics.PorterDuff ;
import android.graphics.PorterDuffColorFilter ;
import android.graphics.drawable.Drawable ;
2021-09-21 07:33:49 +00:00
import android.graphics.drawable.Icon ;
2021-07-24 02:37:17 +00:00
import android.media.AudioAttributes ;
import android.net.Uri ;
import android.os.Build ;
import android.os.Bundle ;
import android.os.Parcelable ;
import android.os.SystemClock ;
import android.text.SpannableStringBuilder ;
import android.text.TextUtils ;
import android.text.style.TextAppearanceSpan ;
import android.widget.RemoteViews ;
import androidx.annotation.ColorInt ;
import androidx.annotation.DimenRes ;
import androidx.annotation.Dimension ;
import androidx.annotation.NonNull ;
import androidx.annotation.Nullable ;
import androidx.annotation.RequiresApi ;
import androidx.annotation.RestrictTo ;
import androidx.core.R ;
import androidx.core.app.Person ;
2021-09-21 07:33:49 +00:00
import androidx.core.content.LocusIdCompat ;
import androidx.core.content.pm.ShortcutInfoCompat ;
2021-07-24 02:37:17 +00:00
import androidx.core.graphics.drawable.IconCompat ;
import androidx.core.text.BidiFormatter ;
2021-08-09 22:50:52 +00:00
import androidx.core.view.ViewCompat ;
2021-07-24 02:37:17 +00:00
import java.lang.annotation.Retention ;
import java.lang.annotation.RetentionPolicy ;
import java.text.NumberFormat ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.Collections ;
import java.util.Iterator ;
import java.util.List ;
import java.util.Objects ;
public class NotificationCompat {
public static final int BADGE_ICON_LARGE = 2 ;
public static final int BADGE_ICON_NONE = 0 ;
public static final int BADGE_ICON_SMALL = 1 ;
public static final String CATEGORY_ALARM = " alarm " ;
public static final String CATEGORY_CALL = " call " ;
public static final String CATEGORY_EMAIL = " email " ;
public static final String CATEGORY_ERROR = " err " ;
public static final String CATEGORY_EVENT = " event " ;
2021-09-21 07:33:49 +00:00
public static final String CATEGORY_LOCATION_SHARING = " location_sharing " ;
2021-07-24 02:37:17 +00:00
public static final String CATEGORY_MESSAGE = " msg " ;
2021-09-21 07:33:49 +00:00
public static final String CATEGORY_MISSED_CALL = " missed_call " ;
2021-07-24 02:37:17 +00:00
public static final String CATEGORY_NAVIGATION = " navigation " ;
public static final String CATEGORY_PROGRESS = " progress " ;
public static final String CATEGORY_PROMO = " promo " ;
public static final String CATEGORY_RECOMMENDATION = " recommendation " ;
public static final String CATEGORY_REMINDER = " reminder " ;
public static final String CATEGORY_SERVICE = " service " ;
public static final String CATEGORY_SOCIAL = " social " ;
public static final String CATEGORY_STATUS = " status " ;
2021-09-21 07:33:49 +00:00
public static final String CATEGORY_STOPWATCH = " stopwatch " ;
2021-07-24 02:37:17 +00:00
public static final String CATEGORY_SYSTEM = " sys " ;
public static final String CATEGORY_TRANSPORT = " transport " ;
2021-09-21 07:33:49 +00:00
public static final String CATEGORY_WORKOUT = " workout " ;
2021-07-24 02:37:17 +00:00
@ColorInt
public static final int COLOR_DEFAULT = 0 ;
public static final int DEFAULT_ALL = - 1 ;
public static final int DEFAULT_LIGHTS = 4 ;
public static final int DEFAULT_SOUND = 1 ;
public static final int DEFAULT_VIBRATE = 2 ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_AUDIO_CONTENTS_URI = " android.audioContents " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_BACKGROUND_IMAGE_URI = " android.backgroundImageUri " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_BIG_TEXT = " android.bigText " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
public static final String EXTRA_CHANNEL_GROUP_ID = " android.intent.extra.CHANNEL_GROUP_ID " ;
@SuppressLint ( { " ActionValue " } )
public static final String EXTRA_CHANNEL_ID = " android.intent.extra.CHANNEL_ID " ;
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_CHRONOMETER_COUNT_DOWN = " android.chronometerCountDown " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
public static final String EXTRA_COLORIZED = " android.colorized " ;
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_COMPACT_ACTIONS = " android.compactActions " ;
2021-09-21 07:33:49 +00:00
public static final String EXTRA_COMPAT_TEMPLATE = " androidx.core.app.extra.COMPAT_TEMPLATE " ;
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_CONVERSATION_TITLE = " android.conversationTitle " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_HIDDEN_CONVERSATION_TITLE = " android.hiddenConversationTitle " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
public static final String EXTRA_HISTORIC_MESSAGES = " android.messages.historic " ;
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_INFO_TEXT = " android.infoText " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_IS_GROUP_CONVERSATION = " android.isGroupConversation " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_LARGE_ICON = " android.largeIcon " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_LARGE_ICON_BIG = " android.largeIcon.big " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_MEDIA_SESSION = " android.mediaSession " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_MESSAGES = " android.messages " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_MESSAGING_STYLE_USER = " android.messagingStyleUser " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
public static final String EXTRA_NOTIFICATION_ID = " android.intent.extra.NOTIFICATION_ID " ;
@SuppressLint ( { " ActionValue " } )
public static final String EXTRA_NOTIFICATION_TAG = " android.intent.extra.NOTIFICATION_TAG " ;
@SuppressLint ( { " ActionValue " } )
@Deprecated
2021-07-24 02:37:17 +00:00
public static final String EXTRA_PEOPLE = " android.people " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
public static final String EXTRA_PEOPLE_LIST = " android.people.list " ;
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_PICTURE = " android.picture " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_PROGRESS = " android.progress " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_PROGRESS_INDETERMINATE = " android.progressIndeterminate " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_PROGRESS_MAX = " android.progressMax " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_REMOTE_INPUT_HISTORY = " android.remoteInputHistory " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_SELF_DISPLAY_NAME = " android.selfDisplayName " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_SHOW_CHRONOMETER = " android.showChronometer " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_SHOW_WHEN = " android.showWhen " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_SMALL_ICON = " android.icon " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_SUB_TEXT = " android.subText " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_SUMMARY_TEXT = " android.summaryText " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_TEMPLATE = " android.template " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_TEXT = " android.text " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_TEXT_LINES = " android.textLines " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_TITLE = " android.title " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
2021-07-24 02:37:17 +00:00
public static final String EXTRA_TITLE_BIG = " android.title.big " ;
public static final int FLAG_AUTO_CANCEL = 16 ;
public static final int FLAG_BUBBLE = 4096 ;
public static final int FLAG_FOREGROUND_SERVICE = 64 ;
public static final int FLAG_GROUP_SUMMARY = 512 ;
@Deprecated
public static final int FLAG_HIGH_PRIORITY = 128 ;
public static final int FLAG_INSISTENT = 4 ;
public static final int FLAG_LOCAL_ONLY = 256 ;
public static final int FLAG_NO_CLEAR = 32 ;
public static final int FLAG_ONGOING_EVENT = 2 ;
public static final int FLAG_ONLY_ALERT_ONCE = 8 ;
public static final int FLAG_SHOW_LIGHTS = 1 ;
public static final int GROUP_ALERT_ALL = 0 ;
public static final int GROUP_ALERT_CHILDREN = 2 ;
public static final int GROUP_ALERT_SUMMARY = 1 ;
public static final String GROUP_KEY_SILENT = " silent " ;
2021-09-21 07:33:49 +00:00
@SuppressLint ( { " ActionValue " } )
public static final String INTENT_CATEGORY_NOTIFICATION_PREFERENCES = " android.intent.category.NOTIFICATION_PREFERENCES " ;
2021-07-24 02:37:17 +00:00
public static final int PRIORITY_DEFAULT = 0 ;
public static final int PRIORITY_HIGH = 1 ;
public static final int PRIORITY_LOW = - 1 ;
public static final int PRIORITY_MAX = 2 ;
public static final int PRIORITY_MIN = - 2 ;
public static final int STREAM_DEFAULT = - 1 ;
public static final int VISIBILITY_PRIVATE = 0 ;
public static final int VISIBILITY_PUBLIC = 1 ;
public static final int VISIBILITY_SECRET = - 1 ;
public static class Action {
public static final String EXTRA_SEMANTIC_ACTION = " android.support.action.semanticAction " ;
public static final String EXTRA_SHOWS_USER_INTERFACE = " android.support.action.showsUserInterface " ;
public static final int SEMANTIC_ACTION_ARCHIVE = 5 ;
public static final int SEMANTIC_ACTION_CALL = 10 ;
public static final int SEMANTIC_ACTION_DELETE = 4 ;
public static final int SEMANTIC_ACTION_MARK_AS_READ = 2 ;
public static final int SEMANTIC_ACTION_MARK_AS_UNREAD = 3 ;
public static final int SEMANTIC_ACTION_MUTE = 6 ;
public static final int SEMANTIC_ACTION_NONE = 0 ;
public static final int SEMANTIC_ACTION_REPLY = 1 ;
public static final int SEMANTIC_ACTION_THUMBS_DOWN = 9 ;
public static final int SEMANTIC_ACTION_THUMBS_UP = 8 ;
public static final int SEMANTIC_ACTION_UNMUTE = 7 ;
public PendingIntent actionIntent ;
@Deprecated
public int icon ;
private boolean mAllowGeneratedReplies ;
private final RemoteInput [ ] mDataOnlyRemoteInputs ;
public final Bundle mExtras ;
@Nullable
private IconCompat mIcon ;
private final boolean mIsContextual ;
private final RemoteInput [ ] mRemoteInputs ;
private final int mSemanticAction ;
public boolean mShowsUserInterface ;
public CharSequence title ;
public static final class Builder {
private boolean mAllowGeneratedReplies ;
private final Bundle mExtras ;
private final IconCompat mIcon ;
private final PendingIntent mIntent ;
private boolean mIsContextual ;
private ArrayList < RemoteInput > mRemoteInputs ;
private int mSemanticAction ;
private boolean mShowsUserInterface ;
private final CharSequence mTitle ;
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
2021-09-21 07:33:49 +00:00
public Builder ( int i , @Nullable CharSequence charSequence , @Nullable PendingIntent pendingIntent ) {
2021-07-24 02:37:17 +00:00
this ( i ! = 0 ? IconCompat . createWithResource ( null , " " , i ) : null , charSequence , pendingIntent , new Bundle ( ) , null , true , 0 , true , false ) ;
}
2021-09-21 07:33:49 +00:00
public Builder ( @NonNull Action action ) {
2021-07-24 02:37:17 +00:00
this ( action . getIconCompat ( ) , action . title , action . actionIntent , new Bundle ( action . mExtras ) , action . getRemoteInputs ( ) , action . getAllowGeneratedReplies ( ) , action . getSemanticAction ( ) , action . mShowsUserInterface , action . isContextual ( ) ) ;
}
public Builder ( @Nullable IconCompat iconCompat , @Nullable CharSequence charSequence , @Nullable PendingIntent pendingIntent ) {
this ( iconCompat , charSequence , pendingIntent , new Bundle ( ) , null , true , 0 , true , false ) ;
}
2021-09-21 07:33:49 +00:00
private Builder ( @Nullable IconCompat iconCompat , @Nullable CharSequence charSequence , @Nullable PendingIntent pendingIntent , @NonNull Bundle bundle , @Nullable RemoteInput [ ] remoteInputArr , boolean z2 , int i , boolean z3 , boolean z4 ) {
2021-07-24 02:37:17 +00:00
this . mAllowGeneratedReplies = true ;
this . mShowsUserInterface = true ;
this . mIcon = iconCompat ;
this . mTitle = Builder . limitCharSequenceLength ( charSequence ) ;
this . mIntent = pendingIntent ;
this . mExtras = bundle ;
this . mRemoteInputs = remoteInputArr = = null ? null : new ArrayList < > ( Arrays . asList ( remoteInputArr ) ) ;
this . mAllowGeneratedReplies = z2 ;
this . mSemanticAction = i ;
this . mShowsUserInterface = z3 ;
this . mIsContextual = z4 ;
}
private void checkContextualActionNullFields ( ) {
if ( this . mIsContextual ) {
Objects . requireNonNull ( this . mIntent , " Contextual Actions must contain a valid PendingIntent " ) ;
}
}
2021-09-21 07:33:49 +00:00
@NonNull
@RequiresApi ( 19 )
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public static Builder fromAndroidAction ( @NonNull Notification . Action action ) {
Builder builder = ( Build . VERSION . SDK_INT < 23 | | action . getIcon ( ) = = null ) ? new Builder ( action . icon , action . title , action . actionIntent ) : new Builder ( IconCompat . createFromIcon ( action . getIcon ( ) ) , action . title , action . actionIntent ) ;
RemoteInput [ ] remoteInputs = action . getRemoteInputs ( ) ;
if ( ! ( remoteInputs = = null | | remoteInputs . length = = 0 ) ) {
for ( RemoteInput remoteInput : remoteInputs ) {
builder . addRemoteInput ( RemoteInput . fromPlatform ( remoteInput ) ) ;
}
}
int i = Build . VERSION . SDK_INT ;
if ( i > = 24 ) {
builder . mAllowGeneratedReplies = action . getAllowGeneratedReplies ( ) ;
}
if ( i > = 28 ) {
builder . setSemanticAction ( action . getSemanticAction ( ) ) ;
}
if ( i > = 29 ) {
builder . setContextual ( action . isContextual ( ) ) ;
}
return builder ;
}
@NonNull
public Builder addExtras ( @Nullable Bundle bundle ) {
2021-07-24 02:37:17 +00:00
if ( bundle ! = null ) {
this . mExtras . putAll ( bundle ) ;
}
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder addRemoteInput ( @Nullable RemoteInput remoteInput ) {
2021-07-24 02:37:17 +00:00
if ( this . mRemoteInputs = = null ) {
this . mRemoteInputs = new ArrayList < > ( ) ;
}
2021-09-21 07:33:49 +00:00
if ( remoteInput ! = null ) {
this . mRemoteInputs . add ( remoteInput ) ;
}
2021-07-24 02:37:17 +00:00
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Action build ( ) {
checkContextualActionNullFields ( ) ;
ArrayList arrayList = new ArrayList ( ) ;
ArrayList arrayList2 = new ArrayList ( ) ;
ArrayList < RemoteInput > arrayList3 = this . mRemoteInputs ;
if ( arrayList3 ! = null ) {
Iterator < RemoteInput > it = arrayList3 . iterator ( ) ;
while ( it . hasNext ( ) ) {
RemoteInput next = it . next ( ) ;
if ( next . isDataOnly ( ) ) {
arrayList . add ( next ) ;
} else {
arrayList2 . add ( next ) ;
}
}
}
RemoteInput [ ] remoteInputArr = null ;
RemoteInput [ ] remoteInputArr2 = arrayList . isEmpty ( ) ? null : ( RemoteInput [ ] ) arrayList . toArray ( new RemoteInput [ arrayList . size ( ) ] ) ;
if ( ! arrayList2 . isEmpty ( ) ) {
remoteInputArr = ( RemoteInput [ ] ) arrayList2 . toArray ( new RemoteInput [ arrayList2 . size ( ) ] ) ;
}
return new Action ( this . mIcon , this . mTitle , this . mIntent , this . mExtras , remoteInputArr , remoteInputArr2 , this . mAllowGeneratedReplies , this . mSemanticAction , this . mShowsUserInterface , this . mIsContextual ) ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder extend ( @NonNull Extender extender ) {
2021-07-24 02:37:17 +00:00
extender . extend ( this ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Bundle getExtras ( ) {
return this . mExtras ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setAllowGeneratedReplies ( boolean z2 ) {
this . mAllowGeneratedReplies = z2 ;
return this ;
}
@NonNull
public Builder setContextual ( boolean z2 ) {
this . mIsContextual = z2 ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setSemanticAction ( int i ) {
this . mSemanticAction = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setShowsUserInterface ( boolean z2 ) {
this . mShowsUserInterface = z2 ;
return this ;
}
}
public interface Extender {
2021-09-21 07:33:49 +00:00
@NonNull
Builder extend ( @NonNull Builder builder ) ;
2021-07-24 02:37:17 +00:00
}
@Retention ( RetentionPolicy . SOURCE )
public @interface SemanticAction {
}
public static final class WearableExtender implements Extender {
private static final int DEFAULT_FLAGS = 1 ;
private static final String EXTRA_WEARABLE_EXTENSIONS = " android.wearable.EXTENSIONS " ;
private static final int FLAG_AVAILABLE_OFFLINE = 1 ;
private static final int FLAG_HINT_DISPLAY_INLINE = 4 ;
private static final int FLAG_HINT_LAUNCHES_ACTIVITY = 2 ;
private static final String KEY_CANCEL_LABEL = " cancelLabel " ;
private static final String KEY_CONFIRM_LABEL = " confirmLabel " ;
private static final String KEY_FLAGS = " flags " ;
private static final String KEY_IN_PROGRESS_LABEL = " inProgressLabel " ;
private CharSequence mCancelLabel ;
private CharSequence mConfirmLabel ;
private int mFlags = 1 ;
private CharSequence mInProgressLabel ;
public WearableExtender ( ) {
}
2021-09-21 07:33:49 +00:00
public WearableExtender ( @NonNull Action action ) {
2021-08-09 22:50:52 +00:00
Bundle bundle = action . getExtras ( ) . getBundle ( EXTRA_WEARABLE_EXTENSIONS ) ;
2021-07-24 02:37:17 +00:00
if ( bundle ! = null ) {
2021-08-09 22:50:52 +00:00
this . mFlags = bundle . getInt ( KEY_FLAGS , 1 ) ;
this . mInProgressLabel = bundle . getCharSequence ( KEY_IN_PROGRESS_LABEL ) ;
this . mConfirmLabel = bundle . getCharSequence ( KEY_CONFIRM_LABEL ) ;
this . mCancelLabel = bundle . getCharSequence ( KEY_CANCEL_LABEL ) ;
2021-07-24 02:37:17 +00:00
}
}
private void setFlag ( int i , boolean z2 ) {
if ( z2 ) {
this . mFlags = i | this . mFlags ;
return ;
}
this . mFlags = ( ~ i ) & this . mFlags ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public WearableExtender clone ( ) {
WearableExtender wearableExtender = new WearableExtender ( ) ;
wearableExtender . mFlags = this . mFlags ;
wearableExtender . mInProgressLabel = this . mInProgressLabel ;
wearableExtender . mConfirmLabel = this . mConfirmLabel ;
wearableExtender . mCancelLabel = this . mCancelLabel ;
return wearableExtender ;
}
@Override // androidx.core.app.NotificationCompat.Action.Extender
2021-09-21 07:33:49 +00:00
@NonNull
public Builder extend ( @NonNull Builder builder ) {
2021-07-24 02:37:17 +00:00
Bundle bundle = new Bundle ( ) ;
int i = this . mFlags ;
if ( i ! = 1 ) {
2021-08-09 22:50:52 +00:00
bundle . putInt ( KEY_FLAGS , i ) ;
2021-07-24 02:37:17 +00:00
}
CharSequence charSequence = this . mInProgressLabel ;
if ( charSequence ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putCharSequence ( KEY_IN_PROGRESS_LABEL , charSequence ) ;
2021-07-24 02:37:17 +00:00
}
CharSequence charSequence2 = this . mConfirmLabel ;
if ( charSequence2 ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putCharSequence ( KEY_CONFIRM_LABEL , charSequence2 ) ;
2021-07-24 02:37:17 +00:00
}
CharSequence charSequence3 = this . mCancelLabel ;
if ( charSequence3 ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putCharSequence ( KEY_CANCEL_LABEL , charSequence3 ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:50:52 +00:00
builder . getExtras ( ) . putBundle ( EXTRA_WEARABLE_EXTENSIONS , bundle ) ;
2021-07-24 02:37:17 +00:00
return builder ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
@Deprecated
public CharSequence getCancelLabel ( ) {
return this . mCancelLabel ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
@Deprecated
public CharSequence getConfirmLabel ( ) {
return this . mConfirmLabel ;
}
public boolean getHintDisplayActionInline ( ) {
return ( this . mFlags & 4 ) ! = 0 ;
}
public boolean getHintLaunchesActivity ( ) {
return ( this . mFlags & 2 ) ! = 0 ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
@Deprecated
public CharSequence getInProgressLabel ( ) {
return this . mInProgressLabel ;
}
public boolean isAvailableOffline ( ) {
return ( this . mFlags & 1 ) ! = 0 ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public WearableExtender setAvailableOffline ( boolean z2 ) {
setFlag ( 1 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
2021-09-21 07:33:49 +00:00
public WearableExtender setCancelLabel ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mCancelLabel = charSequence ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
2021-09-21 07:33:49 +00:00
public WearableExtender setConfirmLabel ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mConfirmLabel = charSequence ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public WearableExtender setHintDisplayActionInline ( boolean z2 ) {
setFlag ( 4 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public WearableExtender setHintLaunchesActivity ( boolean z2 ) {
setFlag ( 2 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
2021-09-21 07:33:49 +00:00
public WearableExtender setInProgressLabel ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mInProgressLabel = charSequence ;
return this ;
}
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
2021-09-21 07:33:49 +00:00
public Action ( int i , @Nullable CharSequence charSequence , @Nullable PendingIntent pendingIntent ) {
2021-07-24 02:37:17 +00:00
this ( i ! = 0 ? IconCompat . createWithResource ( null , " " , i ) : null , charSequence , pendingIntent ) ;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
2021-09-21 07:33:49 +00:00
public Action ( int i , @Nullable CharSequence charSequence , @Nullable PendingIntent pendingIntent , @Nullable Bundle bundle , @Nullable RemoteInput [ ] remoteInputArr , @Nullable RemoteInput [ ] remoteInputArr2 , boolean z2 , int i2 , boolean z3 , boolean z4 ) {
2021-07-24 02:37:17 +00:00
this ( i ! = 0 ? IconCompat . createWithResource ( null , " " , i ) : null , charSequence , pendingIntent , bundle , remoteInputArr , remoteInputArr2 , z2 , i2 , z3 , z4 ) ;
}
public Action ( @Nullable IconCompat iconCompat , @Nullable CharSequence charSequence , @Nullable PendingIntent pendingIntent ) {
this ( iconCompat , charSequence , pendingIntent , new Bundle ( ) , ( RemoteInput [ ] ) null , ( RemoteInput [ ] ) null , true , 0 , true , false ) ;
}
2021-09-21 07:33:49 +00:00
public Action ( @Nullable IconCompat iconCompat , @Nullable CharSequence charSequence , @Nullable PendingIntent pendingIntent , @Nullable Bundle bundle , @Nullable RemoteInput [ ] remoteInputArr , @Nullable RemoteInput [ ] remoteInputArr2 , boolean z2 , int i , boolean z3 , boolean z4 ) {
2021-07-24 02:37:17 +00:00
this . mShowsUserInterface = true ;
this . mIcon = iconCompat ;
if ( iconCompat ! = null & & iconCompat . getType ( ) = = 2 ) {
this . icon = iconCompat . getResId ( ) ;
}
this . title = Builder . limitCharSequenceLength ( charSequence ) ;
this . actionIntent = pendingIntent ;
this . mExtras = bundle = = null ? new Bundle ( ) : bundle ;
this . mRemoteInputs = remoteInputArr ;
this . mDataOnlyRemoteInputs = remoteInputArr2 ;
this . mAllowGeneratedReplies = z2 ;
this . mSemanticAction = i ;
this . mShowsUserInterface = z3 ;
this . mIsContextual = z4 ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public PendingIntent getActionIntent ( ) {
return this . actionIntent ;
}
public boolean getAllowGeneratedReplies ( ) {
return this . mAllowGeneratedReplies ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public RemoteInput [ ] getDataOnlyRemoteInputs ( ) {
return this . mDataOnlyRemoteInputs ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Bundle getExtras ( ) {
return this . mExtras ;
}
@Deprecated
public int getIcon ( ) {
return this . icon ;
}
@Nullable
public IconCompat getIconCompat ( ) {
int i ;
if ( this . mIcon = = null & & ( i = this . icon ) ! = 0 ) {
this . mIcon = IconCompat . createWithResource ( null , " " , i ) ;
}
return this . mIcon ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public RemoteInput [ ] getRemoteInputs ( ) {
return this . mRemoteInputs ;
}
public int getSemanticAction ( ) {
return this . mSemanticAction ;
}
public boolean getShowsUserInterface ( ) {
return this . mShowsUserInterface ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public CharSequence getTitle ( ) {
return this . title ;
}
public boolean isContextual ( ) {
return this . mIsContextual ;
}
}
@Retention ( RetentionPolicy . SOURCE )
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public @interface BadgeIconType {
}
public static class BigPictureStyle extends Style {
2021-09-21 07:33:49 +00:00
private static final String TEMPLATE_CLASS_NAME = " androidx.core.app.NotificationCompat$BigPictureStyle " ;
private IconCompat mBigLargeIcon ;
2021-07-24 02:37:17 +00:00
private boolean mBigLargeIconSet ;
private Bitmap mPicture ;
2021-09-21 07:33:49 +00:00
@RequiresApi ( 16 )
public static class Api16Impl {
private Api16Impl ( ) {
}
@RequiresApi ( 16 )
public static void setBigLargeIcon ( Notification . BigPictureStyle bigPictureStyle , Bitmap bitmap ) {
bigPictureStyle . bigLargeIcon ( bitmap ) ;
}
@RequiresApi ( 16 )
public static void setSummaryText ( Notification . BigPictureStyle bigPictureStyle , CharSequence charSequence ) {
bigPictureStyle . setSummaryText ( charSequence ) ;
}
}
@RequiresApi ( 23 )
public static class Api23Impl {
private Api23Impl ( ) {
}
@RequiresApi ( 23 )
public static void setBigLargeIcon ( Notification . BigPictureStyle bigPictureStyle , Icon icon ) {
bigPictureStyle . bigLargeIcon ( icon ) ;
}
}
2021-07-24 02:37:17 +00:00
public BigPictureStyle ( ) {
}
2021-09-21 07:33:49 +00:00
public BigPictureStyle ( @Nullable Builder builder ) {
2021-07-24 02:37:17 +00:00
setBuilder ( builder ) ;
}
2021-09-21 07:33:49 +00:00
@Nullable
private static IconCompat asIconCompat ( @Nullable Parcelable parcelable ) {
if ( parcelable = = null ) {
return null ;
}
if ( Build . VERSION . SDK_INT > = 23 & & ( parcelable instanceof Icon ) ) {
return IconCompat . createFromIcon ( ( Icon ) parcelable ) ;
}
if ( parcelable instanceof Bitmap ) {
return IconCompat . createWithBitmap ( ( Bitmap ) parcelable ) ;
}
return null ;
}
2021-07-24 02:37:17 +00:00
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void apply ( NotificationBuilderWithBuilderAccessor notificationBuilderWithBuilderAccessor ) {
2021-09-21 07:33:49 +00:00
int i = Build . VERSION . SDK_INT ;
2021-07-24 02:37:17 +00:00
Notification . BigPictureStyle bigPicture = new Notification . BigPictureStyle ( notificationBuilderWithBuilderAccessor . getBuilder ( ) ) . setBigContentTitle ( this . mBigContentTitle ) . bigPicture ( this . mPicture ) ;
if ( this . mBigLargeIconSet ) {
2021-09-21 07:33:49 +00:00
IconCompat iconCompat = this . mBigLargeIcon ;
Context context = null ;
if ( iconCompat = = null ) {
Api16Impl . setBigLargeIcon ( bigPicture , null ) ;
} else if ( i > = 23 ) {
if ( notificationBuilderWithBuilderAccessor instanceof NotificationCompatBuilder ) {
context = ( ( NotificationCompatBuilder ) notificationBuilderWithBuilderAccessor ) . getContext ( ) ;
}
Api23Impl . setBigLargeIcon ( bigPicture , this . mBigLargeIcon . toIcon ( context ) ) ;
} else if ( iconCompat . getType ( ) = = 1 ) {
Api16Impl . setBigLargeIcon ( bigPicture , this . mBigLargeIcon . getBitmap ( ) ) ;
} else {
Api16Impl . setBigLargeIcon ( bigPicture , null ) ;
}
2021-07-24 02:37:17 +00:00
}
if ( this . mSummaryTextSet ) {
2021-09-21 07:33:49 +00:00
Api16Impl . setSummaryText ( bigPicture , this . mSummaryText ) ;
2021-07-24 02:37:17 +00:00
}
}
2021-09-21 07:33:49 +00:00
@NonNull
public BigPictureStyle bigLargeIcon ( @Nullable Bitmap bitmap ) {
this . mBigLargeIcon = bitmap = = null ? null : IconCompat . createWithBitmap ( bitmap ) ;
2021-07-24 02:37:17 +00:00
this . mBigLargeIconSet = true ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public BigPictureStyle bigPicture ( @Nullable Bitmap bitmap ) {
2021-07-24 02:37:17 +00:00
this . mPicture = bitmap ;
return this ;
}
2021-09-21 07:33:49 +00:00
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void clearCompatExtraKeys ( @NonNull Bundle bundle ) {
super . clearCompatExtraKeys ( bundle ) ;
bundle . remove ( NotificationCompat . EXTRA_LARGE_ICON_BIG ) ;
bundle . remove ( NotificationCompat . EXTRA_PICTURE ) ;
}
@Override // androidx.core.app.NotificationCompat.Style
@NonNull
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public String getClassName ( ) {
return TEMPLATE_CLASS_NAME ;
}
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void restoreFromCompatExtras ( @NonNull Bundle bundle ) {
super . restoreFromCompatExtras ( bundle ) ;
if ( bundle . containsKey ( NotificationCompat . EXTRA_LARGE_ICON_BIG ) ) {
this . mBigLargeIcon = asIconCompat ( bundle . getParcelable ( NotificationCompat . EXTRA_LARGE_ICON_BIG ) ) ;
this . mBigLargeIconSet = true ;
}
this . mPicture = ( Bitmap ) bundle . getParcelable ( NotificationCompat . EXTRA_PICTURE ) ;
}
@NonNull
public BigPictureStyle setBigContentTitle ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mBigContentTitle = Builder . limitCharSequenceLength ( charSequence ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public BigPictureStyle setSummaryText ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mSummaryText = Builder . limitCharSequenceLength ( charSequence ) ;
this . mSummaryTextSet = true ;
return this ;
}
}
public static class BigTextStyle extends Style {
2021-09-21 07:33:49 +00:00
private static final String TEMPLATE_CLASS_NAME = " androidx.core.app.NotificationCompat$BigTextStyle " ;
2021-07-24 02:37:17 +00:00
private CharSequence mBigText ;
public BigTextStyle ( ) {
}
2021-09-21 07:33:49 +00:00
public BigTextStyle ( @Nullable Builder builder ) {
2021-07-24 02:37:17 +00:00
setBuilder ( builder ) ;
}
2021-09-21 07:33:49 +00:00
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void addCompatExtras ( @NonNull Bundle bundle ) {
super . addCompatExtras ( bundle ) ;
}
2021-07-24 02:37:17 +00:00
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void apply ( NotificationBuilderWithBuilderAccessor notificationBuilderWithBuilderAccessor ) {
Notification . BigTextStyle bigText = new Notification . BigTextStyle ( notificationBuilderWithBuilderAccessor . getBuilder ( ) ) . setBigContentTitle ( this . mBigContentTitle ) . bigText ( this . mBigText ) ;
if ( this . mSummaryTextSet ) {
bigText . setSummaryText ( this . mSummaryText ) ;
}
}
2021-09-21 07:33:49 +00:00
@NonNull
public BigTextStyle bigText ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mBigText = Builder . limitCharSequenceLength ( charSequence ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void clearCompatExtraKeys ( @NonNull Bundle bundle ) {
super . clearCompatExtraKeys ( bundle ) ;
bundle . remove ( NotificationCompat . EXTRA_BIG_TEXT ) ;
}
@Override // androidx.core.app.NotificationCompat.Style
@NonNull
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public String getClassName ( ) {
return TEMPLATE_CLASS_NAME ;
}
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void restoreFromCompatExtras ( @NonNull Bundle bundle ) {
super . restoreFromCompatExtras ( bundle ) ;
this . mBigText = bundle . getCharSequence ( NotificationCompat . EXTRA_BIG_TEXT ) ;
}
@NonNull
public BigTextStyle setBigContentTitle ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mBigContentTitle = Builder . limitCharSequenceLength ( charSequence ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public BigTextStyle setSummaryText ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mSummaryText = Builder . limitCharSequenceLength ( charSequence ) ;
this . mSummaryTextSet = true ;
return this ;
}
}
public static final class BubbleMetadata {
private static final int FLAG_AUTO_EXPAND_BUBBLE = 1 ;
private static final int FLAG_SUPPRESS_NOTIFICATION = 2 ;
private PendingIntent mDeleteIntent ;
private int mDesiredHeight ;
@DimenRes
private int mDesiredHeightResId ;
private int mFlags ;
private IconCompat mIcon ;
private PendingIntent mPendingIntent ;
2021-09-21 07:33:49 +00:00
private String mShortcutId ;
@RequiresApi ( 29 )
public static class Api29Impl {
private Api29Impl ( ) {
}
@Nullable
@RequiresApi ( 29 )
public static BubbleMetadata fromPlatform ( @Nullable Notification . BubbleMetadata bubbleMetadata ) {
if ( bubbleMetadata = = null | | bubbleMetadata . getIntent ( ) = = null ) {
return null ;
}
Builder suppressNotification = new Builder ( bubbleMetadata . getIntent ( ) , IconCompat . createFromIcon ( bubbleMetadata . getIcon ( ) ) ) . setAutoExpandBubble ( bubbleMetadata . getAutoExpandBubble ( ) ) . setDeleteIntent ( bubbleMetadata . getDeleteIntent ( ) ) . setSuppressNotification ( bubbleMetadata . isNotificationSuppressed ( ) ) ;
if ( bubbleMetadata . getDesiredHeight ( ) ! = 0 ) {
suppressNotification . setDesiredHeight ( bubbleMetadata . getDesiredHeight ( ) ) ;
}
if ( bubbleMetadata . getDesiredHeightResId ( ) ! = 0 ) {
suppressNotification . setDesiredHeightResId ( bubbleMetadata . getDesiredHeightResId ( ) ) ;
}
return suppressNotification . build ( ) ;
}
@Nullable
@RequiresApi ( 29 )
public static Notification . BubbleMetadata toPlatform ( @Nullable BubbleMetadata bubbleMetadata ) {
if ( bubbleMetadata = = null | | bubbleMetadata . getIntent ( ) = = null ) {
return null ;
}
Notification . BubbleMetadata . Builder suppressNotification = new Notification . BubbleMetadata . Builder ( ) . setIcon ( bubbleMetadata . getIcon ( ) . toIcon ( ) ) . setIntent ( bubbleMetadata . getIntent ( ) ) . setDeleteIntent ( bubbleMetadata . getDeleteIntent ( ) ) . setAutoExpandBubble ( bubbleMetadata . getAutoExpandBubble ( ) ) . setSuppressNotification ( bubbleMetadata . isNotificationSuppressed ( ) ) ;
if ( bubbleMetadata . getDesiredHeight ( ) ! = 0 ) {
suppressNotification . setDesiredHeight ( bubbleMetadata . getDesiredHeight ( ) ) ;
}
if ( bubbleMetadata . getDesiredHeightResId ( ) ! = 0 ) {
suppressNotification . setDesiredHeightResId ( bubbleMetadata . getDesiredHeightResId ( ) ) ;
}
return suppressNotification . build ( ) ;
}
}
@RequiresApi ( 30 )
public static class Api30Impl {
private Api30Impl ( ) {
}
@Nullable
@RequiresApi ( 30 )
public static BubbleMetadata fromPlatform ( @Nullable Notification . BubbleMetadata bubbleMetadata ) {
if ( bubbleMetadata = = null ) {
return null ;
}
Builder builder = bubbleMetadata . getShortcutId ( ) ! = null ? new Builder ( bubbleMetadata . getShortcutId ( ) ) : new Builder ( bubbleMetadata . getIntent ( ) , IconCompat . createFromIcon ( bubbleMetadata . getIcon ( ) ) ) ;
builder . setAutoExpandBubble ( bubbleMetadata . getAutoExpandBubble ( ) ) . setDeleteIntent ( bubbleMetadata . getDeleteIntent ( ) ) . setSuppressNotification ( bubbleMetadata . isNotificationSuppressed ( ) ) ;
if ( bubbleMetadata . getDesiredHeight ( ) ! = 0 ) {
builder . setDesiredHeight ( bubbleMetadata . getDesiredHeight ( ) ) ;
}
if ( bubbleMetadata . getDesiredHeightResId ( ) ! = 0 ) {
builder . setDesiredHeightResId ( bubbleMetadata . getDesiredHeightResId ( ) ) ;
}
return builder . build ( ) ;
}
@Nullable
@RequiresApi ( 30 )
public static Notification . BubbleMetadata toPlatform ( @Nullable BubbleMetadata bubbleMetadata ) {
if ( bubbleMetadata = = null ) {
return null ;
}
Notification . BubbleMetadata . Builder builder = bubbleMetadata . getShortcutId ( ) ! = null ? new Notification . BubbleMetadata . Builder ( bubbleMetadata . getShortcutId ( ) ) : new Notification . BubbleMetadata . Builder ( bubbleMetadata . getIntent ( ) , bubbleMetadata . getIcon ( ) . toIcon ( ) ) ;
builder . setDeleteIntent ( bubbleMetadata . getDeleteIntent ( ) ) . setAutoExpandBubble ( bubbleMetadata . getAutoExpandBubble ( ) ) . setSuppressNotification ( bubbleMetadata . isNotificationSuppressed ( ) ) ;
if ( bubbleMetadata . getDesiredHeight ( ) ! = 0 ) {
builder . setDesiredHeight ( bubbleMetadata . getDesiredHeight ( ) ) ;
}
if ( bubbleMetadata . getDesiredHeightResId ( ) ! = 0 ) {
builder . setDesiredHeightResId ( bubbleMetadata . getDesiredHeightResId ( ) ) ;
}
return builder . build ( ) ;
}
}
2021-07-24 02:37:17 +00:00
public static final class Builder {
private PendingIntent mDeleteIntent ;
private int mDesiredHeight ;
@DimenRes
private int mDesiredHeightResId ;
private int mFlags ;
private IconCompat mIcon ;
private PendingIntent mPendingIntent ;
2021-09-21 07:33:49 +00:00
private String mShortcutId ;
@Deprecated
public Builder ( ) {
}
public Builder ( @NonNull PendingIntent pendingIntent , @NonNull IconCompat iconCompat ) {
Objects . requireNonNull ( pendingIntent , " Bubble requires non-null pending intent " ) ;
Objects . requireNonNull ( iconCompat , " Bubbles require non-null icon " ) ;
this . mPendingIntent = pendingIntent ;
this . mIcon = iconCompat ;
}
2021-07-24 02:37:17 +00:00
2021-09-21 07:33:49 +00:00
@RequiresApi ( 30 )
public Builder ( @NonNull String str ) {
if ( ! TextUtils . isEmpty ( str ) ) {
this . mShortcutId = str ;
return ;
}
throw new NullPointerException ( " Bubble requires a non-null shortcut id " ) ;
}
@NonNull
2021-07-24 02:37:17 +00:00
private Builder setFlag ( int i , boolean z2 ) {
if ( z2 ) {
this . mFlags = i | this . mFlags ;
} else {
this . mFlags = ( ~ i ) & this . mFlags ;
}
return this ;
}
@NonNull
@SuppressLint ( { " SyntheticAccessor " } )
public BubbleMetadata build ( ) {
2021-09-21 07:33:49 +00:00
String str = this . mShortcutId ;
if ( str = = null ) {
Objects . requireNonNull ( this . mPendingIntent , " Must supply pending intent or shortcut to bubble " ) ;
2021-07-24 02:37:17 +00:00
}
2021-09-21 07:33:49 +00:00
if ( str = = null ) {
Objects . requireNonNull ( this . mIcon , " Must supply an icon or shortcut for the bubble " ) ;
}
BubbleMetadata bubbleMetadata = new BubbleMetadata ( this . mPendingIntent , this . mDeleteIntent , this . mIcon , this . mDesiredHeight , this . mDesiredHeightResId , this . mFlags , str ) ;
bubbleMetadata . setFlags ( this . mFlags ) ;
return bubbleMetadata ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public Builder setAutoExpandBubble ( boolean z2 ) {
setFlag ( 1 , z2 ) ;
return this ;
}
@NonNull
public Builder setDeleteIntent ( @Nullable PendingIntent pendingIntent ) {
this . mDeleteIntent = pendingIntent ;
return this ;
}
@NonNull
public Builder setDesiredHeight ( @Dimension ( unit = 0 ) int i ) {
this . mDesiredHeight = Math . max ( i , 0 ) ;
this . mDesiredHeightResId = 0 ;
return this ;
}
@NonNull
public Builder setDesiredHeightResId ( @DimenRes int i ) {
this . mDesiredHeightResId = i ;
this . mDesiredHeight = 0 ;
return this ;
}
@NonNull
public Builder setIcon ( @NonNull IconCompat iconCompat ) {
2021-09-21 07:33:49 +00:00
if ( this . mShortcutId = = null ) {
Objects . requireNonNull ( iconCompat , " Bubbles require non-null icon " ) ;
2021-07-24 02:37:17 +00:00
this . mIcon = iconCompat ;
return this ;
}
2021-09-21 07:33:49 +00:00
throw new IllegalStateException ( " Created as a shortcut bubble, cannot set an Icon. Consider using BubbleMetadata.Builder(PendingIntent,Icon) instead. " ) ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public Builder setIntent ( @NonNull PendingIntent pendingIntent ) {
2021-09-21 07:33:49 +00:00
if ( this . mShortcutId = = null ) {
Objects . requireNonNull ( pendingIntent , " Bubble requires non-null pending intent " ) ;
2021-07-24 02:37:17 +00:00
this . mPendingIntent = pendingIntent ;
return this ;
}
2021-09-21 07:33:49 +00:00
throw new IllegalStateException ( " Created as a shortcut bubble, cannot set a PendingIntent. Consider using BubbleMetadata.Builder(PendingIntent,Icon) instead. " ) ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public Builder setSuppressNotification ( boolean z2 ) {
setFlag ( 2 , z2 ) ;
return this ;
}
}
2021-09-21 07:33:49 +00:00
private BubbleMetadata ( @Nullable PendingIntent pendingIntent , @Nullable PendingIntent pendingIntent2 , @Nullable IconCompat iconCompat , int i , @DimenRes int i2 , int i3 , @Nullable String str ) {
2021-07-24 02:37:17 +00:00
this . mPendingIntent = pendingIntent ;
this . mIcon = iconCompat ;
this . mDesiredHeight = i ;
this . mDesiredHeightResId = i2 ;
this . mDeleteIntent = pendingIntent2 ;
this . mFlags = i3 ;
2021-09-21 07:33:49 +00:00
this . mShortcutId = str ;
2021-07-24 02:37:17 +00:00
}
@Nullable
public static BubbleMetadata fromPlatform ( @Nullable Notification . BubbleMetadata bubbleMetadata ) {
if ( bubbleMetadata = = null ) {
return null ;
}
2021-09-21 07:33:49 +00:00
int i = Build . VERSION . SDK_INT ;
if ( i > = 30 ) {
return Api30Impl . fromPlatform ( bubbleMetadata ) ;
2021-07-24 02:37:17 +00:00
}
2021-09-21 07:33:49 +00:00
if ( i = = 29 ) {
return Api29Impl . fromPlatform ( bubbleMetadata ) ;
2021-07-24 02:37:17 +00:00
}
2021-09-21 07:33:49 +00:00
return null ;
2021-07-24 02:37:17 +00:00
}
@Nullable
public static Notification . BubbleMetadata toPlatform ( @Nullable BubbleMetadata bubbleMetadata ) {
if ( bubbleMetadata = = null ) {
return null ;
}
2021-09-21 07:33:49 +00:00
int i = Build . VERSION . SDK_INT ;
if ( i > = 30 ) {
return Api30Impl . toPlatform ( bubbleMetadata ) ;
2021-07-24 02:37:17 +00:00
}
2021-09-21 07:33:49 +00:00
if ( i = = 29 ) {
return Api29Impl . toPlatform ( bubbleMetadata ) ;
2021-07-24 02:37:17 +00:00
}
2021-09-21 07:33:49 +00:00
return null ;
2021-07-24 02:37:17 +00:00
}
public boolean getAutoExpandBubble ( ) {
return ( this . mFlags & 1 ) ! = 0 ;
}
@Nullable
public PendingIntent getDeleteIntent ( ) {
return this . mDeleteIntent ;
}
@Dimension ( unit = 0 )
public int getDesiredHeight ( ) {
return this . mDesiredHeight ;
}
@DimenRes
public int getDesiredHeightResId ( ) {
return this . mDesiredHeightResId ;
}
2021-09-21 07:33:49 +00:00
@Nullable
@SuppressLint ( { " InvalidNullConversion " } )
2021-07-24 02:37:17 +00:00
public IconCompat getIcon ( ) {
return this . mIcon ;
}
2021-09-21 07:33:49 +00:00
@Nullable
@SuppressLint ( { " InvalidNullConversion " } )
2021-07-24 02:37:17 +00:00
public PendingIntent getIntent ( ) {
return this . mPendingIntent ;
}
2021-09-21 07:33:49 +00:00
@Nullable
public String getShortcutId ( ) {
return this . mShortcutId ;
}
2021-07-24 02:37:17 +00:00
public boolean isNotificationSuppressed ( ) {
return ( this . mFlags & 2 ) ! = 0 ;
}
2021-09-21 07:33:49 +00:00
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void setFlags ( int i ) {
this . mFlags = i ;
}
2021-07-24 02:37:17 +00:00
}
public static class Builder {
private static final int MAX_CHARSEQUENCE_LENGTH = 5120 ;
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public ArrayList < Action > mActions ;
public boolean mAllowSystemGeneratedContextualActions ;
public int mBadgeIcon ;
public RemoteViews mBigContentView ;
public BubbleMetadata mBubbleMetadata ;
public String mCategory ;
public String mChannelId ;
public boolean mChronometerCountDown ;
public int mColor ;
public boolean mColorized ;
public boolean mColorizedSet ;
public CharSequence mContentInfo ;
public PendingIntent mContentIntent ;
public CharSequence mContentText ;
public CharSequence mContentTitle ;
public RemoteViews mContentView ;
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public Context mContext ;
public Bundle mExtras ;
public PendingIntent mFullScreenIntent ;
public int mGroupAlertBehavior ;
public String mGroupKey ;
public boolean mGroupSummary ;
public RemoteViews mHeadsUpContentView ;
public ArrayList < Action > mInvisibleActions ;
public Bitmap mLargeIcon ;
public boolean mLocalOnly ;
2021-09-21 07:33:49 +00:00
public LocusIdCompat mLocusId ;
2021-07-24 02:37:17 +00:00
public Notification mNotification ;
public int mNumber ;
@Deprecated
public ArrayList < String > mPeople ;
2021-09-21 07:33:49 +00:00
@NonNull
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public ArrayList < Person > mPersonList ;
2021-07-24 02:37:17 +00:00
public int mPriority ;
public int mProgress ;
public boolean mProgressIndeterminate ;
public int mProgressMax ;
public Notification mPublicVersion ;
public CharSequence [ ] mRemoteInputHistory ;
2021-09-21 07:33:49 +00:00
public CharSequence mSettingsText ;
2021-07-24 02:37:17 +00:00
public String mShortcutId ;
public boolean mShowWhen ;
public boolean mSilent ;
2021-09-21 07:33:49 +00:00
public Icon mSmallIcon ;
2021-07-24 02:37:17 +00:00
public String mSortKey ;
public Style mStyle ;
public CharSequence mSubText ;
public RemoteViews mTickerView ;
public long mTimeout ;
public boolean mUseChronometer ;
public int mVisibility ;
@Deprecated
2021-09-21 07:33:49 +00:00
public Builder ( @NonNull Context context ) {
this ( context , ( String ) null ) ;
}
@RequiresApi ( 19 )
public Builder ( @NonNull Context context , @NonNull Notification notification ) {
this ( context , NotificationCompat . getChannelId ( notification ) ) ;
ArrayList parcelableArrayList ;
Bundle bundle = notification . extras ;
Style extractStyleFromNotification = Style . extractStyleFromNotification ( notification ) ;
setContentTitle ( NotificationCompat . getContentTitle ( notification ) ) . setContentText ( NotificationCompat . getContentText ( notification ) ) . setContentInfo ( NotificationCompat . getContentInfo ( notification ) ) . setSubText ( NotificationCompat . getSubText ( notification ) ) . setSettingsText ( NotificationCompat . getSettingsText ( notification ) ) . setStyle ( extractStyleFromNotification ) . setContentIntent ( notification . contentIntent ) . setGroup ( NotificationCompat . getGroup ( notification ) ) . setGroupSummary ( NotificationCompat . isGroupSummary ( notification ) ) . setLocusId ( NotificationCompat . getLocusId ( notification ) ) . setWhen ( notification . when ) . setShowWhen ( NotificationCompat . getShowWhen ( notification ) ) . setUsesChronometer ( NotificationCompat . getUsesChronometer ( notification ) ) . setAutoCancel ( NotificationCompat . getAutoCancel ( notification ) ) . setOnlyAlertOnce ( NotificationCompat . getOnlyAlertOnce ( notification ) ) . setOngoing ( NotificationCompat . getOngoing ( notification ) ) . setLocalOnly ( NotificationCompat . getLocalOnly ( notification ) ) . setLargeIcon ( notification . largeIcon ) . setBadgeIconType ( NotificationCompat . getBadgeIconType ( notification ) ) . setCategory ( NotificationCompat . getCategory ( notification ) ) . setBubbleMetadata ( NotificationCompat . getBubbleMetadata ( notification ) ) . setNumber ( notification . number ) . setTicker ( notification . tickerText ) . setContentIntent ( notification . contentIntent ) . setDeleteIntent ( notification . deleteIntent ) . setFullScreenIntent ( notification . fullScreenIntent , NotificationCompat . getHighPriority ( notification ) ) . setSound ( notification . sound , notification . audioStreamType ) . setVibrate ( notification . vibrate ) . setLights ( notification . ledARGB , notification . ledOnMS , notification . ledOffMS ) . setDefaults ( notification . defaults ) . setPriority ( notification . priority ) . setColor ( NotificationCompat . getColor ( notification ) ) . setVisibility ( NotificationCompat . getVisibility ( notification ) ) . setPublicVersion ( NotificationCompat . getPublicVersion ( notification ) ) . setSortKey ( NotificationCompat . getSortKey ( notification ) ) . setTimeoutAfter ( NotificationCompat . getTimeoutAfter ( notification ) ) . setShortcutId ( NotificationCompat . getShortcutId ( notification ) ) . setProgress ( bundle . getInt ( NotificationCompat . EXTRA_PROGRESS_MAX ) , bundle . getInt ( NotificationCompat . EXTRA_PROGRESS ) , bundle . getBoolean ( NotificationCompat . EXTRA_PROGRESS_INDETERMINATE ) ) . setAllowSystemGeneratedContextualActions ( NotificationCompat . getAllowSystemGeneratedContextualActions ( notification ) ) . setSmallIcon ( notification . icon , notification . iconLevel ) . addExtras ( getExtrasWithoutDuplicateData ( notification , extractStyleFromNotification ) ) ;
if ( Build . VERSION . SDK_INT > = 23 ) {
this . mSmallIcon = notification . getSmallIcon ( ) ;
}
Notification . Action [ ] actionArr = notification . actions ;
if ( ! ( actionArr = = null | | actionArr . length = = 0 ) ) {
for ( Notification . Action action : actionArr ) {
addAction ( Action . Builder . fromAndroidAction ( action ) . build ( ) ) ;
}
}
List < Action > invisibleActions = NotificationCompat . getInvisibleActions ( notification ) ;
if ( ! invisibleActions . isEmpty ( ) ) {
for ( Action action2 : invisibleActions ) {
addInvisibleAction ( action2 ) ;
}
}
String [ ] stringArray = notification . extras . getStringArray ( NotificationCompat . EXTRA_PEOPLE ) ;
if ( ! ( stringArray = = null | | stringArray . length = = 0 ) ) {
for ( String str : stringArray ) {
addPerson ( str ) ;
}
}
if ( Build . VERSION . SDK_INT > = 28 & & ( parcelableArrayList = notification . extras . getParcelableArrayList ( NotificationCompat . EXTRA_PEOPLE_LIST ) ) ! = null & & ! parcelableArrayList . isEmpty ( ) ) {
Iterator it = parcelableArrayList . iterator ( ) ;
while ( it . hasNext ( ) ) {
addPerson ( Person . fromAndroidPerson ( ( Person ) it . next ( ) ) ) ;
}
}
int i = Build . VERSION . SDK_INT ;
if ( i > = 24 & & bundle . containsKey ( NotificationCompat . EXTRA_CHRONOMETER_COUNT_DOWN ) ) {
setChronometerCountDown ( bundle . getBoolean ( NotificationCompat . EXTRA_CHRONOMETER_COUNT_DOWN ) ) ;
}
if ( i > = 26 & & bundle . containsKey ( NotificationCompat . EXTRA_COLORIZED ) ) {
setColorized ( bundle . getBoolean ( NotificationCompat . EXTRA_COLORIZED ) ) ;
}
2021-07-24 02:37:17 +00:00
}
public Builder ( @NonNull Context context , @NonNull String str ) {
this . mActions = new ArrayList < > ( ) ;
2021-09-21 07:33:49 +00:00
this . mPersonList = new ArrayList < > ( ) ;
2021-07-24 02:37:17 +00:00
this . mInvisibleActions = new ArrayList < > ( ) ;
this . mShowWhen = true ;
this . mLocalOnly = false ;
this . mColor = 0 ;
this . mVisibility = 0 ;
this . mBadgeIcon = 0 ;
this . mGroupAlertBehavior = 0 ;
Notification notification = new Notification ( ) ;
this . mNotification = notification ;
this . mContext = context ;
this . mChannelId = str ;
notification . when = System . currentTimeMillis ( ) ;
this . mNotification . audioStreamType = - 1 ;
this . mPriority = 0 ;
this . mPeople = new ArrayList < > ( ) ;
this . mAllowSystemGeneratedContextualActions = true ;
}
2021-09-21 07:33:49 +00:00
@Nullable
@RequiresApi ( 19 )
private static Bundle getExtrasWithoutDuplicateData ( @NonNull Notification notification , @Nullable Style style ) {
if ( notification . extras = = null ) {
return null ;
}
Bundle bundle = new Bundle ( notification . extras ) ;
bundle . remove ( NotificationCompat . EXTRA_TITLE ) ;
bundle . remove ( NotificationCompat . EXTRA_TEXT ) ;
bundle . remove ( NotificationCompat . EXTRA_INFO_TEXT ) ;
bundle . remove ( NotificationCompat . EXTRA_SUB_TEXT ) ;
bundle . remove ( NotificationCompat . EXTRA_CHANNEL_ID ) ;
bundle . remove ( NotificationCompat . EXTRA_CHANNEL_GROUP_ID ) ;
bundle . remove ( NotificationCompat . EXTRA_SHOW_WHEN ) ;
bundle . remove ( NotificationCompat . EXTRA_PROGRESS ) ;
bundle . remove ( NotificationCompat . EXTRA_PROGRESS_MAX ) ;
bundle . remove ( NotificationCompat . EXTRA_PROGRESS_INDETERMINATE ) ;
bundle . remove ( NotificationCompat . EXTRA_CHRONOMETER_COUNT_DOWN ) ;
bundle . remove ( NotificationCompat . EXTRA_COLORIZED ) ;
bundle . remove ( NotificationCompat . EXTRA_PEOPLE_LIST ) ;
bundle . remove ( NotificationCompat . EXTRA_PEOPLE ) ;
bundle . remove ( NotificationCompatExtras . EXTRA_SORT_KEY ) ;
bundle . remove ( NotificationCompatExtras . EXTRA_GROUP_KEY ) ;
bundle . remove ( NotificationCompatExtras . EXTRA_GROUP_SUMMARY ) ;
bundle . remove ( NotificationCompatExtras . EXTRA_LOCAL_ONLY ) ;
bundle . remove ( NotificationCompatExtras . EXTRA_ACTION_EXTRAS ) ;
Bundle bundle2 = bundle . getBundle ( CarExtender . EXTRA_CAR_EXTENDER ) ;
if ( bundle2 ! = null ) {
Bundle bundle3 = new Bundle ( bundle2 ) ;
bundle3 . remove ( CarExtender . EXTRA_INVISIBLE_ACTIONS ) ;
bundle . putBundle ( CarExtender . EXTRA_CAR_EXTENDER , bundle3 ) ;
}
if ( style ! = null ) {
style . clearCompatExtraKeys ( bundle ) ;
}
return bundle ;
}
@Nullable
public static CharSequence limitCharSequenceLength ( @Nullable CharSequence charSequence ) {
2021-08-09 22:50:52 +00:00
return ( charSequence ! = null & & charSequence . length ( ) > MAX_CHARSEQUENCE_LENGTH ) ? charSequence . subSequence ( 0 , MAX_CHARSEQUENCE_LENGTH ) : charSequence ;
2021-07-24 02:37:17 +00:00
}
2021-09-21 07:33:49 +00:00
@Nullable
private Bitmap reduceLargeIconSize ( @Nullable Bitmap bitmap ) {
2021-07-24 02:37:17 +00:00
if ( bitmap = = null | | Build . VERSION . SDK_INT > = 27 ) {
return bitmap ;
}
Resources resources = this . mContext . getResources ( ) ;
int dimensionPixelSize = resources . getDimensionPixelSize ( R . dimen . compat_notification_large_icon_max_width ) ;
int dimensionPixelSize2 = resources . getDimensionPixelSize ( R . dimen . compat_notification_large_icon_max_height ) ;
if ( bitmap . getWidth ( ) < = dimensionPixelSize & & bitmap . getHeight ( ) < = dimensionPixelSize2 ) {
return bitmap ;
}
double min = Math . min ( ( ( double ) dimensionPixelSize ) / ( ( double ) Math . max ( 1 , bitmap . getWidth ( ) ) ) , ( ( double ) dimensionPixelSize2 ) / ( ( double ) Math . max ( 1 , bitmap . getHeight ( ) ) ) ) ;
return Bitmap . createScaledBitmap ( bitmap , ( int ) Math . ceil ( ( ( double ) bitmap . getWidth ( ) ) * min ) , ( int ) Math . ceil ( ( ( double ) bitmap . getHeight ( ) ) * min ) , true ) ;
}
private void setFlag ( int i , boolean z2 ) {
if ( z2 ) {
Notification notification = this . mNotification ;
notification . flags = i | notification . flags ;
return ;
}
Notification notification2 = this . mNotification ;
notification2 . flags = ( ~ i ) & notification2 . flags ;
}
2021-09-21 07:33:49 +00:00
private boolean useExistingRemoteView ( ) {
Style style = this . mStyle ;
return style = = null | | ! style . displayCustomViewInline ( ) ;
}
@NonNull
public Builder addAction ( int i , @Nullable CharSequence charSequence , @Nullable PendingIntent pendingIntent ) {
2021-07-24 02:37:17 +00:00
this . mActions . add ( new Action ( i , charSequence , pendingIntent ) ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder addAction ( @Nullable Action action ) {
if ( action ! = null ) {
this . mActions . add ( action ) ;
}
2021-07-24 02:37:17 +00:00
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder addExtras ( @Nullable Bundle bundle ) {
2021-07-24 02:37:17 +00:00
if ( bundle ! = null ) {
Bundle bundle2 = this . mExtras ;
if ( bundle2 = = null ) {
this . mExtras = new Bundle ( bundle ) ;
} else {
bundle2 . putAll ( bundle ) ;
}
}
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@RequiresApi ( 21 )
2021-09-21 07:33:49 +00:00
public Builder addInvisibleAction ( int i , @Nullable CharSequence charSequence , @Nullable PendingIntent pendingIntent ) {
this . mInvisibleActions . add ( new Action ( i , charSequence , pendingIntent ) ) ;
return this ;
2021-07-24 02:37:17 +00:00
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@RequiresApi ( 21 )
2021-09-21 07:33:49 +00:00
public Builder addInvisibleAction ( @Nullable Action action ) {
if ( action ! = null ) {
this . mInvisibleActions . add ( action ) ;
}
return this ;
}
@NonNull
public Builder addPerson ( @Nullable Person person ) {
if ( person ! = null ) {
this . mPersonList . add ( person ) ;
}
2021-07-24 02:37:17 +00:00
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
@Deprecated
public Builder addPerson ( @Nullable String str ) {
if ( str ! = null & & ! str . isEmpty ( ) ) {
this . mPeople . add ( str ) ;
}
2021-07-24 02:37:17 +00:00
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Notification build ( ) {
return new NotificationCompatBuilder ( this ) . build ( ) ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder clearActions ( ) {
this . mActions . clear ( ) ;
return this ;
}
@NonNull
public Builder clearInvisibleActions ( ) {
this . mInvisibleActions . clear ( ) ;
Bundle bundle = this . mExtras . getBundle ( CarExtender . EXTRA_CAR_EXTENDER ) ;
if ( bundle ! = null ) {
Bundle bundle2 = new Bundle ( bundle ) ;
bundle2 . remove ( CarExtender . EXTRA_INVISIBLE_ACTIONS ) ;
this . mExtras . putBundle ( CarExtender . EXTRA_CAR_EXTENDER , bundle2 ) ;
}
return this ;
}
@NonNull
public Builder clearPeople ( ) {
this . mPersonList . clear ( ) ;
this . mPeople . clear ( ) ;
return this ;
}
@Nullable
@SuppressLint ( { " BuilderSetStyle " } )
public RemoteViews createBigContentView ( ) {
RemoteViews makeBigContentView ;
int i = Build . VERSION . SDK_INT ;
if ( this . mBigContentView ! = null & & useExistingRemoteView ( ) ) {
return this . mBigContentView ;
}
NotificationCompatBuilder notificationCompatBuilder = new NotificationCompatBuilder ( this ) ;
Style style = this . mStyle ;
if ( style ! = null & & ( makeBigContentView = style . makeBigContentView ( notificationCompatBuilder ) ) ! = null ) {
return makeBigContentView ;
}
Notification build = notificationCompatBuilder . build ( ) ;
return i > = 24 ? Notification . Builder . recoverBuilder ( this . mContext , build ) . createBigContentView ( ) : build . bigContentView ;
}
@Nullable
@SuppressLint ( { " BuilderSetStyle " } )
public RemoteViews createContentView ( ) {
RemoteViews makeContentView ;
if ( this . mContentView ! = null & & useExistingRemoteView ( ) ) {
return this . mContentView ;
}
NotificationCompatBuilder notificationCompatBuilder = new NotificationCompatBuilder ( this ) ;
Style style = this . mStyle ;
if ( style ! = null & & ( makeContentView = style . makeContentView ( notificationCompatBuilder ) ) ! = null ) {
return makeContentView ;
}
Notification build = notificationCompatBuilder . build ( ) ;
return Build . VERSION . SDK_INT > = 24 ? Notification . Builder . recoverBuilder ( this . mContext , build ) . createContentView ( ) : build . contentView ;
}
@Nullable
@SuppressLint ( { " BuilderSetStyle " } )
public RemoteViews createHeadsUpContentView ( ) {
RemoteViews makeHeadsUpContentView ;
int i = Build . VERSION . SDK_INT ;
if ( this . mHeadsUpContentView ! = null & & useExistingRemoteView ( ) ) {
return this . mHeadsUpContentView ;
}
NotificationCompatBuilder notificationCompatBuilder = new NotificationCompatBuilder ( this ) ;
Style style = this . mStyle ;
if ( style ! = null & & ( makeHeadsUpContentView = style . makeHeadsUpContentView ( notificationCompatBuilder ) ) ! = null ) {
return makeHeadsUpContentView ;
}
Notification build = notificationCompatBuilder . build ( ) ;
return i > = 24 ? Notification . Builder . recoverBuilder ( this . mContext , build ) . createHeadsUpContentView ( ) : build . headsUpContentView ;
}
@NonNull
public Builder extend ( @NonNull Extender extender ) {
2021-07-24 02:37:17 +00:00
extender . extend ( this ) ;
return this ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public RemoteViews getBigContentView ( ) {
return this . mBigContentView ;
}
@Nullable
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public BubbleMetadata getBubbleMetadata ( ) {
return this . mBubbleMetadata ;
}
2021-09-21 07:33:49 +00:00
@ColorInt
2021-07-24 02:37:17 +00:00
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public int getColor ( ) {
return this . mColor ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public RemoteViews getContentView ( ) {
return this . mContentView ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Bundle getExtras ( ) {
if ( this . mExtras = = null ) {
this . mExtras = new Bundle ( ) ;
}
return this . mExtras ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public RemoteViews getHeadsUpContentView ( ) {
return this . mHeadsUpContentView ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public Notification getNotification ( ) {
return build ( ) ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public int getPriority ( ) {
return this . mPriority ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public long getWhenIfShowing ( ) {
if ( this . mShowWhen ) {
return this . mNotification . when ;
}
return 0 ;
}
@NonNull
public Builder setAllowSystemGeneratedContextualActions ( boolean z2 ) {
this . mAllowSystemGeneratedContextualActions = z2 ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setAutoCancel ( boolean z2 ) {
setFlag ( 16 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setBadgeIconType ( int i ) {
this . mBadgeIcon = i ;
return this ;
}
@NonNull
public Builder setBubbleMetadata ( @Nullable BubbleMetadata bubbleMetadata ) {
this . mBubbleMetadata = bubbleMetadata ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setCategory ( @Nullable String str ) {
2021-07-24 02:37:17 +00:00
this . mCategory = str ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setChannelId ( @NonNull String str ) {
this . mChannelId = str ;
return this ;
}
@NonNull
@RequiresApi ( 24 )
public Builder setChronometerCountDown ( boolean z2 ) {
this . mChronometerCountDown = z2 ;
2021-09-21 07:33:49 +00:00
getExtras ( ) . putBoolean ( NotificationCompat . EXTRA_CHRONOMETER_COUNT_DOWN , z2 ) ;
2021-07-24 02:37:17 +00:00
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setColor ( @ColorInt int i ) {
this . mColor = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setColorized ( boolean z2 ) {
this . mColorized = z2 ;
this . mColorizedSet = true ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setContent ( @Nullable RemoteViews remoteViews ) {
2021-07-24 02:37:17 +00:00
this . mNotification . contentView = remoteViews ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setContentInfo ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mContentInfo = limitCharSequenceLength ( charSequence ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setContentIntent ( @Nullable PendingIntent pendingIntent ) {
2021-07-24 02:37:17 +00:00
this . mContentIntent = pendingIntent ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setContentText ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mContentText = limitCharSequenceLength ( charSequence ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setContentTitle ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mContentTitle = limitCharSequenceLength ( charSequence ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setCustomBigContentView ( @Nullable RemoteViews remoteViews ) {
2021-07-24 02:37:17 +00:00
this . mBigContentView = remoteViews ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setCustomContentView ( @Nullable RemoteViews remoteViews ) {
2021-07-24 02:37:17 +00:00
this . mContentView = remoteViews ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setCustomHeadsUpContentView ( @Nullable RemoteViews remoteViews ) {
2021-07-24 02:37:17 +00:00
this . mHeadsUpContentView = remoteViews ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setDefaults ( int i ) {
Notification notification = this . mNotification ;
notification . defaults = i ;
if ( ( i & 4 ) ! = 0 ) {
notification . flags | = 1 ;
}
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setDeleteIntent ( @Nullable PendingIntent pendingIntent ) {
2021-07-24 02:37:17 +00:00
this . mNotification . deleteIntent = pendingIntent ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setExtras ( @Nullable Bundle bundle ) {
2021-07-24 02:37:17 +00:00
this . mExtras = bundle ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setFullScreenIntent ( @Nullable PendingIntent pendingIntent , boolean z2 ) {
2021-07-24 02:37:17 +00:00
this . mFullScreenIntent = pendingIntent ;
setFlag ( 128 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setGroup ( @Nullable String str ) {
2021-07-24 02:37:17 +00:00
this . mGroupKey = str ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setGroupAlertBehavior ( int i ) {
this . mGroupAlertBehavior = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setGroupSummary ( boolean z2 ) {
this . mGroupSummary = z2 ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setLargeIcon ( @Nullable Bitmap bitmap ) {
2021-07-24 02:37:17 +00:00
this . mLargeIcon = reduceLargeIconSize ( bitmap ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setLights ( @ColorInt int i , int i2 , int i3 ) {
Notification notification = this . mNotification ;
notification . ledARGB = i ;
notification . ledOnMS = i2 ;
notification . ledOffMS = i3 ;
notification . flags = ( ( i2 = = 0 | | i3 = = 0 ) ? 0 : 1 ) | ( notification . flags & - 2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setLocalOnly ( boolean z2 ) {
this . mLocalOnly = z2 ;
return this ;
}
@NonNull
2021-09-21 07:33:49 +00:00
public Builder setLocusId ( @Nullable LocusIdCompat locusIdCompat ) {
this . mLocusId = locusIdCompat ;
return this ;
}
@NonNull
@Deprecated
2021-07-24 02:37:17 +00:00
public Builder setNotificationSilent ( ) {
this . mSilent = true ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setNumber ( int i ) {
this . mNumber = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setOngoing ( boolean z2 ) {
setFlag ( 2 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setOnlyAlertOnce ( boolean z2 ) {
setFlag ( 8 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setPriority ( int i ) {
this . mPriority = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setProgress ( int i , int i2 , boolean z2 ) {
this . mProgressMax = i ;
this . mProgress = i2 ;
this . mProgressIndeterminate = z2 ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setPublicVersion ( @Nullable Notification notification ) {
2021-07-24 02:37:17 +00:00
this . mPublicVersion = notification ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setRemoteInputHistory ( @Nullable CharSequence [ ] charSequenceArr ) {
2021-07-24 02:37:17 +00:00
this . mRemoteInputHistory = charSequenceArr ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setSettingsText ( @Nullable CharSequence charSequence ) {
this . mSettingsText = limitCharSequenceLength ( charSequence ) ;
return this ;
}
@NonNull
public Builder setShortcutId ( @Nullable String str ) {
2021-07-24 02:37:17 +00:00
this . mShortcutId = str ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setShortcutInfo ( @Nullable ShortcutInfoCompat shortcutInfoCompat ) {
if ( shortcutInfoCompat = = null ) {
return this ;
}
this . mShortcutId = shortcutInfoCompat . getId ( ) ;
if ( this . mLocusId = = null ) {
if ( shortcutInfoCompat . getLocusId ( ) ! = null ) {
this . mLocusId = shortcutInfoCompat . getLocusId ( ) ;
} else if ( shortcutInfoCompat . getId ( ) ! = null ) {
this . mLocusId = new LocusIdCompat ( shortcutInfoCompat . getId ( ) ) ;
}
}
if ( this . mContentTitle = = null ) {
setContentTitle ( shortcutInfoCompat . getShortLabel ( ) ) ;
}
return this ;
}
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setShowWhen ( boolean z2 ) {
this . mShowWhen = z2 ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setSilent ( boolean z2 ) {
this . mSilent = z2 ;
return this ;
}
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setSmallIcon ( int i ) {
this . mNotification . icon = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setSmallIcon ( int i , int i2 ) {
Notification notification = this . mNotification ;
notification . icon = i ;
notification . iconLevel = i2 ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
@RequiresApi ( 23 )
public Builder setSmallIcon ( @NonNull IconCompat iconCompat ) {
this . mSmallIcon = iconCompat . toIcon ( this . mContext ) ;
return this ;
}
@NonNull
public Builder setSortKey ( @Nullable String str ) {
2021-07-24 02:37:17 +00:00
this . mSortKey = str ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setSound ( @Nullable Uri uri ) {
2021-07-24 02:37:17 +00:00
Notification notification = this . mNotification ;
notification . sound = uri ;
notification . audioStreamType = - 1 ;
notification . audioAttributes = new AudioAttributes . Builder ( ) . setContentType ( 4 ) . setUsage ( 5 ) . build ( ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setSound ( @Nullable Uri uri , int i ) {
2021-07-24 02:37:17 +00:00
Notification notification = this . mNotification ;
notification . sound = uri ;
notification . audioStreamType = i ;
notification . audioAttributes = new AudioAttributes . Builder ( ) . setContentType ( 4 ) . setLegacyStreamType ( i ) . build ( ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setStyle ( @Nullable Style style ) {
2021-07-24 02:37:17 +00:00
if ( this . mStyle ! = style ) {
this . mStyle = style ;
if ( style ! = null ) {
style . setBuilder ( this ) ;
}
}
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setSubText ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mSubText = limitCharSequenceLength ( charSequence ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setTicker ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mNotification . tickerText = limitCharSequenceLength ( charSequence ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
@Deprecated
public Builder setTicker ( @Nullable CharSequence charSequence , @Nullable RemoteViews remoteViews ) {
2021-07-24 02:37:17 +00:00
this . mNotification . tickerText = limitCharSequenceLength ( charSequence ) ;
this . mTickerView = remoteViews ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setTimeoutAfter ( long j ) {
this . mTimeout = j ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setUsesChronometer ( boolean z2 ) {
this . mUseChronometer = z2 ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setVibrate ( @Nullable long [ ] jArr ) {
2021-07-24 02:37:17 +00:00
this . mNotification . vibrate = jArr ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setVisibility ( int i ) {
this . mVisibility = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setWhen ( long j ) {
this . mNotification . when = j ;
return this ;
}
}
public static final class CarExtender implements Extender {
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public static final String EXTRA_CAR_EXTENDER = " android.car.EXTENSIONS " ;
private static final String EXTRA_COLOR = " app_color " ;
private static final String EXTRA_CONVERSATION = " car_conversation " ;
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public static final String EXTRA_INVISIBLE_ACTIONS = " invisible_actions " ;
private static final String EXTRA_LARGE_ICON = " large_icon " ;
private static final String KEY_AUTHOR = " author " ;
private static final String KEY_MESSAGES = " messages " ;
private static final String KEY_ON_READ = " on_read " ;
private static final String KEY_ON_REPLY = " on_reply " ;
private static final String KEY_PARTICIPANTS = " participants " ;
private static final String KEY_REMOTE_INPUT = " remote_input " ;
private static final String KEY_TEXT = " text " ;
private static final String KEY_TIMESTAMP = " timestamp " ;
private int mColor = 0 ;
private Bitmap mLargeIcon ;
private UnreadConversation mUnreadConversation ;
@Deprecated
public static class UnreadConversation {
private final long mLatestTimestamp ;
private final String [ ] mMessages ;
private final String [ ] mParticipants ;
private final PendingIntent mReadPendingIntent ;
private final RemoteInput mRemoteInput ;
private final PendingIntent mReplyPendingIntent ;
public static class Builder {
private long mLatestTimestamp ;
private final List < String > mMessages = new ArrayList ( ) ;
private final String mParticipant ;
private PendingIntent mReadPendingIntent ;
private RemoteInput mRemoteInput ;
private PendingIntent mReplyPendingIntent ;
2021-09-21 07:33:49 +00:00
public Builder ( @NonNull String str ) {
2021-07-24 02:37:17 +00:00
this . mParticipant = str ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder addMessage ( @Nullable String str ) {
if ( str ! = null ) {
this . mMessages . add ( str ) ;
}
2021-07-24 02:37:17 +00:00
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public UnreadConversation build ( ) {
List < String > list = this . mMessages ;
return new UnreadConversation ( ( String [ ] ) list . toArray ( new String [ list . size ( ) ] ) , this . mRemoteInput , this . mReplyPendingIntent , this . mReadPendingIntent , new String [ ] { this . mParticipant } , this . mLatestTimestamp ) ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Builder setLatestTimestamp ( long j ) {
this . mLatestTimestamp = j ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setReadPendingIntent ( @Nullable PendingIntent pendingIntent ) {
2021-07-24 02:37:17 +00:00
this . mReadPendingIntent = pendingIntent ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Builder setReplyAction ( @Nullable PendingIntent pendingIntent , @Nullable RemoteInput remoteInput ) {
2021-07-24 02:37:17 +00:00
this . mRemoteInput = remoteInput ;
this . mReplyPendingIntent = pendingIntent ;
return this ;
}
}
2021-09-21 07:33:49 +00:00
public UnreadConversation ( @Nullable String [ ] strArr , @Nullable RemoteInput remoteInput , @Nullable PendingIntent pendingIntent , @Nullable PendingIntent pendingIntent2 , @Nullable String [ ] strArr2 , long j ) {
2021-07-24 02:37:17 +00:00
this . mMessages = strArr ;
this . mRemoteInput = remoteInput ;
this . mReadPendingIntent = pendingIntent2 ;
this . mReplyPendingIntent = pendingIntent ;
this . mParticipants = strArr2 ;
this . mLatestTimestamp = j ;
}
public long getLatestTimestamp ( ) {
return this . mLatestTimestamp ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public String [ ] getMessages ( ) {
return this . mMessages ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public String getParticipant ( ) {
String [ ] strArr = this . mParticipants ;
if ( strArr . length > 0 ) {
return strArr [ 0 ] ;
}
return null ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public String [ ] getParticipants ( ) {
return this . mParticipants ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public PendingIntent getReadPendingIntent ( ) {
return this . mReadPendingIntent ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public RemoteInput getRemoteInput ( ) {
return this . mRemoteInput ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public PendingIntent getReplyPendingIntent ( ) {
return this . mReplyPendingIntent ;
}
}
public CarExtender ( ) {
}
2021-09-21 07:33:49 +00:00
public CarExtender ( @NonNull Notification notification ) {
2021-08-09 22:50:52 +00:00
Bundle bundle = NotificationCompat . getExtras ( notification ) = = null ? null : NotificationCompat . getExtras ( notification ) . getBundle ( EXTRA_CAR_EXTENDER ) ;
2021-07-24 02:37:17 +00:00
if ( bundle ! = null ) {
2021-08-09 22:50:52 +00:00
this . mLargeIcon = ( Bitmap ) bundle . getParcelable ( EXTRA_LARGE_ICON ) ;
this . mColor = bundle . getInt ( EXTRA_COLOR , 0 ) ;
this . mUnreadConversation = getUnreadConversationFromBundle ( bundle . getBundle ( EXTRA_CONVERSATION ) ) ;
2021-07-24 02:37:17 +00:00
}
}
@RequiresApi ( 21 )
private static Bundle getBundleForUnreadConversation ( @NonNull UnreadConversation unreadConversation ) {
Bundle bundle = new Bundle ( ) ;
String str = ( unreadConversation . getParticipants ( ) = = null | | unreadConversation . getParticipants ( ) . length < = 1 ) ? null : unreadConversation . getParticipants ( ) [ 0 ] ;
int length = unreadConversation . getMessages ( ) . length ;
Parcelable [ ] parcelableArr = new Parcelable [ length ] ;
for ( int i = 0 ; i < length ; i + + ) {
Bundle bundle2 = new Bundle ( ) ;
bundle2 . putString ( " text " , unreadConversation . getMessages ( ) [ i ] ) ;
2021-08-09 22:50:52 +00:00
bundle2 . putString ( KEY_AUTHOR , str ) ;
2021-07-24 02:37:17 +00:00
parcelableArr [ i ] = bundle2 ;
}
2021-08-09 22:50:52 +00:00
bundle . putParcelableArray ( KEY_MESSAGES , parcelableArr ) ;
2021-07-24 02:37:17 +00:00
RemoteInput remoteInput = unreadConversation . getRemoteInput ( ) ;
if ( remoteInput ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putParcelable ( KEY_REMOTE_INPUT , new RemoteInput . Builder ( remoteInput . getResultKey ( ) ) . setLabel ( remoteInput . getLabel ( ) ) . setChoices ( remoteInput . getChoices ( ) ) . setAllowFreeFormInput ( remoteInput . getAllowFreeFormInput ( ) ) . addExtras ( remoteInput . getExtras ( ) ) . build ( ) ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:50:52 +00:00
bundle . putParcelable ( KEY_ON_REPLY , unreadConversation . getReplyPendingIntent ( ) ) ;
bundle . putParcelable ( KEY_ON_READ , unreadConversation . getReadPendingIntent ( ) ) ;
bundle . putStringArray ( KEY_PARTICIPANTS , unreadConversation . getParticipants ( ) ) ;
bundle . putLong ( KEY_TIMESTAMP , unreadConversation . getLatestTimestamp ( ) ) ;
2021-07-24 02:37:17 +00:00
return bundle ;
}
@RequiresApi ( 21 )
private static UnreadConversation getUnreadConversationFromBundle ( @Nullable Bundle bundle ) {
String [ ] strArr ;
boolean z2 ;
RemoteInput remoteInput = null ;
if ( bundle = = null ) {
return null ;
}
2021-08-09 22:50:52 +00:00
Parcelable [ ] parcelableArray = bundle . getParcelableArray ( KEY_MESSAGES ) ;
2021-07-24 02:37:17 +00:00
if ( parcelableArray ! = null ) {
int length = parcelableArray . length ;
String [ ] strArr2 = new String [ length ] ;
int i = 0 ;
while ( true ) {
if ( i > = length ) {
z2 = true ;
break ;
} else if ( ! ( parcelableArray [ i ] instanceof Bundle ) ) {
break ;
} else {
strArr2 [ i ] = ( ( Bundle ) parcelableArray [ i ] ) . getString ( " text " ) ;
if ( strArr2 [ i ] = = null ) {
break ;
}
i + + ;
}
}
z2 = false ;
if ( ! z2 ) {
return null ;
}
strArr = strArr2 ;
} else {
strArr = null ;
}
2021-08-09 22:50:52 +00:00
PendingIntent pendingIntent = ( PendingIntent ) bundle . getParcelable ( KEY_ON_READ ) ;
PendingIntent pendingIntent2 = ( PendingIntent ) bundle . getParcelable ( KEY_ON_REPLY ) ;
RemoteInput remoteInput2 = ( RemoteInput ) bundle . getParcelable ( KEY_REMOTE_INPUT ) ;
String [ ] stringArray = bundle . getStringArray ( KEY_PARTICIPANTS ) ;
2021-07-24 02:37:17 +00:00
if ( stringArray = = null | | stringArray . length ! = 1 ) {
return null ;
}
if ( remoteInput2 ! = null ) {
remoteInput = new RemoteInput ( remoteInput2 . getResultKey ( ) , remoteInput2 . getLabel ( ) , remoteInput2 . getChoices ( ) , remoteInput2 . getAllowFreeFormInput ( ) , Build . VERSION . SDK_INT > = 29 ? remoteInput2 . getEditChoicesBeforeSending ( ) : 0 , remoteInput2 . getExtras ( ) , null ) ;
}
2021-08-09 22:50:52 +00:00
return new UnreadConversation ( strArr , remoteInput , pendingIntent2 , pendingIntent , stringArray , bundle . getLong ( KEY_TIMESTAMP ) ) ;
2021-07-24 02:37:17 +00:00
}
@Override // androidx.core.app.NotificationCompat.Extender
2021-09-21 07:33:49 +00:00
@NonNull
public Builder extend ( @NonNull Builder builder ) {
2021-07-24 02:37:17 +00:00
Bundle bundle = new Bundle ( ) ;
Bitmap bitmap = this . mLargeIcon ;
if ( bitmap ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putParcelable ( EXTRA_LARGE_ICON , bitmap ) ;
2021-07-24 02:37:17 +00:00
}
int i = this . mColor ;
if ( i ! = 0 ) {
2021-08-09 22:50:52 +00:00
bundle . putInt ( EXTRA_COLOR , i ) ;
2021-07-24 02:37:17 +00:00
}
UnreadConversation unreadConversation = this . mUnreadConversation ;
if ( unreadConversation ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putBundle ( EXTRA_CONVERSATION , getBundleForUnreadConversation ( unreadConversation ) ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:50:52 +00:00
builder . getExtras ( ) . putBundle ( EXTRA_CAR_EXTENDER , bundle ) ;
2021-07-24 02:37:17 +00:00
return builder ;
}
@ColorInt
public int getColor ( ) {
return this . mColor ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public Bitmap getLargeIcon ( ) {
return this . mLargeIcon ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
@Deprecated
public UnreadConversation getUnreadConversation ( ) {
return this . mUnreadConversation ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public CarExtender setColor ( @ColorInt int i ) {
this . mColor = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public CarExtender setLargeIcon ( @Nullable Bitmap bitmap ) {
2021-07-24 02:37:17 +00:00
this . mLargeIcon = bitmap ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
2021-09-21 07:33:49 +00:00
public CarExtender setUnreadConversation ( @Nullable UnreadConversation unreadConversation ) {
2021-07-24 02:37:17 +00:00
this . mUnreadConversation = unreadConversation ;
return this ;
}
}
public static class DecoratedCustomViewStyle extends Style {
private static final int MAX_ACTION_BUTTONS = 3 ;
2021-09-21 07:33:49 +00:00
private static final String TEMPLATE_CLASS_NAME = " androidx.core.app.NotificationCompat$DecoratedCustomViewStyle " ;
2021-07-24 02:37:17 +00:00
private RemoteViews createRemoteViews ( RemoteViews remoteViews , boolean z2 ) {
int min ;
boolean z3 = true ;
int i = 0 ;
RemoteViews applyStandardTemplate = applyStandardTemplate ( true , R . layout . notification_template_custom_big , false ) ;
applyStandardTemplate . removeAllViews ( R . id . actions ) ;
List < Action > nonContextualActions = getNonContextualActions ( this . mBuilder . mActions ) ;
if ( ! z2 | | nonContextualActions = = null | | ( min = Math . min ( nonContextualActions . size ( ) , 3 ) ) < = 0 ) {
z3 = false ;
} else {
for ( int i2 = 0 ; i2 < min ; i2 + + ) {
applyStandardTemplate . addView ( R . id . actions , generateActionButton ( nonContextualActions . get ( i2 ) ) ) ;
}
}
if ( ! z3 ) {
i = 8 ;
}
applyStandardTemplate . setViewVisibility ( R . id . actions , i ) ;
applyStandardTemplate . setViewVisibility ( R . id . action_divider , i ) ;
buildIntoRemoteViews ( applyStandardTemplate , remoteViews ) ;
return applyStandardTemplate ;
}
private RemoteViews generateActionButton ( Action action ) {
boolean z2 = action . actionIntent = = null ;
RemoteViews remoteViews = new RemoteViews ( this . mBuilder . mContext . getPackageName ( ) , z2 ? R . layout . notification_action_tombstone : R . layout . notification_action ) ;
2021-09-21 07:33:49 +00:00
IconCompat iconCompat = action . getIconCompat ( ) ;
if ( iconCompat ! = null ) {
remoteViews . setImageViewBitmap ( R . id . action_image , createColoredBitmap ( iconCompat , this . mBuilder . mContext . getResources ( ) . getColor ( R . color . notification_action_color_filter ) ) ) ;
}
2021-07-24 02:37:17 +00:00
remoteViews . setTextViewText ( R . id . action_text , action . title ) ;
if ( ! z2 ) {
remoteViews . setOnClickPendingIntent ( R . id . action_container , action . actionIntent ) ;
}
remoteViews . setContentDescription ( R . id . action_container , action . title ) ;
return remoteViews ;
}
private static List < Action > getNonContextualActions ( List < Action > list ) {
if ( list = = null ) {
return null ;
}
ArrayList arrayList = new ArrayList ( ) ;
for ( Action action : list ) {
if ( ! action . isContextual ( ) ) {
arrayList . add ( action ) ;
}
}
return arrayList ;
}
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void apply ( NotificationBuilderWithBuilderAccessor notificationBuilderWithBuilderAccessor ) {
if ( Build . VERSION . SDK_INT > = 24 ) {
notificationBuilderWithBuilderAccessor . getBuilder ( ) . setStyle ( new Notification . DecoratedCustomViewStyle ( ) ) ;
}
}
2021-09-21 07:33:49 +00:00
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public boolean displayCustomViewInline ( ) {
return true ;
}
@Override // androidx.core.app.NotificationCompat.Style
@NonNull
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public String getClassName ( ) {
return TEMPLATE_CLASS_NAME ;
}
2021-07-24 02:37:17 +00:00
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public RemoteViews makeBigContentView ( NotificationBuilderWithBuilderAccessor notificationBuilderWithBuilderAccessor ) {
if ( Build . VERSION . SDK_INT > = 24 ) {
return null ;
}
RemoteViews bigContentView = this . mBuilder . getBigContentView ( ) ;
if ( bigContentView = = null ) {
bigContentView = this . mBuilder . getContentView ( ) ;
}
if ( bigContentView = = null ) {
return null ;
}
return createRemoteViews ( bigContentView , true ) ;
}
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public RemoteViews makeContentView ( NotificationBuilderWithBuilderAccessor notificationBuilderWithBuilderAccessor ) {
if ( Build . VERSION . SDK_INT < 24 & & this . mBuilder . getContentView ( ) ! = null ) {
return createRemoteViews ( this . mBuilder . getContentView ( ) , false ) ;
}
return null ;
}
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public RemoteViews makeHeadsUpContentView ( NotificationBuilderWithBuilderAccessor notificationBuilderWithBuilderAccessor ) {
if ( Build . VERSION . SDK_INT > = 24 ) {
return null ;
}
RemoteViews headsUpContentView = this . mBuilder . getHeadsUpContentView ( ) ;
RemoteViews contentView = headsUpContentView ! = null ? headsUpContentView : this . mBuilder . getContentView ( ) ;
if ( headsUpContentView = = null ) {
return null ;
}
return createRemoteViews ( contentView , true ) ;
}
}
public interface Extender {
2021-09-21 07:33:49 +00:00
@NonNull
Builder extend ( @NonNull Builder builder ) ;
2021-07-24 02:37:17 +00:00
}
@Retention ( RetentionPolicy . SOURCE )
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public @interface GroupAlertBehavior {
}
public static class InboxStyle extends Style {
2021-09-21 07:33:49 +00:00
private static final String TEMPLATE_CLASS_NAME = " androidx.core.app.NotificationCompat$InboxStyle " ;
2021-07-24 02:37:17 +00:00
private ArrayList < CharSequence > mTexts = new ArrayList < > ( ) ;
public InboxStyle ( ) {
}
2021-09-21 07:33:49 +00:00
public InboxStyle ( @Nullable Builder builder ) {
2021-07-24 02:37:17 +00:00
setBuilder ( builder ) ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public InboxStyle addLine ( @Nullable CharSequence charSequence ) {
if ( charSequence ! = null ) {
this . mTexts . add ( Builder . limitCharSequenceLength ( charSequence ) ) ;
}
2021-07-24 02:37:17 +00:00
return this ;
}
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void apply ( NotificationBuilderWithBuilderAccessor notificationBuilderWithBuilderAccessor ) {
Notification . InboxStyle bigContentTitle = new Notification . InboxStyle ( notificationBuilderWithBuilderAccessor . getBuilder ( ) ) . setBigContentTitle ( this . mBigContentTitle ) ;
if ( this . mSummaryTextSet ) {
bigContentTitle . setSummaryText ( this . mSummaryText ) ;
}
Iterator < CharSequence > it = this . mTexts . iterator ( ) ;
while ( it . hasNext ( ) ) {
bigContentTitle . addLine ( it . next ( ) ) ;
}
}
2021-09-21 07:33:49 +00:00
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void clearCompatExtraKeys ( @NonNull Bundle bundle ) {
super . clearCompatExtraKeys ( bundle ) ;
bundle . remove ( NotificationCompat . EXTRA_TEXT_LINES ) ;
}
@Override // androidx.core.app.NotificationCompat.Style
@NonNull
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public String getClassName ( ) {
return TEMPLATE_CLASS_NAME ;
}
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void restoreFromCompatExtras ( @NonNull Bundle bundle ) {
super . restoreFromCompatExtras ( bundle ) ;
this . mTexts . clear ( ) ;
if ( bundle . containsKey ( NotificationCompat . EXTRA_TEXT_LINES ) ) {
Collections . addAll ( this . mTexts , bundle . getCharSequenceArray ( NotificationCompat . EXTRA_TEXT_LINES ) ) ;
}
}
@NonNull
public InboxStyle setBigContentTitle ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mBigContentTitle = Builder . limitCharSequenceLength ( charSequence ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public InboxStyle setSummaryText ( @Nullable CharSequence charSequence ) {
2021-07-24 02:37:17 +00:00
this . mSummaryText = Builder . limitCharSequenceLength ( charSequence ) ;
this . mSummaryTextSet = true ;
return this ;
}
}
public static class MessagingStyle extends Style {
public static final int MAXIMUM_RETAINED_MESSAGES = 25 ;
2021-09-21 07:33:49 +00:00
private static final String TEMPLATE_CLASS_NAME = " androidx.core.app.NotificationCompat$MessagingStyle " ;
2021-07-24 02:37:17 +00:00
@Nullable
private CharSequence mConversationTitle ;
2021-09-21 07:33:49 +00:00
private final List < Message > mHistoricMessages = new ArrayList ( ) ;
2021-07-24 02:37:17 +00:00
@Nullable
private Boolean mIsGroupConversation ;
private final List < Message > mMessages = new ArrayList ( ) ;
private Person mUser ;
public static final class Message {
public static final String KEY_DATA_MIME_TYPE = " type " ;
public static final String KEY_DATA_URI = " uri " ;
public static final String KEY_EXTRAS_BUNDLE = " extras " ;
public static final String KEY_NOTIFICATION_PERSON = " sender_person " ;
public static final String KEY_PERSON = " person " ;
public static final String KEY_SENDER = " sender " ;
public static final String KEY_TEXT = " text " ;
public static final String KEY_TIMESTAMP = " time " ;
@Nullable
private String mDataMimeType ;
@Nullable
private Uri mDataUri ;
private Bundle mExtras ;
@Nullable
private final Person mPerson ;
private final CharSequence mText ;
private final long mTimestamp ;
2021-09-21 07:33:49 +00:00
public Message ( @Nullable CharSequence charSequence , long j , @Nullable Person person ) {
2021-07-24 02:37:17 +00:00
this . mExtras = new Bundle ( ) ;
this . mText = charSequence ;
this . mTimestamp = j ;
this . mPerson = person ;
}
@Deprecated
2021-09-21 07:33:49 +00:00
public Message ( @Nullable CharSequence charSequence , long j , @Nullable CharSequence charSequence2 ) {
2021-07-24 02:37:17 +00:00
this ( charSequence , j , new Person . Builder ( ) . setName ( charSequence2 ) . build ( ) ) ;
}
@NonNull
2021-09-21 07:33:49 +00:00
public static Bundle [ ] getBundleArrayForMessages ( @NonNull List < Message > list ) {
2021-07-24 02:37:17 +00:00
Bundle [ ] bundleArr = new Bundle [ list . size ( ) ] ;
int size = list . size ( ) ;
for ( int i = 0 ; i < size ; i + + ) {
bundleArr [ i ] = list . get ( i ) . toBundle ( ) ;
}
return bundleArr ;
}
@Nullable
2021-09-21 07:33:49 +00:00
public static Message getMessageFromBundle ( @NonNull Bundle bundle ) {
2021-07-24 02:37:17 +00:00
try {
2021-08-09 22:50:52 +00:00
if ( bundle . containsKey ( KEY_TEXT ) ) {
2021-07-24 02:37:17 +00:00
if ( bundle . containsKey ( " time " ) ) {
2021-08-09 22:50:52 +00:00
Message message = new Message ( bundle . getCharSequence ( KEY_TEXT ) , bundle . getLong ( " time " ) , bundle . containsKey ( KEY_PERSON ) ? Person . fromBundle ( bundle . getBundle ( KEY_PERSON ) ) : ( ! bundle . containsKey ( KEY_NOTIFICATION_PERSON ) | | Build . VERSION . SDK_INT < 28 ) ? bundle . containsKey ( KEY_SENDER ) ? new Person . Builder ( ) . setName ( bundle . getCharSequence ( KEY_SENDER ) ) . build ( ) : null : Person . fromAndroidPerson ( ( android . app . Person ) bundle . getParcelable ( KEY_NOTIFICATION_PERSON ) ) ) ;
if ( bundle . containsKey ( " type " ) & & bundle . containsKey ( KEY_DATA_URI ) ) {
message . setData ( bundle . getString ( " type " ) , ( Uri ) bundle . getParcelable ( KEY_DATA_URI ) ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:50:52 +00:00
if ( bundle . containsKey ( KEY_EXTRAS_BUNDLE ) ) {
message . getExtras ( ) . putAll ( bundle . getBundle ( KEY_EXTRAS_BUNDLE ) ) ;
2021-07-24 02:37:17 +00:00
}
return message ;
}
}
} catch ( ClassCastException unused ) {
}
return null ;
}
@NonNull
2021-09-21 07:33:49 +00:00
public static List < Message > getMessagesFromBundleArray ( @NonNull Parcelable [ ] parcelableArr ) {
2021-07-24 02:37:17 +00:00
Message messageFromBundle ;
ArrayList arrayList = new ArrayList ( parcelableArr . length ) ;
for ( int i = 0 ; i < parcelableArr . length ; i + + ) {
if ( ( parcelableArr [ i ] instanceof Bundle ) & & ( messageFromBundle = getMessageFromBundle ( ( Bundle ) parcelableArr [ i ] ) ) ! = null ) {
arrayList . add ( messageFromBundle ) ;
}
}
return arrayList ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
private Bundle toBundle ( ) {
Bundle bundle = new Bundle ( ) ;
CharSequence charSequence = this . mText ;
if ( charSequence ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putCharSequence ( KEY_TEXT , charSequence ) ;
2021-07-24 02:37:17 +00:00
}
bundle . putLong ( " time " , this . mTimestamp ) ;
Person person = this . mPerson ;
if ( person ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putCharSequence ( KEY_SENDER , person . getName ( ) ) ;
2021-07-24 02:37:17 +00:00
if ( Build . VERSION . SDK_INT > = 28 ) {
2021-08-09 22:50:52 +00:00
bundle . putParcelable ( KEY_NOTIFICATION_PERSON , this . mPerson . toAndroidPerson ( ) ) ;
2021-07-24 02:37:17 +00:00
} else {
2021-08-09 22:50:52 +00:00
bundle . putBundle ( KEY_PERSON , this . mPerson . toBundle ( ) ) ;
2021-07-24 02:37:17 +00:00
}
}
String str = this . mDataMimeType ;
if ( str ! = null ) {
bundle . putString ( " type " , str ) ;
}
Uri uri = this . mDataUri ;
if ( uri ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putParcelable ( KEY_DATA_URI , uri ) ;
2021-07-24 02:37:17 +00:00
}
Bundle bundle2 = this . mExtras ;
if ( bundle2 ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putBundle ( KEY_EXTRAS_BUNDLE , bundle2 ) ;
2021-07-24 02:37:17 +00:00
}
return bundle ;
}
@Nullable
public String getDataMimeType ( ) {
return this . mDataMimeType ;
}
@Nullable
public Uri getDataUri ( ) {
return this . mDataUri ;
}
@NonNull
public Bundle getExtras ( ) {
return this . mExtras ;
}
@Nullable
public Person getPerson ( ) {
return this . mPerson ;
}
@Nullable
@Deprecated
public CharSequence getSender ( ) {
Person person = this . mPerson ;
if ( person = = null ) {
return null ;
}
return person . getName ( ) ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public CharSequence getText ( ) {
return this . mText ;
}
public long getTimestamp ( ) {
return this . mTimestamp ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public Message setData ( @Nullable String str , @Nullable Uri uri ) {
2021-07-24 02:37:17 +00:00
this . mDataMimeType = str ;
this . mDataUri = uri ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
@RequiresApi ( 24 )
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public Notification . MessagingStyle . Message toAndroidMessage ( ) {
Notification . MessagingStyle . Message message ;
Person person = getPerson ( ) ;
CharSequence charSequence = null ;
android . app . Person person2 = null ;
if ( Build . VERSION . SDK_INT > = 28 ) {
CharSequence text = getText ( ) ;
long timestamp = getTimestamp ( ) ;
if ( person ! = null ) {
person2 = person . toAndroidPerson ( ) ;
}
message = new Notification . MessagingStyle . Message ( text , timestamp , person2 ) ;
} else {
CharSequence text2 = getText ( ) ;
long timestamp2 = getTimestamp ( ) ;
if ( person ! = null ) {
charSequence = person . getName ( ) ;
}
message = new Notification . MessagingStyle . Message ( text2 , timestamp2 , charSequence ) ;
}
if ( getDataMimeType ( ) ! = null ) {
message . setData ( getDataMimeType ( ) , getDataUri ( ) ) ;
}
return message ;
}
2021-07-24 02:37:17 +00:00
}
2021-09-21 07:33:49 +00:00
public MessagingStyle ( ) {
2021-07-24 02:37:17 +00:00
}
public MessagingStyle ( @NonNull Person person ) {
if ( ! TextUtils . isEmpty ( person . getName ( ) ) ) {
this . mUser = person ;
return ;
}
throw new IllegalArgumentException ( " User's name must not be empty. " ) ;
}
@Deprecated
public MessagingStyle ( @NonNull CharSequence charSequence ) {
this . mUser = new Person . Builder ( ) . setName ( charSequence ) . build ( ) ;
}
@Nullable
2021-09-21 07:33:49 +00:00
public static MessagingStyle extractMessagingStyleFromNotification ( @NonNull Notification notification ) {
Style extractStyleFromNotification = Style . extractStyleFromNotification ( notification ) ;
if ( extractStyleFromNotification instanceof MessagingStyle ) {
return ( MessagingStyle ) extractStyleFromNotification ;
2021-07-24 02:37:17 +00:00
}
2021-09-21 07:33:49 +00:00
return null ;
2021-07-24 02:37:17 +00:00
}
@Nullable
private Message findLatestIncomingMessage ( ) {
int size = this . mMessages . size ( ) ;
while ( true ) {
size - - ;
if ( size > = 0 ) {
Message message = this . mMessages . get ( size ) ;
if ( message . getPerson ( ) ! = null & & ! TextUtils . isEmpty ( message . getPerson ( ) . getName ( ) ) ) {
return message ;
}
} else if ( this . mMessages . isEmpty ( ) ) {
return null ;
} else {
List < Message > list = this . mMessages ;
return list . get ( list . size ( ) - 1 ) ;
}
}
}
private boolean hasMessagesWithoutSender ( ) {
for ( int size = this . mMessages . size ( ) - 1 ; size > = 0 ; size - - ) {
Message message = this . mMessages . get ( size ) ;
if ( message . getPerson ( ) ! = null & & message . getPerson ( ) . getName ( ) = = null ) {
return true ;
}
}
return false ;
}
@NonNull
private TextAppearanceSpan makeFontColorSpan ( int i ) {
return new TextAppearanceSpan ( null , 0 , 0 , ColorStateList . valueOf ( i ) , null ) ;
}
2021-09-21 07:33:49 +00:00
private CharSequence makeMessageLine ( @NonNull Message message ) {
2021-07-24 02:37:17 +00:00
BidiFormatter instance = BidiFormatter . getInstance ( ) ;
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder ( ) ;
2021-08-09 22:50:52 +00:00
int i = 1 ! = 0 ? ViewCompat . MEASURED_STATE_MASK : - 1 ;
2021-07-24 02:37:17 +00:00
CharSequence charSequence = " " ;
CharSequence name = message . getPerson ( ) = = null ? charSequence : message . getPerson ( ) . getName ( ) ;
if ( TextUtils . isEmpty ( name ) ) {
name = this . mUser . getName ( ) ;
if ( ! ( 1 = = 0 | | this . mBuilder . getColor ( ) = = 0 ) ) {
i = this . mBuilder . getColor ( ) ;
}
}
CharSequence unicodeWrap = instance . unicodeWrap ( name ) ;
spannableStringBuilder . append ( unicodeWrap ) ;
spannableStringBuilder . setSpan ( makeFontColorSpan ( i ) , spannableStringBuilder . length ( ) - unicodeWrap . length ( ) , spannableStringBuilder . length ( ) , 33 ) ;
if ( message . getText ( ) ! = null ) {
charSequence = message . getText ( ) ;
}
spannableStringBuilder . append ( ( CharSequence ) " " ) . append ( instance . unicodeWrap ( charSequence ) ) ;
return spannableStringBuilder ;
}
@Override // androidx.core.app.NotificationCompat.Style
2021-09-21 07:33:49 +00:00
public void addCompatExtras ( @NonNull Bundle bundle ) {
2021-07-24 02:37:17 +00:00
super . addCompatExtras ( bundle ) ;
2021-08-09 22:50:52 +00:00
bundle . putCharSequence ( NotificationCompat . EXTRA_SELF_DISPLAY_NAME , this . mUser . getName ( ) ) ;
bundle . putBundle ( NotificationCompat . EXTRA_MESSAGING_STYLE_USER , this . mUser . toBundle ( ) ) ;
bundle . putCharSequence ( NotificationCompat . EXTRA_HIDDEN_CONVERSATION_TITLE , this . mConversationTitle ) ;
2021-07-24 02:37:17 +00:00
if ( this . mConversationTitle ! = null & & this . mIsGroupConversation . booleanValue ( ) ) {
2021-08-09 22:50:52 +00:00
bundle . putCharSequence ( NotificationCompat . EXTRA_CONVERSATION_TITLE , this . mConversationTitle ) ;
2021-07-24 02:37:17 +00:00
}
if ( ! this . mMessages . isEmpty ( ) ) {
2021-08-09 22:50:52 +00:00
bundle . putParcelableArray ( NotificationCompat . EXTRA_MESSAGES , Message . getBundleArrayForMessages ( this . mMessages ) ) ;
2021-07-24 02:37:17 +00:00
}
2021-09-21 07:33:49 +00:00
if ( ! this . mHistoricMessages . isEmpty ( ) ) {
bundle . putParcelableArray ( NotificationCompat . EXTRA_HISTORIC_MESSAGES , Message . getBundleArrayForMessages ( this . mHistoricMessages ) ) ;
}
2021-07-24 02:37:17 +00:00
Boolean bool = this . mIsGroupConversation ;
if ( bool ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putBoolean ( NotificationCompat . EXTRA_IS_GROUP_CONVERSATION , bool . booleanValue ( ) ) ;
2021-07-24 02:37:17 +00:00
}
}
2021-09-21 07:33:49 +00:00
@NonNull
public MessagingStyle addHistoricMessage ( @Nullable Message message ) {
if ( message ! = null ) {
this . mHistoricMessages . add ( message ) ;
if ( this . mHistoricMessages . size ( ) > 25 ) {
this . mHistoricMessages . remove ( 0 ) ;
}
2021-07-24 02:37:17 +00:00
}
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public MessagingStyle addMessage ( @Nullable Message message ) {
if ( message ! = null ) {
this . mMessages . add ( message ) ;
if ( this . mMessages . size ( ) > 25 ) {
this . mMessages . remove ( 0 ) ;
}
}
return this ;
}
@NonNull
public MessagingStyle addMessage ( @Nullable CharSequence charSequence , long j , @Nullable Person person ) {
2021-07-24 02:37:17 +00:00
addMessage ( new Message ( charSequence , j , person ) ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
2021-09-21 07:33:49 +00:00
public MessagingStyle addMessage ( @Nullable CharSequence charSequence , long j , @Nullable CharSequence charSequence2 ) {
2021-07-24 02:37:17 +00:00
this . mMessages . add ( new Message ( charSequence , j , new Person . Builder ( ) . setName ( charSequence2 ) . build ( ) ) ) ;
if ( this . mMessages . size ( ) > 25 ) {
this . mMessages . remove ( 0 ) ;
}
return this ;
}
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void apply ( NotificationBuilderWithBuilderAccessor notificationBuilderWithBuilderAccessor ) {
setGroupConversation ( isGroupConversation ( ) ) ;
int i = Build . VERSION . SDK_INT ;
if ( i > = 24 ) {
Notification . MessagingStyle messagingStyle = i > = 28 ? new Notification . MessagingStyle ( this . mUser . toAndroidPerson ( ) ) : new Notification . MessagingStyle ( this . mUser . getName ( ) ) ;
2021-09-21 07:33:49 +00:00
for ( Message message : this . mMessages ) {
messagingStyle . addMessage ( message . toAndroidMessage ( ) ) ;
}
if ( Build . VERSION . SDK_INT > = 26 ) {
for ( Message message2 : this . mHistoricMessages ) {
messagingStyle . addHistoricMessage ( message2 . toAndroidMessage ( ) ) ;
}
}
if ( this . mIsGroupConversation . booleanValue ( ) | | Build . VERSION . SDK_INT > = 28 ) {
2021-07-24 02:37:17 +00:00
messagingStyle . setConversationTitle ( this . mConversationTitle ) ;
}
2021-09-21 07:33:49 +00:00
if ( Build . VERSION . SDK_INT > = 28 ) {
2021-07-24 02:37:17 +00:00
messagingStyle . setGroupConversation ( this . mIsGroupConversation . booleanValue ( ) ) ;
}
messagingStyle . setBuilder ( notificationBuilderWithBuilderAccessor . getBuilder ( ) ) ;
return ;
}
Message findLatestIncomingMessage = findLatestIncomingMessage ( ) ;
if ( this . mConversationTitle ! = null & & this . mIsGroupConversation . booleanValue ( ) ) {
notificationBuilderWithBuilderAccessor . getBuilder ( ) . setContentTitle ( this . mConversationTitle ) ;
} else if ( findLatestIncomingMessage ! = null ) {
notificationBuilderWithBuilderAccessor . getBuilder ( ) . setContentTitle ( " " ) ;
if ( findLatestIncomingMessage . getPerson ( ) ! = null ) {
notificationBuilderWithBuilderAccessor . getBuilder ( ) . setContentTitle ( findLatestIncomingMessage . getPerson ( ) . getName ( ) ) ;
}
}
if ( findLatestIncomingMessage ! = null ) {
notificationBuilderWithBuilderAccessor . getBuilder ( ) . setContentText ( this . mConversationTitle ! = null ? makeMessageLine ( findLatestIncomingMessage ) : findLatestIncomingMessage . getText ( ) ) ;
}
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder ( ) ;
boolean z2 = this . mConversationTitle ! = null | | hasMessagesWithoutSender ( ) ;
for ( int size = this . mMessages . size ( ) - 1 ; size > = 0 ; size - - ) {
Message message3 = this . mMessages . get ( size ) ;
CharSequence makeMessageLine = z2 ? makeMessageLine ( message3 ) : message3 . getText ( ) ;
if ( size ! = this . mMessages . size ( ) - 1 ) {
spannableStringBuilder . insert ( 0 , ( CharSequence ) " \ n " ) ;
}
spannableStringBuilder . insert ( 0 , makeMessageLine ) ;
}
new Notification . BigTextStyle ( notificationBuilderWithBuilderAccessor . getBuilder ( ) ) . setBigContentTitle ( null ) . bigText ( spannableStringBuilder ) ;
}
2021-09-21 07:33:49 +00:00
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void clearCompatExtraKeys ( @NonNull Bundle bundle ) {
super . clearCompatExtraKeys ( bundle ) ;
bundle . remove ( NotificationCompat . EXTRA_MESSAGING_STYLE_USER ) ;
bundle . remove ( NotificationCompat . EXTRA_SELF_DISPLAY_NAME ) ;
bundle . remove ( NotificationCompat . EXTRA_CONVERSATION_TITLE ) ;
bundle . remove ( NotificationCompat . EXTRA_HIDDEN_CONVERSATION_TITLE ) ;
bundle . remove ( NotificationCompat . EXTRA_MESSAGES ) ;
bundle . remove ( NotificationCompat . EXTRA_HISTORIC_MESSAGES ) ;
bundle . remove ( NotificationCompat . EXTRA_IS_GROUP_CONVERSATION ) ;
}
@Override // androidx.core.app.NotificationCompat.Style
@NonNull
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public String getClassName ( ) {
return TEMPLATE_CLASS_NAME ;
}
2021-07-24 02:37:17 +00:00
@Nullable
public CharSequence getConversationTitle ( ) {
return this . mConversationTitle ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public List < Message > getHistoricMessages ( ) {
return this . mHistoricMessages ;
}
@NonNull
2021-07-24 02:37:17 +00:00
public List < Message > getMessages ( ) {
return this . mMessages ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public Person getUser ( ) {
return this . mUser ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
@Deprecated
public CharSequence getUserDisplayName ( ) {
return this . mUser . getName ( ) ;
}
public boolean isGroupConversation ( ) {
Builder builder = this . mBuilder ;
if ( builder ! = null & & builder . mContext . getApplicationInfo ( ) . targetSdkVersion < 28 & & this . mIsGroupConversation = = null ) {
return this . mConversationTitle ! = null ;
}
Boolean bool = this . mIsGroupConversation ;
if ( bool ! = null ) {
return bool . booleanValue ( ) ;
}
return false ;
}
@Override // androidx.core.app.NotificationCompat.Style
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
2021-09-21 07:33:49 +00:00
public void restoreFromCompatExtras ( @NonNull Bundle bundle ) {
super . restoreFromCompatExtras ( bundle ) ;
2021-07-24 02:37:17 +00:00
this . mMessages . clear ( ) ;
2021-08-09 22:50:52 +00:00
if ( bundle . containsKey ( NotificationCompat . EXTRA_MESSAGING_STYLE_USER ) ) {
this . mUser = Person . fromBundle ( bundle . getBundle ( NotificationCompat . EXTRA_MESSAGING_STYLE_USER ) ) ;
2021-07-24 02:37:17 +00:00
} else {
2021-08-09 22:50:52 +00:00
this . mUser = new Person . Builder ( ) . setName ( bundle . getString ( NotificationCompat . EXTRA_SELF_DISPLAY_NAME ) ) . build ( ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:50:52 +00:00
CharSequence charSequence = bundle . getCharSequence ( NotificationCompat . EXTRA_CONVERSATION_TITLE ) ;
2021-07-24 02:37:17 +00:00
this . mConversationTitle = charSequence ;
if ( charSequence = = null ) {
2021-08-09 22:50:52 +00:00
this . mConversationTitle = bundle . getCharSequence ( NotificationCompat . EXTRA_HIDDEN_CONVERSATION_TITLE ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:50:52 +00:00
Parcelable [ ] parcelableArray = bundle . getParcelableArray ( NotificationCompat . EXTRA_MESSAGES ) ;
2021-07-24 02:37:17 +00:00
if ( parcelableArray ! = null ) {
this . mMessages . addAll ( Message . getMessagesFromBundleArray ( parcelableArray ) ) ;
}
2021-09-21 07:33:49 +00:00
Parcelable [ ] parcelableArray2 = bundle . getParcelableArray ( NotificationCompat . EXTRA_HISTORIC_MESSAGES ) ;
if ( parcelableArray2 ! = null ) {
this . mHistoricMessages . addAll ( Message . getMessagesFromBundleArray ( parcelableArray2 ) ) ;
}
2021-08-09 22:50:52 +00:00
if ( bundle . containsKey ( NotificationCompat . EXTRA_IS_GROUP_CONVERSATION ) ) {
this . mIsGroupConversation = Boolean . valueOf ( bundle . getBoolean ( NotificationCompat . EXTRA_IS_GROUP_CONVERSATION ) ) ;
2021-07-24 02:37:17 +00:00
}
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public MessagingStyle setConversationTitle ( @Nullable CharSequence charSequence ) {
this . mConversationTitle = charSequence ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public MessagingStyle setGroupConversation ( boolean z2 ) {
this . mIsGroupConversation = Boolean . valueOf ( z2 ) ;
return this ;
}
}
@Retention ( RetentionPolicy . SOURCE )
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public @interface NotificationVisibility {
}
@Retention ( RetentionPolicy . SOURCE )
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public @interface StreamType {
}
public static abstract class Style {
public CharSequence mBigContentTitle ;
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public Builder mBuilder ;
public CharSequence mSummaryText ;
public boolean mSummaryTextSet = false ;
private int calculateTopPadding ( ) {
Resources resources = this . mBuilder . mContext . getResources ( ) ;
int dimensionPixelSize = resources . getDimensionPixelSize ( R . dimen . notification_top_pad ) ;
int dimensionPixelSize2 = resources . getDimensionPixelSize ( R . dimen . notification_top_pad_large_text ) ;
float constrain = ( constrain ( resources . getConfiguration ( ) . fontScale , 1 . 0f , 1 . 3f ) - 1 . 0f ) / 0 . 29999995f ;
return Math . round ( ( constrain * ( ( float ) dimensionPixelSize2 ) ) + ( ( 1 . 0f - constrain ) * ( ( float ) dimensionPixelSize ) ) ) ;
}
private static float constrain ( float f , float f2 , float f3 ) {
return f < f2 ? f2 : f > f3 ? f3 : f ;
}
2021-09-21 07:33:49 +00:00
@Nullable
public static Style constructCompatStyleByName ( @Nullable String str ) {
if ( str = = null ) {
return null ;
}
char c2 = 65535 ;
switch ( str . hashCode ( ) ) {
case - 716705180 :
if ( str . equals ( " androidx.core.app.NotificationCompat$DecoratedCustomViewStyle " ) ) {
c2 = 0 ;
break ;
}
break ;
case - 171946061 :
if ( str . equals ( " androidx.core.app.NotificationCompat$BigPictureStyle " ) ) {
c2 = 1 ;
break ;
}
break ;
case 912942987 :
if ( str . equals ( " androidx.core.app.NotificationCompat$InboxStyle " ) ) {
c2 = 2 ;
break ;
}
break ;
case 919595044 :
if ( str . equals ( " androidx.core.app.NotificationCompat$BigTextStyle " ) ) {
c2 = 3 ;
break ;
}
break ;
case 2090799565 :
if ( str . equals ( " androidx.core.app.NotificationCompat$MessagingStyle " ) ) {
c2 = 4 ;
break ;
}
break ;
}
switch ( c2 ) {
case 0 :
return new DecoratedCustomViewStyle ( ) ;
case 1 :
return new BigPictureStyle ( ) ;
case 2 :
return new InboxStyle ( ) ;
case 3 :
return new BigTextStyle ( ) ;
case 4 :
return new MessagingStyle ( ) ;
default :
return null ;
}
}
@Nullable
private static Style constructCompatStyleByPlatformName ( @Nullable String str ) {
if ( str = = null ) {
return null ;
}
int i = Build . VERSION . SDK_INT ;
if ( str . equals ( Notification . BigPictureStyle . class . getName ( ) ) ) {
return new BigPictureStyle ( ) ;
}
if ( str . equals ( Notification . BigTextStyle . class . getName ( ) ) ) {
return new BigTextStyle ( ) ;
}
if ( str . equals ( Notification . InboxStyle . class . getName ( ) ) ) {
return new InboxStyle ( ) ;
}
if ( i > = 24 ) {
if ( str . equals ( Notification . MessagingStyle . class . getName ( ) ) ) {
return new MessagingStyle ( ) ;
}
if ( str . equals ( Notification . DecoratedCustomViewStyle . class . getName ( ) ) ) {
return new DecoratedCustomViewStyle ( ) ;
}
}
return null ;
}
@Nullable
public static Style constructCompatStyleForBundle ( @NonNull Bundle bundle ) {
Style constructCompatStyleByName = constructCompatStyleByName ( bundle . getString ( NotificationCompat . EXTRA_COMPAT_TEMPLATE ) ) ;
return constructCompatStyleByName ! = null ? constructCompatStyleByName : ( bundle . containsKey ( NotificationCompat . EXTRA_SELF_DISPLAY_NAME ) | | bundle . containsKey ( NotificationCompat . EXTRA_MESSAGING_STYLE_USER ) ) ? new MessagingStyle ( ) : bundle . containsKey ( NotificationCompat . EXTRA_PICTURE ) ? new BigPictureStyle ( ) : bundle . containsKey ( NotificationCompat . EXTRA_BIG_TEXT ) ? new BigTextStyle ( ) : bundle . containsKey ( NotificationCompat . EXTRA_TEXT_LINES ) ? new InboxStyle ( ) : constructCompatStyleByPlatformName ( bundle . getString ( NotificationCompat . EXTRA_TEMPLATE ) ) ;
}
@Nullable
public static Style constructStyleForExtras ( @NonNull Bundle bundle ) {
Style constructCompatStyleForBundle = constructCompatStyleForBundle ( bundle ) ;
if ( constructCompatStyleForBundle = = null ) {
return null ;
}
try {
constructCompatStyleForBundle . restoreFromCompatExtras ( bundle ) ;
return constructCompatStyleForBundle ;
} catch ( ClassCastException unused ) {
return null ;
}
}
2021-07-24 02:37:17 +00:00
private Bitmap createColoredBitmap ( int i , int i2 , int i3 ) {
return createColoredBitmap ( IconCompat . createWithResource ( this . mBuilder . mContext , i ) , i2 , i3 ) ;
}
2021-09-21 07:33:49 +00:00
private Bitmap createColoredBitmap ( @NonNull IconCompat iconCompat , int i , int i2 ) {
2021-07-24 02:37:17 +00:00
Drawable loadDrawable = iconCompat . loadDrawable ( this . mBuilder . mContext ) ;
int intrinsicWidth = i2 = = 0 ? loadDrawable . getIntrinsicWidth ( ) : i2 ;
if ( i2 = = 0 ) {
i2 = loadDrawable . getIntrinsicHeight ( ) ;
}
Bitmap createBitmap = Bitmap . createBitmap ( intrinsicWidth , i2 , Bitmap . Config . ARGB_8888 ) ;
loadDrawable . setBounds ( 0 , 0 , intrinsicWidth , i2 ) ;
if ( i ! = 0 ) {
loadDrawable . mutate ( ) . setColorFilter ( new PorterDuffColorFilter ( i , PorterDuff . Mode . SRC_IN ) ) ;
}
loadDrawable . draw ( new Canvas ( createBitmap ) ) ;
return createBitmap ;
}
private Bitmap createIconWithBackground ( int i , int i2 , int i3 , int i4 ) {
int i5 = R . drawable . notification_icon_background ;
if ( i4 = = 0 ) {
i4 = 0 ;
}
Bitmap createColoredBitmap = createColoredBitmap ( i5 , i4 , i2 ) ;
Canvas canvas = new Canvas ( createColoredBitmap ) ;
Drawable mutate = this . mBuilder . mContext . getResources ( ) . getDrawable ( i ) . mutate ( ) ;
mutate . setFilterBitmap ( true ) ;
int i6 = ( i2 - i3 ) / 2 ;
int i7 = i3 + i6 ;
mutate . setBounds ( i6 , i6 , i7 , i7 ) ;
mutate . setColorFilter ( new PorterDuffColorFilter ( - 1 , PorterDuff . Mode . SRC_ATOP ) ) ;
mutate . draw ( canvas ) ;
return createColoredBitmap ;
}
2021-09-21 07:33:49 +00:00
@Nullable
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public static Style extractStyleFromNotification ( @NonNull Notification notification ) {
Bundle extras = NotificationCompat . getExtras ( notification ) ;
if ( extras = = null ) {
return null ;
}
return constructStyleForExtras ( extras ) ;
}
2021-07-24 02:37:17 +00:00
private void hideNormalContent ( RemoteViews remoteViews ) {
remoteViews . setViewVisibility ( R . id . title , 8 ) ;
remoteViews . setViewVisibility ( R . id . text2 , 8 ) ;
remoteViews . setViewVisibility ( R . id . text , 8 ) ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
2021-09-21 07:33:49 +00:00
public void addCompatExtras ( @NonNull Bundle bundle ) {
if ( this . mSummaryTextSet ) {
bundle . putCharSequence ( NotificationCompat . EXTRA_SUMMARY_TEXT , this . mSummaryText ) ;
}
CharSequence charSequence = this . mBigContentTitle ;
if ( charSequence ! = null ) {
bundle . putCharSequence ( NotificationCompat . EXTRA_TITLE_BIG , charSequence ) ;
}
String className = getClassName ( ) ;
if ( className ! = null ) {
bundle . putString ( NotificationCompat . EXTRA_COMPAT_TEMPLATE , className ) ;
}
2021-07-24 02:37:17 +00:00
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void apply ( NotificationBuilderWithBuilderAccessor notificationBuilderWithBuilderAccessor ) {
}
/* JADX WARNING: Removed duplicated region for block: B:32:0x0100 */
/* JADX WARNING: Removed duplicated region for block: B:38:0x011d */
/* JADX WARNING: Removed duplicated region for block: B:43:0x0141 */
/* JADX WARNING: Removed duplicated region for block: B:51:0x0188 */
/* JADX WARNING: Removed duplicated region for block: B:54:0x018d */
/* JADX WARNING: Removed duplicated region for block: B:55:0x018f */
/* JADX WARNING: Removed duplicated region for block: B:58:0x0199 */
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public RemoteViews applyStandardTemplate ( boolean z2 , int i , boolean z3 ) {
boolean z4 ;
boolean z5 ;
CharSequence charSequence ;
boolean z6 ;
Resources resources = this . mBuilder . mContext . getResources ( ) ;
RemoteViews remoteViews = new RemoteViews ( this . mBuilder . mContext . getPackageName ( ) , i ) ;
this . mBuilder . getPriority ( ) ;
int i2 = Build . VERSION . SDK_INT ;
Builder builder = this . mBuilder ;
int i3 = 0 ;
if ( builder . mLargeIcon ! = null ) {
int i4 = R . id . icon ;
remoteViews . setViewVisibility ( i4 , 0 ) ;
remoteViews . setImageViewBitmap ( i4 , this . mBuilder . mLargeIcon ) ;
if ( z2 & & this . mBuilder . mNotification . icon ! = 0 ) {
int dimensionPixelSize = resources . getDimensionPixelSize ( R . dimen . notification_right_icon_size ) ;
Builder builder2 = this . mBuilder ;
Bitmap createIconWithBackground = createIconWithBackground ( builder2 . mNotification . icon , dimensionPixelSize , dimensionPixelSize - ( resources . getDimensionPixelSize ( R . dimen . notification_small_icon_background_padding ) * 2 ) , builder2 . getColor ( ) ) ;
int i5 = R . id . right_icon ;
remoteViews . setImageViewBitmap ( i5 , createIconWithBackground ) ;
remoteViews . setViewVisibility ( i5 , 0 ) ;
}
} else if ( z2 & & builder . mNotification . icon ! = 0 ) {
int i6 = R . id . icon ;
remoteViews . setViewVisibility ( i6 , 0 ) ;
int dimensionPixelSize2 = resources . getDimensionPixelSize ( R . dimen . notification_large_icon_width ) - resources . getDimensionPixelSize ( R . dimen . notification_big_circle_margin ) ;
int dimensionPixelSize3 = resources . getDimensionPixelSize ( R . dimen . notification_small_icon_size_as_large ) ;
Builder builder3 = this . mBuilder ;
remoteViews . setImageViewBitmap ( i6 , createIconWithBackground ( builder3 . mNotification . icon , dimensionPixelSize2 , dimensionPixelSize3 , builder3 . getColor ( ) ) ) ;
}
CharSequence charSequence2 = this . mBuilder . mContentTitle ;
if ( charSequence2 ! = null ) {
remoteViews . setTextViewText ( R . id . title , charSequence2 ) ;
}
CharSequence charSequence3 = this . mBuilder . mContentText ;
boolean z7 = true ;
if ( charSequence3 ! = null ) {
remoteViews . setTextViewText ( R . id . text , charSequence3 ) ;
z4 = true ;
} else {
z4 = false ;
}
Builder builder4 = this . mBuilder ;
CharSequence charSequence4 = builder4 . mContentInfo ;
if ( charSequence4 ! = null ) {
int i7 = R . id . info ;
remoteViews . setTextViewText ( i7 , charSequence4 ) ;
remoteViews . setViewVisibility ( i7 , 0 ) ;
} else if ( builder4 . mNumber > 0 ) {
if ( this . mBuilder . mNumber > resources . getInteger ( R . integer . status_bar_notification_info_maxnum ) ) {
remoteViews . setTextViewText ( R . id . info , resources . getString ( R . string . status_bar_notification_info_overflow ) ) ;
} else {
remoteViews . setTextViewText ( R . id . info , NumberFormat . getIntegerInstance ( ) . format ( ( long ) this . mBuilder . mNumber ) ) ;
}
remoteViews . setViewVisibility ( R . id . info , 0 ) ;
} else {
remoteViews . setViewVisibility ( R . id . info , 8 ) ;
z5 = false ;
charSequence = this . mBuilder . mSubText ;
if ( charSequence ! = null ) {
remoteViews . setTextViewText ( R . id . text , charSequence ) ;
CharSequence charSequence5 = this . mBuilder . mContentText ;
if ( charSequence5 ! = null ) {
int i8 = R . id . text2 ;
remoteViews . setTextViewText ( i8 , charSequence5 ) ;
remoteViews . setViewVisibility ( i8 , 0 ) ;
z6 = true ;
if ( z6 ) {
if ( z3 ) {
remoteViews . setTextViewTextSize ( R . id . text , 0 , ( float ) resources . getDimensionPixelSize ( R . dimen . notification_subtext_size ) ) ;
}
remoteViews . setViewPadding ( R . id . line1 , 0 , 0 , 0 , 0 ) ;
}
if ( this . mBuilder . getWhenIfShowing ( ) = = 0 ) {
z7 = z5 ;
} else if ( this . mBuilder . mUseChronometer ) {
int i9 = R . id . chronometer ;
remoteViews . setViewVisibility ( i9 , 0 ) ;
remoteViews . setLong ( i9 , " setBase " , ( SystemClock . elapsedRealtime ( ) - System . currentTimeMillis ( ) ) + this . mBuilder . getWhenIfShowing ( ) ) ;
remoteViews . setBoolean ( i9 , " setStarted " , true ) ;
boolean z8 = this . mBuilder . mChronometerCountDown ;
if ( z8 & & i2 > = 24 ) {
remoteViews . setChronometerCountDown ( i9 , z8 ) ;
}
} else {
int i10 = R . id . time ;
remoteViews . setViewVisibility ( i10 , 0 ) ;
remoteViews . setLong ( i10 , " setTime " , this . mBuilder . getWhenIfShowing ( ) ) ;
}
remoteViews . setViewVisibility ( R . id . right_side , z7 ? 0 : 8 ) ;
int i11 = R . id . line3 ;
if ( ! z4 ) {
i3 = 8 ;
}
remoteViews . setViewVisibility ( i11 , i3 ) ;
return remoteViews ;
}
remoteViews . setViewVisibility ( R . id . text2 , 8 ) ;
}
z6 = false ;
if ( z6 ) {
}
if ( this . mBuilder . getWhenIfShowing ( ) = = 0 ) {
}
remoteViews . setViewVisibility ( R . id . right_side , z7 ? 0 : 8 ) ;
int i11 = R . id . line3 ;
if ( ! z4 ) {
}
remoteViews . setViewVisibility ( i11 , i3 ) ;
return remoteViews ;
}
z4 = true ;
z5 = true ;
charSequence = this . mBuilder . mSubText ;
if ( charSequence ! = null ) {
}
z6 = false ;
if ( z6 ) {
}
if ( this . mBuilder . getWhenIfShowing ( ) = = 0 ) {
}
remoteViews . setViewVisibility ( R . id . right_side , z7 ? 0 : 8 ) ;
int i11 = R . id . line3 ;
if ( ! z4 ) {
}
remoteViews . setViewVisibility ( i11 , i3 ) ;
return remoteViews ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public Notification build ( ) {
Builder builder = this . mBuilder ;
if ( builder ! = null ) {
return builder . build ( ) ;
}
return null ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void buildIntoRemoteViews ( RemoteViews remoteViews , RemoteViews remoteViews2 ) {
hideNormalContent ( remoteViews ) ;
int i = R . id . notification_main_column ;
remoteViews . removeAllViews ( i ) ;
remoteViews . addView ( i , remoteViews2 . clone ( ) ) ;
remoteViews . setViewVisibility ( i , 0 ) ;
remoteViews . setViewPadding ( R . id . notification_main_column_container , 0 , calculateTopPadding ( ) , 0 , 0 ) ;
}
2021-09-21 07:33:49 +00:00
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public void clearCompatExtraKeys ( @NonNull Bundle bundle ) {
bundle . remove ( NotificationCompat . EXTRA_SUMMARY_TEXT ) ;
bundle . remove ( NotificationCompat . EXTRA_TITLE_BIG ) ;
bundle . remove ( NotificationCompat . EXTRA_COMPAT_TEMPLATE ) ;
}
2021-07-24 02:37:17 +00:00
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public Bitmap createColoredBitmap ( int i , int i2 ) {
return createColoredBitmap ( i , i2 , 0 ) ;
}
2021-09-21 07:33:49 +00:00
public Bitmap createColoredBitmap ( @NonNull IconCompat iconCompat , int i ) {
2021-07-24 02:37:17 +00:00
return createColoredBitmap ( iconCompat , i , 0 ) ;
}
2021-09-21 07:33:49 +00:00
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public boolean displayCustomViewInline ( ) {
return false ;
}
@Nullable
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public String getClassName ( ) {
return null ;
}
2021-07-24 02:37:17 +00:00
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public RemoteViews makeBigContentView ( NotificationBuilderWithBuilderAccessor notificationBuilderWithBuilderAccessor ) {
return null ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public RemoteViews makeContentView ( NotificationBuilderWithBuilderAccessor notificationBuilderWithBuilderAccessor ) {
return null ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public RemoteViews makeHeadsUpContentView ( NotificationBuilderWithBuilderAccessor notificationBuilderWithBuilderAccessor ) {
return null ;
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
2021-09-21 07:33:49 +00:00
public void restoreFromCompatExtras ( @NonNull Bundle bundle ) {
if ( bundle . containsKey ( NotificationCompat . EXTRA_SUMMARY_TEXT ) ) {
this . mSummaryText = bundle . getCharSequence ( NotificationCompat . EXTRA_SUMMARY_TEXT ) ;
this . mSummaryTextSet = true ;
}
this . mBigContentTitle = bundle . getCharSequence ( NotificationCompat . EXTRA_TITLE_BIG ) ;
2021-07-24 02:37:17 +00:00
}
2021-09-21 07:33:49 +00:00
public void setBuilder ( @Nullable Builder builder ) {
2021-07-24 02:37:17 +00:00
if ( this . mBuilder ! = builder ) {
this . mBuilder = builder ;
if ( builder ! = null ) {
builder . setStyle ( this ) ;
}
}
}
}
public static final class WearableExtender implements Extender {
private static final int DEFAULT_CONTENT_ICON_GRAVITY = 8388613 ;
private static final int DEFAULT_FLAGS = 1 ;
private static final int DEFAULT_GRAVITY = 80 ;
private static final String EXTRA_WEARABLE_EXTENSIONS = " android.wearable.EXTENSIONS " ;
private static final int FLAG_BIG_PICTURE_AMBIENT = 32 ;
private static final int FLAG_CONTENT_INTENT_AVAILABLE_OFFLINE = 1 ;
private static final int FLAG_HINT_AVOID_BACKGROUND_CLIPPING = 16 ;
private static final int FLAG_HINT_CONTENT_INTENT_LAUNCHES_ACTIVITY = 64 ;
private static final int FLAG_HINT_HIDE_ICON = 2 ;
private static final int FLAG_HINT_SHOW_BACKGROUND_ONLY = 4 ;
private static final int FLAG_START_SCROLL_BOTTOM = 8 ;
private static final String KEY_ACTIONS = " actions " ;
private static final String KEY_BACKGROUND = " background " ;
private static final String KEY_BRIDGE_TAG = " bridgeTag " ;
private static final String KEY_CONTENT_ACTION_INDEX = " contentActionIndex " ;
private static final String KEY_CONTENT_ICON = " contentIcon " ;
private static final String KEY_CONTENT_ICON_GRAVITY = " contentIconGravity " ;
private static final String KEY_CUSTOM_CONTENT_HEIGHT = " customContentHeight " ;
private static final String KEY_CUSTOM_SIZE_PRESET = " customSizePreset " ;
private static final String KEY_DISMISSAL_ID = " dismissalId " ;
private static final String KEY_DISPLAY_INTENT = " displayIntent " ;
private static final String KEY_FLAGS = " flags " ;
private static final String KEY_GRAVITY = " gravity " ;
private static final String KEY_HINT_SCREEN_TIMEOUT = " hintScreenTimeout " ;
private static final String KEY_PAGES = " pages " ;
@Deprecated
public static final int SCREEN_TIMEOUT_LONG = - 1 ;
@Deprecated
public static final int SCREEN_TIMEOUT_SHORT = 0 ;
@Deprecated
public static final int SIZE_DEFAULT = 0 ;
@Deprecated
public static final int SIZE_FULL_SCREEN = 5 ;
@Deprecated
public static final int SIZE_LARGE = 4 ;
@Deprecated
public static final int SIZE_MEDIUM = 3 ;
@Deprecated
public static final int SIZE_SMALL = 2 ;
@Deprecated
public static final int SIZE_XSMALL = 1 ;
public static final int UNSET_ACTION_INDEX = - 1 ;
private ArrayList < Action > mActions = new ArrayList < > ( ) ;
private Bitmap mBackground ;
private String mBridgeTag ;
private int mContentActionIndex = - 1 ;
private int mContentIcon ;
private int mContentIconGravity = 8388613 ;
private int mCustomContentHeight ;
private int mCustomSizePreset = 0 ;
private String mDismissalId ;
private PendingIntent mDisplayIntent ;
private int mFlags = 1 ;
private int mGravity = 80 ;
private int mHintScreenTimeout ;
private ArrayList < Notification > mPages = new ArrayList < > ( ) ;
public WearableExtender ( ) {
}
2021-09-21 07:33:49 +00:00
public WearableExtender ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
Bundle extras = NotificationCompat . getExtras ( notification ) ;
2021-08-09 22:50:52 +00:00
Bundle bundle = extras ! = null ? extras . getBundle ( EXTRA_WEARABLE_EXTENSIONS ) : null ;
2021-07-24 02:37:17 +00:00
if ( bundle ! = null ) {
2021-08-09 22:50:52 +00:00
ArrayList parcelableArrayList = bundle . getParcelableArrayList ( KEY_ACTIONS ) ;
2021-07-24 02:37:17 +00:00
if ( parcelableArrayList ! = null ) {
int size = parcelableArrayList . size ( ) ;
Action [ ] actionArr = new Action [ size ] ;
for ( int i = 0 ; i < size ; i + + ) {
actionArr [ i ] = NotificationCompat . getActionCompatFromAction ( ( Notification . Action ) parcelableArrayList . get ( i ) ) ;
}
Collections . addAll ( this . mActions , actionArr ) ;
}
2021-08-09 22:50:52 +00:00
this . mFlags = bundle . getInt ( KEY_FLAGS , 1 ) ;
this . mDisplayIntent = ( PendingIntent ) bundle . getParcelable ( KEY_DISPLAY_INTENT ) ;
Notification [ ] notificationArrayFromBundle = NotificationCompat . getNotificationArrayFromBundle ( bundle , KEY_PAGES ) ;
2021-07-24 02:37:17 +00:00
if ( notificationArrayFromBundle ! = null ) {
Collections . addAll ( this . mPages , notificationArrayFromBundle ) ;
}
2021-08-09 22:50:52 +00:00
this . mBackground = ( Bitmap ) bundle . getParcelable ( KEY_BACKGROUND ) ;
this . mContentIcon = bundle . getInt ( KEY_CONTENT_ICON ) ;
this . mContentIconGravity = bundle . getInt ( KEY_CONTENT_ICON_GRAVITY , 8388613 ) ;
this . mContentActionIndex = bundle . getInt ( KEY_CONTENT_ACTION_INDEX , - 1 ) ;
this . mCustomSizePreset = bundle . getInt ( KEY_CUSTOM_SIZE_PRESET , 0 ) ;
this . mCustomContentHeight = bundle . getInt ( KEY_CUSTOM_CONTENT_HEIGHT ) ;
this . mGravity = bundle . getInt ( KEY_GRAVITY , 80 ) ;
this . mHintScreenTimeout = bundle . getInt ( KEY_HINT_SCREEN_TIMEOUT ) ;
this . mDismissalId = bundle . getString ( KEY_DISMISSAL_ID ) ;
this . mBridgeTag = bundle . getString ( KEY_BRIDGE_TAG ) ;
2021-07-24 02:37:17 +00:00
}
}
@RequiresApi ( 20 )
private static Notification . Action getActionFromActionCompat ( Action action ) {
Notification . Action . Builder builder ;
int i = Build . VERSION . SDK_INT ;
if ( i > = 23 ) {
IconCompat iconCompat = action . getIconCompat ( ) ;
builder = new Notification . Action . Builder ( iconCompat = = null ? null : iconCompat . toIcon ( ) , action . getTitle ( ) , action . getActionIntent ( ) ) ;
} else {
IconCompat iconCompat2 = action . getIconCompat ( ) ;
builder = new Notification . Action . Builder ( ( iconCompat2 = = null | | iconCompat2 . getType ( ) ! = 2 ) ? 0 : iconCompat2 . getResId ( ) , action . getTitle ( ) , action . getActionIntent ( ) ) ;
}
Bundle bundle = action . getExtras ( ) ! = null ? new Bundle ( action . getExtras ( ) ) : new Bundle ( ) ;
2021-08-09 22:50:52 +00:00
bundle . putBoolean ( NotificationCompatJellybean . EXTRA_ALLOW_GENERATED_REPLIES , action . getAllowGeneratedReplies ( ) ) ;
2021-07-24 02:37:17 +00:00
if ( i > = 24 ) {
builder . setAllowGeneratedReplies ( action . getAllowGeneratedReplies ( ) ) ;
}
builder . addExtras ( bundle ) ;
RemoteInput [ ] remoteInputs = action . getRemoteInputs ( ) ;
if ( remoteInputs ! = null ) {
for ( RemoteInput remoteInput : RemoteInput . fromCompat ( remoteInputs ) ) {
builder . addRemoteInput ( remoteInput ) ;
}
}
return builder . build ( ) ;
}
private void setFlag ( int i , boolean z2 ) {
if ( z2 ) {
this . mFlags = i | this . mFlags ;
return ;
}
this . mFlags = ( ~ i ) & this . mFlags ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public WearableExtender addAction ( @NonNull Action action ) {
2021-07-24 02:37:17 +00:00
this . mActions . add ( action ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public WearableExtender addActions ( @NonNull List < Action > list ) {
2021-07-24 02:37:17 +00:00
this . mActions . addAll ( list ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
2021-09-21 07:33:49 +00:00
public WearableExtender addPage ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
this . mPages . add ( notification ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
2021-09-21 07:33:49 +00:00
public WearableExtender addPages ( @NonNull List < Notification > list ) {
2021-07-24 02:37:17 +00:00
this . mPages . addAll ( list ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public WearableExtender clearActions ( ) {
this . mActions . clear ( ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public WearableExtender clearPages ( ) {
this . mPages . clear ( ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public WearableExtender clone ( ) {
WearableExtender wearableExtender = new WearableExtender ( ) ;
wearableExtender . mActions = new ArrayList < > ( this . mActions ) ;
wearableExtender . mFlags = this . mFlags ;
wearableExtender . mDisplayIntent = this . mDisplayIntent ;
wearableExtender . mPages = new ArrayList < > ( this . mPages ) ;
wearableExtender . mBackground = this . mBackground ;
wearableExtender . mContentIcon = this . mContentIcon ;
wearableExtender . mContentIconGravity = this . mContentIconGravity ;
wearableExtender . mContentActionIndex = this . mContentActionIndex ;
wearableExtender . mCustomSizePreset = this . mCustomSizePreset ;
wearableExtender . mCustomContentHeight = this . mCustomContentHeight ;
wearableExtender . mGravity = this . mGravity ;
wearableExtender . mHintScreenTimeout = this . mHintScreenTimeout ;
wearableExtender . mDismissalId = this . mDismissalId ;
wearableExtender . mBridgeTag = this . mBridgeTag ;
return wearableExtender ;
}
@Override // androidx.core.app.NotificationCompat.Extender
2021-09-21 07:33:49 +00:00
@NonNull
public Builder extend ( @NonNull Builder builder ) {
2021-07-24 02:37:17 +00:00
Bundle bundle = new Bundle ( ) ;
if ( ! this . mActions . isEmpty ( ) ) {
ArrayList < ? extends Parcelable > arrayList = new ArrayList < > ( this . mActions . size ( ) ) ;
Iterator < Action > it = this . mActions . iterator ( ) ;
while ( it . hasNext ( ) ) {
arrayList . add ( getActionFromActionCompat ( it . next ( ) ) ) ;
}
2021-08-09 22:50:52 +00:00
bundle . putParcelableArrayList ( KEY_ACTIONS , arrayList ) ;
2021-07-24 02:37:17 +00:00
}
int i = this . mFlags ;
if ( i ! = 1 ) {
2021-08-09 22:50:52 +00:00
bundle . putInt ( KEY_FLAGS , i ) ;
2021-07-24 02:37:17 +00:00
}
PendingIntent pendingIntent = this . mDisplayIntent ;
if ( pendingIntent ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putParcelable ( KEY_DISPLAY_INTENT , pendingIntent ) ;
2021-07-24 02:37:17 +00:00
}
if ( ! this . mPages . isEmpty ( ) ) {
ArrayList < Notification > arrayList2 = this . mPages ;
2021-08-09 22:50:52 +00:00
bundle . putParcelableArray ( KEY_PAGES , ( Parcelable [ ] ) arrayList2 . toArray ( new Notification [ arrayList2 . size ( ) ] ) ) ;
2021-07-24 02:37:17 +00:00
}
Bitmap bitmap = this . mBackground ;
if ( bitmap ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putParcelable ( KEY_BACKGROUND , bitmap ) ;
2021-07-24 02:37:17 +00:00
}
int i2 = this . mContentIcon ;
if ( i2 ! = 0 ) {
2021-08-09 22:50:52 +00:00
bundle . putInt ( KEY_CONTENT_ICON , i2 ) ;
2021-07-24 02:37:17 +00:00
}
int i3 = this . mContentIconGravity ;
if ( i3 ! = 8388613 ) {
2021-08-09 22:50:52 +00:00
bundle . putInt ( KEY_CONTENT_ICON_GRAVITY , i3 ) ;
2021-07-24 02:37:17 +00:00
}
int i4 = this . mContentActionIndex ;
if ( i4 ! = - 1 ) {
2021-08-09 22:50:52 +00:00
bundle . putInt ( KEY_CONTENT_ACTION_INDEX , i4 ) ;
2021-07-24 02:37:17 +00:00
}
int i5 = this . mCustomSizePreset ;
if ( i5 ! = 0 ) {
2021-08-09 22:50:52 +00:00
bundle . putInt ( KEY_CUSTOM_SIZE_PRESET , i5 ) ;
2021-07-24 02:37:17 +00:00
}
int i6 = this . mCustomContentHeight ;
if ( i6 ! = 0 ) {
2021-08-09 22:50:52 +00:00
bundle . putInt ( KEY_CUSTOM_CONTENT_HEIGHT , i6 ) ;
2021-07-24 02:37:17 +00:00
}
int i7 = this . mGravity ;
if ( i7 ! = 80 ) {
2021-08-09 22:50:52 +00:00
bundle . putInt ( KEY_GRAVITY , i7 ) ;
2021-07-24 02:37:17 +00:00
}
int i8 = this . mHintScreenTimeout ;
if ( i8 ! = 0 ) {
2021-08-09 22:50:52 +00:00
bundle . putInt ( KEY_HINT_SCREEN_TIMEOUT , i8 ) ;
2021-07-24 02:37:17 +00:00
}
String str = this . mDismissalId ;
if ( str ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putString ( KEY_DISMISSAL_ID , str ) ;
2021-07-24 02:37:17 +00:00
}
String str2 = this . mBridgeTag ;
if ( str2 ! = null ) {
2021-08-09 22:50:52 +00:00
bundle . putString ( KEY_BRIDGE_TAG , str2 ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:50:52 +00:00
builder . getExtras ( ) . putBundle ( EXTRA_WEARABLE_EXTENSIONS , bundle ) ;
2021-07-24 02:37:17 +00:00
return builder ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public List < Action > getActions ( ) {
return this . mActions ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
@Deprecated
public Bitmap getBackground ( ) {
return this . mBackground ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public String getBridgeTag ( ) {
return this . mBridgeTag ;
}
public int getContentAction ( ) {
return this . mContentActionIndex ;
}
@Deprecated
public int getContentIcon ( ) {
return this . mContentIcon ;
}
@Deprecated
public int getContentIconGravity ( ) {
return this . mContentIconGravity ;
}
public boolean getContentIntentAvailableOffline ( ) {
return ( this . mFlags & 1 ) ! = 0 ;
}
@Deprecated
public int getCustomContentHeight ( ) {
return this . mCustomContentHeight ;
}
@Deprecated
public int getCustomSizePreset ( ) {
return this . mCustomSizePreset ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
public String getDismissalId ( ) {
return this . mDismissalId ;
}
2021-09-21 07:33:49 +00:00
@Nullable
2021-07-24 02:37:17 +00:00
@Deprecated
public PendingIntent getDisplayIntent ( ) {
return this . mDisplayIntent ;
}
@Deprecated
public int getGravity ( ) {
return this . mGravity ;
}
@Deprecated
public boolean getHintAmbientBigPicture ( ) {
return ( this . mFlags & 32 ) ! = 0 ;
}
@Deprecated
public boolean getHintAvoidBackgroundClipping ( ) {
return ( this . mFlags & 16 ) ! = 0 ;
}
public boolean getHintContentIntentLaunchesActivity ( ) {
return ( this . mFlags & 64 ) ! = 0 ;
}
@Deprecated
public boolean getHintHideIcon ( ) {
return ( this . mFlags & 2 ) ! = 0 ;
}
@Deprecated
public int getHintScreenTimeout ( ) {
return this . mHintScreenTimeout ;
}
@Deprecated
public boolean getHintShowBackgroundOnly ( ) {
return ( this . mFlags & 4 ) ! = 0 ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public List < Notification > getPages ( ) {
return this . mPages ;
}
public boolean getStartScrollBottom ( ) {
return ( this . mFlags & 8 ) ! = 0 ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
2021-09-21 07:33:49 +00:00
public WearableExtender setBackground ( @Nullable Bitmap bitmap ) {
2021-07-24 02:37:17 +00:00
this . mBackground = bitmap ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public WearableExtender setBridgeTag ( @Nullable String str ) {
2021-07-24 02:37:17 +00:00
this . mBridgeTag = str ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public WearableExtender setContentAction ( int i ) {
this . mContentActionIndex = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public WearableExtender setContentIcon ( int i ) {
this . mContentIcon = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public WearableExtender setContentIconGravity ( int i ) {
this . mContentIconGravity = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public WearableExtender setContentIntentAvailableOffline ( boolean z2 ) {
setFlag ( 1 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public WearableExtender setCustomContentHeight ( int i ) {
this . mCustomContentHeight = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public WearableExtender setCustomSizePreset ( int i ) {
this . mCustomSizePreset = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
public WearableExtender setDismissalId ( @Nullable String str ) {
2021-07-24 02:37:17 +00:00
this . mDismissalId = str ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
2021-09-21 07:33:49 +00:00
public WearableExtender setDisplayIntent ( @Nullable PendingIntent pendingIntent ) {
2021-07-24 02:37:17 +00:00
this . mDisplayIntent = pendingIntent ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public WearableExtender setGravity ( int i ) {
this . mGravity = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public WearableExtender setHintAmbientBigPicture ( boolean z2 ) {
setFlag ( 32 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public WearableExtender setHintAvoidBackgroundClipping ( boolean z2 ) {
setFlag ( 16 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public WearableExtender setHintContentIntentLaunchesActivity ( boolean z2 ) {
setFlag ( 64 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public WearableExtender setHintHideIcon ( boolean z2 ) {
setFlag ( 2 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public WearableExtender setHintScreenTimeout ( int i ) {
this . mHintScreenTimeout = i ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@Deprecated
public WearableExtender setHintShowBackgroundOnly ( boolean z2 ) {
setFlag ( 4 , z2 ) ;
return this ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
public WearableExtender setStartScrollBottom ( boolean z2 ) {
setFlag ( 8 , z2 ) ;
return this ;
}
}
2021-09-21 07:33:49 +00:00
@Nullable
public static Action getAction ( @NonNull Notification notification , int i ) {
2021-07-24 02:37:17 +00:00
return getActionCompatFromAction ( notification . actions [ i ] ) ;
}
2021-09-21 07:33:49 +00:00
@NonNull
2021-07-24 02:37:17 +00:00
@RequiresApi ( 20 )
2021-09-21 07:33:49 +00:00
public static Action getActionCompatFromAction ( @NonNull Notification . Action action ) {
2021-07-24 02:37:17 +00:00
RemoteInput [ ] remoteInputArr ;
int i ;
RemoteInput [ ] remoteInputs = action . getRemoteInputs ( ) ;
IconCompat iconCompat = null ;
if ( remoteInputs = = null ) {
remoteInputArr = null ;
} else {
RemoteInput [ ] remoteInputArr2 = new RemoteInput [ remoteInputs . length ] ;
for ( int i2 = 0 ; i2 < remoteInputs . length ; i2 + + ) {
RemoteInput remoteInput = remoteInputs [ i2 ] ;
remoteInputArr2 [ i2 ] = new RemoteInput ( remoteInput . getResultKey ( ) , remoteInput . getLabel ( ) , remoteInput . getChoices ( ) , remoteInput . getAllowFreeFormInput ( ) , Build . VERSION . SDK_INT > = 29 ? remoteInput . getEditChoicesBeforeSending ( ) : 0 , remoteInput . getExtras ( ) , null ) ;
}
remoteInputArr = remoteInputArr2 ;
}
int i3 = Build . VERSION . SDK_INT ;
2021-08-09 22:50:52 +00:00
boolean z2 = i3 > = 24 ? action . getExtras ( ) . getBoolean ( NotificationCompatJellybean . EXTRA_ALLOW_GENERATED_REPLIES ) | | action . getAllowGeneratedReplies ( ) : action . getExtras ( ) . getBoolean ( NotificationCompatJellybean . EXTRA_ALLOW_GENERATED_REPLIES ) ;
boolean z3 = action . getExtras ( ) . getBoolean ( Action . EXTRA_SHOWS_USER_INTERFACE , true ) ;
int semanticAction = i3 > = 28 ? action . getSemanticAction ( ) : action . getExtras ( ) . getInt ( Action . EXTRA_SEMANTIC_ACTION , 0 ) ;
2021-07-24 02:37:17 +00:00
boolean isContextual = i3 > = 29 ? action . isContextual ( ) : false ;
if ( i3 < 23 ) {
return new Action ( action . icon , action . title , action . actionIntent , action . getExtras ( ) , remoteInputArr , ( RemoteInput [ ] ) null , z2 , semanticAction , z3 , isContextual ) ;
}
if ( action . getIcon ( ) = = null & & ( i = action . icon ) ! = 0 ) {
return new Action ( i , action . title , action . actionIntent , action . getExtras ( ) , remoteInputArr , ( RemoteInput [ ] ) null , z2 , semanticAction , z3 , isContextual ) ;
}
if ( action . getIcon ( ) ! = null ) {
iconCompat = IconCompat . createFromIconOrNullIfZeroResId ( action . getIcon ( ) ) ;
}
return new Action ( iconCompat , action . title , action . actionIntent , action . getExtras ( ) , remoteInputArr , ( RemoteInput [ ] ) null , z2 , semanticAction , z3 , isContextual ) ;
}
2021-09-21 07:33:49 +00:00
public static int getActionCount ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
Notification . Action [ ] actionArr = notification . actions ;
if ( actionArr ! = null ) {
return actionArr . length ;
}
return 0 ;
}
2021-09-21 07:33:49 +00:00
public static boolean getAllowSystemGeneratedContextualActions ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
if ( Build . VERSION . SDK_INT > = 29 ) {
return notification . getAllowSystemGeneratedContextualActions ( ) ;
}
return false ;
}
2021-09-21 07:33:49 +00:00
public static boolean getAutoCancel ( @NonNull Notification notification ) {
return ( notification . flags & 16 ) ! = 0 ;
}
public static int getBadgeIconType ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
if ( Build . VERSION . SDK_INT > = 26 ) {
return notification . getBadgeIconType ( ) ;
}
return 0 ;
}
@Nullable
public static BubbleMetadata getBubbleMetadata ( @NonNull Notification notification ) {
if ( Build . VERSION . SDK_INT > = 29 ) {
return BubbleMetadata . fromPlatform ( notification . getBubbleMetadata ( ) ) ;
}
return null ;
}
2021-09-21 07:33:49 +00:00
@Nullable
public static String getCategory ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
return notification . category ;
}
2021-09-21 07:33:49 +00:00
@Nullable
public static String getChannelId ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
if ( Build . VERSION . SDK_INT > = 26 ) {
return notification . getChannelId ( ) ;
}
return null ;
}
2021-09-21 07:33:49 +00:00
public static int getColor ( @NonNull Notification notification ) {
return notification . color ;
}
@Nullable
@RequiresApi ( 19 )
public static CharSequence getContentInfo ( @NonNull Notification notification ) {
return notification . extras . getCharSequence ( EXTRA_INFO_TEXT ) ;
}
@Nullable
@RequiresApi ( 19 )
public static CharSequence getContentText ( @NonNull Notification notification ) {
return notification . extras . getCharSequence ( EXTRA_TEXT ) ;
}
@Nullable
2021-07-24 02:37:17 +00:00
@RequiresApi ( 19 )
2021-09-21 07:33:49 +00:00
public static CharSequence getContentTitle ( @NonNull Notification notification ) {
2021-08-09 22:50:52 +00:00
return notification . extras . getCharSequence ( EXTRA_TITLE ) ;
2021-07-24 02:37:17 +00:00
}
@Nullable
2021-09-21 07:33:49 +00:00
public static Bundle getExtras ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
return notification . extras ;
}
2021-09-21 07:33:49 +00:00
@Nullable
public static String getGroup ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
return notification . getGroup ( ) ;
}
2021-09-21 07:33:49 +00:00
public static int getGroupAlertBehavior ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
if ( Build . VERSION . SDK_INT > = 26 ) {
return notification . getGroupAlertBehavior ( ) ;
}
return 0 ;
}
2021-09-21 07:33:49 +00:00
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP_PREFIX } )
public static boolean getHighPriority ( @NonNull Notification notification ) {
return ( notification . flags & 128 ) ! = 0 ;
}
@NonNull
2021-07-24 02:37:17 +00:00
@RequiresApi ( 21 )
2021-09-21 07:33:49 +00:00
public static List < Action > getInvisibleActions ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
Bundle bundle ;
ArrayList arrayList = new ArrayList ( ) ;
2021-08-09 22:50:52 +00:00
Bundle bundle2 = notification . extras . getBundle ( CarExtender . EXTRA_CAR_EXTENDER ) ;
if ( ! ( bundle2 = = null | | ( bundle = bundle2 . getBundle ( CarExtender . EXTRA_INVISIBLE_ACTIONS ) ) = = null ) ) {
2021-07-24 02:37:17 +00:00
for ( int i = 0 ; i < bundle . size ( ) ; i + + ) {
arrayList . add ( NotificationCompatJellybean . getActionFromBundle ( bundle . getBundle ( Integer . toString ( i ) ) ) ) ;
}
}
return arrayList ;
}
2021-09-21 07:33:49 +00:00
public static boolean getLocalOnly ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
return ( notification . flags & 256 ) ! = 0 ;
}
2021-09-21 07:33:49 +00:00
@Nullable
public static LocusIdCompat getLocusId ( @NonNull Notification notification ) {
LocusId locusId ;
if ( Build . VERSION . SDK_INT < 29 | | ( locusId = notification . getLocusId ( ) ) = = null ) {
return null ;
}
return LocusIdCompat . toLocusIdCompat ( locusId ) ;
}
@NonNull
public static Notification [ ] getNotificationArrayFromBundle ( @NonNull Bundle bundle , @NonNull String str ) {
2021-07-24 02:37:17 +00:00
Parcelable [ ] parcelableArray = bundle . getParcelableArray ( str ) ;
if ( ( parcelableArray instanceof Notification [ ] ) | | parcelableArray = = null ) {
return ( Notification [ ] ) parcelableArray ;
}
Notification [ ] notificationArr = new Notification [ parcelableArray . length ] ;
for ( int i = 0 ; i < parcelableArray . length ; i + + ) {
notificationArr [ i ] = ( Notification ) parcelableArray [ i ] ;
}
bundle . putParcelableArray ( str , notificationArr ) ;
return notificationArr ;
}
2021-09-21 07:33:49 +00:00
public static boolean getOngoing ( @NonNull Notification notification ) {
return ( notification . flags & 2 ) ! = 0 ;
}
public static boolean getOnlyAlertOnce ( @NonNull Notification notification ) {
return ( notification . flags & 8 ) ! = 0 ;
}
@NonNull
public static List < Person > getPeople ( @NonNull Notification notification ) {
ArrayList arrayList = new ArrayList ( ) ;
if ( Build . VERSION . SDK_INT > = 28 ) {
ArrayList parcelableArrayList = notification . extras . getParcelableArrayList ( EXTRA_PEOPLE_LIST ) ;
if ( parcelableArrayList ! = null & & ! parcelableArrayList . isEmpty ( ) ) {
Iterator it = parcelableArrayList . iterator ( ) ;
while ( it . hasNext ( ) ) {
arrayList . add ( Person . fromAndroidPerson ( ( android . app . Person ) it . next ( ) ) ) ;
}
}
} else {
String [ ] stringArray = notification . extras . getStringArray ( EXTRA_PEOPLE ) ;
if ( ! ( stringArray = = null | | stringArray . length = = 0 ) ) {
for ( String str : stringArray ) {
arrayList . add ( new Person . Builder ( ) . setUri ( str ) . build ( ) ) ;
}
}
}
return arrayList ;
}
@Nullable
public static Notification getPublicVersion ( @NonNull Notification notification ) {
return notification . publicVersion ;
}
@Nullable
public static CharSequence getSettingsText ( @NonNull Notification notification ) {
if ( Build . VERSION . SDK_INT > = 26 ) {
return notification . getSettingsText ( ) ;
}
return null ;
}
@Nullable
public static String getShortcutId ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
if ( Build . VERSION . SDK_INT > = 26 ) {
return notification . getShortcutId ( ) ;
}
return null ;
}
2021-09-21 07:33:49 +00:00
@RequiresApi ( 19 )
public static boolean getShowWhen ( @NonNull Notification notification ) {
return notification . extras . getBoolean ( EXTRA_SHOW_WHEN ) ;
}
@Nullable
public static String getSortKey ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
return notification . getSortKey ( ) ;
}
2021-09-21 07:33:49 +00:00
@Nullable
@RequiresApi ( 19 )
public static CharSequence getSubText ( @NonNull Notification notification ) {
return notification . extras . getCharSequence ( EXTRA_SUB_TEXT ) ;
}
public static long getTimeoutAfter ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
if ( Build . VERSION . SDK_INT > = 26 ) {
return notification . getTimeoutAfter ( ) ;
}
return 0 ;
}
2021-09-21 07:33:49 +00:00
@RequiresApi ( 19 )
public static boolean getUsesChronometer ( @NonNull Notification notification ) {
return notification . extras . getBoolean ( EXTRA_SHOW_CHRONOMETER ) ;
}
public static int getVisibility ( @NonNull Notification notification ) {
return notification . visibility ;
}
public static boolean isGroupSummary ( @NonNull Notification notification ) {
2021-07-24 02:37:17 +00:00
return ( notification . flags & 512 ) ! = 0 ;
}
}