正在查看: Mint v5.7.3 应用的 TBLClassicUnit.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Mint v5.7.3 应用的 TBLClassicUnit.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.taboola.android;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Insets;
import android.graphics.Point;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowMetrics;
import android.webkit.ConsoleMessage;
import android.webkit.CookieManager;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AbsoluteLayout;
import android.widget.FrameLayout;
import androidx.annotation.ColorInt;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.k2;
import com.snowplowanalytics.snowplow.tracker.constants.Parameters;
import com.taboola.android.f;
import com.taboola.android.global_components.advertisingid.TBLAdvertisingIdInfo;
import com.taboola.android.global_components.network.TBLNetworkManager;
import com.taboola.android.listeners.TBLClassicListener;
import com.taboola.android.listeners.TBLWebListener;
import com.taboola.android.tblweb.TBLWebPage;
import com.taboola.android.tblweb.TBLWebUnit;
import com.taboola.android.tblweb.TBLWebViewManager;
import com.taboola.android.utils.TBLSdkDetailsHelper;
import com.taboola.android.utils.q;
import com.thoughtbot.expandablerecyclerview.BuildConfig;
import in.juspay.hyper.constants.LogCategory;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
@Keep
public class TBLClassicUnit extends FrameLayout implements com.taboola.android.k {
public static final String ABOUT_BLANK_URL = "about:blank";
private static final int DEFAULT_TEXT_ZOOM = 100;
public static final int DUMMY_HEIGHT = 2;
static final String HTML_TEMPLATE_FILE_NAME = "template.html";
public static final int INVALID_HEIGHT = -3;
public static final int ORIENTATION_UNDEFINED = 0;
private static final String TAG = "TBLClassicUnit";
private static final String WEBVIEW_ERROR = "WEBVIEW_ERROR";
static int sMaxWidgetSizeGpu;
private com.taboola.android.b mCCTabHandler;
private String mCcpaOptout;
private boolean mCheckHiddenWidget;
private boolean mDisableLocationCollection;
HashMap<String, String> mFetchContentParams;
boolean mForceHeightMode;
String mFramework;
boolean mHasDispatchedLoadEvent;
Integer mInitialHeight;
Handler mInvalidationHandler;
private boolean mIsAddedToPage;
Boolean mIsAutoResizeHeight;
boolean mIsScrollEnabled;
private boolean mIsStoriesEnabled;
long mLastExecuteTimeForAnalytics;
@Nullable
String mMediatedVia;
String mMode;
n mOnAttachStateChangeListener;
ViewTreeObserver.OnScrollChangedListener mOnScrollChangedListener;
int mOrientation;
String mPageId;
String mPageType;
String mPageUrl;
List<Map> mPassedActionList;
String mPlacement;
private int mPlacementType;
String mProgressBarColor;
float mProgressBarDuration;
String mPublisherName;
Runnable mRedoResizeForGpu;
int mScreenMaxHeight;
com.taboola.android.i mScrollChangedListenerImpl;
private boolean mShouldAllowFileAccessInWebView;
boolean mShouldAllowNonOrganicClickOverride;
private boolean mShouldAutoCollapseOnError;
private boolean mShouldHideScrollBars;
boolean mShouldKeepDependencies;
private boolean mShouldKeepViewId;
private boolean mShouldMobileLoaderUseNewErrorCodeSystem;
TBLAdvertisingIdInfo mTBLAdvertisingIdInfo;
private com.taboola.android.c mTBLClassicFetchManager;
private TBLClassicListener mTBLClassicListener;
private ve.b mTBLConfigManager;
@Nullable
private com.taboola.android.e mTBLFetchOnQueueResult;
com.taboola.android.global_components.monitor.a mTBLMonitorHelper;
private TBLNetworkManager mTBLNetworkManager;
TBLPublisherInfo mTBLPublisherInfo;
private TBLWebUnit mTBLWebUnit;
@Nullable
private com.taboola.android.l mTBLWebView;
String mTargetType;
private com.taboola.android.m mTemplateJS;
private final Runnable mTimeOutRunnableTask;
Handler mUIHandler;
private HashMap<String, String> mUnrecognizedExtraProperties;
String mUserId;
String mViewId;
private FrameLayout.LayoutParams mWebViewParams;
int mWidgetMaxHeight;
String mWidgetStyle;
boolean shouldCheckCacheSize;
boolean shouldIgnoreScrollEvents;
class a implements Runnable {
final int a;
a(int i) {
this.a = i;
}
@Override
public void run() {
TBLClassicUnit.this.resizeWidget(this.a);
}
}
class b implements f.c {
b() {
}
@Override
public void a(int i) {
TBLClassicUnit.sMaxWidgetSizeGpu = i;
TBLClassicUnit tBLClassicUnit = TBLClassicUnit.this;
tBLClassicUnit.mWidgetMaxHeight = Math.min(i, TBLSdkDetailsHelper.getDisplayHeight(tBLClassicUnit.getContext()) * 2);
com.taboola.android.utils.g.a(TBLClassicUnit.TAG, "onMaxWidgetSizeRetrieved(): mWidgetMaxHeight = [" + TBLClassicUnit.this.mWidgetMaxHeight + "], sMaxWidgetSizeGpu = [" + TBLClassicUnit.sMaxWidgetSizeGpu + "]");
}
}
class c implements Runnable {
final WebView a;
c(WebView webView) {
this.a = webView;
}
@Override
public void run() {
WebView webView = this.a;
if (webView != null) {
webView.invalidate();
com.taboola.android.utils.g.a(TBLClassicUnit.TAG, "invalidateWebView executed");
}
}
}
static class d {
static final int[] a;
static {
int[] iArr = new int[com.taboola.android.utils.c.values().length];
a = iArr;
try {
iArr[com.taboola.android.utils.c.ALLOW_NON_ORGANIC_OVERRIDE_PROP.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[com.taboola.android.utils.c.USE_ONLINE_TEMPLATE.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
a[com.taboola.android.utils.c.KEEP_DEPENDENCIES_PROP.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
a[com.taboola.android.utils.c.ENABLE_HORIZONTAL_SCROLL_PROP.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
a[com.taboola.android.utils.c.HIDE_SCROLLING_BARS.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
a[com.taboola.android.utils.c.ALLOW_FILE_ACCESS.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
a[com.taboola.android.utils.c.CCPA_DNS.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
a[com.taboola.android.utils.c.DISABLE_LOCATION_COLLECTION.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
try {
a[com.taboola.android.utils.c.DETAILED_ERROR_CODES.ordinal()] = 9;
} catch (NoSuchFieldError unused9) {
}
try {
a[com.taboola.android.utils.c.AUTO_COLLAPSE_ON_ERROR.ordinal()] = 10;
} catch (NoSuchFieldError unused10) {
}
try {
a[com.taboola.android.utils.c.VISIBLE_CHECK_HIDDEN_WIDGET.ordinal()] = 11;
} catch (NoSuchFieldError unused11) {
}
try {
a[com.taboola.android.utils.c.ENABLE_STORIES.ordinal()] = 12;
} catch (NoSuchFieldError unused12) {
}
try {
a[com.taboola.android.utils.c.UNRECOGNIZABLE.ordinal()] = 13;
} catch (NoSuchFieldError unused13) {
}
}
}
class e implements Runnable {
e() {
}
@Override
public void run() {
if (TBLClassicUnit.this.mTBLFetchOnQueueResult != null) {
TBLClassicUnit.this.mTBLFetchOnQueueResult.a(2);
TBLClassicUnit.this.mTBLFetchOnQueueResult = null;
}
}
}
class f extends TBLWebListener {
f() {
}
@Override
public void onEvent(int i, String str) {
if (TBLClassicUnit.this.mTBLClassicListener != null) {
TBLClassicUnit.this.mTBLClassicListener.onEvent(i, str);
}
}
@Override
public boolean onItemClick(String str, String str2, String str3, boolean z, String str4) {
if (TBLClassicUnit.this.mTBLClassicListener != null) {
return TBLClassicUnit.this.mTBLClassicListener.onItemClick(str, str2, str3, z, str4);
}
return true;
}
@Override
public void onOrientationChange(int i) {
TBLClassicUnit.this.onOrientationChange(q.a(i));
}
@Override
public void onRenderFailed(String str, String str2) {
com.taboola.android.utils.g.b(TBLClassicUnit.TAG, "onRenderFailed: " + str + " " + str2);
TBLClassicUnit.this.dispatchLoadFailed(str2);
}
@Override
public void onRenderSuccessful(String str, int i) {
com.taboola.android.utils.g.a(TBLClassicUnit.TAG, "onRenderSuccessful: " + str);
TBLClassicUnit.this.dispatchLoadSuccessful();
}
@Override
public void onResize(String str, int i) {
if (TBLClassicUnit.this.mPlacementType == 3) {
return;
}
TBLClassicUnit.this.resizeWidget(q.a(i));
if (TBLClassicUnit.this.mTBLClassicListener != null) {
TBLClassicUnit.this.mTBLClassicListener.onResize(i);
}
}
@Override
public void onUpdateContentCompleted() {
if (TBLClassicUnit.this.mTBLClassicListener != null) {
TBLClassicUnit.this.mTBLClassicListener.onUpdateContentCompleted();
}
}
}
class g extends WebViewClient {
g() {
}
@Override
public void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
}
@Override
public void onReceivedError(WebView webView, int i, String str, String str2) {
super.onReceivedError(webView, i, str, str2);
TBLClassicUnit.this.dispatchLoadFailed(str);
}
@Override
@TargetApi(23)
public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
onReceivedError(webView, webResourceError.getErrorCode(), webResourceError.getDescription().toString(), webResourceRequest.getUrl().toString());
}
}
class h extends WebChromeClient {
private final String a = WebChromeClient.class.getSimpleName();
h() {
}
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
com.taboola.android.utils.g.a(this.a, consoleMessage.message() + ", source: " + consoleMessage.sourceId() + " From line " + consoleMessage.lineNumber());
return true;
}
@Override
public boolean onJsAlert(WebView webView, String str, String str2, JsResult jsResult) {
com.taboola.android.utils.g.a(this.a, "onJsAlert :: " + str2);
return super.onJsAlert(webView, str, str2, jsResult);
}
}
class i implements Runnable {
i() {
}
@Override
public void run() {
if (TBLClassicUnit.this.mTBLWebView != null) {
TBLClassicUnit.this.mTBLWebView.getSettings().setAllowFileAccess(TBLClassicUnit.this.mShouldAllowFileAccessInWebView);
} else {
com.taboola.android.utils.g.b(TBLClassicUnit.TAG, "Failed to set allow file access, because tblWebView is null");
}
}
}
class j implements Runnable {
final com.taboola.android.l a;
j(com.taboola.android.l lVar) {
this.a = lVar;
}
@Override
public void run() {
TBLClassicUnit tBLClassicUnit = TBLClassicUnit.this;
tBLClassicUnit.shouldIgnoreScrollEvents = false;
tBLClassicUnit.invalidateWebView(this.a);
}
}
class k implements Runnable {
final com.taboola.android.l a;
k(com.taboola.android.l lVar) {
this.a = lVar;
}
@Override
public void run() {
TBLClassicUnit.this.invalidateWebView(this.a);
}
}
class l implements ViewTreeObserver.OnScrollChangedListener {
final Runnable a;
final Runnable b;
l(Runnable runnable, Runnable runnable2) {
this.a = runnable;
this.b = runnable2;
}
@Override
public void onScrollChanged() {
TBLClassicUnit tBLClassicUnit = TBLClassicUnit.this;
if (tBLClassicUnit.shouldIgnoreScrollEvents) {
return;
}
tBLClassicUnit.shouldIgnoreScrollEvents = true;
Handler handler = tBLClassicUnit.mInvalidationHandler;
if (handler != null) {
handler.postDelayed(this.a, 500L);
TBLClassicUnit.this.mInvalidationHandler.postDelayed(this.b, 5000L);
}
}
}
class m implements Runnable {
m() {
}
@Override
public void run() {
TBLClassicUnit.this.invalidate();
if (TBLClassicUnit.this.mTBLWebUnit == null) {
TBLClassicUnit.this.initTBLWebUnit();
}
TBLClassicUnit.this.mTBLWebUnit.scrollToTop();
if (TBLClassicUnit.this.mTBLWebView.getScrollviewParent() != null) {
TBLClassicUnit.this.mTBLWebView.getScrollviewParent().scrollTo(0, 0);
}
}
}
static class n implements View.OnAttachStateChangeListener {
WeakReference<TBLClassicUnit> a;
n(TBLClassicUnit tBLClassicUnit) {
if (this.a == null) {
this.a = new WeakReference<>(tBLClassicUnit);
}
}
public void a() {
this.a.clear();
this.a = null;
}
@Override
public void onViewAttachedToWindow(View view) {
}
@Override
public void onViewDetachedFromWindow(View view) {
WeakReference<TBLClassicUnit> weakReference = this.a;
if (weakReference == null || weakReference.get() == null) {
return;
}
this.a.get().clear();
}
}
public TBLClassicUnit(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.mCCTabHandler = null;
this.mHasDispatchedLoadEvent = false;
this.mShouldAllowNonOrganicClickOverride = false;
this.mShouldKeepDependencies = false;
this.shouldCheckCacheSize = false;
this.mProgressBarDuration = -1.0f;
this.shouldIgnoreScrollEvents = false;
this.mFetchContentParams = new HashMap<>();
this.mShouldAllowFileAccessInWebView = false;
this.mShouldMobileLoaderUseNewErrorCodeSystem = true;
this.mShouldAutoCollapseOnError = false;
this.mCheckHiddenWidget = true;
this.mIsStoriesEnabled = false;
this.mIsAddedToPage = false;
this.mLastExecuteTimeForAnalytics = 0L;
this.mTimeOutRunnableTask = new e();
constructXMLCommon(context, attributeSet);
}
public TBLClassicUnit(Context context, AttributeSet attributeSet, int i2) {
super(context, attributeSet, i2);
this.mCCTabHandler = null;
this.mHasDispatchedLoadEvent = false;
this.mShouldAllowNonOrganicClickOverride = false;
this.mShouldKeepDependencies = false;
this.shouldCheckCacheSize = false;
this.mProgressBarDuration = -1.0f;
this.shouldIgnoreScrollEvents = false;
this.mFetchContentParams = new HashMap<>();
this.mShouldAllowFileAccessInWebView = false;
this.mShouldMobileLoaderUseNewErrorCodeSystem = true;
this.mShouldAutoCollapseOnError = false;
this.mCheckHiddenWidget = true;
this.mIsStoriesEnabled = false;
this.mIsAddedToPage = false;
this.mLastExecuteTimeForAnalytics = 0L;
this.mTimeOutRunnableTask = new e();
constructXMLCommon(context, attributeSet);
}
TBLClassicUnit(Context context, com.taboola.android.c cVar, TBLClassicListener tBLClassicListener, TBLNetworkManager tBLNetworkManager, ve.b bVar, TBLPublisherInfo tBLPublisherInfo, TBLAdvertisingIdInfo tBLAdvertisingIdInfo, com.taboola.android.global_components.monitor.a aVar) {
super(context);
this.mCCTabHandler = null;
this.mHasDispatchedLoadEvent = false;
this.mShouldAllowNonOrganicClickOverride = false;
this.mShouldKeepDependencies = false;
this.shouldCheckCacheSize = false;
this.mProgressBarDuration = -1.0f;
this.shouldIgnoreScrollEvents = false;
this.mFetchContentParams = new HashMap<>();
this.mShouldAllowFileAccessInWebView = false;
this.mShouldMobileLoaderUseNewErrorCodeSystem = true;
this.mShouldAutoCollapseOnError = false;
this.mCheckHiddenWidget = true;
this.mIsStoriesEnabled = false;
this.mIsAddedToPage = false;
this.mLastExecuteTimeForAnalytics = 0L;
this.mTimeOutRunnableTask = new e();
this.mTBLMonitorHelper = aVar;
this.mTBLNetworkManager = tBLNetworkManager;
this.mTBLConfigManager = bVar;
this.mTBLPublisherInfo = tBLPublisherInfo;
this.mTBLAdvertisingIdInfo = tBLAdvertisingIdInfo;
this.mTBLClassicFetchManager = cVar;
this.mTBLClassicListener = tBLClassicListener;
this.mTemplateJS = new com.taboola.android.m();
this.mUIHandler = new Handler(Looper.getMainLooper());
com.taboola.android.l createWebView = createWebView();
if (createWebView != null) {
setWebView(createWebView);
} else {
com.taboola.android.utils.g.a(TAG, "Unable to set created webView to classicUnit because it is null");
}
}
private void constructXMLCommon(Context context, AttributeSet attributeSet) {
getGlobalComponentsStatically();
this.mTemplateJS = new com.taboola.android.m();
this.mUIHandler = new Handler(Looper.getMainLooper());
com.taboola.android.l createWebView = createWebView();
if (createWebView == null) {
com.taboola.android.utils.g.a(TAG, "Unable to set created webView to classicUnit because it is null");
return;
}
setWebView(createWebView);
parseXmlAttributes(context, attributeSet);
com.taboola.android.utils.g.a(TAG, "initialized basic components");
}
private void getGlobalComponentsStatically() {
ITBLImpl taboolaImpl = Taboola.getTaboolaImpl();
this.mTBLPublisherInfo = taboolaImpl.getPublisherInfo();
this.mTBLAdvertisingIdInfo = taboolaImpl.getAdvertisingIdInfo();
this.mTBLMonitorHelper = taboolaImpl.getMonitorHelper();
this.mTBLNetworkManager = taboolaImpl.getNetworkManager();
this.mTBLConfigManager = taboolaImpl.loadAndGetConfigManager();
}
private void initializeFeatures(String str) {
if (TextUtils.isEmpty(str)) {
com.taboola.android.utils.g.b(TAG, "initializeFeatures called with empty or null placement.");
return;
}
this.mShouldAllowNonOrganicClickOverride = this.mTBLConfigManager.h(str, "allowNonOrganicClickOverride", this.mShouldAllowNonOrganicClickOverride);
com.taboola.android.l lVar = this.mTBLWebView;
lVar.setOnline(this.mTBLConfigManager.h(str, "useOnlineTemplate", lVar.i()));
this.mShouldKeepDependencies = this.mTBLConfigManager.h(str, "keepDependencies", this.mShouldKeepDependencies);
com.taboola.android.l lVar2 = this.mTBLWebView;
lVar2.setEnableHorizontalScroll(this.mTBLConfigManager.h(str, "enableHorizontalScroll", lVar2.g()));
this.mShouldHideScrollBars = this.mTBLConfigManager.h(str, "hideScrollingBars", this.mShouldHideScrollBars);
syncScrollBarsWithFlag();
this.mDisableLocationCollection = this.mTBLConfigManager.h(str, ve.d.a(com.taboola.android.utils.c.DISABLE_LOCATION_COLLECTION), this.mDisableLocationCollection);
this.mCcpaOptout = this.mTBLConfigManager.g(str, "cdns", null);
this.mShouldAllowFileAccessInWebView = this.mTBLConfigManager.h(str, ve.d.a(com.taboola.android.utils.c.ALLOW_FILE_ACCESS), this.mShouldAllowFileAccessInWebView);
this.mUIHandler.post(new i());
this.mShouldAutoCollapseOnError = this.mTBLConfigManager.h(str, ve.d.a(com.taboola.android.utils.c.AUTO_COLLAPSE_ON_ERROR), this.mShouldAutoCollapseOnError);
this.mShouldMobileLoaderUseNewErrorCodeSystem = this.mTBLConfigManager.h(str, ve.d.a(com.taboola.android.utils.c.DETAILED_ERROR_CODES), this.mShouldMobileLoaderUseNewErrorCodeSystem);
this.mCheckHiddenWidget = this.mTBLConfigManager.h(str, ve.d.a(com.taboola.android.utils.c.VISIBLE_CHECK_HIDDEN_WIDGET), this.mCheckHiddenWidget);
this.mIsStoriesEnabled = this.mTBLConfigManager.h(this.mPlacement, ve.d.a(com.taboola.android.utils.c.ENABLE_STORIES), this.mIsStoriesEnabled);
}
private boolean isCacheTooSmall(int i2) {
int i3;
int systemBars;
WindowManager windowManager = (WindowManager) getContext().getSystemService("window");
if (windowManager == null) {
return false;
}
DisplayMetrics displayMetrics = new DisplayMetrics();
if (Build.VERSION.SDK_INT >= 30) {
WindowMetrics a2 = com.comscore.android.b.a(windowManager);
WindowInsets a3 = com.comscore.android.d.a(a2);
systemBars = WindowInsets.Type.systemBars();
Insets a4 = k2.a(a3, systemBars);
i3 = (com.comscore.android.c.a(a2).width() - androidx.appcompat.widget.d.a(a4)) - androidx.appcompat.widget.f.a(a4);
} else {
windowManager.getDefaultDisplay().getMetrics(displayMetrics);
i3 = displayMetrics.widthPixels;
}
return ((long) ((i3 * i2) * 4)) > ((long) ViewConfiguration.get(getContext()).getScaledMaximumDrawingCacheSize());
}
private void scheduleResizeWidget(int i2) {
removeCallbacks(this.mRedoResizeForGpu);
a aVar = new a(i2);
this.mRedoResizeForGpu = aVar;
postDelayed(aVar, 500L);
}
private void sendFailedToCreateWebViewMessageToKusto() {
if (Math.random() * 10.0d > 1.0d) {
return;
}
this.mTBLNetworkManager.getKustoHandler().sendEventToKusto(new af.b("Failed To create WebView"), null);
}
private void setFetchOnQueueResultCallback(@Nullable com.taboola.android.e eVar) {
this.mTBLFetchOnQueueResult = eVar;
this.mUIHandler.postDelayed(this.mTimeOutRunnableTask, this.mTBLClassicFetchManager.g());
}
private void syncScrollBarsWithFlag() {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
lVar.setVerticalScrollBarEnabled(!this.mShouldHideScrollBars);
this.mTBLWebView.setHorizontalScrollBarEnabled(!this.mShouldHideScrollBars);
}
}
private void updateMaxGPUSize() {
String str = TAG;
com.taboola.android.utils.g.a(str, "updateMaxGPUSize :: called");
try {
if (this.mScreenMaxHeight == 0) {
this.mScreenMaxHeight = TBLSdkDetailsHelper.getDisplayHeight(getContext());
com.taboola.android.utils.g.a(str, "mScreenMaxHeight " + this.mScreenMaxHeight);
}
this.mWidgetMaxHeight = this.mScreenMaxHeight;
if (sMaxWidgetSizeGpu == 0) {
int b2 = com.taboola.android.f.b(getContext());
sMaxWidgetSizeGpu = b2;
if (b2 != 0) {
this.mWidgetMaxHeight = Math.min(b2, TBLSdkDetailsHelper.getDisplayHeight(getContext()) * 2);
return;
}
invalidateWebView(this.mTBLWebView);
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
com.taboola.android.f.c(lVar, new b());
}
}
} catch (Exception e2) {
this.mWidgetMaxHeight = 500;
com.taboola.android.utils.g.b(TAG, "updateMaxGPUSize: " + e2.getMessage());
}
}
protected void adjustUnitToType(int i2, boolean z) {
Boolean bool;
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar == null) {
com.taboola.android.utils.g.a(TAG, "Unable to adjustUnitToType because tblWebView is null");
return;
}
if (i2 == 0) {
setInterceptScroll(false);
setScrollEnabled(false);
if (this.mTBLWebView.getProgressBarEnabled() == null) {
setProgressBarEnabled(Boolean.FALSE);
}
Boolean bool2 = this.mIsAutoResizeHeight;
setAutoResizeHeight(Boolean.valueOf(bool2 != null ? bool2.booleanValue() : true));
return;
}
if (i2 == 1) {
lVar.setShouldInterceptScroll(true);
setScrollEnabled(true);
if (z || this.mTBLWebView.getProgressBarEnabled() == null) {
setProgressBarEnabled(Boolean.TRUE);
} else {
setProgressBarEnabled(this.mTBLWebView.getProgressBarEnabled());
}
if (z || (bool = this.mIsAutoResizeHeight) == null) {
setAutoResizeHeight(Boolean.TRUE);
return;
} else {
setAutoResizeHeight(bool);
return;
}
}
if (i2 != 2) {
if (i2 != 3) {
return;
}
setProgressBarEnabled(Boolean.FALSE);
return;
}
lVar.setShouldInterceptScroll(true);
setScrollEnabled(true);
if (z || this.mTBLWebView.getProgressBarEnabled() == null) {
setProgressBarEnabled(Boolean.TRUE);
} else {
setProgressBarEnabled(this.mTBLWebView.getProgressBarEnabled());
}
Boolean bool3 = this.mIsAutoResizeHeight;
if (bool3 != null && bool3.booleanValue()) {
com.taboola.android.utils.g.b(TAG, "Feed type widget should never have AutoResizeHeight set to true. Setting it to false.");
}
setAutoResizeHeight(Boolean.FALSE);
}
@NonNull
int[] calculateMeasureSize(int i2, int i3) {
int childCount = getChildCount();
measureChildren(i2, i3);
int i4 = 0;
int i5 = 0;
for (int i6 = 0; i6 < childCount; i6++) {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
View childAt = lVar.getChildAt(0);
if (childAt != null && childAt.getVisibility() != 8) {
if (Build.VERSION.SDK_INT < 30) {
if (childAt instanceof GLSurfaceView) {
AbsoluteLayout.LayoutParams layoutParams = (AbsoluteLayout.LayoutParams) childAt.getLayoutParams();
int measuredWidth = layoutParams.x + childAt.getMeasuredWidth();
int measuredHeight = layoutParams.y + childAt.getMeasuredHeight();
i4 = Math.max(i4, measuredWidth);
i5 = Math.max(i5, measuredHeight);
} else {
com.taboola.android.utils.g.a(TAG, "Found child which isn't GLSurfaceView on OS under R");
}
} else if (childAt instanceof GLSurfaceView) {
int measuredWidth2 = childAt.getMeasuredWidth();
int measuredHeight2 = childAt.getMeasuredHeight();
i4 = Math.max(i4, measuredWidth2);
i5 = Math.max(i5, measuredHeight2);
} else {
com.taboola.android.utils.g.a(TAG, "Found child which isn't GLSurfaceView");
}
}
} else {
com.taboola.android.utils.g.a(TAG, "Unable to calculate GLSurfaceView, because tblWebView is null");
}
}
return new int[]{View.resolveSizeAndState(Math.max(i4 + getPaddingLeft() + getPaddingRight(), getSuggestedMinimumWidth()), i2, 0), View.resolveSizeAndState(Math.max(i5 + getPaddingTop() + getPaddingBottom(), getSuggestedMinimumHeight()), i3, 0)};
}
void calculateWidgetMaxHeight() {
int i2 = getResources().getConfiguration().orientation;
if (this.mOrientation != i2) {
this.mOrientation = i2;
this.mScreenMaxHeight = TBLSdkDetailsHelper.getDisplayHeight(getContext()) * 2;
String str = TAG;
com.taboola.android.utils.g.a(str, "calculateWidgetMaxHeight() called, mScreenMaxHeight = [" + this.mScreenMaxHeight + "]");
int i3 = sMaxWidgetSizeGpu;
if (i3 > 0) {
this.mWidgetMaxHeight = Math.min(i3, this.mScreenMaxHeight);
com.taboola.android.utils.g.a(str, "calculateWidgetMaxHeight() called, mWidgetMaxHeight = [" + this.mWidgetMaxHeight + "]");
}
}
}
@Override
public boolean canScrollVertically(int i2) {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
return lVar.canScrollVertically(i2);
}
com.taboola.android.utils.g.a(TAG, "Unable to canScrollVertically because tblWebView is null, return false");
return false;
}
@Override
public void clear() {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
lVar.e();
}
this.mShouldKeepDependencies = false;
n nVar = this.mOnAttachStateChangeListener;
if (nVar != null) {
nVar.a();
this.mOnAttachStateChangeListener = null;
}
com.taboola.android.i iVar = this.mScrollChangedListenerImpl;
if (iVar != null) {
iVar.c(this.mOnScrollChangedListener);
}
clearScrollChangeListener();
clearTBLWebInstance();
}
void clearScrollChangeListener() {
com.taboola.android.i iVar = this.mScrollChangedListenerImpl;
if (iVar != null) {
iVar.b();
this.mScrollChangedListenerImpl = null;
}
}
protected void clearTBLWebInstance() {
TBLWebUnit tBLWebUnit = this.mTBLWebUnit;
if (tBLWebUnit != null) {
tBLWebUnit.clear();
this.mTBLWebUnit = null;
}
}
void clearWebView() {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
lVar.loadUrl(ABOUT_BLANK_URL);
this.mTBLWebView.clearHistory();
}
}
@Nullable
com.taboola.android.l createWebView() {
try {
return new com.taboola.android.l(getContext(), this);
} catch (Throwable th) {
String str = TAG;
com.taboola.android.utils.g.b(str, "WEBVIEW_ERROR - Unable to create webView, message - " + th.getLocalizedMessage());
sendFailedToCreateWebViewMessageToKusto();
if (this.mShouldAutoCollapseOnError) {
com.taboola.android.utils.g.a(str, "Failed to create TBLWebView and shouldAutoCollapseOnError is true, so we making this view gone");
setLayoutParams(new ViewGroup.LayoutParams(0, 0));
setVisibility(8);
}
TBLClassicListener tBLClassicListener = this.mTBLClassicListener;
if (tBLClassicListener == null) {
return null;
}
tBLClassicListener.onAdReceiveFail(WEBVIEW_ERROR);
return null;
}
}
void dispatchLoadFailed(String str) {
if (this.mHasDispatchedLoadEvent) {
return;
}
this.mHasDispatchedLoadEvent = true;
TBLClassicListener tBLClassicListener = this.mTBLClassicListener;
if (tBLClassicListener != null) {
tBLClassicListener.onAdReceiveFail(str);
}
Handler handler = this.mUIHandler;
if (handler != null) {
handler.removeCallbacks(this.mTimeOutRunnableTask);
}
com.taboola.android.e eVar = this.mTBLFetchOnQueueResult;
if (eVar != null) {
eVar.a(1);
this.mTBLFetchOnQueueResult = null;
}
}
void dispatchLoadSuccessful() {
if (this.mHasDispatchedLoadEvent) {
return;
}
this.mHasDispatchedLoadEvent = true;
TBLClassicListener tBLClassicListener = this.mTBLClassicListener;
if (tBLClassicListener != null) {
tBLClassicListener.onAdReceiveSuccess();
}
Handler handler = this.mUIHandler;
if (handler != null) {
handler.removeCallbacks(this.mTimeOutRunnableTask);
}
com.taboola.android.e eVar = this.mTBLFetchOnQueueResult;
if (eVar != null) {
eVar.a(0);
this.mTBLFetchOnQueueResult = null;
}
}
public TBLClassicUnit fetchContent() {
if (this.mTBLWebView == null) {
com.taboola.android.utils.g.a(TAG, "Unable to fetchContent because tblWebView is null");
return this;
}
this.mLastExecuteTimeForAnalytics = System.currentTimeMillis();
if (Taboola.getTaboolaImpl().isKillSwitchEnabled(getPlacement())) {
dispatchLoadFailed("INTERNAL_1");
com.taboola.android.utils.g.b(TAG, "fetchContent | INTERNAL_1");
return this;
}
if (!this.mIsAddedToPage) {
com.taboola.android.utils.g.a(TAG, "The Unit's Page is null, if you added the Unit using XML, please create a Page and make sure you add the Unit to it using TBLClassicPage.addUnitToPage(<Unit>);.");
return this;
}
if (this.mTBLFetchOnQueueResult != null) {
com.taboola.android.utils.g.a(TAG, "This Unit is already waiting for a fetch. Not asking another fetch.");
return this;
}
this.mTBLClassicFetchManager.f(this);
return this;
}
public Boolean getAutoResizeHeight() {
return this.mIsAutoResizeHeight;
}
public String getFramework() {
return this.mFramework;
}
public boolean getInterceptScroll() {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
return lVar.l();
}
return false;
}
public String getMode() {
return this.mMode;
}
public String getOptionalWidgetStyle() {
return this.mWidgetStyle;
}
public String getPageId() {
return this.mPageId;
}
public String getPageType() {
return this.mPageType;
}
public String getPageUrl() {
return this.mPageUrl;
}
public String getPlacement() {
return this.mPlacement;
}
public int getPlacementType() {
return this.mPlacementType;
}
public Boolean getProgressBarEnabled() {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
return lVar.getProgressBarEnabled();
}
return null;
}
public String getPublisherName() {
return this.mPublisherName;
}
public boolean getScrollEnabled() {
return this.mIsScrollEnabled;
}
public boolean getShouldKeepViewId() {
return this.mShouldKeepViewId;
}
com.taboola.android.c getTBLClassicFetchManager() {
return this.mTBLClassicFetchManager;
}
public TBLWebUnit getTBLWebUnit() {
return this.mTBLWebUnit;
}
public com.taboola.android.l getTBLWebView() {
return this.mTBLWebView;
}
public String getTargetType() {
return this.mTargetType;
}
public com.taboola.android.m getTemplateJS() {
return this.mTemplateJS;
}
public int getTextZoom() {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
return lVar.getSettings().getTextZoom();
}
return 100;
}
HashMap<String, String> getUnrecognizedExtraProperties() {
return this.mUnrecognizedExtraProperties;
}
public WebChromeClient getWebChromeClient() {
return new h();
}
public WebViewClient getWebViewClient() {
g gVar = new g();
com.taboola.android.utils.g.a(TAG, "getWebViewClient :: initialized");
return gVar;
}
boolean hasMinimalAttributes() {
return (TextUtils.isEmpty(this.mPublisherName) || TextUtils.isEmpty(this.mMode) || TextUtils.isEmpty(this.mPlacement) || TextUtils.isEmpty(this.mPageUrl) || TextUtils.isEmpty(this.mPageType)) ? false : true;
}
void initJsExtraProperties() {
this.mUnrecognizedExtraProperties.put("isUsedInTaboolaWidget", "true");
this.mUnrecognizedExtraProperties.put("mediatedVia", this.mMediatedVia);
this.mUnrecognizedExtraProperties.put("allowNonOrganicClickOverride", this.mShouldAllowNonOrganicClickOverride ? "true" : "false");
if (!TextUtils.isEmpty(this.mCcpaOptout)) {
this.mUnrecognizedExtraProperties.put("cdns", this.mCcpaOptout);
}
if (this.mTBLWebView.g()) {
this.mUnrecognizedExtraProperties.put("enableHorizontalScroll", "true");
}
try {
if (this.mPassedActionList != null) {
this.mUnrecognizedExtraProperties.put("initActions", new JSONArray((Collection) this.mPassedActionList).toString());
}
} catch (Exception e2) {
com.taboola.android.utils.g.c(TAG, "unable to pass actions", e2);
}
String a2 = ve.d.a(com.taboola.android.utils.c.DISABLE_LOCATION_COLLECTION);
if (!this.mUnrecognizedExtraProperties.containsKey(a2)) {
this.mUnrecognizedExtraProperties.put(a2, String.valueOf(this.mDisableLocationCollection));
}
this.mUnrecognizedExtraProperties.put(ve.d.a(com.taboola.android.utils.c.AUTO_COLLAPSE_ON_ERROR), String.valueOf(this.mShouldAutoCollapseOnError));
this.mUnrecognizedExtraProperties.put(ve.d.a(com.taboola.android.utils.c.DETAILED_ERROR_CODES), String.valueOf(this.mShouldMobileLoaderUseNewErrorCodeSystem));
this.mUnrecognizedExtraProperties.put(ve.d.a(com.taboola.android.utils.c.VISIBLE_CHECK_HIDDEN_WIDGET), String.valueOf(this.mCheckHiddenWidget));
TBLWebUnit tBLWebUnit = this.mTBLWebUnit;
if (tBLWebUnit != null) {
tBLWebUnit.setPlacement(getPlacement());
this.mTBLWebUnit.setUnitExtraProperties(this.mUnrecognizedExtraProperties);
}
}
@SuppressLint({"SetJavaScriptEnabled"})
protected void initTBLWebUnit() {
CookieManager.getInstance().setAcceptCookie(true);
updateScrollBehaviour();
TBLWebUnit build = new TBLWebPage(this.mTBLNetworkManager, this.mTBLConfigManager, this.mTBLAdvertisingIdInfo, this.mTBLMonitorHelper, true).build(this.mTBLWebView, new f());
this.mTBLWebUnit = build;
if (build != null) {
build.setViewId(this.mViewId);
}
}
void initWidgetSettings() {
this.mCCTabHandler = new com.taboola.android.b(getContext());
this.mTBLMonitorHelper = Taboola.getTaboolaImpl().getMonitorHelper();
this.mUnrecognizedExtraProperties = new HashMap<>();
this.mTBLConfigManager = Taboola.getTaboolaImpl().loadAndGetConfigManager();
Taboola.setLogLevel(com.taboola.android.utils.g.d());
updateMaxGPUSize();
setDefaultValues();
this.mTBLWebView.setSaveEnabled(true);
this.mTBLWebView.setWillNotDraw(false);
setBackgroundColor(0);
WebSettings settings = this.mTBLWebView.getSettings();
settings.setLoadsImagesAutomatically(true);
settings.setLoadWithOverviewMode(true);
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
if (Build.VERSION.SDK_INT < 30) {
settings.setAppCacheEnabled(true);
} else {
com.taboola.android.utils.g.a(TAG, "Not using app cache, After api 30 it is recommended to use Service Workers instead on the web side");
}
settings.setUseWideViewPort(true);
this.mTBLWebView.setWebViewClient(getWebViewClient());
this.mTBLWebView.setWebChromeClient(getWebChromeClient());
settings.setCacheMode(-1);
this.mTBLWebView.setLayerType(0, null);
settings.setAllowFileAccess(this.mShouldAllowFileAccessInWebView);
if (com.taboola.android.utils.g.d() <= 3) {
WebView.setWebContentsDebuggingEnabled(true);
}
com.taboola.android.utils.g.a(TAG, "initWebView :: initialized WebView");
}
public void invalidateWebView(WebView webView) {
post(new c(webView));
}
@Override
public boolean isHorizontalScrollBarEnabled() {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
return lVar.isHorizontalScrollBarEnabled();
}
return false;
}
public boolean isScrolledToTop() {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
return lVar.k();
}
com.taboola.android.utils.g.b(TAG, "Returning isScrolledToTop default false, because webView is null");
return false;
}
void loadWebView() {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar == null) {
com.taboola.android.utils.g.a(TAG, "Unable to loadWebView tblWebView is null");
return;
}
if (lVar.i()) {
this.mHasDispatchedLoadEvent = false;
com.taboola.android.l lVar2 = this.mTBLWebView;
lVar2.loadUrl(this.mTemplateJS.a(this.mPageType, this.mPageId, this.mPublisherName, this.mTargetType, this.mWidgetStyle, this.mViewId, this.mPageUrl, this.mPlacement, this.mMode, lVar2.getProgressBarEnabled().booleanValue(), this.mProgressBarColor, this.mProgressBarDuration));
return;
}
String a2 = com.taboola.android.utils.a.a(getContext(), HTML_TEMPLATE_FILE_NAME);
String str = this.mPublisherName;
String format = String.format(a2, str, this.mWidgetStyle, this.mPageType, this.mPageId, this.mPageUrl, this.mMode, this.mPlacement, this.mFramework, this.mTargetType, str, this.mViewId);
com.taboola.android.utils.g.a(TAG, "loadWebView html:\n" + format);
this.mHasDispatchedLoadEvent = false;
this.mTBLWebView.loadDataWithBaseURL("https://cdn.taboola.com/mobile-sdk/init/", format, "text/html", "utf-8", null);
}
void managedFetch(@Nullable com.taboola.android.e eVar) {
Point e2;
setFetchOnQueueResultCallback(eVar);
if (this.mInitialHeight == null) {
ViewGroup.LayoutParams layoutParams = getLayoutParams();
boolean z = layoutParams != null;
Integer valueOf = Integer.valueOf(z ? layoutParams.height : -3);
this.mInitialHeight = valueOf;
if (valueOf.intValue() < 0) {
if (z) {
layoutParams.height = 2;
} else {
layoutParams = new ViewGroup.LayoutParams(-1, 2);
}
setLayoutParams(layoutParams);
}
}
if (this.mTBLMonitorHelper.g().booleanValue() && (e2 = this.mTBLMonitorHelper.e()) != null) {
int i2 = e2.y;
int i3 = e2.x;
ViewGroup.LayoutParams layoutParams2 = getLayoutParams();
if (layoutParams2 != null) {
layoutParams2.height = i2;
layoutParams2.width = i3;
} else {
layoutParams2 = new ViewGroup.LayoutParams(i3, i2);
}
setLayoutParams(layoutParams2);
}
String str = TAG;
com.taboola.android.utils.g.a(str, "publisher[" + this.mPublisherName + "] mode[" + this.mMode + "] placement[" + this.mPlacement + "] pageType[" + this.mPageType + "] pageUrl[" + this.mPageUrl + "] viewID[" + this.mViewId + "]");
initJsExtraProperties();
notifyMonitorFetchContent();
String url = this.mTBLWebView.getUrl();
if (TextUtils.equals(ABOUT_BLANK_URL, url)) {
url = null;
}
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null && lVar.i() && !TextUtils.isEmpty(url) && this.mShouldKeepViewId) {
this.mHasDispatchedLoadEvent = false;
this.mTBLWebView.reload();
} else if (!hasMinimalAttributes()) {
com.taboola.android.utils.g.b(str, "Required parameters are not set");
dispatchLoadFailed("Required parameters are not set");
} else {
clearWebView();
this.mHasDispatchedLoadEvent = false;
loadWebView();
}
}
public void mlRequestsUnitTypeChange(int i2, String str, int i3) {
int i4 = this.mPlacementType;
if (i4 == 0) {
com.taboola.android.utils.g.a(TAG, "mlRequestsUnitTypeChange | can't set Unit Type, TBLClassicUnit is set currently set to page middle.");
return;
}
if (i4 == 3) {
com.taboola.android.utils.g.a(TAG, "mlRequestsUnitTypeChange | can't set Unit Type, TBLClassicUnit is set currently set to page stories.");
return;
}
if (i4 == i2) {
com.taboola.android.utils.g.a(TAG, "mlRequestsUnitTypeChange | can't set Unit Type, TBLClassicUnit is already of requested type (" + i2 + ").");
return;
}
setPlacementType(i2);
setPlacement(str);
adjustUnitToType(i2, true);
if (i2 == 1) {
resizeWidget(i3);
com.taboola.android.utils.g.a(TAG, "mlRequestsUnitTypeChange | MobileLoader requested a change to Unit type PAGE_BOTTOM.");
} else if (i2 == 2) {
resizeWidget(this.mWidgetMaxHeight);
com.taboola.android.utils.g.a(TAG, "mlRequestsUnitTypeChange | MobileLoader requested a change to Unit type FEED.");
}
}
void notifyMonitorFetchContent() {
if (this.mTBLWebView == null) {
com.taboola.android.utils.g.a(TAG, "Unable to notifyMonitorFetchContent because tblWebView is null");
return;
}
if (this.mTBLMonitorHelper.g().booleanValue()) {
this.mFetchContentParams.put("publisher", this.mPublisherName);
this.mFetchContentParams.put("mode", this.mMode);
this.mFetchContentParams.put("placement", this.mPlacement);
this.mFetchContentParams.put("pageType", this.mPageType);
this.mFetchContentParams.put("targetType", this.mTargetType);
this.mFetchContentParams.put("pageId", this.mPageId);
this.mFetchContentParams.put("pageUrl", this.mPageUrl);
this.mFetchContentParams.put("viewID", this.mViewId);
this.mFetchContentParams.put("framework", this.mFramework);
this.mFetchContentParams.put("customTabsSupported", String.valueOf(this.mCCTabHandler.f()));
this.mFetchContentParams.put("progressBarColor", this.mProgressBarColor);
this.mFetchContentParams.put("progressBarEnabled", String.valueOf(this.mTBLWebView.getProgressBarEnabled()));
View scrollviewParent = this.mTBLWebView.getScrollviewParent();
if (scrollviewParent != null) {
this.mFetchContentParams.put("scrollviewParent", scrollviewParent.getClass().getSimpleName());
}
this.mFetchContentParams.put("shouldInterceptScroll", String.valueOf(this.mTBLWebView.l()));
this.mFetchContentParams.put("enableHorizontalScroll", String.valueOf(this.mTBLWebView.g()));
this.mFetchContentParams.put("getAutoResizeHeight", String.valueOf(this.mIsAutoResizeHeight));
this.mFetchContentParams.put("maxScreenHeight", String.valueOf(this.mScreenMaxHeight));
this.mFetchContentParams.put("maxWidgetSizeGpu", String.valueOf(sMaxWidgetSizeGpu));
this.mFetchContentParams.put("getScrollEnabled", String.valueOf(this.mIsScrollEnabled));
if (getLayoutParams() != null) {
ViewGroup.LayoutParams layoutParams = getLayoutParams();
this.mFetchContentParams.put("layoutParams", layoutParams.getClass().getCanonicalName() + "= { width=" + com.taboola.android.utils.i.c(layoutParams.width) + ", height=" + com.taboola.android.utils.i.c(layoutParams.height) + " }");
}
String str = this.mUserId;
if (str != null) {
this.mFetchContentParams.put("unified_id", str);
}
this.mTBLMonitorHelper.k(this.mTBLWebUnit.getWebViewManager(), this.mPlacement, this.mFetchContentParams);
}
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
String str = TAG;
com.taboola.android.utils.g.a(str, "onAttachedToWindow");
if (this.mTBLWebView == null) {
com.taboola.android.utils.g.a(str, "Unable to handle onAttachedToWindow because tblWebView is null");
return;
}
if (this.mTBLWebUnit == null) {
initTBLWebUnit();
}
this.mTBLWebUnit.notifyUpdateHeight();
com.taboola.android.b bVar = this.mCCTabHandler;
if (bVar != null) {
bVar.d();
}
calculateWidgetMaxHeight();
if (this.mPlacementType == 2) {
getLayoutParams().height = TBLSdkDetailsHelper.getDisplayHeight(getContext()) * 2;
}
}
public void onDestroy() {
clear();
}
@Override
protected void onDetachedFromWindow() {
if (!this.mShouldKeepDependencies) {
clear();
}
com.taboola.android.utils.g.a(TAG, "onDetachedFromWindow");
com.taboola.android.b bVar = this.mCCTabHandler;
if (bVar != null) {
bVar.h();
}
super.onDetachedFromWindow();
}
@Override
protected void onMeasure(int i2, int i3) {
calculateWidgetMaxHeight();
int[] calculateMeasureSize = calculateMeasureSize(i2, i3);
int i4 = this.mWidgetMaxHeight;
if (i4 <= 0) {
i4 = this.mScreenMaxHeight;
}
int i5 = calculateMeasureSize[1];
if (i5 > i4) {
int mode = View.MeasureSpec.getMode(i3);
String str = TAG;
com.taboola.android.utils.g.a(str, "onMeasure() called before with: heightMeasureSpec = [" + i3 + "], heightSpecMode = " + com.taboola.android.utils.i.b(mode) + "], heightLimit = [" + i4 + "], measuredHeightPixels = [" + i5 + "]");
int i6 = calculateMeasureSize[0];
setMeasuredDimension(i6, i4);
StringBuilder sb2 = new StringBuilder();
sb2.append("onMeasure(): setMeasuredDimension called with: measuredWidth = [");
sb2.append(i6);
sb2.append("], measuredHeight = [");
sb2.append(i4);
sb2.append("]");
com.taboola.android.utils.g.a(str, sb2.toString());
i3 = View.MeasureSpec.makeMeasureSpec(i4, mode);
}
if (this.mTBLWebView != null) {
this.mWebViewParams.height = View.MeasureSpec.getSize(i3);
this.mWebViewParams.width = View.MeasureSpec.getSize(i2);
this.mTBLWebView.setLayoutParams(this.mWebViewParams);
}
super.onMeasure(i2, i3);
}
protected void onOrientationChange(int i2) {
if (this.mTBLWebView == null) {
com.taboola.android.utils.g.a(TAG, "Unable to handle onOrientationChange because tblWebView is null");
return;
}
com.taboola.android.utils.g.a(TAG, "onOrientationChange() called with: heightPx = [" + i2 + "]");
this.mOrientation = 0;
calculateWidgetMaxHeight();
resizeWidget(i2);
post(new m());
}
@Override
protected void onWindowVisibilityChanged(int i2) {
super.onWindowVisibilityChanged(i2);
com.taboola.android.b bVar = this.mCCTabHandler;
if (bVar != null && bVar.e() && i2 == 0) {
this.mCCTabHandler.g(false);
}
}
@Deprecated
public void overrideViewId(String str) {
setViewId(str);
}
void parseXmlAttributes(Context context, AttributeSet attributeSet) {
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.TBLClassicUnit, 0, 0);
setAutoResizeHeight(Boolean.valueOf(obtainStyledAttributes.getBoolean(R.styleable.TBLClassicUnit_autoResizeHeight, this.mIsAutoResizeHeight.booleanValue())));
setScrollEnabled(obtainStyledAttributes.getBoolean(R.styleable.TBLClassicUnit_scrollEnabled, this.mIsScrollEnabled));
Boolean progressBarEnabled = this.mTBLWebView.getProgressBarEnabled();
setProgressBarEnabled(Boolean.valueOf(obtainStyledAttributes.getBoolean(R.styleable.TBLClassicUnit_progressBarEnabled, progressBarEnabled != null ? progressBarEnabled.booleanValue() : true)));
setProgressBarColor(obtainStyledAttributes.getColor(R.styleable.TBLClassicUnit_progressBarColor, -1));
setProgressBarDuration(obtainStyledAttributes.getFloat(R.styleable.TBLClassicUnit_progressBarDuration, this.mProgressBarDuration));
int i2 = R.styleable.TBLClassicUnit_auto_resize_height;
Boolean bool = this.mIsAutoResizeHeight;
setAutoResizeHeight(Boolean.valueOf(obtainStyledAttributes.getBoolean(i2, bool != null ? bool.booleanValue() : true)));
setScrollEnabled(obtainStyledAttributes.getBoolean(R.styleable.TBLClassicUnit_scroll_enabled, this.mIsScrollEnabled));
String string = obtainStyledAttributes.getString(R.styleable.TBLClassicUnit_tb_publisher);
String string2 = obtainStyledAttributes.getString(R.styleable.TBLClassicUnit_tb_mode);
String string3 = obtainStyledAttributes.getString(R.styleable.TBLClassicUnit_tb_placement);
String string4 = obtainStyledAttributes.getString(R.styleable.TBLClassicUnit_tb_page_type);
String string5 = obtainStyledAttributes.getString(R.styleable.TBLClassicUnit_tb_target_type);
String string6 = obtainStyledAttributes.getString(R.styleable.TBLClassicUnit_tb_url);
if (string != null) {
setPublisherName(string);
}
if (string2 != null) {
setMode(string2);
}
if (string3 != null) {
setPlacement(string3);
}
if (string4 != null) {
setPageType(string4);
}
if (string5 != null) {
setTargetType(string5);
}
if (string6 != null) {
setPageUrl(string6);
}
obtainStyledAttributes.recycle();
}
public void refresh() {
refresh(false);
}
void refresh(boolean z) {
if (z || this.mShouldKeepViewId) {
updateContent();
} else {
com.taboola.android.utils.g.b(TAG, "KeepViewId is false, please use TBLClassicPage.refresh().");
}
}
public TBLClassicUnit reset() {
if (this.mTBLWebView == null) {
com.taboola.android.utils.g.a(TAG, "Unable to reset because tblWebView is null");
return this;
}
setDefaultValues();
clearWebView();
return this;
}
public void resizeWidget(int i2) {
Integer valueOf;
boolean z;
String str = TAG;
com.taboola.android.utils.g.a(str, "resizeWidget(" + i2 + ")");
if (sMaxWidgetSizeGpu == 0) {
com.taboola.android.utils.g.a(str, "resizeWidget: postponing resizing until max widget size is resolved");
scheduleResizeWidget(i2);
return;
}
removeCallbacks(this.mRedoResizeForGpu);
ViewGroup.LayoutParams layoutParams = getLayoutParams();
Integer num = this.mInitialHeight;
if (num == null || num.intValue() >= 0) {
valueOf = layoutParams != null ? Integer.valueOf(layoutParams.height) : null;
z = false;
} else {
valueOf = this.mInitialHeight;
z = true;
}
int min = (valueOf == null || valueOf.intValue() <= 0) ? this.mWidgetMaxHeight : Math.min(valueOf.intValue(), this.mWidgetMaxHeight);
if (i2 > min) {
setScrollEnabled(true);
i2 = min;
z = true;
}
if (z || getAutoResizeHeight().booleanValue()) {
if (i2 == (layoutParams != null ? layoutParams.height : 0)) {
com.taboola.android.utils.g.a(str, String.format("resizeWidget() for placement \"%s\" is same height as before: %d", com.taboola.android.utils.n.b(getPlacement()), Integer.valueOf(i2)));
return;
}
StringBuilder sb2 = new StringBuilder();
sb2.append("resized widget height to ");
sb2.append(i2);
sb2.append(" px, was before ");
sb2.append(layoutParams != null ? Integer.valueOf(layoutParams.height) : "no param");
com.taboola.android.utils.g.a(str, sb2.toString());
if (layoutParams != null) {
layoutParams.height = i2;
} else {
layoutParams = new ViewGroup.LayoutParams(-1, i2);
}
setLayoutParams(layoutParams);
TBLClassicListener tBLClassicListener = this.mTBLClassicListener;
if (tBLClassicListener != null) {
tBLClassicListener.onResize(i2);
}
}
if (this.shouldCheckCacheSize && isCacheTooSmall(i2)) {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
lVar.setLayerType(0, null);
}
this.shouldCheckCacheSize = false;
fetchContent();
}
}
void sendABTestEvents(gf.b... bVarArr) {
TBLWebUnit tBLWebUnit = this.mTBLWebUnit;
if (tBLWebUnit == null) {
com.taboola.android.utils.g.b(TAG, "Cannot send events, WebUnit is null.");
return;
}
TBLWebViewManager webViewManager = tBLWebUnit.getWebViewManager();
if (webViewManager == null) {
com.taboola.android.utils.g.b(TAG, "Cannot send events, WebViewManager is null.");
} else {
webViewManager.sendABTestEvents(bVarArr);
}
}
void sendStoryStepEvents(gf.d... dVarArr) {
TBLWebUnit tBLWebUnit = this.mTBLWebUnit;
if (tBLWebUnit == null) {
com.taboola.android.utils.g.b(TAG, "Cannot send events, WebUnit is null.");
return;
}
TBLWebViewManager webViewManager = tBLWebUnit.getWebViewManager();
if (webViewManager == null) {
com.taboola.android.utils.g.b(TAG, "Cannot send events, WebViewManager is null.");
} else {
webViewManager.sendStoryStepEvents(dVarArr);
}
}
public TBLClassicUnit setAction(int i2, String str) {
HashMap hashMap = new HashMap();
hashMap.put(LogCategory.ACTION, String.valueOf(i2));
hashMap.put(Parameters.DATA, str);
if (this.mPassedActionList == null) {
this.mPassedActionList = new ArrayList();
}
this.mPassedActionList.add(hashMap);
return this;
}
void setAddedToPage() {
this.mIsAddedToPage = true;
}
public TBLClassicUnit setAutoResizeHeight(Boolean bool) {
this.mIsAutoResizeHeight = bool;
return this;
}
void setClassicFetchManager(com.taboola.android.c cVar) {
this.mTBLClassicFetchManager = cVar;
}
void setDefaultValues() {
TBLPublisherInfo tBLPublisherInfo = this.mTBLPublisherInfo;
if (tBLPublisherInfo != null) {
this.mPublisherName = tBLPublisherInfo.getPublisherName();
} else {
this.mPublisherName = BuildConfig.FLAVOR;
com.taboola.android.utils.g.b(TAG, "You are about to use TBLClassicUnit without PublisherInfo, verify you have called Taboola.init() with publisher information before creating any Page or Unit");
}
this.mMode = BuildConfig.FLAVOR;
this.mPlacement = BuildConfig.FLAVOR;
this.mPageType = BuildConfig.FLAVOR;
this.mTargetType = "mix";
this.mPageId = "auto";
this.mPageUrl = BuildConfig.FLAVOR;
this.mWidgetStyle = BuildConfig.FLAVOR;
this.mFramework = "mobile-sdk";
this.mIsScrollEnabled = false;
this.mIsAutoResizeHeight = Boolean.TRUE;
com.taboola.android.utils.g.a(TAG, "setDefaultValues :: initialize fields with default values");
}
@Override
public void setFocusable(boolean z) {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar == null) {
com.taboola.android.utils.g.a(TAG, "Unable to setFocusable, mTBLWebView is null");
} else {
lVar.setFocusable(z);
}
}
public void setFramework(String str) {
this.mFramework = str;
}
public void setInterceptScroll(boolean z) {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar == null) {
com.taboola.android.utils.g.a(TAG, "Unable to setInterceptScroll because tblWebView is null");
return;
}
lVar.setShouldInterceptScroll(z);
if (this.mTBLWebView.l()) {
setAutoResizeHeight(Boolean.FALSE);
setScrollEnabled(true);
}
}
public TBLClassicUnit setMediatedVia(String str) {
this.mMediatedVia = this.mTBLConfigManager.g(this.mPlacement, ve.d.a(com.taboola.android.utils.c.MEDIATED_VIA_PROP), str);
return this;
}
public TBLClassicUnit setMode(String str) {
if (str != null && !str.isEmpty()) {
this.mMode = str;
}
return this;
}
public TBLClassicUnit setOptionalWidgetStyle(String str) {
this.mWidgetStyle = str;
return this;
}
public TBLClassicUnit setPageId(String str) {
if (str != null && !str.isEmpty()) {
this.mPageId = str;
}
return this;
}
public TBLClassicUnit setPageType(String str) {
if (str != null && !str.isEmpty()) {
this.mPageType = str;
}
return this;
}
public TBLClassicUnit setPageUrl(String str) {
if (str != null && !str.isEmpty()) {
this.mPageUrl = str;
}
return this;
}
public TBLClassicUnit setPlacement(String str) {
if (this.mTBLWebView == null) {
com.taboola.android.utils.g.a(TAG, "Unable to setPlacement because tblWebView is null");
return this;
}
if (!TextUtils.isEmpty(str)) {
this.mPlacement = str;
initializeFeatures(str);
}
return this;
}
public void setPlacementType(int i2) {
this.mPlacementType = i2;
}
public TBLClassicUnit setProgressBarColor(@ColorInt int i2) {
if (i2 != -1) {
this.mProgressBarColor = com.taboola.android.utils.n.a(i2);
}
return this;
}
public TBLClassicUnit setProgressBarDuration(float f2) {
if (f2 >= 0.0f) {
this.mProgressBarDuration = f2;
} else {
com.taboola.android.utils.g.j(TAG, "setProgressBarDuration | Duration cannot be negative. Using default duration: " + this.mProgressBarDuration);
}
return this;
}
public TBLClassicUnit setProgressBarEnabled(Boolean bool) {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
lVar.setProgressBarEnabled(bool);
}
return this;
}
public TBLClassicUnit setPublisherName(String str) {
if (str != null && !str.isEmpty()) {
this.mPublisherName = str;
this.mTBLConfigManager.u(str);
}
return this;
}
public TBLClassicUnit setScrollEnabled(boolean z) {
this.mIsScrollEnabled = z;
updateScrollBehaviour();
return this;
}
TBLClassicUnit setShouldKeepViewId(boolean z) {
this.mShouldKeepViewId = this.mTBLConfigManager.h(this.mPlacement, ve.d.a(com.taboola.android.utils.c.KEEP_VIEW_ID), z);
return this;
}
public TBLClassicUnit setTBLClassicListener(TBLClassicListener tBLClassicListener) {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
lVar.setTBLClassicListener(tBLClassicListener);
}
this.mTBLClassicListener = tBLClassicListener;
return this;
}
void setTBLWebUnit(TBLWebUnit tBLWebUnit) {
this.mTBLWebUnit = tBLWebUnit;
}
public TBLClassicUnit setTag(@NonNull String str) {
if (this.mTBLWebView == null) {
com.taboola.android.utils.g.a(TAG, "Unable to setTag because tblWebView is null");
return this;
}
this.mTBLWebUnit.setTag(str);
return this;
}
public TBLClassicUnit setTargetType(String str) {
if (str != null && !str.isEmpty()) {
this.mTargetType = str;
}
return this;
}
public void setTemplateJS(com.taboola.android.m mVar) {
this.mTemplateJS = mVar;
}
public TBLClassicUnit setTextZoom(int i2) {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
lVar.getSettings().setTextZoom(i2);
}
return this;
}
public TBLClassicUnit setUnitExtraProperties(HashMap<String, String> hashMap) {
if (this.mTBLWebView == null) {
com.taboola.android.utils.g.a(TAG, "Unable to setUnitExtraProperties because tblWebView is null");
return this;
}
if (hashMap != null && !hashMap.isEmpty()) {
for (String str : hashMap.keySet()) {
String str2 = hashMap.get(str);
boolean z = false;
boolean z2 = str2 != null;
this.mFetchContentParams.put(str, str2);
switch (d.a[com.taboola.android.utils.c.a(str).ordinal()]) {
case 1:
boolean h2 = this.mTBLConfigManager.h(this.mPlacement, "allowNonOrganicClickOverride", Boolean.parseBoolean(str2));
this.mShouldAllowNonOrganicClickOverride = h2;
this.mTBLConfigManager.s(this.mPlacement, str, h2);
z = z2;
break;
case 2:
this.mTBLWebView.setOnline(this.mTBLConfigManager.h(this.mPlacement, "useOnlineTemplate", Boolean.parseBoolean(str2)));
this.mTBLConfigManager.s(this.mPlacement, str, this.mTBLWebView.i());
z = z2;
break;
case 3:
boolean h3 = this.mTBLConfigManager.h(this.mPlacement, "keepDependencies", Boolean.parseBoolean(str2));
this.mShouldKeepDependencies = h3;
this.mTBLConfigManager.s(this.mPlacement, str, h3);
z = z2;
break;
case 4:
this.mTBLWebView.setEnableHorizontalScroll(this.mTBLConfigManager.h(this.mPlacement, "enableHorizontalScroll", Boolean.parseBoolean(str2)));
this.mTBLConfigManager.s(this.mPlacement, str, this.mTBLWebView.g());
z = z2;
break;
case 5:
boolean h4 = this.mTBLConfigManager.h(this.mPlacement, str, Boolean.parseBoolean(str2));
this.mShouldHideScrollBars = h4;
this.mTBLConfigManager.s(this.mPlacement, str, h4);
syncScrollBarsWithFlag();
z = z2;
break;
case 6:
boolean h5 = this.mTBLConfigManager.h(this.mPlacement, str, Boolean.parseBoolean(str2));
this.mShouldAllowFileAccessInWebView = h5;
this.mTBLConfigManager.s(this.mPlacement, str, h5);
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar != null) {
lVar.getSettings().setAllowFileAccess(this.mShouldAllowFileAccessInWebView);
} else {
com.taboola.android.utils.g.b(TAG, "Failed to set allow file access, because tblWebView is null");
}
z = z2;
break;
case 7:
String g2 = this.mTBLConfigManager.g(this.mPlacement, str, com.taboola.android.utils.b.b(str2));
this.mCcpaOptout = g2;
this.mTBLConfigManager.r(this.mPlacement, str, g2);
z = z2;
break;
case 8:
boolean h6 = this.mTBLConfigManager.h(this.mPlacement, str, Boolean.parseBoolean(str2));
this.mDisableLocationCollection = h6;
this.mTBLConfigManager.s(this.mPlacement, str, h6);
this.mUnrecognizedExtraProperties.put(str, String.valueOf(this.mDisableLocationCollection));
z = z2;
break;
case 9:
boolean h10 = this.mTBLConfigManager.h(this.mPlacement, str, Boolean.parseBoolean(str2));
this.mShouldMobileLoaderUseNewErrorCodeSystem = h10;
this.mTBLConfigManager.s(this.mPlacement, str, h10);
this.mUnrecognizedExtraProperties.put(str, String.valueOf(this.mShouldMobileLoaderUseNewErrorCodeSystem));
z = z2;
break;
case 10:
boolean h11 = this.mTBLConfigManager.h(this.mPlacement, str, Boolean.parseBoolean(str2));
this.mShouldAutoCollapseOnError = h11;
this.mTBLConfigManager.s(this.mPlacement, str, h11);
this.mUnrecognizedExtraProperties.put(str, String.valueOf(this.mShouldAutoCollapseOnError));
z = z2;
break;
case 11:
boolean h12 = this.mTBLConfigManager.h(this.mPlacement, str, Boolean.parseBoolean(str2));
this.mCheckHiddenWidget = h12;
this.mTBLConfigManager.s(this.mPlacement, str, h12);
this.mUnrecognizedExtraProperties.put(str, String.valueOf(this.mCheckHiddenWidget));
z = z2;
break;
case 12:
boolean h13 = this.mTBLConfigManager.h(this.mPlacement, str, Boolean.parseBoolean(str2));
this.mIsStoriesEnabled = h13;
this.mUnrecognizedExtraProperties.put(str, String.valueOf(h13));
default:
com.taboola.android.utils.g.a(TAG, "setExtraProperties key = " + str + " will be sent to rbox");
this.mUnrecognizedExtraProperties.put(str, str2);
break;
}
if (!z) {
ve.b bVar = this.mTBLConfigManager;
String str3 = this.mPlacement;
bVar.r(str3, str, bVar.g(str3, str, str2));
}
}
this.mUnrecognizedExtraProperties.put("isUsedInTaboolaWidget", "true");
}
return this;
}
public TBLClassicUnit setUserId(String str) {
if (this.mTBLWebView == null) {
com.taboola.android.utils.g.a(TAG, "Unable to setUserId because tblWebView is null");
return this;
}
this.mUserId = str;
this.mTBLWebUnit.setUserId(str);
return this;
}
TBLClassicUnit setViewId(String str) {
if (str != null && str.length() > 18) {
com.taboola.android.utils.g.b(TAG, "Please set a shorter than 18 characters viewId.");
return this;
}
if (TextUtils.isEmpty(str)) {
str = Long.toString(System.currentTimeMillis());
}
this.mViewId = str;
TBLWebUnit tBLWebUnit = this.mTBLWebUnit;
if (tBLWebUnit != null) {
tBLWebUnit.setViewId(str);
}
return this;
}
void setWebView(com.taboola.android.l lVar) {
if (lVar == null) {
com.taboola.android.utils.g.b(TAG, "Trying to set new instance of tblWebView, but provided null");
return;
}
com.taboola.android.l lVar2 = this.mTBLWebView;
if (lVar2 != null) {
lVar2.e();
}
this.mTBLWebView = lVar;
TBLClassicListener tBLClassicListener = this.mTBLClassicListener;
if (tBLClassicListener != null) {
lVar.setTBLClassicListener(tBLClassicListener);
}
removeAllViews();
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
this.mWebViewParams = layoutParams;
addView(this.mTBLWebView, layoutParams);
this.mTBLWebView.setBackgroundColor(0);
setBackgroundColor(0);
initWidgetSettings();
initTBLWebUnit();
}
public void showProgressBar() {
com.taboola.android.l lVar = this.mTBLWebView;
if (lVar == null || !lVar.getProgressBarEnabled().booleanValue()) {
com.taboola.android.utils.g.j(TAG, "progress bar is manually disabled");
} else {
this.mTBLWebUnit.showProgressBar();
}
}
void startInvalidationOnScrollEvents(com.taboola.android.l lVar) {
if (this.mInvalidationHandler == null) {
this.mInvalidationHandler = new Handler(Looper.getMainLooper());
}
j jVar = new j(lVar);
k kVar = new k(lVar);
com.taboola.android.i iVar = this.mScrollChangedListenerImpl;
if (iVar == null) {
this.mScrollChangedListenerImpl = new com.taboola.android.i(this.mTBLWebView);
} else {
iVar.c(this.mOnScrollChangedListener);
}
if (this.mOnScrollChangedListener == null) {
this.mOnScrollChangedListener = new l(jVar, kVar);
}
this.mScrollChangedListenerImpl.a(this.mOnScrollChangedListener);
}
public void updateAction(int i2, String str) {
this.mTBLWebUnit.updatePassedAction(i2, str);
}
public void updateContent() {
if (this.mTBLWebView == null) {
com.taboola.android.utils.g.a(TAG, "Unable to updateContent because tblWebView is null");
} else {
this.mLastExecuteTimeForAnalytics = System.currentTimeMillis();
this.mTBLWebUnit.updateContent();
}
}
void updateScrollBehaviour() {
if (!this.mShouldHideScrollBars) {
this.mTBLWebView.setVerticalScrollBarEnabled(this.mIsScrollEnabled);
}
String str = TAG;
StringBuilder sb2 = new StringBuilder();
sb2.append("updateScrollBehaviour :: scroll enabled ");
sb2.append(this.mIsScrollEnabled);
sb2.append(", scroll shown: ");
sb2.append(!this.mShouldHideScrollBars);
com.taboola.android.utils.g.a(str, sb2.toString());
}
public void webViewAttachedToWindow(View view) {
if (this.mTBLWebView == null || view == null || this.mOnAttachStateChangeListener != null) {
return;
}
n nVar = new n(this);
this.mOnAttachStateChangeListener = nVar;
view.addOnAttachStateChangeListener(nVar);
this.mShouldKeepDependencies = true;
}
}