imToken v2.14.1版本的 MD5 值为:83050b2c91219b46832c8336279e7878
以下内容为反编译后的 ArticleWebView.java 源代码,内容仅作参考
package com.helpscout.beacon.internal.presentation.ui.article;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Build;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.exifinterface.media.ExifInterface;
import com.facebook.common.callercontext.ContextChain;
import com.facebook.react.uimanager.ViewProps;
import com.helpscout.beacon.internal.core.model.ArticleDetailsApi;
import com.helpscout.beacon.ui.R;
import f0.a;
import io.sentry.SentryBaseEvent;
import io.sentry.Session;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.Lazy;
import kotlin.LazyKt;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Lambda;
import kotlin.jvm.internal.Reflection;
import org.koin.core.Koin;
import org.koin.core.component.KoinComponent;
import org.koin.core.component.KoinScopeComponent;
import org.koin.core.qualifier.Qualifier;
import org.koin.mp.KoinPlatformTools;
@Metadata(bv = {}, d1 = {"\u0000z\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u000f\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\b\u0000\u0018\u00002\u00020\u00012\u00020\u0002:\u0001\u0004B\u001b\u0012\u0006\u0010;\u001a\u00020:\u0012\n\b\u0002\u0010=\u001a\u0004\u0018\u00010<¢\u0006\u0004\b>\u0010?J\b\u0010\u0004\u001a\u00020\u0003H\u0002J\u0018\u0010\u0004\u001a\u00020\u00032\u0006\u0010\u0006\u001a\u00020\u00052\u0006\u0010\b\u001a\u00020\u0007H\u0002J\u0010\u0010\u000b\u001a\u00020\u00032\u0006\u0010\n\u001a\u00020\tH\u0016J\b\u0010\f\u001a\u00020\u0003H\u0016J\u0010\u0010\u0010\u001a\u00020\u000f2\u0006\u0010\u000e\u001a\u00020\rH\u0016J\u0010\u0010\u0013\u001a\u00020\u00032\u0006\u0010\u0012\u001a\u00020\u0011H\u0007J6\u0010\u0004\u001a\u00020\u00032\u0006\u0010\u0015\u001a\u00020\u00142\u0012\u0010\u0018\u001a\u000e\u0012\u0004\u0012\u00020\u0017\u0012\u0004\u0012\u00020\u00030\u00162\u0012\u0010\u0019\u001a\u000e\u0012\u0004\u0012\u00020\u000f\u0012\u0004\u0012\u00020\u00030\u0016R\u001b\u0010\u001e\u001a\u00020\u001a8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0004\u0010\u001b\u001a\u0004\b\u001c\u0010\u001dR\u001b\u0010#\u001a\u00020\u001f8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b \u0010\u001b\u001a\u0004\b!\u0010\"R\u0018\u0010'\u001a\u0004\u0018\u00010$8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b%\u0010&R\u0018\u0010\n\u001a\u0004\u0018\u00010\t8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b(\u0010)R\u0016\u0010,\u001a\u00020\u000f8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b*\u0010+R\u0018\u0010/\u001a\u0004\u0018\u00010\u00178\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b-\u0010.R\"\u0010\u0018\u001a\u000e\u0012\u0004\u0012\u00020\u0017\u0012\u0004\u0012\u00020\u00030\u00168\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b0\u00101R\"\u00103\u001a\u000e\u0012\u0004\u0012\u00020\u000f\u0012\u0004\u0012\u00020\u00030\u00168\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b2\u00101R\u0014\u00107\u001a\u0002048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b5\u00106R\u0016\u00109\u001a\u00020\u000f8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b8\u0010+¨\u0006@"}, d2 = {"Lcom/helpscout/beacon/internal/presentation/ui/article/ArticleWebView;", "Landroid/webkit/WebView;", "Lf0/a;", "", "a", "Landroid/content/res/Resources;", "resources", "Landroid/webkit/WebSettings;", "settings", "Landroid/graphics/Canvas;", "canvas", "onDraw", "destroy", "Landroid/view/MotionEvent;", "ev", "", "onTouchEvent", "Landroid/webkit/WebViewClient;", "client", "setupWebSettings", "Lcom/helpscout/beacon/internal/core/model/ArticleDetailsApi;", "articleApi", "Lkotlin/Function1;", "", "linkClick", "loadingCallback", "Lb0/d;", "Lkotlin/Lazy;", "getBeaconStringResolver", "()Lb0/d;", "beaconStringResolver", "Lp0/e;", "b", "getArticleBuilder", "()Lp0/e;", "articleBuilder", "Landroid/graphics/Bitmap;", "c", "Landroid/graphics/Bitmap;", "bitmap", "d", "Landroid/graphics/Canvas;", "e", "Z", "useSoftwareLayer", "f", "Ljava/lang/String;", "currentUrl", "g", "Lkotlin/jvm/functions/Function1;", "h", "loading", "Ljava/lang/Runnable;", ContextChain.TAG_INFRA, "Ljava/lang/Runnable;", "mNotifyPageRenderedInHardwareLayer", "j", ViewProps.VISIBLE, "Landroid/content/Context;", "context", "Landroid/util/AttributeSet;", Session.JsonKeys.ATTRS, "<init>", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", "beacon_release"}, k = 1, mv = {1, 7, 1})
public final class ArticleWebView extends WebView implements f0.a {
private final Lazy f1167a;
private final Lazy f1168b;
private Bitmap f1169c;
private Canvas f1170d;
private boolean f1171e;
private String f1172f;
private Function1<? super String, Unit> f1173g;
private Function1<? super Boolean, Unit> f1174h;
private final Runnable f1175i;
private boolean f1176j;
public Map<Integer, View> f1177k;
@Metadata(bv = {}, d1 = {"\u00006\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\b\u0086\u0004\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0011\u0010\u0012J&\u0010\t\u001a\u00020\b2\b\u0010\u0003\u001a\u0004\u0018\u00010\u00022\b\u0010\u0005\u001a\u0004\u0018\u00010\u00042\b\u0010\u0007\u001a\u0004\u0018\u00010\u0006H\u0016J\u0018\u0010\n\u001a\u00020\b2\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004H\u0016J\u001c\u0010\u000e\u001a\u00020\r2\b\u0010\u0003\u001a\u0004\u0018\u00010\u00022\b\u0010\f\u001a\u0004\u0018\u00010\u000bH\u0017J\u0018\u0010\u000e\u001a\u00020\r2\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004H\u0016J\u001e\u0010\u0010\u001a\u0004\u0018\u00010\u000f2\b\u0010\u0003\u001a\u0004\u0018\u00010\u00022\b\u0010\f\u001a\u0004\u0018\u00010\u000bH\u0016¨\u0006\u0013"}, d2 = {"Lcom/helpscout/beacon/internal/presentation/ui/article/ArticleWebView$a;", "Landroid/webkit/WebViewClient;", "Landroid/webkit/WebView;", "view", "", "url", "Landroid/graphics/Bitmap;", "favicon", "", "onPageStarted", "onPageFinished", "Landroid/webkit/WebResourceRequest;", SentryBaseEvent.JsonKeys.REQUEST, "", "shouldOverrideUrlLoading", "Landroid/webkit/WebResourceResponse;", "shouldInterceptRequest", "<init>", "(Lcom/helpscout/beacon/internal/presentation/ui/article/ArticleWebView;)V", "beacon_release"}, k = 1, mv = {1, 7, 1})
public final class a extends WebViewClient {
public a() {
}
@Override
public void onPageFinished(WebView view, String url) {
Intrinsics.checkNotNullParameter(view, "view");
Intrinsics.checkNotNullParameter(url, "url");
ArticleWebView.this.f1174h.invoke(Boolean.FALSE);
super.onPageFinished(view, url);
}
@Override
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
ArticleWebView.this.f1174h.invoke(Boolean.TRUE);
super.onPageStarted(webView, str, bitmap);
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
Uri url;
return Intrinsics.areEqual((webResourceRequest == null || (url = webResourceRequest.getUrl()) == null) ? null : url.getLastPathSegment(), "favicon.ico") ? new WebResourceResponse("image/png", null, null) : super.shouldInterceptRequest(webView, webResourceRequest);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
Uri url;
String uri;
if (webResourceRequest == null || (url = webResourceRequest.getUrl()) == null || (uri = url.toString()) == null) {
return true;
}
ArticleWebView.this.f1173g.invoke(uri);
return true;
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Intrinsics.checkNotNullParameter(view, "view");
Intrinsics.checkNotNullParameter(url, "url");
ArticleWebView.this.f1173g.invoke(url);
return true;
}
}
@Metadata(bv = {}, d1 = {"\u0000\u000e\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"", "it", "", "a", "(Ljava/lang/String;)V"}, k = 3, mv = {1, 7, 1})
static final class b extends Lambda implements Function1<String, Unit> {
public static final b f1179a = new b();
b() {
super(1);
}
public final void a(String it) {
Intrinsics.checkNotNullParameter(it, "it");
}
@Override
public Unit invoke(String str) {
a(str);
return Unit.INSTANCE;
}
}
@Metadata(bv = {}, d1 = {"\u0000\u000e\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"", "it", "", "a", "(Z)V"}, k = 3, mv = {1, 7, 1})
static final class c extends Lambda implements Function1<Boolean, Unit> {
public static final c f1180a = new c();
c() {
super(1);
}
public final void a(boolean z2) {
}
@Override
public Unit invoke(Boolean bool) {
a(bool.booleanValue());
return Unit.INSTANCE;
}
}
@Metadata(d1 = {"\u0000\f\n\u0002\b\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\u0010\u0000\u001a\u0002H\u0001\"\n\b\u0000\u0010\u0001\u0018\u0001*\u00020\u0002H\n¢\u0006\u0004\b\u0003\u0010\u0004¨\u0006\u0005"}, d2 = {"<anonymous>", ExifInterface.GPS_DIRECTION_TRUE, "", "invoke", "()Ljava/lang/Object;", "org/koin/core/component/KoinComponentKt$inject$1"}, k = 3, mv = {1, 7, 1}, xi = 48)
public static final class d extends Lambda implements Function0<b0.d> {
final KoinComponent f1181a;
final Qualifier f1182b;
final Function0 f1183c;
public d(KoinComponent koinComponent, Qualifier qualifier, Function0 function0) {
super(0);
this.f1181a = koinComponent;
this.f1182b = qualifier;
this.f1183c = function0;
}
@Override
public final b0.d invoke() {
KoinComponent koinComponent = this.f1181a;
return (koinComponent instanceof KoinScopeComponent ? ((KoinScopeComponent) koinComponent).getScope() : koinComponent.getKoin().getScopeRegistry().getRootScope()).get(Reflection.getOrCreateKotlinClass(b0.d.class), this.f1182b, this.f1183c);
}
}
@Metadata(d1 = {"\u0000\f\n\u0002\b\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\u0010\u0000\u001a\u0002H\u0001\"\n\b\u0000\u0010\u0001\u0018\u0001*\u00020\u0002H\n¢\u0006\u0004\b\u0003\u0010\u0004¨\u0006\u0005"}, d2 = {"<anonymous>", ExifInterface.GPS_DIRECTION_TRUE, "", "invoke", "()Ljava/lang/Object;", "org/koin/core/component/KoinComponentKt$inject$1"}, k = 3, mv = {1, 7, 1}, xi = 48)
public static final class e extends Lambda implements Function0<p0.e> {
final KoinComponent f1184a;
final Qualifier f1185b;
final Function0 f1186c;
public e(KoinComponent koinComponent, Qualifier qualifier, Function0 function0) {
super(0);
this.f1184a = koinComponent;
this.f1185b = qualifier;
this.f1186c = function0;
}
@Override
public final p0.e invoke() {
KoinComponent koinComponent = this.f1184a;
return (koinComponent instanceof KoinScopeComponent ? ((KoinScopeComponent) koinComponent).getScope() : koinComponent.getKoin().getScopeRegistry().getRootScope()).get(Reflection.getOrCreateKotlinClass(p0.e.class), this.f1185b, this.f1186c);
}
}
public ArticleWebView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
Intrinsics.checkNotNullParameter(context, "context");
this.f1177k = new LinkedHashMap();
this.f1167a = LazyKt.lazy(KoinPlatformTools.INSTANCE.defaultLazyMode(), (Function0) new d(this, null, null));
this.f1168b = LazyKt.lazy(KoinPlatformTools.INSTANCE.defaultLazyMode(), (Function0) new e(this, null, null));
this.f1173g = b.f1179a;
this.f1174h = c.f1180a;
this.f1175i = new Runnable() {
@Override
public final void run() {
ArticleWebView.c(ArticleWebView.this);
}
};
setupWebSettings(new a());
}
public ArticleWebView(Context context, AttributeSet attributeSet, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this(context, (i2 & 2) != 0 ? null : attributeSet);
}
private final void a() {
if (this.f1169c != null) {
this.f1169c = null;
this.f1170d = null;
}
}
private final void a(Resources resources, WebSettings webSettings) {
float f2 = resources.getConfiguration().fontScale;
int integer = resources.getInteger(R.integer.hs_beacon_conversation_desired_font_size_px);
webSettings.setTextZoom((int) (((webSettings.getTextZoom() * integer) / resources.getInteger(R.integer.hs_beacon_conversation_unstyled_font_size_px)) * f2));
}
public static final void c(ArticleWebView this$0) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.f1171e = false;
this$0.a();
this$0.invalidate();
}
private final p0.e getArticleBuilder() {
return (p0.e) this.f1168b.getValue();
}
private final b0.d getBeaconStringResolver() {
return (b0.d) this.f1167a.getValue();
}
public final void a(ArticleDetailsApi articleApi, Function1<? super String, Unit> linkClick, Function1<? super Boolean, Unit> loadingCallback) {
Intrinsics.checkNotNullParameter(articleApi, "articleApi");
Intrinsics.checkNotNullParameter(linkClick, "linkClick");
Intrinsics.checkNotNullParameter(loadingCallback, "loadingCallback");
if (Intrinsics.areEqual(this.f1172f, articleApi.getUrl())) {
loadingCallback.invoke(Boolean.FALSE);
return;
}
this.f1172f = articleApi.getUrl();
this.f1173g = linkClick;
this.f1174h = loadingCallback;
loadDataWithBaseURL("https://cookie-compliance-url.com/", getArticleBuilder().a(articleApi, getBeaconStringResolver().U0()), "text/html", "utf-8", null);
}
@Override
public void destroy() {
a();
removeCallbacks(this.f1175i);
super.destroy();
}
@Override
public Koin getKoin() {
return a.C0091a.a(this);
}
@Override
public void onDraw(Canvas canvas) {
Intrinsics.checkNotNullParameter(canvas, "canvas");
super.onDraw(canvas);
if (!this.f1171e || !this.f1176j || getWidth() <= 0 || getHeight() <= 0) {
return;
}
if (this.f1169c == null) {
try {
this.f1169c = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565);
Bitmap bitmap = this.f1169c;
Intrinsics.checkNotNull(bitmap);
this.f1170d = new Canvas(bitmap);
} catch (OutOfMemoryError unused) {
this.f1169c = null;
this.f1170d = null;
this.f1171e = false;
}
}
if (this.f1169c != null) {
int scrollX = getScrollX();
int scrollY = getScrollY();
Canvas canvas2 = this.f1170d;
Intrinsics.checkNotNull(canvas2);
canvas2.save();
Canvas canvas3 = this.f1170d;
Intrinsics.checkNotNull(canvas3);
canvas3.translate(-scrollX, -scrollY);
super.onDraw(this.f1170d);
Canvas canvas4 = this.f1170d;
Intrinsics.checkNotNull(canvas4);
canvas4.restore();
Bitmap bitmap2 = this.f1169c;
Intrinsics.checkNotNull(bitmap2);
canvas.drawBitmap(bitmap2, scrollX, scrollY, (Paint) null);
}
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
Intrinsics.checkNotNullParameter(ev, "ev");
if (ev.getActionMasked() == 5) {
requestDisallowInterceptTouchEvent(true);
}
return super.onTouchEvent(ev);
}
public final void setupWebSettings(WebViewClient client) {
int i2;
Intrinsics.checkNotNullParameter(client, "client");
WebSettings settings = getSettings();
settings.setAppCacheEnabled(true);
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(false);
settings.setAllowFileAccess(false);
settings.setJavaScriptCanOpenWindowsAutomatically(false);
settings.setBlockNetworkImage(false);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
int i3 = Build.VERSION.SDK_INT;
if (i3 >= 23) {
i2 = i3 >= 23 ? 2 : 0;
Intrinsics.checkNotNullExpressionValue(settings, "settings.apply {\n …E\n }\n }");
Resources resources = getResources();
Intrinsics.checkNotNullExpressionValue(resources, "resources");
a(resources, settings);
setWebViewClient(client);
}
settings.setMixedContentMode(i2);
Intrinsics.checkNotNullExpressionValue(settings, "settings.apply {\n …E\n }\n }");
Resources resources2 = getResources();
Intrinsics.checkNotNullExpressionValue(resources2, "resources");
a(resources2, settings);
setWebViewClient(client);
}
}