Kredit Buddy v1.0.3版本的 MD5 值为:f4b596abe8f2517a065859e5f8fec243
以下内容为反编译后的 WebViewManager.java 源代码,内容仅作参考
package com.onesignal.inAppMessages.internal.display.impl;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback;
import android.webkit.WebView;
import com.onesignal.common.JSONObjectExtensionsKt;
import com.onesignal.common.ViewUtils;
import com.onesignal.common.threading.ThreadUtilsKt;
import com.onesignal.core.internal.application.IActivityLifecycleHandler;
import com.onesignal.core.internal.application.IApplicationService;
import com.onesignal.debug.LogLevel;
import com.onesignal.debug.internal.logging.Logging;
import com.onesignal.inAppMessages.internal.InAppMessage;
import com.onesignal.inAppMessages.internal.InAppMessageClickResult;
import com.onesignal.inAppMessages.internal.InAppMessageContent;
import com.onesignal.inAppMessages.internal.InAppMessagePage;
import com.onesignal.inAppMessages.internal.display.impl.InAppMessageView;
import com.onesignal.inAppMessages.internal.lifecycle.IInAppLifecycleService;
import com.onesignal.inAppMessages.internal.prompt.IInAppMessagePromptFactory;
import com.onesignal.session.internal.outcomes.impl.OutcomeConstants;
import java.util.Arrays;
import java.util.Locale;
import kotlin.Metadata;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.text.StringsKt__IndentKt;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.Dispatchers;
import kotlinx.coroutines.sync.Mutex;
import kotlinx.coroutines.sync.MutexKt;
import okhttp3.HttpUrl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONException;
import org.json.JSONObject;
@Metadata
@TargetApi
public final class WebViewManager implements IActivityLifecycleHandler {
@NotNull
public static final String EVENT_TYPE_ACTION_TAKEN = "action_taken";
@NotNull
public static final String EVENT_TYPE_KEY = "type";
@NotNull
public static final String EVENT_TYPE_PAGE_CHANGE = "page_change";
@NotNull
public static final String EVENT_TYPE_RENDERING_COMPLETE = "rendering_complete";
@NotNull
public static final String EVENT_TYPE_RESIZE = "resize";
@NotNull
public static final String GET_PAGE_META_DATA_JS_FUNCTION = "getPageMetaData()";
@NotNull
public static final String IAM_DISPLAY_LOCATION_KEY = "displayLocation";
@NotNull
public static final String IAM_DRAG_TO_DISMISS_DISABLED_KEY = "dragToDismissDisabled";
@NotNull
public static final String IAM_PAGE_META_DATA_KEY = "pageMetaData";
@NotNull
public static final String JS_OBJ_NAME = "OSAndroid";
@NotNull
public static final String SAFE_AREA_JS_OBJECT = "{\n top: %d,\n bottom: %d,\n right: %d,\n left: %d,\n}";
@NotNull
public static final String SET_SAFE_AREA_INSETS_JS_FUNCTION = "setSafeAreaInsets(%s)";
@NotNull
public static final String SET_SAFE_AREA_INSETS_SCRIPT = "\n\n<script>\n setSafeAreaInsets(%s);\n</script>";
@NotNull
private final IApplicationService _applicationService;
@NotNull
private final IInAppLifecycleService _lifecycle;
@NotNull
private final IInAppMessagePromptFactory _promptFactory;
@NotNull
private Activity activity;
private boolean closing;
@Nullable
private String currentActivityName;
private boolean dismissFired;
@Nullable
private Integer lastPageHeight;
@NotNull
private final InAppMessage message;
@NotNull
private final InAppMessageContent messageContent;
@Nullable
private InAppMessageView messageView;
@NotNull
private final Mutex messageViewMutex;
@Nullable
private OSWebView webView;
@NotNull
public static final Companion Companion = new Companion(null);
private static final int MARGIN_PX_SIZE = ViewUtils.INSTANCE.dpToPx(24);
@Metadata
public static final class Companion {
private Companion() {
}
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
@Metadata
public final class OSJavaScriptInterface {
public OSJavaScriptInterface() {
}
private final Position getDisplayLocation(JSONObject jSONObject) {
Position position = Position.FULL_SCREEN;
try {
if (jSONObject.has(WebViewManager.IAM_DISPLAY_LOCATION_KEY) && !Intrinsics.a(jSONObject.get(WebViewManager.IAM_DISPLAY_LOCATION_KEY), HttpUrl.FRAGMENT_ENCODE_SET)) {
String optString = jSONObject.optString(WebViewManager.IAM_DISPLAY_LOCATION_KEY, "FULL_SCREEN");
Intrinsics.e(optString, "jsonObject.optString(\n … )");
Locale locale = Locale.getDefault();
Intrinsics.e(locale, "getDefault()");
String upperCase = optString.toUpperCase(locale);
Intrinsics.e(upperCase, "this as java.lang.String).toUpperCase(locale)");
return Position.valueOf(upperCase);
}
return position;
} catch (JSONException e2) {
e2.printStackTrace();
return position;
}
}
private final boolean getDragToDismissDisabled(JSONObject jSONObject) {
try {
return jSONObject.getBoolean(WebViewManager.IAM_DRAG_TO_DISMISS_DISABLED_KEY);
} catch (JSONException unused) {
return false;
}
}
private final int getPageHeightData(JSONObject jSONObject) {
try {
WebViewManager webViewManager = WebViewManager.this;
Activity activity = webViewManager.activity;
JSONObject jSONObject2 = jSONObject.getJSONObject(WebViewManager.IAM_PAGE_META_DATA_KEY);
Intrinsics.e(jSONObject2, "jsonObject.getJSONObject(IAM_PAGE_META_DATA_KEY)");
return webViewManager.pageRectToViewHeight(activity, jSONObject2);
} catch (JSONException unused) {
return -1;
}
}
private final void handleActionTaken(JSONObject jSONObject) throws JSONException {
JSONObject body = jSONObject.getJSONObject("body");
Intrinsics.e(body, "body");
String safeString = JSONObjectExtensionsKt.safeString(body, OutcomeConstants.OUTCOME_ID);
WebViewManager.this.closing = body.getBoolean("close");
if (WebViewManager.this.message.isPreview()) {
WebViewManager.this._lifecycle.messageActionOccurredOnPreview(WebViewManager.this.message, new InAppMessageClickResult(body, WebViewManager.this._promptFactory));
} else if (safeString != null) {
WebViewManager.this._lifecycle.messageActionOccurredOnMessage(WebViewManager.this.message, new InAppMessageClickResult(body, WebViewManager.this._promptFactory));
}
if (WebViewManager.this.closing) {
WebViewManager.this.backgroundDismissAndAwaitNextMessage();
}
}
private final void handlePageChange(JSONObject jSONObject) throws JSONException {
WebViewManager.this._lifecycle.messagePageChanged(WebViewManager.this.message, new InAppMessagePage(jSONObject));
}
private final void handleRenderComplete(JSONObject jSONObject) {
int pageHeightData;
Position displayLocation = getDisplayLocation(jSONObject);
if (displayLocation == Position.FULL_SCREEN) {
pageHeightData = -1;
} else {
pageHeightData = getPageHeightData(jSONObject);
}
boolean dragToDismissDisabled = getDragToDismissDisabled(jSONObject);
WebViewManager.this.messageContent.setDisplayLocation(displayLocation);
WebViewManager.this.messageContent.setPageHeight(pageHeightData);
WebViewManager.this.createNewInAppMessageView(dragToDismissDisabled);
}
@JavascriptInterface
public final void postMessage(@NotNull String message) {
Intrinsics.f(message, "message");
try {
Logging.debug$default("OSJavaScriptInterface:postMessage: " + message, null, 2, null);
JSONObject jSONObject = new JSONObject(message);
String string = jSONObject.getString(WebViewManager.EVENT_TYPE_KEY);
if (string != null) {
switch (string.hashCode()) {
case -1484226720:
if (string.equals(WebViewManager.EVENT_TYPE_PAGE_CHANGE)) {
handlePageChange(jSONObject);
return;
}
return;
case -934437708:
string.equals(WebViewManager.EVENT_TYPE_RESIZE);
return;
case 42998156:
if (string.equals(WebViewManager.EVENT_TYPE_RENDERING_COMPLETE)) {
handleRenderComplete(jSONObject);
return;
}
return;
case 1851145598:
if (string.equals(WebViewManager.EVENT_TYPE_ACTION_TAKEN)) {
InAppMessageView inAppMessageView = WebViewManager.this.messageView;
boolean z = false;
if (inAppMessageView != null && !inAppMessageView.isDragging()) {
z = true;
}
if (z) {
handleActionTaken(jSONObject);
return;
}
return;
}
return;
default:
return;
}
}
} catch (JSONException e2) {
e2.printStackTrace();
}
}
}
@Metadata
public enum Position {
TOP_BANNER,
BOTTOM_BANNER,
CENTER_MODAL,
FULL_SCREEN;
@Metadata
public class WhenMappings {
public static final int[] $EnumSwitchMapping$0;
static {
int[] iArr = new int[Position.values().length];
iArr[Position.TOP_BANNER.ordinal()] = 1;
iArr[Position.BOTTOM_BANNER.ordinal()] = 2;
$EnumSwitchMapping$0 = iArr;
}
}
public final boolean isBanner() {
int i2 = WhenMappings.$EnumSwitchMapping$0[ordinal()];
return i2 == 1 || i2 == 2;
}
}
public WebViewManager(@NotNull InAppMessage message, @NotNull Activity activity, @NotNull InAppMessageContent messageContent, @NotNull IInAppLifecycleService _lifecycle, @NotNull IApplicationService _applicationService, @NotNull IInAppMessagePromptFactory _promptFactory) {
Intrinsics.f(message, "message");
Intrinsics.f(activity, "activity");
Intrinsics.f(messageContent, "messageContent");
Intrinsics.f(_lifecycle, "_lifecycle");
Intrinsics.f(_applicationService, "_applicationService");
Intrinsics.f(_promptFactory, "_promptFactory");
this.message = message;
this.activity = activity;
this.messageContent = messageContent;
this._lifecycle = _lifecycle;
this._applicationService = _applicationService;
this._promptFactory = _promptFactory;
this.messageViewMutex = MutexKt.b(false, 1, null);
}
private final void blurryRenderingWebViewForKitKatWorkAround(WebView webView) {
}
public final Object calculateHeightAndShowWebViewAfterNewActivity(Continuation<? super Unit> continuation) {
WebViewManager$calculateHeightAndShowWebViewAfterNewActivity$1 webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1;
int i2;
final WebViewManager webViewManager;
WebViewManager webViewManager2;
if (continuation instanceof WebViewManager$calculateHeightAndShowWebViewAfterNewActivity$1) {
webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1 = (WebViewManager$calculateHeightAndShowWebViewAfterNewActivity$1) continuation;
int i3 = webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.label;
if ((i3 & Integer.MIN_VALUE) != 0) {
webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.label = i3 - Integer.MIN_VALUE;
Object obj = webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.result;
Object d2 = IntrinsicsKt.d();
i2 = webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.label;
if (i2 == 0) {
if (i2 != 1) {
if (i2 != 2) {
if (i2 == 3) {
webViewManager2 = (WebViewManager) webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.L$0;
ResultKt.b(obj);
webViewManager = webViewManager2;
OSWebView oSWebView = webViewManager.webView;
Intrinsics.c(oSWebView);
oSWebView.evaluateJavascript(GET_PAGE_META_DATA_JS_FUNCTION, new ValueCallback() {
@Override
public final void onReceiveValue(Object obj2) {
WebViewManager.m22calculateHeightAndShowWebViewAfterNewActivity$lambda0(WebViewManager.this, (String) obj2);
}
});
return Unit.f25611a;
}
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
webViewManager = (WebViewManager) webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.L$0;
ResultKt.b(obj);
webViewManager.setWebViewToMaxSize(webViewManager.activity);
if (webViewManager.messageContent.isFullBleed()) {
webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.L$0 = webViewManager;
webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.label = 3;
if (webViewManager.updateSafeAreaInsets(webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1) == d2) {
return d2;
}
webViewManager2 = webViewManager;
webViewManager = webViewManager2;
}
OSWebView oSWebView2 = webViewManager.webView;
Intrinsics.c(oSWebView2);
oSWebView2.evaluateJavascript(GET_PAGE_META_DATA_JS_FUNCTION, new ValueCallback() {
@Override
public final void onReceiveValue(Object obj2) {
WebViewManager.m22calculateHeightAndShowWebViewAfterNewActivity$lambda0(WebViewManager.this, (String) obj2);
}
});
return Unit.f25611a;
}
ResultKt.b(obj);
return Unit.f25611a;
}
ResultKt.b(obj);
InAppMessageView inAppMessageView = this.messageView;
if (inAppMessageView == null) {
return Unit.f25611a;
}
Intrinsics.c(inAppMessageView);
if (inAppMessageView.getDisplayPosition() == Position.FULL_SCREEN && !this.messageContent.isFullBleed()) {
webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.label = 1;
if (showMessageView(null, webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1) == d2) {
return d2;
}
return Unit.f25611a;
}
Logging.debug$default("In app message new activity, calculate height and show ", null, 2, null);
IApplicationService iApplicationService = this._applicationService;
webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.L$0 = this;
webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.label = 2;
if (iApplicationService.waitUntilActivityReady(webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1) == d2) {
return d2;
}
webViewManager = this;
webViewManager.setWebViewToMaxSize(webViewManager.activity);
if (webViewManager.messageContent.isFullBleed()) {
}
OSWebView oSWebView22 = webViewManager.webView;
Intrinsics.c(oSWebView22);
oSWebView22.evaluateJavascript(GET_PAGE_META_DATA_JS_FUNCTION, new ValueCallback() {
@Override
public final void onReceiveValue(Object obj2) {
WebViewManager.m22calculateHeightAndShowWebViewAfterNewActivity$lambda0(WebViewManager.this, (String) obj2);
}
});
return Unit.f25611a;
}
}
webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1 = new WebViewManager$calculateHeightAndShowWebViewAfterNewActivity$1(this, continuation);
Object obj2 = webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.result;
Object d22 = IntrinsicsKt.d();
i2 = webViewManager$calculateHeightAndShowWebViewAfterNewActivity$1.label;
if (i2 == 0) {
}
}
public static final void m22calculateHeightAndShowWebViewAfterNewActivity$lambda0(WebViewManager this$0, String str) {
Intrinsics.f(this$0, "this$0");
try {
ThreadUtilsKt.suspendifyOnThread$default(0, new WebViewManager$calculateHeightAndShowWebViewAfterNewActivity$2$1(this$0, this$0.pageRectToViewHeight(this$0.activity, new JSONObject(str)), null), 1, null);
} catch (JSONException e2) {
e2.printStackTrace();
}
}
private final void enableWebViewRemoteDebugging() {
if (Logging.atLogLevel(LogLevel.DEBUG)) {
WebView.setWebContentsDebuggingEnabled(true);
}
}
private final int getWebViewMaxSizeX(Activity activity) {
if (this.messageContent.isFullBleed()) {
return ViewUtils.INSTANCE.getFullbleedWindowWidth(activity);
}
return ViewUtils.INSTANCE.getWindowWidth(activity) - (MARGIN_PX_SIZE * 2);
}
private final int getWebViewMaxSizeY(Activity activity) {
int i2;
if (this.messageContent.isFullBleed()) {
i2 = 0;
} else {
i2 = MARGIN_PX_SIZE * 2;
}
return ViewUtils.INSTANCE.getWindowHeight(activity) - i2;
}
public final int pageRectToViewHeight(Activity activity, JSONObject jSONObject) {
try {
int dpToPx = ViewUtils.INSTANCE.dpToPx(jSONObject.getJSONObject("rect").getInt("height"));
Logging.debug$default("getPageHeightData:pxHeight: " + dpToPx, null, 2, null);
int webViewMaxSizeY = getWebViewMaxSizeY(activity);
if (dpToPx > webViewMaxSizeY) {
Logging.debug$default("getPageHeightData:pxHeight is over screen max: " + webViewMaxSizeY, null, 2, null);
return webViewMaxSizeY;
}
return dpToPx;
} catch (JSONException e2) {
Logging.error("pageRectToViewHeight could not get page height", e2);
return -1;
}
}
private final void setMessageView(InAppMessageView inAppMessageView) {
this.messageView = inAppMessageView;
}
private final void setWebViewToMaxSize(Activity activity) {
OSWebView oSWebView = this.webView;
Intrinsics.c(oSWebView);
oSWebView.layout(0, 0, getWebViewMaxSizeX(activity), getWebViewMaxSizeY(activity));
}
public final Object showMessageView(Integer num, Continuation<? super Unit> continuation) {
WebViewManager$showMessageView$1 webViewManager$showMessageView$1;
int i2;
WebViewManager webViewManager;
Integer num2;
Mutex mutex;
WebViewManager webViewManager2;
InAppMessageView inAppMessageView;
InAppMessageView inAppMessageView2;
Unit unit;
try {
if (continuation instanceof WebViewManager$showMessageView$1) {
webViewManager$showMessageView$1 = (WebViewManager$showMessageView$1) continuation;
int i3 = webViewManager$showMessageView$1.label;
if ((i3 & Integer.MIN_VALUE) != 0) {
webViewManager$showMessageView$1.label = i3 - Integer.MIN_VALUE;
Object obj = webViewManager$showMessageView$1.result;
Object d2 = IntrinsicsKt.d();
i2 = webViewManager$showMessageView$1.label;
if (i2 == 0) {
if (i2 != 1) {
if (i2 != 2) {
if (i2 != 3) {
if (i2 == 4) {
mutex = (Mutex) webViewManager$showMessageView$1.L$0;
ResultKt.b(obj);
unit = Unit.f25611a;
mutex.b(null);
return unit;
}
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
mutex = (Mutex) webViewManager$showMessageView$1.L$1;
webViewManager2 = (WebViewManager) webViewManager$showMessageView$1.L$0;
ResultKt.b(obj);
inAppMessageView2 = webViewManager2.messageView;
if (inAppMessageView2 != null) {
webViewManager$showMessageView$1.L$0 = mutex;
webViewManager$showMessageView$1.L$1 = null;
webViewManager$showMessageView$1.L$2 = null;
webViewManager$showMessageView$1.label = 4;
if (inAppMessageView2.checkIfShouldDismiss(webViewManager$showMessageView$1) == d2) {
return d2;
}
unit = Unit.f25611a;
mutex.b(null);
return unit;
}
unit = null;
mutex.b(null);
return unit;
}
mutex = (Mutex) webViewManager$showMessageView$1.L$1;
webViewManager2 = (WebViewManager) webViewManager$showMessageView$1.L$0;
ResultKt.b(obj);
inAppMessageView = webViewManager2.messageView;
if (inAppMessageView != null) {
Activity activity = webViewManager2.activity;
webViewManager$showMessageView$1.L$0 = webViewManager2;
webViewManager$showMessageView$1.L$1 = mutex;
webViewManager$showMessageView$1.L$2 = null;
webViewManager$showMessageView$1.label = 3;
if (inAppMessageView.showView(activity, webViewManager$showMessageView$1) == d2) {
return d2;
}
}
inAppMessageView2 = webViewManager2.messageView;
if (inAppMessageView2 != null) {
}
} else {
mutex = (Mutex) webViewManager$showMessageView$1.L$2;
num2 = (Integer) webViewManager$showMessageView$1.L$1;
webViewManager = (WebViewManager) webViewManager$showMessageView$1.L$0;
ResultKt.b(obj);
}
} else {
ResultKt.b(obj);
Mutex mutex2 = this.messageViewMutex;
webViewManager$showMessageView$1.L$0 = this;
webViewManager$showMessageView$1.L$1 = num;
webViewManager$showMessageView$1.L$2 = mutex2;
webViewManager$showMessageView$1.label = 1;
if (mutex2.a(null, webViewManager$showMessageView$1) == d2) {
return d2;
}
webViewManager = this;
num2 = num;
mutex = mutex2;
}
if (webViewManager.messageView != null) {
Logging.warn$default("No messageView found to update a with a new height.", null, 2, null);
Unit unit2 = Unit.f25611a;
mutex.b(null);
return unit2;
}
Logging.debug$default("In app message, showing first one with height: " + num2, null, 2, null);
InAppMessageView inAppMessageView3 = webViewManager.messageView;
if (inAppMessageView3 != null) {
OSWebView oSWebView = webViewManager.webView;
Intrinsics.c(oSWebView);
inAppMessageView3.setWebView(oSWebView);
}
if (num2 != null) {
webViewManager.lastPageHeight = num2;
InAppMessageView inAppMessageView4 = webViewManager.messageView;
if (inAppMessageView4 != null) {
int intValue = num2.intValue();
webViewManager$showMessageView$1.L$0 = webViewManager;
webViewManager$showMessageView$1.L$1 = mutex;
webViewManager$showMessageView$1.L$2 = null;
webViewManager$showMessageView$1.label = 2;
if (inAppMessageView4.updateHeight(intValue, webViewManager$showMessageView$1) == d2) {
return d2;
}
}
}
webViewManager2 = webViewManager;
inAppMessageView = webViewManager2.messageView;
if (inAppMessageView != null) {
}
inAppMessageView2 = webViewManager2.messageView;
if (inAppMessageView2 != null) {
}
}
}
if (i2 == 0) {
}
if (webViewManager.messageView != null) {
}
} catch (Throwable th) {
num.b(null);
throw th;
}
webViewManager$showMessageView$1 = new WebViewManager$showMessageView$1(this, continuation);
Object obj2 = webViewManager$showMessageView$1.result;
Object d22 = IntrinsicsKt.d();
i2 = webViewManager$showMessageView$1.label;
}
public final Object updateSafeAreaInsets(Continuation<? super Unit> continuation) {
Object g2 = BuildersKt.g(Dispatchers.c(), new WebViewManager$updateSafeAreaInsets$2(this, null), continuation);
return g2 == IntrinsicsKt.d() ? g2 : Unit.f25611a;
}
public final void backgroundDismissAndAwaitNextMessage() {
ThreadUtilsKt.suspendifyOnThread$default(0, new WebViewManager$backgroundDismissAndAwaitNextMessage$1(this, null), 1, null);
}
public final void createNewInAppMessageView(boolean z) {
this.lastPageHeight = Integer.valueOf(this.messageContent.getPageHeight());
OSWebView oSWebView = this.webView;
Intrinsics.c(oSWebView);
setMessageView(new InAppMessageView(oSWebView, this.messageContent, z));
InAppMessageView inAppMessageView = this.messageView;
Intrinsics.c(inAppMessageView);
inAppMessageView.setMessageController(new InAppMessageView.InAppMessageViewListener() {
@Override
public void onMessageWasDismissed() {
IApplicationService iApplicationService;
WebViewManager.this._lifecycle.messageWasDismissed(WebViewManager.this.message);
iApplicationService = WebViewManager.this._applicationService;
iApplicationService.removeActivityLifecycleHandler(this);
}
@Override
public void onMessageWasDisplayed() {
WebViewManager.this._lifecycle.messageWasDisplayed(WebViewManager.this.message);
}
@Override
public void onMessageWillDismiss() {
WebViewManager.this._lifecycle.messageWillDismiss(WebViewManager.this.message);
}
});
this._applicationService.addActivityLifecycleHandler(this);
}
@Nullable
public final Object dismissAndAwaitNextMessage(@NotNull Continuation<? super Unit> continuation) {
WebViewManager$dismissAndAwaitNextMessage$1 webViewManager$dismissAndAwaitNextMessage$1;
int i2;
WebViewManager webViewManager;
if (continuation instanceof WebViewManager$dismissAndAwaitNextMessage$1) {
webViewManager$dismissAndAwaitNextMessage$1 = (WebViewManager$dismissAndAwaitNextMessage$1) continuation;
int i3 = webViewManager$dismissAndAwaitNextMessage$1.label;
if ((i3 & Integer.MIN_VALUE) != 0) {
webViewManager$dismissAndAwaitNextMessage$1.label = i3 - Integer.MIN_VALUE;
Object obj = webViewManager$dismissAndAwaitNextMessage$1.result;
Object d2 = IntrinsicsKt.d();
i2 = webViewManager$dismissAndAwaitNextMessage$1.label;
if (i2 == 0) {
if (i2 == 1) {
webViewManager = (WebViewManager) webViewManager$dismissAndAwaitNextMessage$1.L$0;
ResultKt.b(obj);
} else {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
} else {
ResultKt.b(obj);
InAppMessageView inAppMessageView = this.messageView;
if (inAppMessageView != null && !this.dismissFired) {
this.dismissFired = true;
this._lifecycle.messageWillDismiss(this.message);
webViewManager$dismissAndAwaitNextMessage$1.L$0 = this;
webViewManager$dismissAndAwaitNextMessage$1.label = 1;
if (inAppMessageView.dismissAndAwaitNextMessage(webViewManager$dismissAndAwaitNextMessage$1) == d2) {
return d2;
}
webViewManager = this;
} else {
return Unit.f25611a;
}
}
webViewManager.dismissFired = false;
webViewManager.setMessageView(null);
return Unit.f25611a;
}
}
webViewManager$dismissAndAwaitNextMessage$1 = new WebViewManager$dismissAndAwaitNextMessage$1(this, continuation);
Object obj2 = webViewManager$dismissAndAwaitNextMessage$1.result;
Object d22 = IntrinsicsKt.d();
i2 = webViewManager$dismissAndAwaitNextMessage$1.label;
if (i2 == 0) {
}
webViewManager.dismissFired = false;
webViewManager.setMessageView(null);
return Unit.f25611a;
}
@Override
public void onActivityAvailable(@NotNull Activity activity) {
Intrinsics.f(activity, "activity");
String str = this.currentActivityName;
this.activity = activity;
this.currentActivityName = activity.getLocalClassName();
Logging.debug$default("In app message activity available currentActivityName: " + this.currentActivityName + " lastActivityName: " + str, null, 2, null);
ThreadUtilsKt.suspendifyOnMain(new WebViewManager$onActivityAvailable$1(str, this, null));
}
@Override
public void onActivityStopped(@NotNull Activity activity) {
String f2;
Intrinsics.f(activity, "activity");
f2 = StringsKt__IndentKt.f("\n In app message activity stopped, cleaning views, currentActivityName: " + this.currentActivityName + "\n activity: " + this.activity + "\n messageView: " + this.messageView + "\n ");
Logging.debug$default(f2, null, 2, null);
if (this.messageView != null && Intrinsics.a(activity.getLocalClassName(), this.currentActivityName)) {
InAppMessageView inAppMessageView = this.messageView;
Intrinsics.c(inAppMessageView);
inAppMessageView.removeAllViews();
}
}
public final void setContentSafeAreaInsets(@NotNull InAppMessageContent content, @NotNull Activity activity) {
Intrinsics.f(content, "content");
Intrinsics.f(activity, "activity");
String contentHtml = content.getContentHtml();
int[] cutoutAndStatusBarInsets = ViewUtils.INSTANCE.getCutoutAndStatusBarInsets(activity);
StringCompanionObject stringCompanionObject = StringCompanionObject.f25864a;
String format = String.format(SAFE_AREA_JS_OBJECT, Arrays.copyOf(new Object[]{Integer.valueOf(cutoutAndStatusBarInsets[0]), Integer.valueOf(cutoutAndStatusBarInsets[1]), Integer.valueOf(cutoutAndStatusBarInsets[2]), Integer.valueOf(cutoutAndStatusBarInsets[3])}, 4));
Intrinsics.e(format, "format(format, *args)");
String format2 = String.format(SET_SAFE_AREA_INSETS_SCRIPT, Arrays.copyOf(new Object[]{format}, 1));
Intrinsics.e(format2, "format(format, *args)");
content.setContentHtml(contentHtml + format2);
}
@SuppressLint
@Nullable
public final Object setupWebView(@NotNull Activity activity, @NotNull String str, boolean z, @NotNull Continuation<? super Unit> continuation) {
WebViewManager$setupWebView$1 webViewManager$setupWebView$1;
int i2;
WebViewManager webViewManager;
if (continuation instanceof WebViewManager$setupWebView$1) {
webViewManager$setupWebView$1 = (WebViewManager$setupWebView$1) continuation;
int i3 = webViewManager$setupWebView$1.label;
if ((i3 & Integer.MIN_VALUE) != 0) {
webViewManager$setupWebView$1.label = i3 - Integer.MIN_VALUE;
Object obj = webViewManager$setupWebView$1.result;
Object d2 = IntrinsicsKt.d();
i2 = webViewManager$setupWebView$1.label;
if (i2 == 0) {
if (i2 == 1) {
str = (String) webViewManager$setupWebView$1.L$2;
activity = (Activity) webViewManager$setupWebView$1.L$1;
webViewManager = (WebViewManager) webViewManager$setupWebView$1.L$0;
ResultKt.b(obj);
} else {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
} else {
ResultKt.b(obj);
enableWebViewRemoteDebugging();
OSWebView oSWebView = new OSWebView(activity);
this.webView = oSWebView;
Intrinsics.c(oSWebView);
oSWebView.setOverScrollMode(2);
OSWebView oSWebView2 = this.webView;
Intrinsics.c(oSWebView2);
oSWebView2.setVerticalScrollBarEnabled(false);
OSWebView oSWebView3 = this.webView;
Intrinsics.c(oSWebView3);
oSWebView3.setHorizontalScrollBarEnabled(false);
OSWebView oSWebView4 = this.webView;
Intrinsics.c(oSWebView4);
oSWebView4.getSettings().setJavaScriptEnabled(true);
OSWebView oSWebView5 = this.webView;
Intrinsics.c(oSWebView5);
oSWebView5.addJavascriptInterface(new OSJavaScriptInterface(), JS_OBJ_NAME);
if (z) {
OSWebView oSWebView6 = this.webView;
Intrinsics.c(oSWebView6);
oSWebView6.setSystemUiVisibility(3074);
if (Build.VERSION.SDK_INT >= 30) {
OSWebView oSWebView7 = this.webView;
Intrinsics.c(oSWebView7);
oSWebView7.setFitsSystemWindows(false);
}
}
OSWebView oSWebView8 = this.webView;
Intrinsics.c(oSWebView8);
blurryRenderingWebViewForKitKatWorkAround(oSWebView8);
this._lifecycle.messageWillDisplay(this.message);
IApplicationService iApplicationService = this._applicationService;
webViewManager$setupWebView$1.L$0 = this;
webViewManager$setupWebView$1.L$1 = activity;
webViewManager$setupWebView$1.L$2 = str;
webViewManager$setupWebView$1.label = 1;
if (iApplicationService.waitUntilActivityReady(webViewManager$setupWebView$1) == d2) {
return d2;
}
webViewManager = this;
}
webViewManager.setWebViewToMaxSize(activity);
OSWebView oSWebView9 = webViewManager.webView;
Intrinsics.c(oSWebView9);
oSWebView9.loadData(str, "text/html; charset=utf-8", "base64");
return Unit.f25611a;
}
}
webViewManager$setupWebView$1 = new WebViewManager$setupWebView$1(this, continuation);
Object obj2 = webViewManager$setupWebView$1.result;
Object d22 = IntrinsicsKt.d();
i2 = webViewManager$setupWebView$1.label;
if (i2 == 0) {
}
webViewManager.setWebViewToMaxSize(activity);
OSWebView oSWebView92 = webViewManager.webView;
Intrinsics.c(oSWebView92);
oSWebView92.loadData(str, "text/html; charset=utf-8", "base64");
return Unit.f25611a;
}
}