导航菜单

页面标题

页面副标题

КЛ£ v1.0.0 - Browser.java 源代码

正在查看: КЛ£ v1.0.0 应用的 Browser.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package im.pggrnmxjgs.messenger.browser;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import com.google.android.exoplayer2.text.ttml.TtmlNode;
import im.pggrnmxjgs.messenger.FileLog;
import im.pggrnmxjgs.messenger.NotificationCenter;
import im.pggrnmxjgs.messenger.SharedConfig;
import im.pggrnmxjgs.messenger.UserConfig;
import im.pggrnmxjgs.messenger.support.customtabs.CustomTabsCallback;
import im.pggrnmxjgs.messenger.support.customtabs.CustomTabsClient;
import im.pggrnmxjgs.messenger.support.customtabs.CustomTabsServiceConnection;
import im.pggrnmxjgs.messenger.support.customtabs.CustomTabsSession;
import im.pggrnmxjgs.messenger.support.customtabsclient.shared.CustomTabsHelper;
import im.pggrnmxjgs.messenger.support.customtabsclient.shared.ServiceConnection;
import im.pggrnmxjgs.messenger.support.customtabsclient.shared.ServiceConnectionCallback;
import im.pggrnmxjgs.tgnet.ConnectionsManager;
import im.pggrnmxjgs.tgnet.TLObject;
import im.pggrnmxjgs.tgnet.TLRPC;
import im.pggrnmxjgs.ui.actionbar.AlertDialog;
import java.lang.ref.WeakReference;

public class Browser {
    private static WeakReference<Activity> currentCustomTabsActivity;
    private static CustomTabsClient customTabsClient;
    private static WeakReference<CustomTabsSession> customTabsCurrentSession;
    private static String customTabsPackageToBind;
    private static CustomTabsServiceConnection customTabsServiceConnection;
    private static CustomTabsSession customTabsSession;

    private static CustomTabsSession getCurrentSession() {
        WeakReference<CustomTabsSession> weakReference = customTabsCurrentSession;
        if (weakReference == null) {
            return null;
        }
        return weakReference.get();
    }

    private static void setCurrentSession(CustomTabsSession session) {
        customTabsCurrentSession = new WeakReference<>(session);
    }

    private static CustomTabsSession getSession() {
        CustomTabsClient customTabsClient2 = customTabsClient;
        if (customTabsClient2 == null) {
            customTabsSession = null;
        } else if (customTabsSession == null) {
            CustomTabsSession newSession = customTabsClient2.newSession(new NavigationCallback());
            customTabsSession = newSession;
            setCurrentSession(newSession);
        }
        return customTabsSession;
    }

    public static void bindCustomTabsService(Activity activity) {
        WeakReference<Activity> weakReference = currentCustomTabsActivity;
        Activity currentActivity = weakReference == null ? null : weakReference.get();
        if (currentActivity != null && currentActivity != activity) {
            unbindCustomTabsService(currentActivity);
        }
        if (customTabsClient != null) {
            return;
        }
        currentCustomTabsActivity = new WeakReference<>(activity);
        try {
            if (TextUtils.isEmpty(customTabsPackageToBind)) {
                String packageNameToUse = CustomTabsHelper.getPackageNameToUse(activity);
                customTabsPackageToBind = packageNameToUse;
                if (packageNameToUse == null) {
                    return;
                }
            }
            ServiceConnection serviceConnection = new ServiceConnection(new ServiceConnectionCallback() {
                @Override
                public void onServiceConnected(CustomTabsClient client) {
                    CustomTabsClient unused = Browser.customTabsClient = client;
                    if (SharedConfig.customTabs && Browser.customTabsClient != null) {
                        try {
                            Browser.customTabsClient.warmup(0L);
                        } catch (Exception e) {
                            FileLog.e(e);
                        }
                    }
                }

                @Override
                public void onServiceDisconnected() {
                    CustomTabsClient unused = Browser.customTabsClient = null;
                }
            });
            customTabsServiceConnection = serviceConnection;
            if (!CustomTabsClient.bindCustomTabsService(activity, customTabsPackageToBind, serviceConnection)) {
                customTabsServiceConnection = null;
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public static void unbindCustomTabsService(Activity activity) {
        if (customTabsServiceConnection == null) {
            return;
        }
        WeakReference<Activity> weakReference = currentCustomTabsActivity;
        Activity currentActivity = weakReference == null ? null : weakReference.get();
        if (currentActivity == activity) {
            currentCustomTabsActivity.clear();
        }
        try {
            activity.unbindService(customTabsServiceConnection);
        } catch (Exception e) {
        }
        customTabsClient = null;
        customTabsSession = null;
    }

    private static class NavigationCallback extends CustomTabsCallback {
        private NavigationCallback() {
        }

        @Override
        public void onNavigationEvent(int navigationEvent, Bundle extras) {
        }
    }

    public static void openUrl(Context context, String url) {
        if (url == null) {
            return;
        }
        openUrl(context, Uri.parse(url), true);
    }

    public static void openUrl(Context context, Uri uri) {
        openUrl(context, uri, true);
    }

    public static void openUrl(Context context, String url, boolean allowCustom) {
        if (context == null || url == null) {
            return;
        }
        openUrl(context, Uri.parse(url), allowCustom);
    }

    public static void openUrl(Context context, Uri uri, boolean allowCustom) {
        openUrl(context, uri, allowCustom, true);
    }

    public static void openUrl(Context context, String url, boolean allowCustom, boolean tryTelegraph) {
        openUrl(context, Uri.parse(url), allowCustom, tryTelegraph);
    }

    public static void openUrl(final android.content.Context r17, final android.net.Uri r18, final boolean r19, boolean r20) {
        throw new UnsupportedOperationException("Method not decompiled: im.pggrnmxjgs.messenger.browser.Browser.openUrl(android.content.Context, android.net.Uri, boolean, boolean):void");
    }

    static void lambda$null$0(AlertDialog[] progressDialog, TLObject response, int currentAccount, Uri finalUri, Context context, boolean allowCustom) {
        try {
            progressDialog[0].dismiss();
        } catch (Throwable th) {
        }
        progressDialog[0] = null;
        boolean ok = false;
        if (response instanceof TLRPC.TL_messageMediaWebPage) {
            TLRPC.TL_messageMediaWebPage webPage = (TLRPC.TL_messageMediaWebPage) response;
            if ((webPage.webpage instanceof TLRPC.TL_webPage) && webPage.webpage.cached_page != null) {
                NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.openArticle, webPage.webpage, finalUri.toString());
                ok = true;
            }
        }
        if (!ok) {
            openUrl(context, finalUri, allowCustom, false);
        }
    }

    static void lambda$openUrl$3(AlertDialog[] progressDialog, final int reqId) {
        if (progressDialog[0] == null) {
            return;
        }
        try {
            progressDialog[0].setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public final void onCancel(DialogInterface dialogInterface) {
                    ConnectionsManager.getInstance(UserConfig.selectedAccount).cancelRequest(reqId, true);
                }
            });
            progressDialog[0].show();
        } catch (Exception e) {
        }
    }

    public static boolean isPassportUrl(String url) {
        String url2;
        if (url == null) {
            return false;
        }
        try {
            url2 = url.toLowerCase();
        } catch (Throwable th) {
        }
        if (!url2.startsWith("hchat:passport") && !url2.startsWith("hchat://passport") && !url2.startsWith("hchat:secureid")) {
            if (url2.contains("resolve")) {
                if (url2.contains("domain=hchatpassport")) {
                    return true;
                }
            }
            return false;
        }
        return true;
    }

    public static boolean isInternalUrl(String url, boolean[] forceBrowser) {
        return isInternalUri(Uri.parse(url), forceBrowser);
    }

    public static boolean isInternalUri(Uri uri, boolean[] forceBrowser) {
        String path;
        String host = uri.getHost();
        String host2 = host != null ? host.toLowerCase() : TtmlNode.ANONYMOUS_REGION_ID;
        if ("hchat".equals(uri.getScheme()) || "www.shareinstall.com.cn".equals(host2)) {
            return true;
        }
        if (!"m12345.com".equals(host2) || (path = uri.getPath()) == null || path.length() <= 1) {
            return false;
        }
        String path2 = path.substring(1).toLowerCase();
        if (!path2.startsWith("blog") && !path2.equals("iv") && !path2.startsWith("faq") && !path2.equals("apps") && !path2.startsWith("s/")) {
            return true;
        }
        if (forceBrowser != null) {
            forceBrowser[0] = true;
        }
        return false;
    }
}