正在查看: Ampture v4.3.1 应用的 BrowseFragmen.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Ampture v4.3.1 应用的 BrowseFragmen.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.kaunik.ampture.fragment;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DownloadManager;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Base64;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager;
import android.webkit.DownloadListener;
import android.webkit.URLUtil;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebStorage;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.appcompat.widget.AppCompatSeekBar;
import androidx.constraintlayout.motion.widget.MotionLayout;
import androidx.core.app.ShareCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.imageview.ShapeableImageView;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.crashlytics.buildtools.ndk.internal.elf.EMachine;
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.protocol.HTTP;
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.protocol.HttpRequestExecutor;
import com.google.firebase.encoders.json.BuildConfig;
import com.google.firebase.messaging.Constants;
import com.kaunik.ampture.R;
import com.kaunik.ampture.activity.MSettingsActivityKt;
import com.kaunik.ampture.activity.MainActivity;
import com.kaunik.ampture.activity.MainActivityKt;
import com.kaunik.ampture.databinding.FragmentBrowseBinding;
import com.kaunik.ampture.util.SnapshotManager;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import kotlin.Metadata;
import kotlin.collections.CollectionsKt;
import kotlin.io.CloseableKt;
import kotlin.io.ConstantsKt;
import kotlin.io.TextStreamsKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Ref;
import kotlin.text.Charsets;
import kotlin.text.Regex;
import kotlin.text.StringsKt;
import kotlinx.coroutines.internal.LockFreeTaskQueueCore;
@Metadata(d1 = {"\u0000¤\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u0011\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0016\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u000e\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u000e\u0018\u00002\u00020\u0001:\u0001vB\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\b\u0010K\u001a\u00020LH\u0003J\b\u0010M\u001a\u00020LH\u0003J\b\u0010N\u001a\u00020LH\u0002J\b\u0010O\u001a\u0004\u0018\u00010=J\b\u0010P\u001a\u0004\u0018\u00010=J\u000e\u0010Q\u001a\u00020 2\u0006\u0010R\u001a\u00020\u0003J\u0012\u0010S\u001a\u00020L2\b\b\u0002\u0010T\u001a\u00020 H\u0002J\u0010\u0010U\u001a\u00020\u00032\u0006\u0010V\u001a\u00020\u0003H\u0002J\"\u0010W\u001a\u00020L2\u0006\u0010X\u001a\u00020\u00062\u0006\u0010Y\u001a\u00020\u00062\b\u0010Z\u001a\u0004\u0018\u00010[H\u0016J\"\u0010\\\u001a\u00020L2\u0006\u0010]\u001a\u00020^2\u0006\u0010_\u001a\u00020`2\b\u0010a\u001a\u0004\u0018\u00010bH\u0016J&\u0010c\u001a\u0004\u0018\u00010`2\u0006\u0010d\u001a\u00020e2\b\u0010f\u001a\u0004\u0018\u00010g2\b\u0010h\u001a\u0004\u0018\u00010iH\u0017J\b\u0010j\u001a\u00020LH\u0016J\b\u0010k\u001a\u00020LH\u0016J\b\u0010l\u001a\u00020LH\u0017J\b\u0010m\u001a\u00020LH\u0002J\b\u0010n\u001a\u00020LH\u0003J\b\u0010o\u001a\u00020LH\u0007J\u001b\u0010p\u001a\u00020L2\f\u0010q\u001a\b\u0012\u0004\u0012\u00020\u00030\u001bH\u0002¢\u0006\u0002\u0010rJ\u0010\u0010s\u001a\u00020L2\u0006\u0010t\u001a\u00020 H\u0002J\b\u0010u\u001a\u00020LH\u0002R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082D¢\u0006\u0002\n\u0000R\u001a\u0010\u0007\u001a\u00020\bX\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b\t\u0010\n\"\u0004\b\u000b\u0010\fR\u000e\u0010\r\u001a\u00020\u000eX\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010\u000f\u001a\u00020\u0006X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0010\u0010\u0011\"\u0004\b\u0012\u0010\u0013R\u000e\u0010\u0014\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0015\u001a\u0004\u0018\u00010\u0003X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0016\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0017\u001a\u0004\u0018\u00010\u0018X\u0082\u000e¢\u0006\u0002\n\u0000R\u001c\u0010\u0019\u001a\u0010\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u001c0\u001b\u0018\u00010\u001aX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001d\u001a\u00020\u001eX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u001f\u001a\u00020 X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010!\u001a\u0004\u0018\u00010\u0003X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\"\u001a\u0004\u0018\u00010\u0003X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010#\u001a\u00020$X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010%\u001a\u0004\u0018\u00010&X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010'\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010(\u001a\u00020 X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b)\u0010*\"\u0004\b+\u0010,R\u001a\u0010-\u001a\u00020\u0003X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b.\u0010/\"\u0004\b0\u0010\u0004R\u000e\u00101\u001a\u00020 X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u00102\u001a\u00020$X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b3\u00104\"\u0004\b5\u00106R\u001a\u00107\u001a\u00020\u0006X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b8\u0010\u0011\"\u0004\b9\u0010\u0013R\u001a\u0010\u0002\u001a\u00020\u0003X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b:\u0010/\"\u0004\b;\u0010\u0004R\u0010\u0010<\u001a\u0004\u0018\u00010=X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010>\u001a\u00020?X\u0086.¢\u0006\u000e\n\u0000\u001a\u0004\b@\u0010A\"\u0004\bB\u0010CR\u001c\u0010D\u001a\u0004\u0018\u00010=X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\bE\u0010F\"\u0004\bG\u0010HR\u0010\u0010I\u001a\u0004\u0018\u00010JX\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006w"}, d2 = {"Lcom/kaunik/ampture/fragment/BrowseFragmen;", "Landroidx/fragment/app/Fragment;", "urlNew", BuildConfig.FLAVOR, "(Ljava/lang/String;)V", "FILE_CHOOSER_REQUEST_CODE", BuildConfig.FLAVOR, "binding", "Lcom/kaunik/ampture/databinding/FragmentBrowseBinding;", "getBinding", "()Lcom/kaunik/ampture/databinding/FragmentBrowseBinding;", "setBinding", "(Lcom/kaunik/ampture/databinding/FragmentBrowseBinding;)V", "buttonHideHandler", "Landroid/os/Handler;", "currentMatchIndex", "getCurrentMatchIndex", "()I", "setCurrentMatchIndex", "(I)V", "currentTextZoom", "currentUrl", "currentZoom", "downloadDialog", "Landroid/app/AlertDialog;", "filePathCallback", "Landroid/webkit/ValueCallback;", BuildConfig.FLAVOR, "Landroid/net/Uri;", "isLoading", "Ljava/util/concurrent/atomic/AtomicBoolean;", "isScrolling", BuildConfig.FLAVOR, "lastAttemptedUrl", "lastErrorUrl", "lastScrollTime", BuildConfig.FLAVOR, "materialDialog", "Landroidx/appcompat/app/AlertDialog;", "scrollOffset", "searchForward", "getSearchForward", "()Z", "setSearchForward", "(Z)V", "searchWord", "getSearchWord", "()Ljava/lang/String;", "setSearchWord", "showingErrorPage", "tabId", "getTabId", "()J", "setTabId", "(J)V", "totalMatches", "getTotalMatches", "setTotalMatches", "getUrlNew", "setUrlNew", "webSnapshot", "Landroid/graphics/Bitmap;", "webView", "Landroid/webkit/WebView;", "getWebView", "()Landroid/webkit/WebView;", "setWebView", "(Landroid/webkit/WebView;)V", "webicon", "getWebicon", "()Landroid/graphics/Bitmap;", "setWebicon", "(Landroid/graphics/Bitmap;)V", "zoomControlDialog", "Landroid/app/Dialog;", "applyEnhancedPrivacySettings", BuildConfig.FLAVOR, "captureWebSnapshot", "checkAndPerformHaptic", "getWebIcon", "getWebSnapshot", "handleContextItemSelection", "item", "hideScrollButton", "immediately", "loadHtmlFromAssets", "filename", "onActivityResult", "requestCode", "resultCode", Constants.ScionAnalytics.MessageType.DATA_MESSAGE, "Landroid/content/Intent;", "onCreateContextMenu", "menu", "Landroid/view/ContextMenu;", "v", "Landroid/view/View;", "menuInfo", "Landroid/view/ContextMenu$ContextMenuInfo;", "onCreateView", "inflater", "Landroid/view/LayoutInflater;", "container", "Landroid/view/ViewGroup;", "savedInstanceState", "Landroid/os/Bundle;", "onDestroyView", "onPause", "onResume", "refreshWebView", "setupScrollToTopButton", "shareWebpageFromFragment", "showContextMenuDialog", "options", "([Ljava/lang/String;)V", "showControlDialog", "isZoom", "showScrollButton", "ZoomControlBinding", "app_release"}, k = 1, mv = {1, 9, 0}, xi = EMachine.EM_H8S)
public final class BrowseFragmen extends Fragment {
private final int FILE_CHOOSER_REQUEST_CODE;
public FragmentBrowseBinding binding;
private Handler buttonHideHandler;
private int currentMatchIndex;
private int currentTextZoom;
private String currentUrl;
private int currentZoom;
private AlertDialog downloadDialog;
private ValueCallback<Uri[]> filePathCallback;
private final AtomicBoolean isLoading;
private boolean isScrolling;
private String lastAttemptedUrl;
private String lastErrorUrl;
private long lastScrollTime;
private androidx.appcompat.app.AlertDialog materialDialog;
private int scrollOffset;
private boolean searchForward;
private String searchWord;
private boolean showingErrorPage;
private long tabId;
private int totalMatches;
private String urlNew;
private Bitmap webSnapshot;
public WebView webView;
private Bitmap webicon;
private Dialog zoomControlDialog;
public final int getCurrentMatchIndex() {
return this.currentMatchIndex;
}
public final boolean getSearchForward() {
return this.searchForward;
}
public final String getSearchWord() {
return this.searchWord;
}
public final long getTabId() {
return this.tabId;
}
public final int getTotalMatches() {
return this.totalMatches;
}
public final String getUrlNew() {
return this.urlNew;
}
public final Bitmap getWebicon() {
return this.webicon;
}
public final Bitmap getWebicon() {
return this.webicon;
}
public final void setBinding(FragmentBrowseBinding fragmentBrowseBinding) {
Intrinsics.checkNotNullParameter(fragmentBrowseBinding, "<set-?>");
this.binding = fragmentBrowseBinding;
}
public final void setCurrentMatchIndex(int i) {
this.currentMatchIndex = i;
}
public final void setSearchForward(boolean z) {
this.searchForward = z;
}
public final void setSearchWord(String str) {
Intrinsics.checkNotNullParameter(str, "<set-?>");
this.searchWord = str;
}
public final void setTabId(long j) {
this.tabId = j;
}
public final void setTotalMatches(int i) {
this.totalMatches = i;
}
public final void setUrlNew(String str) {
Intrinsics.checkNotNullParameter(str, "<set-?>");
this.urlNew = str;
}
public final void setWebView(WebView webView) {
Intrinsics.checkNotNullParameter(webView, "<set-?>");
this.webView = webView;
}
public final void setWebicon(Bitmap bitmap) {
this.webicon = bitmap;
}
public BrowseFragmen(String urlNew) {
Intrinsics.checkNotNullParameter(urlNew, "urlNew");
this.urlNew = urlNew;
this.searchWord = BuildConfig.FLAVOR;
this.currentZoom = 100;
this.currentTextZoom = 100;
this.searchForward = true;
this.FILE_CHOOSER_REQUEST_CODE = 1;
this.isLoading = new AtomicBoolean(false);
this.tabId = System.currentTimeMillis();
this.buttonHideHandler = new Handler(Looper.getMainLooper());
}
public final FragmentBrowseBinding getBinding() {
FragmentBrowseBinding fragmentBrowseBinding = this.binding;
if (fragmentBrowseBinding != null) {
return fragmentBrowseBinding;
}
Intrinsics.throwUninitializedPropertyAccessException("binding");
return null;
}
public final WebView getWebView() {
WebView webView = this.webView;
if (webView != null) {
return webView;
}
Intrinsics.throwUninitializedPropertyAccessException("webView");
return null;
}
@Metadata(d1 = {"\u0000*\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0007\b\u0002\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004R\u0011\u0010\u0005\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\u0007\u0010\bR\u0011\u0010\t\u001a\u00020\n¢\u0006\b\n\u0000\u001a\u0004\b\u000b\u0010\fR\u0011\u0010\r\u001a\u00020\u000e¢\u0006\b\n\u0000\u001a\u0004\b\u000f\u0010\u0010R\u0011\u0010\u0011\u001a\u00020\u000e¢\u0006\b\n\u0000\u001a\u0004\b\u0012\u0010\u0010R\u0011\u0010\u0013\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\u0014\u0010\bR\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u0015"}, d2 = {"Lcom/kaunik/ampture/fragment/BrowseFragmen$ZoomControlBinding;", BuildConfig.FLAVOR, "view", "Landroid/view/View;", "(Landroid/view/View;)V", "applyButton", "Lcom/google/android/material/button/MaterialButton;", "getApplyButton", "()Lcom/google/android/material/button/MaterialButton;", "controlSeekBar", "Landroidx/appcompat/widget/AppCompatSeekBar;", "getControlSeekBar", "()Landroidx/appcompat/widget/AppCompatSeekBar;", "currentValueText", "Landroid/widget/TextView;", "getCurrentValueText", "()Landroid/widget/TextView;", "dialogTitle", "getDialogTitle", "resetButton", "getResetButton", "app_release"}, k = 1, mv = {1, 9, 0}, xi = EMachine.EM_H8S)
static final class ZoomControlBinding {
private final MaterialButton applyButton;
private final AppCompatSeekBar controlSeekBar;
private final TextView currentValueText;
private final TextView dialogTitle;
private final MaterialButton resetButton;
private final View view;
public final MaterialButton getApplyButton() {
return this.applyButton;
}
public final AppCompatSeekBar getControlSeekBar() {
return this.controlSeekBar;
}
public final TextView getCurrentValueText() {
return this.currentValueText;
}
public final TextView getDialogTitle() {
return this.dialogTitle;
}
public final MaterialButton getResetButton() {
return this.resetButton;
}
public ZoomControlBinding(View view) {
Intrinsics.checkNotNullParameter(view, "view");
this.view = view;
View findViewById = view.findViewById(R.id.dialogTitle);
Intrinsics.checkNotNullExpressionValue(findViewById, "findViewById(...)");
this.dialogTitle = (TextView) findViewById;
View findViewById2 = view.findViewById(R.id.currentValueText);
Intrinsics.checkNotNullExpressionValue(findViewById2, "findViewById(...)");
this.currentValueText = (TextView) findViewById2;
AppCompatSeekBar findViewById3 = view.findViewById(R.id.controlSeekBar);
Intrinsics.checkNotNullExpressionValue(findViewById3, "findViewById(...)");
this.controlSeekBar = findViewById3;
MaterialButton findViewById4 = view.findViewById(R.id.resetButton);
Intrinsics.checkNotNullExpressionValue(findViewById4, "findViewById(...)");
this.resetButton = findViewById4;
MaterialButton findViewById5 = view.findViewById(R.id.applyButton);
Intrinsics.checkNotNullExpressionValue(findViewById5, "findViewById(...)");
this.applyButton = findViewById5;
}
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
String str;
Intrinsics.checkNotNullParameter(inflater, "inflater");
final View inflate = inflater.inflate(R.layout.fragment_browse, container, false);
FragmentBrowseBinding bind = FragmentBrowseBinding.bind(inflate);
Intrinsics.checkNotNullExpressionValue(bind, "bind(...)");
setBinding(bind);
WebView webView = getBinding().webView;
Intrinsics.checkNotNullExpressionValue(webView, "webView");
setWebView(webView);
setupScrollToTopButton();
WebSettings settings = getWebView().getSettings();
settings.setJavaScriptEnabled(true);
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setBuiltInZoomControls(false);
settings.setDisplayZoomControls(false);
this.currentZoom = 100;
this.currentTextZoom = getWebView().getSettings().getTextZoom();
getBinding().zoomBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
BrowseFragmen.onCreateView$lambda$1(BrowseFragmen.this, view);
}
});
getBinding().changeTextSizeBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
BrowseFragmen.onCreateView$lambda$2(BrowseFragmen.this, view);
}
});
View findViewById = inflate.findViewById(R.id.upBtn);
Intrinsics.checkNotNullExpressionValue(findViewById, "findViewById(...)");
View findViewById2 = inflate.findViewById(R.id.downBtn);
Intrinsics.checkNotNullExpressionValue(findViewById2, "findViewById(...)");
View findViewById3 = inflate.findViewById(R.id.tvMatches);
Intrinsics.checkNotNullExpressionValue(findViewById3, "findViewById(...)");
final TextView textView = (TextView) findViewById3;
getBinding().webView.setFindListener(new WebView.FindListener() {
@Override
public final void onFindResultReceived(int i, int i2, boolean z) {
BrowseFragmen.onCreateView$lambda$3(BrowseFragmen.this, textView, i, i2, z);
}
});
((Button) findViewById).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
BrowseFragmen.onCreateView$lambda$4(BrowseFragmen.this, view);
}
});
((Button) findViewById2).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
BrowseFragmen.onCreateView$lambda$5(BrowseFragmen.this, view);
}
});
getBinding().inputField.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
BrowseFragmen.this.setSearchWord(String.valueOf(s));
if (BrowseFragmen.this.getSearchWord().length() == 0) {
textView.setVisibility(8);
} else {
BrowseFragmen.this.getBinding().webView.findAllAsync(BrowseFragmen.this.getSearchWord());
textView.setVisibility(0);
}
}
});
getBinding().inputField.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
BrowseFragmen.this.setSearchWord(String.valueOf(s));
BrowseFragmen.this.getBinding().webView.findAllAsync(BrowseFragmen.this.getSearchWord());
}
});
getBinding().inputField.setOnKeyListener(new View.OnKeyListener() {
@Override
public final boolean onKey(View view, int i, KeyEvent keyEvent) {
boolean onCreateView$lambda$6;
onCreateView$lambda$6 = BrowseFragmen.onCreateView$lambda$6(BrowseFragmen.this, inflate, view, i, keyEvent);
return onCreateView$lambda$6;
}
});
getBinding().inputField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public final boolean onEditorAction(TextView textView2, int i, KeyEvent keyEvent) {
boolean onCreateView$lambda$7;
onCreateView$lambda$7 = BrowseFragmen.onCreateView$lambda$7(BrowseFragmen.this, inflate, textView2, i, keyEvent);
return onCreateView$lambda$7;
}
});
getBinding().searchWord.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
BrowseFragmen.onCreateView$lambda$8(BrowseFragmen.this, view);
}
});
FragmentActivity activity = getActivity();
SharedPreferences sharedPreferences = activity != null ? activity.getSharedPreferences("settings", 0) : null;
getBinding().webView.getSettings().setBlockNetworkImage(sharedPreferences != null ? sharedPreferences.getBoolean("data_saver_mode", false) : false);
FragmentActivity activity2 = getActivity();
SharedPreferences sharedPreferences2 = activity2 != null ? activity2.getSharedPreferences("MyPrefs", 0) : null;
if (Intrinsics.areEqual((Object) (sharedPreferences2 != null ? Boolean.valueOf(sharedPreferences2.getBoolean("IsEnabled", true)) : null), (Object) false)) {
getBinding().frameLayout.setVisibility(8);
}
registerForContextMenu(getBinding().webView);
SharedPreferences sharedPreferences3 = requireActivity().getSharedPreferences("SearchEnginePref", 0);
String string = sharedPreferences3 != null ? sharedPreferences3.getString("searchEngine", "Google") : null;
WebView webView2 = getBinding().webView;
if (new Regex("^(https?://)?([\\w-]+\\.)+[a-zA-Z]{2,}(/.*)?$").matches(StringsKt.trim((CharSequence) this.urlNew).toString())) {
if (StringsKt.startsWith$default(this.urlNew, "http://", false, 2, (Object) null)) {
this.urlNew = StringsKt.replaceFirst$default(this.urlNew, "http://", "https://", false, 4, (Object) null);
} else if (!StringsKt.startsWith$default(this.urlNew, "http://", false, 2, (Object) null) && !StringsKt.startsWith$default(this.urlNew, "https://", false, 2, (Object) null)) {
this.urlNew = "https://" + this.urlNew;
}
webView2.loadUrl(this.urlNew);
} else {
if (string != null) {
switch (string.hashCode()) {
case -83502334:
if (string.equals("Perplexity")) {
str = "https://www.perplexity.ai/search?q=" + Uri.encode(this.urlNew);
break;
}
break;
case 2070624:
if (string.equals("Bing")) {
str = "https://www.bing.com/search?q=" + Uri.encode(this.urlNew);
break;
}
break;
case 85186592:
if (string.equals("Yahoo")) {
str = "https://search.yahoo.com/search?p=" + Uri.encode(this.urlNew);
break;
}
break;
case 671954723:
if (string.equals("YouTube")) {
str = "https://www.youtube.com/results?search_query=" + Uri.encode(this.urlNew);
break;
}
break;
case 1774242234:
if (string.equals("DuckDuckGo")) {
str = "https://duckduckgo.com/?q=" + Uri.encode(this.urlNew);
break;
}
break;
}
webView2.loadUrl(str);
}
str = "https://www.google.com/search?q=" + Uri.encode(this.urlNew);
webView2.loadUrl(str);
}
return inflate;
}
public static final void onCreateView$lambda$1(BrowseFragmen this$0, View view) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.checkAndPerformHaptic();
this$0.showControlDialog(true);
}
public static final void onCreateView$lambda$2(BrowseFragmen this$0, View view) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.checkAndPerformHaptic();
this$0.showControlDialog(false);
}
public static final void onCreateView$lambda$3(BrowseFragmen this$0, TextView tvMatches, int i, int i2, boolean z) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
Intrinsics.checkNotNullParameter(tvMatches, "$tvMatches");
this$0.currentMatchIndex = i;
this$0.totalMatches = i2;
if (i2 > 0) {
tvMatches.setText((i + 1) + "/" + i2);
return;
}
tvMatches.setVisibility(8);
}
public static final void onCreateView$lambda$4(BrowseFragmen this$0, View view) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.searchForward = false;
this$0.getBinding().webView.findNext(this$0.searchForward);
Intrinsics.checkNotNull(view);
MSettingsActivityKt.performHapticFeedback(view);
}
public static final void onCreateView$lambda$5(BrowseFragmen this$0, View view) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.searchForward = true;
this$0.getBinding().webView.findNext(this$0.searchForward);
Intrinsics.checkNotNull(view);
MSettingsActivityKt.performHapticFeedback(view);
}
public static final boolean onCreateView$lambda$6(BrowseFragmen this$0, View view, View view2, int i, KeyEvent keyEvent) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
if (i != 66 || keyEvent.getAction() != 1) {
return false;
}
this$0.getBinding().webView.findAllAsync(this$0.searchWord);
FragmentActivity activity = this$0.getActivity();
Object systemService = activity != null ? activity.getSystemService("input_method") : null;
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.view.inputmethod.InputMethodManager");
((InputMethodManager) systemService).hideSoftInputFromWindow(view != null ? view.getWindowToken() : null, 0);
return true;
}
public static final boolean onCreateView$lambda$7(BrowseFragmen this$0, View view, TextView textView, int i, KeyEvent keyEvent) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
if (i != 6) {
return false;
}
this$0.getBinding().webView.findAllAsync(this$0.searchWord);
FragmentActivity activity = this$0.getActivity();
Object systemService = activity != null ? activity.getSystemService("input_method") : null;
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.view.inputmethod.InputMethodManager");
((InputMethodManager) systemService).hideSoftInputFromWindow(view != null ? view.getWindowToken() : null, 0);
return true;
}
public static final void onCreateView$lambda$8(BrowseFragmen this$0, View view) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.checkAndPerformHaptic();
if (this$0.getBinding().searchWordLayout.getVisibility() == 8) {
this$0.getBinding().searchWordLayout.startAnimation(AnimationUtils.loadAnimation(this$0.getContext(), R.anim.fade_in));
this$0.getBinding().searchWordLayout.setVisibility(0);
this$0.getBinding().searchWordLayout.requestFocus();
return;
}
this$0.getBinding().searchWordLayout.startAnimation(AnimationUtils.loadAnimation(this$0.getContext(), R.anim.fade_out));
this$0.getBinding().inputField.getText().clear();
this$0.getBinding().searchWordLayout.setVisibility(8);
this$0.getBinding().searchWordLayout.clearFocus();
}
private final void checkAndPerformHaptic() {
if (requireContext().getSharedPreferences("MyPrefs", 0).getBoolean("HapticEnabled", true)) {
Context requireContext = requireContext();
Intrinsics.checkNotNullExpressionValue(requireContext, "requireContext(...)");
MainActivityKt.performHapticFeedback(requireContext, 50L);
}
}
private final void showControlDialog(final boolean isZoom) {
Dialog dialog = this.zoomControlDialog;
if (dialog != null) {
dialog.dismiss();
}
View inflate = getLayoutInflater().inflate(R.layout.dialog_zoom_text_control, (ViewGroup) null);
Intrinsics.checkNotNull(inflate);
final ZoomControlBinding zoomControlBinding = new ZoomControlBinding(inflate);
final Ref.BooleanRef booleanRef = new Ref.BooleanRef();
Dialog dialog2 = new Dialog(requireContext(), R.style.curved);
dialog2.setContentView(inflate);
Window window = dialog2.getWindow();
if (window != null) {
int i = (int) (r2.heightPixels * 0.05f);
window.setLayout(requireContext().getResources().getDisplayMetrics().widthPixels - (((int) (r2.widthPixels * 0.05f)) * 2), -2);
window.setBackgroundDrawable(new ColorDrawable(0));
window.setWindowAnimations(R.style.DialogAnimation);
WindowManager.LayoutParams attributes = window.getAttributes();
attributes.gravity = 80;
attributes.y = i;
window.setAttributes(attributes);
}
dialog2.setCanceledOnTouchOutside(true);
this.zoomControlDialog = dialog2;
if (Build.VERSION.SDK_INT >= 26) {
zoomControlBinding.getControlSeekBar().setMin(50);
}
final int i2 = isZoom ? this.currentZoom : this.currentTextZoom;
final Ref.IntRef intRef = new Ref.IntRef();
intRef.element = i2;
zoomControlBinding.getDialogTitle().setText(isZoom ? "Page Zoom" : "Text Size");
zoomControlBinding.getControlSeekBar().setProgress(i2);
zoomControlBinding.getCurrentValueText().setText(i2 + "%");
zoomControlBinding.getControlSeekBar().setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int i3 = (Build.VERSION.SDK_INT >= 26 || progress >= 50) ? progress : 50;
if (Build.VERSION.SDK_INT < 26 && progress < 50 && fromUser && seekBar != null) {
seekBar.setProgress(50);
}
Ref.IntRef.this.element = i3;
zoomControlBinding.getCurrentValueText().setText(i3 + "%");
if (isZoom) {
this.getWebView().evaluateJavascript("document.body.style.zoom = '" + (i3 / 100.0f) + "';", null);
return;
}
this.getWebView().getSettings().setTextZoom(i3);
}
});
zoomControlBinding.getResetButton().setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
BrowseFragmen.showControlDialog$lambda$12(Ref.BooleanRef.this, intRef, zoomControlBinding, isZoom, this, view);
}
});
zoomControlBinding.getApplyButton().setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
BrowseFragmen.showControlDialog$lambda$13(Ref.BooleanRef.this, isZoom, this, intRef, view);
}
});
Dialog dialog3 = this.zoomControlDialog;
if (dialog3 != null) {
dialog3.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public final void onDismiss(DialogInterface dialogInterface) {
BrowseFragmen.showControlDialog$lambda$14(Ref.BooleanRef.this, isZoom, this, i2, dialogInterface);
}
});
}
Dialog dialog4 = this.zoomControlDialog;
if (dialog4 != null) {
dialog4.show();
}
}
public static final void showControlDialog$lambda$12(Ref.BooleanRef confirmed, Ref.IntRef tempValue, ZoomControlBinding dialogBinding, boolean z, BrowseFragmen this$0, View view) {
Intrinsics.checkNotNullParameter(confirmed, "$confirmed");
Intrinsics.checkNotNullParameter(tempValue, "$tempValue");
Intrinsics.checkNotNullParameter(dialogBinding, "$dialogBinding");
Intrinsics.checkNotNullParameter(this$0, "this$0");
confirmed.element = true;
tempValue.element = 100;
dialogBinding.getControlSeekBar().setProgress(100);
dialogBinding.getCurrentValueText().setText("100%");
if (z) {
this$0.currentZoom = 100;
this$0.getWebView().evaluateJavascript("document.body.style.zoom = '1';", null);
} else {
this$0.currentTextZoom = 100;
this$0.getWebView().getSettings().setTextZoom(100);
}
Dialog dialog = this$0.zoomControlDialog;
if (dialog != null) {
dialog.dismiss();
}
}
public static final void showControlDialog$lambda$13(Ref.BooleanRef confirmed, boolean z, BrowseFragmen this$0, Ref.IntRef tempValue, View view) {
Intrinsics.checkNotNullParameter(confirmed, "$confirmed");
Intrinsics.checkNotNullParameter(this$0, "this$0");
Intrinsics.checkNotNullParameter(tempValue, "$tempValue");
confirmed.element = true;
if (z) {
this$0.currentZoom = tempValue.element;
this$0.getWebView().evaluateJavascript("document.body.style.zoom = '" + (tempValue.element / 100.0f) + "';", null);
} else {
this$0.currentTextZoom = tempValue.element;
this$0.getWebView().getSettings().setTextZoom(tempValue.element);
}
Dialog dialog = this$0.zoomControlDialog;
if (dialog != null) {
dialog.dismiss();
}
}
public static final void showControlDialog$lambda$14(Ref.BooleanRef confirmed, boolean z, BrowseFragmen this$0, int i, DialogInterface dialogInterface) {
Intrinsics.checkNotNullParameter(confirmed, "$confirmed");
Intrinsics.checkNotNullParameter(this$0, "this$0");
if (confirmed.element) {
return;
}
if (z) {
this$0.getWebView().evaluateJavascript("document.body.style.zoom = '" + (i / 100.0f) + "';", null);
return;
}
this$0.getWebView().getSettings().setTextZoom(i);
}
private final void setupScrollToTopButton() {
getBinding().scrollToTopBtn.setVisibility(8);
getBinding().webView.setOnScrollChangeListener(new View.OnScrollChangeListener() {
@Override
public final void onScrollChange(View view, int i, int i2, int i3, int i4) {
BrowseFragmen.setupScrollToTopButton$lambda$16(BrowseFragmen.this, view, i, i2, i3, i4);
}
});
getBinding().scrollToTopBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
BrowseFragmen.setupScrollToTopButton$lambda$19(BrowseFragmen.this, view);
}
});
}
public static final void setupScrollToTopButton$lambda$16(final BrowseFragmen this$0, View view, int i, int i2, int i3, int i4) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
long currentTimeMillis = System.currentTimeMillis();
this$0.isScrolling = true;
this$0.lastScrollTime = currentTimeMillis;
int i5 = this$0.scrollOffset + (i2 - i4);
this$0.scrollOffset = i5;
if (i2 == 0) {
this$0.hideScrollButton(true);
} else if (i5 > 100) {
this$0.showScrollButton();
} else {
hideScrollButton$default(this$0, false, 1, null);
}
this$0.buttonHideHandler.removeCallbacksAndMessages(null);
this$0.buttonHideHandler.postDelayed(new Runnable() {
@Override
public final void run() {
BrowseFragmen.setupScrollToTopButton$lambda$16$lambda$15(BrowseFragmen.this);
}
}, 1000L);
}
public static final void setupScrollToTopButton$lambda$16$lambda$15(BrowseFragmen this$0) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
if (System.currentTimeMillis() - this$0.lastScrollTime >= 1000) {
hideScrollButton$default(this$0, false, 1, null);
}
}
public static final void setupScrollToTopButton$lambda$19(final BrowseFragmen this$0, View view) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.buttonHideHandler.removeCallbacksAndMessages(null);
this$0.isScrolling = false;
ValueAnimator ofInt = ValueAnimator.ofInt(this$0.getBinding().webView.getScrollY(), 0);
ofInt.setDuration(300L);
ofInt.setInterpolator(new DecelerateInterpolator());
ofInt.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
BrowseFragmen.setupScrollToTopButton$lambda$19$lambda$18$lambda$17(BrowseFragmen.this, valueAnimator);
}
});
ofInt.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
Intrinsics.checkNotNullParameter(animation, "animation");
BrowseFragmen.this.hideScrollButton(true);
BrowseFragmen.this.isScrolling = true;
}
});
ofInt.start();
}
public static final void setupScrollToTopButton$lambda$19$lambda$18$lambda$17(BrowseFragmen this$0, ValueAnimator animator) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
Intrinsics.checkNotNullParameter(animator, "animator");
WebView webView = this$0.getBinding().webView;
Object animatedValue = animator.getAnimatedValue();
Intrinsics.checkNotNull(animatedValue, "null cannot be cast to non-null type kotlin.Int");
webView.scrollTo(0, ((Integer) animatedValue).intValue());
}
private final void showScrollButton() {
if (getBinding().scrollToTopBtn.getVisibility() == 8) {
ImageView imageView = getBinding().scrollToTopBtn;
imageView.setVisibility(0);
imageView.setAlpha(0.0f);
imageView.animate().alpha(1.0f).setDuration(200L).start();
}
}
static void hideScrollButton$default(BrowseFragmen browseFragmen, boolean z, int i, Object obj) {
if ((i & 1) != 0) {
z = false;
}
browseFragmen.hideScrollButton(z);
}
public final void hideScrollButton(boolean immediately) {
if (getBinding().scrollToTopBtn.getVisibility() == 0) {
if (immediately) {
getBinding().scrollToTopBtn.setVisibility(8);
} else {
getBinding().scrollToTopBtn.animate().alpha(0.0f).setDuration(200L).withEndAction(new Runnable() {
@Override
public final void run() {
BrowseFragmen.hideScrollButton$lambda$21(BrowseFragmen.this);
}
}).start();
}
}
}
public static final void hideScrollButton$lambda$21(BrowseFragmen this$0) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.getBinding().scrollToTopBtn.setVisibility(8);
}
public void onResume() {
super.onResume();
MainActivity requireActivity = requireActivity();
Intrinsics.checkNotNull(requireActivity, "null cannot be cast to non-null type com.kaunik.ampture.activity.MainActivity");
final MainActivity mainActivity = requireActivity;
final SharedPreferences sharedPreferences = requireActivity().getSharedPreferences("MyPrefs", 0);
MainActivity.INSTANCE.getTabList().get(MainActivity.INSTANCE.getMyPager().getCurrentItem()).setName(String.valueOf(getBinding().webView.getUrl()));
MainActivity.INSTANCE.getTabsBtn().setText(String.valueOf(MainActivity.INSTANCE.getTabList().size()));
if (sharedPreferences.getBoolean("OneClickPrivacyEnabled", false)) {
applyEnhancedPrivacySettings();
}
getBinding().webView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public final boolean onLongClick(View view) {
boolean onResume$lambda$22;
onResume$lambda$22 = BrowseFragmen.onResume$lambda$22(BrowseFragmen.this, view);
return onResume$lambda$22;
}
});
getBinding().webView.setDownloadListener(new DownloadListener() {
@Override
public final void onDownloadStart(String str, String str2, String str3, String str4, long j) {
BrowseFragmen.onResume$lambda$25(sharedPreferences, this, str, str2, str3, str4, j);
}
});
getBinding().webView.setDownloadListener(new DownloadListener() {
@Override
public final void onDownloadStart(String str, String str2, String str3, String str4, long j) {
BrowseFragmen.onResume$lambda$28(MainActivity.this, this, str, str2, str3, str4, j);
}
});
getBinding().showWebViewUrlWhenMotionlayoutStateIsEndLayout.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
BrowseFragmen.onResume$lambda$29(MainActivity.this, view);
}
});
final MotionLayout findViewById = mainActivity.findViewById(R.id.motionlayout);
findViewById.setTransitionListener(new BrowseFragmen$onResume$5(this));
boolean z = sharedPreferences.getBoolean("IsIPTrackingPrevented", false);
boolean z2 = sharedPreferences.getBoolean("SwipeRefreshEnabled", true);
getBinding().swipeRefreshLayout.setEnabled(z2);
mainActivity.getBinding().refreshBtn.setVisibility(z2 ? 0 : 8);
getBinding().swipeRefreshLayout.setColorSchemeResources(new int[]{R.color.M2});
getBinding().swipeRefreshLayout.setOnChildScrollUpCallback(new SwipeRefreshLayout.OnChildScrollUpCallback() {
public final boolean canChildScrollUp(SwipeRefreshLayout swipeRefreshLayout, View view) {
boolean onResume$lambda$30;
onResume$lambda$30 = BrowseFragmen.onResume$lambda$30(findViewById, this, swipeRefreshLayout, view);
return onResume$lambda$30;
}
});
getBinding().swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
public final void onRefresh() {
BrowseFragmen.onResume$lambda$31(BrowseFragmen.this, findViewById);
}
});
mainActivity.getBinding().refreshBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
BrowseFragmen.onResume$lambda$32(BrowseFragmen.this, view);
}
});
if (!z2) {
mainActivity.getBinding().refreshBtn.setVisibility(0);
}
if (sharedPreferences.getBoolean("SafeBrowsingEnabled", true)) {
WebSettings settings = getBinding().webView.getSettings();
Intrinsics.checkNotNullExpressionValue(settings, "getSettings(...)");
if (Build.VERSION.SDK_INT >= 26) {
settings.setSafeBrowsingEnabled(true);
}
} else {
WebSettings settings2 = getBinding().webView.getSettings();
Intrinsics.checkNotNullExpressionValue(settings2, "getSettings(...)");
if (Build.VERSION.SDK_INT >= 26) {
settings2.setSafeBrowsingEnabled(false);
}
}
boolean z3 = sharedPreferences.getBoolean("JavascriptEnabled", true);
WebView webView = getBinding().webView;
webView.getSettings().setJavaScriptEnabled(z3 && !z);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setDomStorageEnabled(true);
if (z) {
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookies(null);
cookieManager.setAcceptThirdPartyCookies(getBinding().webView, false);
webView.getSettings().setCacheMode(2);
webView.getSettings().setGeolocationEnabled(false);
webView.getSettings().setSaveFormData(false);
webView.evaluateJavascript("(function() {\n let rtc = window.RTCPeerConnection || window.webkitRTCPeerConnection;\n if (rtc) {\n rtc.prototype.createDataChannel = function() {\n console.log(\"WebRTC is disabled to prevent IP leak.\");\n return null;\n };\n rtc.prototype.createOffer = function() {\n console.log(\"WebRTC is disabled to prevent IP leak.\");\n return null;\n };\n rtc.prototype.createAnswer = function() {\n console.log(\"WebRTC is disabled to prevent IP leak.\");\n return null;\n };\n }\n})();", null);
}
webView.setWebViewClient(new BrowseFragmen$onResume$9$1(mainActivity, this, webView));
webView.setWebChromeClient(new WebChromeClient() {
private View customView;
private WebChromeClient.CustomViewCallback customViewCallback;
private int originalOrientation;
@Override
public boolean onShowFileChooser(WebView webView2, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {
int i;
Intrinsics.checkNotNullParameter(filePathCallback, "filePathCallback");
Intrinsics.checkNotNullParameter(fileChooserParams, "fileChooserParams");
BrowseFragmen.this.filePathCallback = filePathCallback;
Intent createIntent = fileChooserParams.createIntent();
try {
BrowseFragmen browseFragmen = BrowseFragmen.this;
i = browseFragmen.FILE_CHOOSER_REQUEST_CODE;
browseFragmen.startActivityForResult(createIntent, i);
return true;
} catch (ActivityNotFoundException unused) {
BrowseFragmen.this.filePathCallback = null;
return false;
}
}
@Override
public void onReceivedIcon(WebView view, Bitmap icon) {
super.onReceivedIcon(view, icon);
try {
mainActivity.getBinding().webIcon.setImageBitmap(icon);
BrowseFragmen.this.setWebicon(icon);
MainActivity.Companion companion = MainActivity.INSTANCE;
MainActivity mainActivity2 = mainActivity;
String url = view != null ? view.getUrl() : null;
Intrinsics.checkNotNull(url);
companion.setBookmarkIndex(mainActivity2.isBookmarked(url));
if (MainActivity.INSTANCE.getBookmarkIndex() != -1) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Intrinsics.checkNotNull(icon);
icon.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
MainActivity.INSTANCE.getBookmarkList().get(MainActivity.INSTANCE.getBookmarkIndex()).setImage(byteArrayOutputStream.toByteArray());
}
} catch (Exception unused) {
}
}
@Override
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {
Window window;
Window window2;
if (this.customView != null) {
onHideCustomView();
return;
}
this.customView = view;
FragmentActivity activity = BrowseFragmen.this.getActivity();
this.originalOrientation = activity != null ? activity.getRequestedOrientation() : 0;
this.customViewCallback = callback;
FragmentActivity activity2 = BrowseFragmen.this.getActivity();
View decorView = (activity2 == null || (window2 = activity2.getWindow()) == null) ? null : window2.getDecorView();
Intrinsics.checkNotNull(decorView, "null cannot be cast to non-null type android.widget.FrameLayout");
((FrameLayout) decorView).addView(this.customView, new FrameLayout.LayoutParams(-1, -1));
FragmentActivity activity3 = BrowseFragmen.this.getActivity();
if (activity3 != null) {
activity3.setRequestedOrientation(6);
}
FragmentActivity activity4 = BrowseFragmen.this.getActivity();
if (activity4 == null || (window = activity4.getWindow()) == null) {
return;
}
window.addFlags(LockFreeTaskQueueCore.MIN_ADD_SPIN_CAPACITY);
}
@Override
public void onHideCustomView() {
Window window;
Window window2;
Window window3;
FragmentActivity activity = BrowseFragmen.this.getActivity();
View view = null;
View decorView = (activity == null || (window3 = activity.getWindow()) == null) ? null : window3.getDecorView();
Intrinsics.checkNotNull(decorView, "null cannot be cast to non-null type android.widget.FrameLayout");
((FrameLayout) decorView).removeView(this.customView);
this.customView = null;
FragmentActivity activity2 = BrowseFragmen.this.getActivity();
if (activity2 != null) {
activity2.setRequestedOrientation(this.originalOrientation);
}
FragmentActivity activity3 = BrowseFragmen.this.getActivity();
if (activity3 != null && (window2 = activity3.getWindow()) != null) {
window2.clearFlags(LockFreeTaskQueueCore.MIN_ADD_SPIN_CAPACITY);
}
WebChromeClient.CustomViewCallback customViewCallback = this.customViewCallback;
if (customViewCallback != null) {
customViewCallback.onCustomViewHidden();
}
MainActivity activity4 = BrowseFragmen.this.getActivity();
Intrinsics.checkNotNull(activity4, "null cannot be cast to non-null type com.kaunik.ampture.activity.MainActivity");
if (activity4.getIsFullscreen()) {
FragmentActivity activity5 = BrowseFragmen.this.getActivity();
if (activity5 != null && (window = activity5.getWindow()) != null) {
view = window.getDecorView();
}
if (view == null) {
return;
}
view.setSystemUiVisibility(4);
}
}
});
getBinding().webView.setOnTouchListener(new View.OnTouchListener() {
@Override
public final boolean onTouch(View view, MotionEvent motionEvent) {
boolean onResume$lambda$34$lambda$33;
onResume$lambda$34$lambda$33 = BrowseFragmen.onResume$lambda$34$lambda$33(MainActivity.this, view, motionEvent);
return onResume$lambda$34$lambda$33;
}
});
webView.setKeepScreenOn(true);
}
public static final boolean onResume$lambda$22(BrowseFragmen this$0, View view) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
Intrinsics.checkNotNull(view, "null cannot be cast to non-null type android.webkit.WebView");
WebView.HitTestResult hitTestResult = ((WebView) view).getHitTestResult();
Intrinsics.checkNotNullExpressionValue(hitTestResult, "getHitTestResult(...)");
if (hitTestResult.getType() != 5) {
return false;
}
this$0.showContextMenuDialog(new String[]{"View Image", "Save Image", "Share", HTTP.CONN_CLOSE});
return true;
}
public static final void onResume$lambda$25(SharedPreferences sharedPreferences, final BrowseFragmen this$0, final String str, String str2, String str3, String str4, long j) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
if (sharedPreferences.getBoolean("BlockDownload", false)) {
return;
}
AlertDialog create = new AlertDialog.Builder(this$0.requireContext()).setTitle("Download confirmation").setMessage("You are about to download a file. Please ensure that the file is from a trusted source to avoid potential harm to your device.").setPositiveButton("Download", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
BrowseFragmen.onResume$lambda$25$lambda$23(BrowseFragmen.this, str, dialogInterface, i);
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).create();
this$0.downloadDialog = create;
if (create != null) {
create.show();
}
}
public static final void onResume$lambda$25$lambda$23(BrowseFragmen this$0, String str, DialogInterface dialogInterface, int i) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse(str)));
}
public static final void onResume$lambda$28(final MainActivity mainRef, BrowseFragmen this$0, final String str, final String str2, String str3, final String str4, long j) {
Intrinsics.checkNotNullParameter(mainRef, "$mainRef");
Intrinsics.checkNotNullParameter(this$0, "this$0");
final String guessFileName = URLUtil.guessFileName(str, str3, str4);
AlertDialog.Builder builder = new AlertDialog.Builder((Context) mainRef);
builder.setTitle("Download");
builder.setMessage("Do you want to download " + guessFileName + "?");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
BrowseFragmen.onResume$lambda$28$lambda$26(str, str4, str2, guessFileName, mainRef, dialogInterface, i);
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
AlertDialog create = builder.create();
this$0.downloadDialog = create;
if (create != null) {
create.show();
}
}
public static final void onResume$lambda$28$lambda$26(String str, String str2, String str3, String str4, MainActivity mainRef, DialogInterface dialogInterface, int i) {
Intrinsics.checkNotNullParameter(mainRef, "$mainRef");
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(str));
request.setMimeType(str2);
request.addRequestHeader("User-Agent", str3);
request.setDescription("Downloading file...");
request.setTitle(str4);
request.allowScanningByMediaScanner();
request.setNotificationVisibility(1);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, str4);
Object systemService = mainRef.getSystemService("download");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.DownloadManager");
((DownloadManager) systemService).enqueue(request);
}
public static final void onResume$lambda$29(MainActivity mainRef, View view) {
Intrinsics.checkNotNullParameter(mainRef, "$mainRef");
mainRef.getBinding().motionlayout.transitionToStart();
}
public static final boolean onResume$lambda$30(MotionLayout motionLayout, BrowseFragmen this$0, SwipeRefreshLayout swipeRefreshLayout, View view) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
Intrinsics.checkNotNullParameter(swipeRefreshLayout, "<anonymous parameter 0>");
return ((motionLayout.getCurrentState() == R.id.start) && (this$0.getBinding().webView.getScrollY() == 0)) ? false : true;
}
public static final void onResume$lambda$31(BrowseFragmen this$0, MotionLayout motionLayout) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
if (this$0.getBinding().webView.getScrollY() == 0 && motionLayout.getCurrentState() == R.id.start) {
this$0.refreshWebView();
}
this$0.getBinding().swipeRefreshLayout.setRefreshing(false);
}
public static final void onResume$lambda$32(BrowseFragmen this$0, View view) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
if (this$0.isLoading.get()) {
this$0.getBinding().webView.stopLoading();
} else {
this$0.refreshWebView();
}
}
public static final boolean onResume$lambda$34$lambda$33(MainActivity mainRef, View view, MotionEvent motionEvent) {
Intrinsics.checkNotNullParameter(mainRef, "$mainRef");
mainRef.getBinding().getRoot().onTouchEvent(motionEvent);
return false;
}
private final void refreshWebView() {
if (this.showingErrorPage && this.lastErrorUrl != null) {
WebView webView = getBinding().webView;
String str = this.lastErrorUrl;
Intrinsics.checkNotNull(str);
webView.loadUrl(str);
return;
}
String url = getBinding().webView.getUrl();
String str2 = url;
if (str2 != null && str2.length() != 0 && !StringsKt.contains$default((CharSequence) str2, (CharSequence) "data:text/html", false, 2, (Object) null)) {
getBinding().webView.loadUrl(url);
return;
}
String str3 = this.currentUrl;
if (str3 != null && str3.length() != 0) {
WebView webView2 = getBinding().webView;
String str4 = this.currentUrl;
Intrinsics.checkNotNull(str4);
webView2.loadUrl(str4);
return;
}
String str5 = this.lastAttemptedUrl;
if (str5 != null && str5.length() != 0) {
WebView webView3 = getBinding().webView;
String str6 = this.lastAttemptedUrl;
Intrinsics.checkNotNull(str6);
webView3.loadUrl(str6);
return;
}
getBinding().webView.reload();
}
public final String loadHtmlFromAssets(String filename) {
InputStream open = requireContext().getAssets().open(filename);
Intrinsics.checkNotNullExpressionValue(open, "open(...)");
Reader inputStreamReader = new InputStreamReader(open, Charsets.UTF_8);
BufferedReader bufferedReader = inputStreamReader instanceof BufferedReader ? (BufferedReader) inputStreamReader : new BufferedReader(inputStreamReader, ConstantsKt.DEFAULT_BUFFER_SIZE);
try {
String readText = TextStreamsKt.readText(bufferedReader);
CloseableKt.closeFinally(bufferedReader, null);
return readText;
} finally {
}
}
public final void captureWebSnapshot() {
try {
final int scrollY = getBinding().webView.getScrollY();
getBinding().webView.scrollTo(0, 0);
if (getBinding().webView.getWidth() <= 0 || getBinding().webView.getHeight() <= 0) {
return;
}
Bitmap createBitmap = Bitmap.createBitmap(getBinding().webView.getWidth(), (int) (getBinding().webView.getWidth() / 1.7777778f), Bitmap.Config.ARGB_8888);
Intrinsics.checkNotNullExpressionValue(createBitmap, "createBitmap(...)");
getBinding().webView.draw(new Canvas(createBitmap));
this.webSnapshot = createBitmap;
Context context = getContext();
if (context != null) {
SnapshotManager.INSTANCE.saveSnapshotToStorage(context, createBitmap, this.tabId);
}
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public final void run() {
BrowseFragmen.captureWebSnapshot$lambda$37(BrowseFragmen.this, scrollY);
}
}, 50L);
} catch (Exception e) {
e.printStackTrace();
}
}
public static final void captureWebSnapshot$lambda$37(BrowseFragmen this$0, int i) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.getBinding().webView.scrollTo(0, i);
}
public final Bitmap getWebSnapshot() {
if (Build.VERSION.SDK_INT < 28) {
return null;
}
Bitmap bitmap = this.webSnapshot;
if (bitmap != null) {
return bitmap;
}
Context context = getContext();
if (context != null) {
return SnapshotManager.INSTANCE.loadSnapshotFromStorage(context, this.tabId);
}
return null;
}
private final void applyEnhancedPrivacySettings() {
WebView webView = getBinding().webView;
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
webView.getSettings().setGeolocationEnabled(false);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookies(null);
cookieManager.setAcceptCookie(false);
cookieManager.setAcceptThirdPartyCookies(getBinding().webView, false);
webView.getSettings().setCacheMode(2);
webView.clearCache(true);
webView.getSettings().setSaveFormData(false);
webView.getSettings().setMixedContentMode(1);
webView.getSettings().setMediaPlaybackRequiresUserGesture(true);
webView.evaluateJavascript("(function() {\n // Set Do Not Track\n if (navigator.doNotTrack === undefined) {\n Object.defineProperty(navigator, 'doNotTrack', { value: '1', writable: false });\n }\n \n // Block known tracking APIs while keeping JavaScript functional\n if (navigator.geolocation) {\n navigator.geolocation.getCurrentPosition = function(success, error) {\n error({ code: 1, message: \"Permission denied for privacy reasons\" });\n };\n }\n \n // Limit WebRTC without completely disabling JavaScript\n if (window.RTCPeerConnection) {\n const originalRTC = window.RTCPeerConnection;\n window.RTCPeerConnection = function(...args) {\n const pc = new originalRTC(...args);\n if (pc.createDataChannel) {\n const origCreateDataChannel = pc.createDataChannel;\n pc.createDataChannel = function() {\n // Block data channels used for tracking\n if (arguments[0].includes('tracking') || arguments[0].includes('analytics')) {\n console.warn('Blocked tracking channel');\n return null;\n }\n return origCreateDataChannel.apply(this, arguments);\n };\n }\n return pc;\n };\n }\n \n // Prevent fingerprinting techniques\n const randomValues = new Uint8Array(10);\n window.crypto.getRandomValues(randomValues);\n const noise = Array.from(randomValues).join('');\n \n // Add noise to canvas fingerprinting\n const origToDataURL = HTMLCanvasElement.prototype.toDataURL;\n HTMLCanvasElement.prototype.toDataURL = function() {\n const result = origToDataURL.apply(this, arguments);\n return result + noise;\n };\n \n // Add noise to audio fingerprinting\n if (window.AudioContext || window.webkitAudioContext) {\n const origGetFloatFrequencyData = AudioContext.prototype.getFloatFrequencyData;\n AudioContext.prototype.getFloatFrequencyData = function() {\n const result = origGetFloatFrequencyData.apply(this, arguments);\n // Add noise to results\n for (let i = 0; i < result.length; i++) {\n result[i] += (Math.random() * 2 - 1) * 0.1;\n }\n return result;\n };\n }\n \n // Block local storage and session storage for privacy\n Object.defineProperty(window, 'localStorage', {\n get: function() {\n return {\n setItem: function() {},\n getItem: function() { return null; },\n removeItem: function() {},\n clear: function() {}\n };\n }\n });\n \n Object.defineProperty(window, 'sessionStorage', {\n get: function() {\n return {\n setItem: function() {},\n getItem: function() { return null; },\n removeItem: function() {},\n clear: function() {}\n };\n }\n });\n \n // Block access to device orientation/motion events\n if (window.DeviceOrientationEvent) {\n window.DeviceOrientationEvent = function() {};\n }\n if (window.DeviceMotionEvent) {\n window.DeviceMotionEvent = function() {};\n }\n})();", null);
getBinding().webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
Uri url;
FragmentActivity activity = BrowseFragmen.this.getActivity();
SharedPreferences sharedPreferences = activity != null ? activity.getSharedPreferences("MyPrefs", 0) : null;
if (sharedPreferences != null && sharedPreferences.getBoolean("BlockBackNavigation", false) && view != null && view.canGoBack()) {
if (!Intrinsics.areEqual(view.getUrl(), String.valueOf(request != null ? request.getUrl() : null))) {
return true;
}
}
String uri = (request == null || (url = request.getUrl()) == null) ? null : url.toString();
if (uri != null && StringsKt.startsWith$default(uri, "http://", false, 2, (Object) null)) {
String replace$default = StringsKt.replace$default(uri, "http://", "https://", false, 4, (Object) null);
if (view != null) {
view.loadUrl(replace$default);
}
return true;
}
return super.shouldOverrideUrlLoading(view, request);
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
Uri url;
String uri;
if (request == null || (url = request.getUrl()) == null || (uri = url.toString()) == null) {
return super.shouldInterceptRequest(view, request);
}
if (isTrackingDomain(uri)) {
byte[] bytes = BuildConfig.FLAVOR.getBytes(Charsets.UTF_8);
Intrinsics.checkNotNullExpressionValue(bytes, "getBytes(...)");
return new WebResourceResponse(HTTP.PLAIN_TEXT_TYPE, "UTF-8", new ByteArrayInputStream(bytes));
}
return super.shouldInterceptRequest(view, request);
}
private final boolean isTrackingDomain(String url) {
List listOf = CollectionsKt.listOf((Object[]) new String[]{"google-analytics.com", "doubleclick.net", "facebook.com/tr", "analytics", "tracker", "pixel", "beacon", "metrics", "tracking", "adservice", "audience", "collect", "telemetry", "app-measurement.com", "dmtrk.net", "dmtrk.com", "ddlnk.net", "ddlnk.com", "trackedlink.net", "trackedweb.net", "emlfiles.com", "emlfiles1.com", "emlfiles2.com", "spgo.io", "eu.spgo.io", "a-ads.com", "abcstats.com", "adnet.com", "admodus.com", "admost.com", "admulti.com", "adonspot.com", "adoptio.net", "adperium.com", "adoftheyear.com", "allyes.com", "atemda.com", "atgsvcs.com", "ati-host.net", "auditude.com", "audienceiq.com", "brainsins.com", "bridgetrack.com", "brightcove.com", "brilig.com", "bunchofads.com", "buscape.com", "bustcash.com", "track.", "stat.", "stats.", "click.", "clk.", "count.", "counter.", "pixel.", "pxl.", "hit.", "monitor.", "log.", "logging.", "logger.", "data.", "impression.", "tag.", "visitor.", "visit.", "trace.", "analytic.", ".track", ".adserver", ".ads.", ".ad.", ".stat", ".click", ".counter", "pardot", "hubspot", "marketo", "mailchimp", "campaign-", "adobe.com/b/ss", "/track", "/tracking", "/analytics", "/pixel", "/beacon", "/counter", "/stat", "/log", "/collect", "/hit", "/event", "/metrics", "/impression"});
if ((listOf instanceof Collection) && listOf.isEmpty()) {
return false;
}
Iterator it = listOf.iterator();
while (it.hasNext()) {
if (StringsKt.contains((CharSequence) url, (CharSequence) it.next(), true)) {
return true;
}
}
return false;
}
});
}
public void onDestroyView() {
Context context;
super.onDestroyView();
this.lastAttemptedUrl = null;
this.currentUrl = null;
this.lastErrorUrl = null;
this.showingErrorPage = false;
if (Build.VERSION.SDK_INT >= 28 && (context = getContext()) != null) {
SnapshotManager.INSTANCE.deleteSnapshotFile(context, this.tabId);
}
AlertDialog alertDialog = this.downloadDialog;
if (alertDialog != null) {
alertDialog.dismiss();
}
this.downloadDialog = null;
this.buttonHideHandler.removeCallbacksAndMessages(null);
Dialog dialog = this.zoomControlDialog;
if (dialog != null) {
dialog.dismiss();
}
this.zoomControlDialog = null;
}
public void onPause() {
super.onPause();
MainActivity requireActivity = requireActivity();
Intrinsics.checkNotNull(requireActivity, "null cannot be cast to non-null type com.kaunik.ampture.activity.MainActivity");
requireActivity.saveBookmarks();
if (!requireActivity().getSharedPreferences("MyPrefs", 0).getBoolean("SaveHistory", true)) {
WebView webView = getBinding().webView;
webView.clearMatches();
webView.clearCache(true);
webView.clearHistory();
webView.clearFormData();
webView.clearSslPreferences();
CookieManager.getInstance().removeAllCookies(null);
WebStorage.getInstance().deleteAllData();
}
androidx.appcompat.app.AlertDialog alertDialog = this.materialDialog;
if (alertDialog != null) {
alertDialog.dismiss();
}
this.materialDialog = null;
}
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
Intrinsics.checkNotNullParameter(menu, "menu");
Intrinsics.checkNotNullParameter(v, "v");
super.onCreateContextMenu(menu, v, menuInfo);
WebView.HitTestResult hitTestResult = getBinding().webView.getHitTestResult();
Intrinsics.checkNotNullExpressionValue(hitTestResult, "getHitTestResult(...)");
int type = hitTestResult.getType();
if (type != 0) {
if (type != 1) {
if (type == 5) {
showContextMenuDialog(new String[]{"View Image", "Save Image", "Share", HTTP.CONN_CLOSE});
return;
} else if (type != 7) {
if (type != 9) {
showContextMenuDialog(new String[]{"Open in New Tab", "Open Tab in Background", "Share", HTTP.CONN_CLOSE});
return;
}
return;
}
}
showContextMenuDialog(new String[]{"Open in New Tab", "Open Tab in Background", "Share", HTTP.CONN_CLOSE});
}
}
private final void showContextMenuDialog(final String[] options) {
this.materialDialog = new MaterialAlertDialogBuilder(requireContext()).setItems(options, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
BrowseFragmen.showContextMenuDialog$lambda$42(BrowseFragmen.this, options, dialogInterface, i);
}
}).setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public final void onDismiss(DialogInterface dialogInterface) {
BrowseFragmen.showContextMenuDialog$lambda$43(BrowseFragmen.this, dialogInterface);
}
}).show();
}
public static final void showContextMenuDialog$lambda$42(BrowseFragmen this$0, String[] options, DialogInterface dialogInterface, int i) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
Intrinsics.checkNotNullParameter(options, "$options");
this$0.handleContextItemSelection(options[i]);
dialogInterface.dismiss();
}
public static final void showContextMenuDialog$lambda$43(BrowseFragmen this$0, DialogInterface dialogInterface) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.materialDialog = null;
}
public final boolean handleContextItemSelection(String item) {
Intrinsics.checkNotNullParameter(item, "item");
Message obtainMessage = new Handler().obtainMessage();
Intrinsics.checkNotNullExpressionValue(obtainMessage, "obtainMessage(...)");
getBinding().webView.requestFocusNodeHref(obtainMessage);
String string = obtainMessage.getData().getString("url");
String string2 = obtainMessage.getData().getString("src");
switch (item.hashCode()) {
case -1368615904:
if (item.equals("View Image") && string2 != null) {
String str = string2;
if (StringsKt.contains$default((CharSequence) str, (CharSequence) "base64", false, 2, (Object) null)) {
String substring = string2.substring(StringsKt.indexOf$default((CharSequence) str, ",", 0, false, 6, (Object) null) + 1);
Intrinsics.checkNotNullExpressionValue(substring, "substring(...)");
byte[] decode = Base64.decode(substring, 0);
Bitmap decodeByteArray = BitmapFactory.decodeByteArray(decode, 0, decode.length);
View shapeableImageView = new ShapeableImageView(requireContext());
shapeableImageView.setImageBitmap(decodeByteArray);
androidx.appcompat.app.AlertDialog create = new MaterialAlertDialogBuilder(requireContext()).setView(shapeableImageView).create();
Intrinsics.checkNotNullExpressionValue(create, "create(...)");
create.show();
shapeableImageView.getLayoutParams().width = Resources.getSystem().getDisplayMetrics().widthPixels;
shapeableImageView.getLayoutParams().height = (int) (Resources.getSystem().getDisplayMetrics().heightPixels * 0.75d);
shapeableImageView.requestLayout();
Window window = create.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(0));
}
} else {
MainActivityKt.changeTab$default(string2, new BrowseFragmen(string2), false, 4, null);
}
}
return true;
case -766974584:
if (item.equals("Open Tab in Background")) {
MainActivityKt.changeTab(String.valueOf(string), new BrowseFragmen(String.valueOf(string)), true);
}
return true;
case 65203672:
item.equals(HTTP.CONN_CLOSE);
return true;
case 79847359:
if (item.equals("Share")) {
if (string == null) {
string = string2;
}
if (string != null) {
String str2 = string;
if (StringsKt.contains$default((CharSequence) str2, (CharSequence) "base64", false, 2, (Object) null)) {
String substring2 = string.substring(StringsKt.indexOf$default((CharSequence) str2, ",", 0, false, 6, (Object) null) + 1);
Intrinsics.checkNotNullExpressionValue(substring2, "substring(...)");
byte[] decode2 = Base64.decode(substring2, 0);
new ShareCompat.IntentBuilder(requireContext()).setChooserTitle("Sharing Url!").setType("image/*").setStream(Uri.parse(MediaStore.Images.Media.insertImage(requireActivity().getContentResolver(), BitmapFactory.decodeByteArray(decode2, 0, decode2.length), "Image", (String) null))).startChooser();
} else {
new ShareCompat.IntentBuilder(requireContext()).setChooserTitle("Sharing this Url").setType(HTTP.PLAIN_TEXT_TYPE).setText(str2).startChooser();
}
} else {
Snackbar.make(getBinding().getRoot(), "Not a Valid Link!", HttpRequestExecutor.DEFAULT_WAIT_FOR_CONTINUE).show();
}
}
return true;
case 1159983184:
if (item.equals("Open in New Tab")) {
MainActivityKt.changeTab$default(String.valueOf(string), new BrowseFragmen(String.valueOf(string)), false, 4, null);
}
return true;
case 1563465976:
if (item.equals("Save Image") && string2 != null) {
String str3 = string2;
if (!StringsKt.contains$default((CharSequence) str3, (CharSequence) "base64", false, 2, (Object) null)) {
startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse(string2)));
return true;
}
String substring3 = string2.substring(StringsKt.indexOf$default((CharSequence) str3, ",", 0, false, 6, (Object) null) + 1);
Intrinsics.checkNotNullExpressionValue(substring3, "substring(...)");
byte[] decode3 = Base64.decode(substring3, 0);
MediaStore.Images.Media.insertImage(requireActivity().getContentResolver(), BitmapFactory.decodeByteArray(decode3, 0, decode3.length), "Image", (String) null);
Snackbar.make(getBinding().getRoot(), "Image Saved Successfully", HttpRequestExecutor.DEFAULT_WAIT_FOR_CONTINUE).show();
}
default:
return true;
}
}
public final void shareWebpageFromFragment() {
String url = getBinding().webView.getUrl();
String str = url;
if (str != null && str.length() != 0) {
Intent intent = new Intent("android.intent.action.SEND");
intent.setType(HTTP.PLAIN_TEXT_TYPE);
intent.putExtra("android.intent.extra.TEXT", url);
MainActivity requireActivity = requireActivity();
Intrinsics.checkNotNull(requireActivity, "null cannot be cast to non-null type com.kaunik.ampture.activity.MainActivity");
MainActivity mainActivity = requireActivity;
mainActivity.startActivity(Intent.createChooser(intent, "Share Webpage using"));
Object systemService = mainActivity.getSystemService("clipboard");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.content.ClipboardManager");
((ClipboardManager) systemService).setPrimaryClip(ClipData.newPlainText("Webpage URL", str));
Snackbar.make(getBinding().getRoot(), "Webpage URL copied to clipboard", -1).show();
return;
}
Snackbar.make(getBinding().getRoot(), "Looks like you have not opened a webpage yet", 0).show();
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == this.FILE_CHOOSER_REQUEST_CODE) {
if (resultCode != -1 || data == null) {
ValueCallback<Uri[]> valueCallback = this.filePathCallback;
if (valueCallback != null) {
valueCallback.onReceiveValue(null);
}
} else {
Uri data2 = data.getData();
Uri[] uriArr = data2 != null ? new Uri[]{data2} : null;
ValueCallback<Uri[]> valueCallback2 = this.filePathCallback;
if (valueCallback2 != null) {
valueCallback2.onReceiveValue(uriArr);
}
}
this.filePathCallback = null;
}
}
}