MD5 校验值:8df004f6dd2453bdf1d8ecd51cca1137
BrazeNotificationStyleFactory.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.braze.push; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.drawable.Icon; import android.os.Build; import android.os.Bundle; import android.widget.RemoteViews; import androidx.core.app.o; import com.braze.Braze; import com.braze.IBrazeDeeplinkHandler; import com.braze.configuration.BrazeConfigurationProvider; import com.braze.enums.BrazeDateFormat; import com.braze.enums.BrazeViewBounds; import com.braze.models.push.BrazeNotificationPayload; import com.braze.push.support.HtmlUtils; import com.braze.support.BrazeImageUtils; import com.braze.support.BrazeLogger; import com.braze.support.DateTimeUtils; import com.braze.support.IntentUtils; import com.braze.ui.BrazeDeeplinkHandler; import com.braze.ui.R$id; import com.braze.ui.R$layout; import java.util.List; import java.util.Map; import kotlin.jvm.internal.h; import kotlin.jvm.internal.p; import tg.r; public class BrazeNotificationStyleFactory { public static final Companion Companion = new Companion(null); public static final class Companion { public Companion(h hVar) { this(); } private final PendingIntent createStoryPageClickedPendingIntent(Context context, BrazeNotificationPayload brazeNotificationPayload, BrazeNotificationPayload.PushStoryPage pushStoryPage) { Intent intent = new Intent("com.braze.action.BRAZE_STORY_CLICKED").setClass(context, NotificationTrampolineActivity.class); p.f(intent, "Intent(Constants.BRAZE_S…lineActivity::class.java)"); intent.setFlags(intent.getFlags() | BrazeDeeplinkHandler.Companion.getInstance().getIntentFlags(IBrazeDeeplinkHandler.IntentFlagPurpose.NOTIFICATION_PUSH_STORY_PAGE_CLICK)); intent.putExtras(brazeNotificationPayload.getNotificationExtras()); intent.putExtra("braze_action_uri", pushStoryPage.getDeeplink()); intent.putExtra("braze_action_use_webview", pushStoryPage.getUseWebview()); intent.putExtra("braze_story_page_id", pushStoryPage.getStoryPageId()); intent.putExtra("braze_campaign_id", pushStoryPage.getCampaignId()); intent.putExtra("nid", BrazeNotificationUtils.getNotificationId(brazeNotificationPayload)); PendingIntent activity = PendingIntent.getActivity(context, IntentUtils.getRequestCode(), intent, IntentUtils.getImmutablePendingIntentFlags()); p.f(activity, "getActivity(\n …tentFlags()\n )"); return activity; } private final PendingIntent createStoryTraversedPendingIntent(Context context, Bundle bundle, int i10) { Intent intent = new Intent("com.braze.action.STORY_TRAVERSE").setClass(context, BrazeNotificationUtils.getNotificationReceiverClass()); p.f(intent, "Intent(Constants.BRAZE_S…otificationReceiverClass)"); if (bundle != null) { bundle.putInt("braze_story_index", i10); intent.putExtras(bundle); } PendingIntent broadcast = PendingIntent.getBroadcast(context, IntentUtils.getRequestCode(), intent, 1073741824 | IntentUtils.getImmutablePendingIntentFlags()); p.f(broadcast, "getBroadcast(\n … flags\n )"); return broadcast; } private final boolean isRemoteViewNotificationAvailableSpaceConstrained(Context context) { if (Build.VERSION.SDK_INT >= 31 && context.getApplicationContext().getApplicationInfo().targetSdkVersion >= 31) { return true; } return false; } private final boolean populatePushStoryPage(RemoteViews remoteViews, BrazeNotificationPayload brazeNotificationPayload, BrazeNotificationPayload.PushStoryPage pushStoryPage) { boolean t10; String subtitle; boolean t11; boolean t12; Context context = brazeNotificationPayload.getContext(); if (context == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$populatePushStoryPage$1.INSTANCE, 3, (Object) null); return false; } BrazeConfigurationProvider configurationProvider = brazeNotificationPayload.getConfigurationProvider(); if (configurationProvider == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$populatePushStoryPage$2.INSTANCE, 3, (Object) null); return false; } String bitmapUrl = pushStoryPage.getBitmapUrl(); if (bitmapUrl != null) { t10 = r.t(bitmapUrl); if (!t10) { Bitmap pushBitmapFromUrl = Braze.Companion.getInstance(context).getImageLoader().getPushBitmapFromUrl(context, brazeNotificationPayload.getNotificationExtras(), bitmapUrl, BrazeViewBounds.NOTIFICATION_ONE_IMAGE_STORY); if (pushBitmapFromUrl == null) { return false; } remoteViews.setImageViewBitmap(R$id.com_braze_story_image_view, pushBitmapFromUrl); String title = pushStoryPage.getTitle(); if (title != null) { t12 = r.t(title); if (!t12) { remoteViews.setTextViewText(R$id.com_braze_story_text_view, HtmlUtils.getHtmlSpannedTextIfEnabled(title, configurationProvider)); remoteViews.setInt(R$id.com_braze_story_text_view_container, "setGravity", pushStoryPage.getTitleGravity()); subtitle = pushStoryPage.getSubtitle(); if (subtitle != null) { t11 = r.t(subtitle); if (!t11) { remoteViews.setTextViewText(R$id.com_braze_story_text_view_small, HtmlUtils.getHtmlSpannedTextIfEnabled(subtitle, configurationProvider)); remoteViews.setInt(R$id.com_braze_story_text_view_small_container, "setGravity", pushStoryPage.getSubtitleGravity()); remoteViews.setOnClickPendingIntent(R$id.com_braze_story_relative_layout, createStoryPageClickedPendingIntent(context, brazeNotificationPayload, pushStoryPage)); return true; } } remoteViews.setInt(R$id.com_braze_story_text_view_small_container, "setVisibility", 8); remoteViews.setOnClickPendingIntent(R$id.com_braze_story_relative_layout, createStoryPageClickedPendingIntent(context, brazeNotificationPayload, pushStoryPage)); return true; } } remoteViews.setInt(R$id.com_braze_story_text_view_container, "setVisibility", 8); subtitle = pushStoryPage.getSubtitle(); if (subtitle != null) { } remoteViews.setInt(R$id.com_braze_story_text_view_small_container, "setVisibility", 8); remoteViews.setOnClickPendingIntent(R$id.com_braze_story_relative_layout, createStoryPageClickedPendingIntent(context, brazeNotificationPayload, pushStoryPage)); return true; } } BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$populatePushStoryPage$3.INSTANCE, 3, (Object) null); return false; } public final o.b getBigPictureNotificationStyle(BrazeNotificationPayload payload) { String bigImageUrl; boolean t10; p.g(payload, "payload"); Context context = payload.getContext(); if (context != null && (bigImageUrl = payload.getBigImageUrl()) != null) { t10 = r.t(bigImageUrl); if (t10) { return null; } Bitmap pushBitmapFromUrl = Braze.Companion.getInstance(context).getImageLoader().getPushBitmapFromUrl(context, payload.getNotificationExtras(), bigImageUrl, BrazeViewBounds.NOTIFICATION_EXPANDED_IMAGE); if (pushBitmapFromUrl == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationStyleFactory$Companion$getBigPictureNotificationStyle$1(bigImageUrl), 3, (Object) null); return null; } try { if (pushBitmapFromUrl.getWidth() > pushBitmapFromUrl.getHeight()) { int pixelsFromDensityAndDp = BrazeImageUtils.getPixelsFromDensityAndDp(BrazeImageUtils.getDensityDpi(context), 192); int i10 = pixelsFromDensityAndDp * 2; int displayWidthPixels = BrazeImageUtils.getDisplayWidthPixels(context); if (i10 > displayWidthPixels) { i10 = displayWidthPixels; } try { pushBitmapFromUrl = Bitmap.createScaledBitmap(pushBitmapFromUrl, i10, pixelsFromDensityAndDp, true); } catch (Exception e10) { BrazeLogger.INSTANCE.brazelog(this, BrazeLogger.Priority.E, e10, BrazeNotificationStyleFactory$Companion$getBigPictureNotificationStyle$2.INSTANCE); } } if (pushBitmapFromUrl == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, BrazeLogger.Priority.I, (Throwable) null, BrazeNotificationStyleFactory$Companion$getBigPictureNotificationStyle$3.INSTANCE, 2, (Object) null); return null; } o.b bVar = new o.b(); bVar.b(pushBitmapFromUrl); setBigPictureSummaryAndTitle(bVar, payload); return bVar; } catch (Exception e11) { BrazeLogger.INSTANCE.brazelog(this, BrazeLogger.Priority.E, e11, BrazeNotificationStyleFactory$Companion$getBigPictureNotificationStyle$4.INSTANCE); return null; } } return null; } public final o.c getBigTextNotificationStyle(BrazeNotificationPayload payload) { CharSequence htmlSpannedTextIfEnabled; p.g(payload, "payload"); o.c cVar = new o.c(); BrazeConfigurationProvider configurationProvider = payload.getConfigurationProvider(); if (configurationProvider == null) { return cVar; } String contentText = payload.getContentText(); if (contentText != null && (htmlSpannedTextIfEnabled = HtmlUtils.getHtmlSpannedTextIfEnabled(contentText, configurationProvider)) != null) { cVar.a(htmlSpannedTextIfEnabled); } String bigSummaryText = payload.getBigSummaryText(); if (bigSummaryText != null) { cVar.c(HtmlUtils.getHtmlSpannedTextIfEnabled(bigSummaryText, configurationProvider)); } String bigTitleText = payload.getBigTitleText(); if (bigTitleText != null) { cVar.b(HtmlUtils.getHtmlSpannedTextIfEnabled(bigTitleText, configurationProvider)); } return cVar; } public final o.h getConversationalPushStyle(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); try { Map<String, BrazeNotificationPayload.ConversationPerson> conversationPersonMap = payload.getConversationPersonMap(); BrazeNotificationPayload.ConversationPerson conversationPerson = conversationPersonMap.get(payload.getConversationReplyPersonId()); if (conversationPerson == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$getConversationalPushStyle$1.INSTANCE, 3, (Object) null); return null; } o.h hVar = new o.h(conversationPerson.getPerson()); for (BrazeNotificationPayload.ConversationMessage conversationMessage : payload.getConversationMessages()) { BrazeNotificationPayload.ConversationPerson conversationPerson2 = conversationPersonMap.get(conversationMessage.getPersonId()); if (conversationPerson2 == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationStyleFactory$Companion$getConversationalPushStyle$2(conversationMessage), 3, (Object) null); return null; } hVar.b(conversationMessage.getMessage(), conversationMessage.getTimestamp(), conversationPerson2.getPerson()); } boolean z10 = true; if (conversationPersonMap.size() <= 1) { z10 = false; } hVar.h(z10); notificationBuilder.E(payload.getConversationShortcutId()); return hVar; } catch (Exception e10) { BrazeLogger.INSTANCE.brazelog(this, BrazeLogger.Priority.E, e10, BrazeNotificationStyleFactory$Companion$getConversationalPushStyle$3.INSTANCE); return null; } } public final o.i getInlineImageStyle(BrazeNotificationPayload payload, o.e notificationBuilder) { boolean t10; int i10; ApplicationInfo applicationInfo; p.g(payload, "payload"); p.g(notificationBuilder, "notificationBuilder"); Context context = payload.getContext(); if (context == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$getInlineImageStyle$1.INSTANCE, 3, (Object) null); return null; } String bigImageUrl = payload.getBigImageUrl(); if (bigImageUrl != null) { t10 = r.t(bigImageUrl); if (!t10) { Bundle notificationExtras = payload.getNotificationExtras(); Bitmap pushBitmapFromUrl = Braze.Companion.getInstance(context).getImageLoader().getPushBitmapFromUrl(context, notificationExtras, bigImageUrl, BrazeViewBounds.NOTIFICATION_INLINE_PUSH_IMAGE); if (pushBitmapFromUrl == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$getInlineImageStyle$3.INSTANCE, 3, (Object) null); return null; } boolean isRemoteViewNotificationAvailableSpaceConstrained = isRemoteViewNotificationAvailableSpaceConstrained(context); String packageName = context.getPackageName(); if (isRemoteViewNotificationAvailableSpaceConstrained) { i10 = R$layout.com_braze_push_inline_image_constrained; } else { i10 = R$layout.com_braze_notification_inline_image; } RemoteViews remoteViews = new RemoteViews(packageName, i10); BrazeConfigurationProvider brazeConfigurationProvider = new BrazeConfigurationProvider(context); Icon createWithResource = Icon.createWithResource(context, brazeConfigurationProvider.getSmallNotificationIconResourceId()); p.f(createWithResource, "createWithResource(\n …nResourceId\n )"); Integer accentColor = payload.getAccentColor(); if (accentColor != null) { createWithResource.setTint(accentColor.intValue()); } remoteViews.setImageViewIcon(R$id.com_braze_inline_image_push_app_icon, createWithResource); PackageManager packageManager = context.getPackageManager(); try { if (Build.VERSION.SDK_INT >= 33) { applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), PackageManager.ApplicationInfoFlags.of(0L)); } else { applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0); } p.f(applicationInfo, "{\n if (Bu… }\n }"); CharSequence applicationLabel = packageManager.getApplicationLabel(applicationInfo); p.e(applicationLabel, "null cannot be cast to non-null type kotlin.String"); remoteViews.setTextViewText(R$id.com_braze_inline_image_push_app_name_text, HtmlUtils.getHtmlSpannedTextIfEnabled((String) applicationLabel, brazeConfigurationProvider)); remoteViews.setTextViewText(R$id.com_braze_inline_image_push_time_text, DateTimeUtils.formatDateNow(BrazeDateFormat.CLOCK_12_HOUR)); String string = notificationExtras.getString("t"); if (string != null) { remoteViews.setTextViewText(R$id.com_braze_inline_image_push_title_text, HtmlUtils.getHtmlSpannedTextIfEnabled(string, brazeConfigurationProvider)); } String string2 = notificationExtras.getString("a"); if (string2 != null) { remoteViews.setTextViewText(R$id.com_braze_inline_image_push_content_text, HtmlUtils.getHtmlSpannedTextIfEnabled(string2, brazeConfigurationProvider)); } notificationBuilder.t(remoteViews); if (isRemoteViewNotificationAvailableSpaceConstrained) { notificationBuilder.x(pushBitmapFromUrl); return new o.g(); } remoteViews.setImageViewBitmap(R$id.com_braze_inline_image_push_side_image, pushBitmapFromUrl); return new NoOpSentinelStyle(); } catch (PackageManager.NameNotFoundException e10) { BrazeLogger.INSTANCE.brazelog(this, BrazeLogger.Priority.E, e10, BrazeNotificationStyleFactory$Companion$getInlineImageStyle$applicationInfo$1.INSTANCE); return null; } } } BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$getInlineImageStyle$2.INSTANCE, 3, (Object) null); return null; } public final o.i getNotificationStyle(o.e notificationBuilder, BrazeNotificationPayload payload) { o.i iVar; p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); if (payload.isPushStory() && payload.getContext() != null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$getNotificationStyle$1.INSTANCE, 3, (Object) null); iVar = getStoryStyle(notificationBuilder, payload); } else if (payload.isConversationalPush() && Build.VERSION.SDK_INT >= 25) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$getNotificationStyle$2.INSTANCE, 3, (Object) null); iVar = getConversationalPushStyle(notificationBuilder, payload); } else if (payload.getBigImageUrl() != null) { if (Build.VERSION.SDK_INT >= 23 && payload.isInlineImagePush()) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$getNotificationStyle$3.INSTANCE, 3, (Object) null); iVar = getInlineImageStyle(payload, notificationBuilder); } else { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$getNotificationStyle$4.INSTANCE, 3, (Object) null); iVar = getBigPictureNotificationStyle(payload); } } else { iVar = null; } if (iVar == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$getNotificationStyle$5.INSTANCE, 3, (Object) null); return getBigTextNotificationStyle(payload); } return iVar; } public final o.g getStoryStyle(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); Context context = payload.getContext(); if (context == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$getStoryStyle$1.INSTANCE, 3, (Object) null); return null; } List<BrazeNotificationPayload.PushStoryPage> pushStoryPages = payload.getPushStoryPages(); int pushStoryPageIndex = payload.getPushStoryPageIndex(); BrazeNotificationPayload.PushStoryPage pushStoryPage = pushStoryPages.get(pushStoryPageIndex); RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R$layout.com_braze_push_story_one_image); if (!populatePushStoryPage(remoteViews, payload, pushStoryPage)) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, BrazeLogger.Priority.W, (Throwable) null, BrazeNotificationStyleFactory$Companion$getStoryStyle$2.INSTANCE, 2, (Object) null); return null; } Bundle notificationExtras = payload.getNotificationExtras(); o.g gVar = new o.g(); int size = pushStoryPages.size(); remoteViews.setOnClickPendingIntent(R$id.com_braze_story_button_previous, createStoryTraversedPendingIntent(context, notificationExtras, ((pushStoryPageIndex - 1) + size) % size)); remoteViews.setOnClickPendingIntent(R$id.com_braze_story_button_next, createStoryTraversedPendingIntent(context, notificationExtras, (pushStoryPageIndex + 1) % size)); notificationBuilder.s(remoteViews); notificationBuilder.B(true); return gVar; } public final void setBigPictureSummaryAndTitle(o.b bigPictureNotificationStyle, BrazeNotificationPayload payload) { String contentText; p.g(bigPictureNotificationStyle, "bigPictureNotificationStyle"); p.g(payload, "payload"); BrazeConfigurationProvider configurationProvider = payload.getConfigurationProvider(); if (configurationProvider == null) { return; } String bigSummaryText = payload.getBigSummaryText(); String bigTitleText = payload.getBigTitleText(); String summaryText = payload.getSummaryText(); if (bigSummaryText != null) { bigPictureNotificationStyle.d(HtmlUtils.getHtmlSpannedTextIfEnabled(bigSummaryText, configurationProvider)); } if (bigTitleText != null) { bigPictureNotificationStyle.c(HtmlUtils.getHtmlSpannedTextIfEnabled(bigTitleText, configurationProvider)); } if (summaryText == null && bigSummaryText == null && (contentText = payload.getContentText()) != null) { bigPictureNotificationStyle.d(HtmlUtils.getHtmlSpannedTextIfEnabled(contentText, configurationProvider)); } } public final void setStyleIfSupported(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); o.i notificationStyle = getNotificationStyle(notificationBuilder, payload); if (!(notificationStyle instanceof NoOpSentinelStyle)) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationStyleFactory$Companion$setStyleIfSupported$1.INSTANCE, 3, (Object) null); notificationBuilder.I(notificationStyle); } } private Companion() { } } public static final class NoOpSentinelStyle extends o.i { } }