CheetahGram v8.5.4版本的 MD5 值为:3d14e79cc242c314d3933620ff3ab030
以下内容为反编译后的 ok.java 源代码,内容仅作参考
package org.telegram.messenger.p110;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import co.cheetah.gram.R;
import java.lang.ref.WeakReference;
import java.net.URLEncoder;
import java.util.List;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.CustomTabsCopyReceiver;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.ShareBroadcastReceiver;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.p110.sr0;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.RequestDelegate;
import org.telegram.ui.LaunchActivity;
import uk.co.chrisjenx.calligraphy.BuildConfig;
public class ok {
private static wr0 a;
private static pr0 b;
private static ur0 c;
private static String d;
private static WeakReference<Activity> e;
public class a implements bu4 {
a() {
}
@Override
public void a() {
pr0 unused = ok.b = null;
}
@Override
public void b(pr0 pr0Var) {
pr0 unused = ok.b = pr0Var;
if (!SharedConfig.customTabs || ok.b == null) {
return;
}
try {
ok.b.c(0L);
} catch (Exception e) {
FileLog.e(e);
}
}
}
public static class b extends nr0 {
private b() {
}
b(a aVar) {
this();
}
@Override
public void c(int i, Bundle bundle) {
}
}
public static void A(Activity activity) {
if (c == null) {
return;
}
WeakReference<Activity> weakReference = e;
if ((weakReference == null ? null : weakReference.get()) == activity) {
e.clear();
}
try {
activity.unbindService(c);
} catch (Exception unused) {
}
b = null;
a = null;
}
public static boolean B(String str) {
return o(str, false, true) || str.matches("^(https://)?t\\.me/iv\\??.*") || str.matches("^(https://)?telegram\\.org/(blog|tour)/?.*");
}
public static void g(Activity activity) {
WeakReference<Activity> weakReference = e;
Activity activity2 = weakReference == null ? null : weakReference.get();
if (activity2 != null && activity2 != activity) {
A(activity2);
}
if (b != null) {
return;
}
e = new WeakReference<>(activity);
try {
if (TextUtils.isEmpty(d)) {
String a2 = rr0.a(activity);
d = a2;
if (a2 == null) {
return;
}
}
au4 au4Var = new au4(new a());
c = au4Var;
if (pr0.a(activity, d, au4Var)) {
return;
}
c = null;
} catch (Exception e2) {
FileLog.e(e2);
}
}
private static wr0 h() {
pr0 pr0Var = b;
a aVar = null;
if (pr0Var == null) {
a = null;
} else if (a == null) {
wr0 b2 = pr0Var.b(new b(aVar));
a = b2;
z(b2);
}
return a;
}
public static boolean i(Uri uri, boolean z, boolean[] zArr) {
String host = uri.getHost();
String lowerCase = host != null ? host.toLowerCase() : BuildConfig.FLAVOR;
if ("ton".equals(uri.getScheme())) {
try {
List<ResolveInfo> queryIntentActivities = ApplicationLoader.applicationContext.getPackageManager().queryIntentActivities(new Intent("android.intent.action.VIEW", uri), 0);
if (queryIntentActivities != null) {
if (queryIntentActivities.size() > 1) {
return false;
}
}
} catch (Exception unused) {
}
return true;
}
if ("tg".equals(uri.getScheme())) {
return true;
}
if ("telegram.dog".equals(lowerCase)) {
String path = uri.getPath();
if (path != null && path.length() > 1) {
if (z) {
return true;
}
String lowerCase2 = path.substring(1).toLowerCase();
if (!lowerCase2.startsWith("blog") && !lowerCase2.equals("iv") && !lowerCase2.startsWith("faq") && !lowerCase2.equals("apps") && !lowerCase2.startsWith("s/")) {
return true;
}
if (zArr != null) {
zArr[0] = true;
}
return false;
}
} else if ("telegram.me".equals(lowerCase) || "t.me".equals(lowerCase)) {
String path2 = uri.getPath();
if (path2 != null && path2.length() > 1) {
if (z) {
return true;
}
String lowerCase3 = path2.substring(1).toLowerCase();
if (!lowerCase3.equals("iv") && !lowerCase3.startsWith("s/")) {
return true;
}
if (zArr != null) {
zArr[0] = true;
}
}
} else if (z && (lowerCase.endsWith("telegram.org") || lowerCase.endsWith("telegra.ph") || lowerCase.endsWith("telesco.pe"))) {
return true;
}
return false;
}
public static boolean j(Uri uri, boolean[] zArr) {
return i(uri, false, zArr);
}
public static boolean k(String str, boolean z, boolean[] zArr) {
return i(Uri.parse(str), z, zArr);
}
public static boolean l(String str, boolean[] zArr) {
return i(Uri.parse(str), false, zArr);
}
public static boolean m(String str) {
String lowerCase;
if (str == null) {
return false;
}
try {
lowerCase = str.toLowerCase();
} catch (Throwable unused) {
}
if (lowerCase.startsWith("tg:passport") || lowerCase.startsWith("tg://passport") || lowerCase.startsWith("tg:secureid")) {
return true;
}
if (lowerCase.contains("resolve")) {
if (lowerCase.contains("domain=telegrampassport")) {
return true;
}
}
return false;
}
public static boolean n(String str, boolean z) {
return o(str, z, false);
}
public static boolean o(String str, boolean z, boolean z2) {
if (z) {
return str.equals("telegra.ph") || str.equals("te.legra.ph") || str.equals("graph.org");
}
StringBuilder sb = new StringBuilder();
sb.append("^(https");
sb.append(z2 ? BuildConfig.FLAVOR : "?");
sb.append("://)?(te\\.?legra\\.ph|graph\\.org).*");
return str.matches(sb.toString());
}
public static void p(org.telegram.ui.ActionBar.i[] iVarArr, i95 i95Var, int i, Uri uri, Context context, boolean z) {
try {
iVarArr[0].dismiss();
} catch (Throwable unused) {
}
iVarArr[0] = null;
boolean z2 = true;
if (i95Var instanceof j86) {
j86 j86Var = (j86) i95Var;
p27 p27Var = j86Var.webpage;
if ((p27Var instanceof o17) && p27Var.r != null) {
NotificationCenter.getInstance(i).postNotificationName(NotificationCenter.openArticle, j86Var.webpage, uri.toString());
if (z2) {
v(context, uri, z, false);
return;
}
return;
}
}
z2 = false;
if (z2) {
}
}
public static void q(final org.telegram.ui.ActionBar.i[] iVarArr, final int i, final Uri uri, final Context context, final boolean z, final i95 i95Var, ov5 ov5Var) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ok.p(iVarArr, i95Var, i, uri, context, z);
}
});
}
public static void r(int i, DialogInterface dialogInterface) {
ConnectionsManager.getInstance(UserConfig.selectedAccount).cancelRequest(i, true);
}
public static void s(org.telegram.ui.ActionBar.i[] iVarArr, final int i) {
if (iVarArr[0] == null) {
return;
}
try {
iVarArr[0].setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
ok.r(i, dialogInterface);
}
});
iVarArr[0].show();
} catch (Exception unused) {
}
}
public static void t(Context context, Uri uri) {
u(context, uri, true);
}
public static void u(Context context, Uri uri, boolean z) {
v(context, uri, z, true);
}
public static void v(final Context context, final Uri uri, final boolean z, boolean z2) {
String[] strArr;
List<ResolveInfo> queryIntentActivities;
StringBuilder sb;
Uri uri2 = uri;
if (context == null || uri2 == null) {
return;
}
final int i = UserConfig.selectedAccount;
boolean[] zArr = {false};
boolean j = j(uri2, zArr);
if (z2) {
try {
if (n(uri.getHost().toLowerCase(), true) || uri.toString().toLowerCase().contains("telegram.org/faq") || uri.toString().toLowerCase().contains("telegram.org/privacy")) {
final org.telegram.ui.ActionBar.i[] iVarArr = {new org.telegram.ui.ActionBar.i(context, 3)};
ie6 ie6Var = new ie6();
ie6Var.b = uri.toString();
final int sendRequest = ConnectionsManager.getInstance(UserConfig.selectedAccount).sendRequest(ie6Var, new RequestDelegate() {
@Override
public final void run(i95 i95Var, ov5 ov5Var) {
ok.q(iVarArr, i, uri, context, z, i95Var, ov5Var);
}
});
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ok.s(iVarArr, sendRequest);
}
}, 1000L);
return;
}
} catch (Exception unused) {
}
}
try {
String scheme = uri.getScheme();
String str = BuildConfig.FLAVOR;
String lowerCase = scheme != null ? uri.getScheme().toLowerCase() : BuildConfig.FLAVOR;
if ("http".equals(lowerCase) || "https".equals(lowerCase)) {
try {
uri2 = uri.normalizeScheme();
} catch (Exception e2) {
FileLog.e(e2);
}
}
if (uri2.getHost() != null) {
str = uri2.getHost().toLowerCase();
}
if (AccountInstance.getInstance(i).getMessagesController().autologinDomains.contains(str)) {
String str2 = "autologin_token=" + URLEncoder.encode(AccountInstance.getInstance(UserConfig.selectedAccount).getMessagesController().autologinToken, com.batch.android.core.a.a);
String uri3 = uri2.toString();
int indexOf = uri3.indexOf("://");
if (indexOf >= 0) {
uri3 = uri3.substring(indexOf + 3);
}
String encodedFragment = uri2.getEncodedFragment();
if (encodedFragment != null) {
uri3 = uri3.substring(0, uri3.indexOf("#" + encodedFragment));
}
if (uri3.indexOf(63) >= 0) {
sb = new StringBuilder();
sb.append(uri3);
sb.append("&");
sb.append(str2);
} else {
sb = new StringBuilder();
sb.append(uri3);
sb.append("?");
sb.append(str2);
}
String sb2 = sb.toString();
if (encodedFragment != null) {
sb2 = sb2 + "#" + encodedFragment;
}
uri2 = Uri.parse("https://" + sb2);
}
if (z && SharedConfig.customTabs && !j && !lowerCase.equals("tel")) {
List<ResolveInfo> list = null;
try {
queryIntentActivities = context.getPackageManager().queryIntentActivities(new Intent("android.intent.action.VIEW", Uri.parse("http://www.google.com")), 0);
} catch (Exception unused2) {
}
if (queryIntentActivities != null && !queryIntentActivities.isEmpty()) {
strArr = new String[queryIntentActivities.size()];
for (int i2 = 0; i2 < queryIntentActivities.size(); i2++) {
try {
strArr[i2] = queryIntentActivities.get(i2).activityInfo.packageName;
if (BuildVars.LOGS_ENABLED) {
FileLog.d("default browser name = " + strArr[i2]);
}
} catch (Exception unused3) {
}
}
list = context.getPackageManager().queryIntentActivities(new Intent("android.intent.action.VIEW", uri2), 0);
int i3 = 0;
if (strArr == null) {
while (i3 < list.size()) {
int i4 = 0;
while (true) {
if (i4 >= strArr.length) {
break;
}
if (strArr[i4].equals(list.get(i3).activityInfo.packageName)) {
list.remove(i3);
i3--;
break;
}
i4++;
}
i3++;
}
} else {
while (i3 < list.size()) {
if (list.get(i3).activityInfo.packageName.toLowerCase().contains("browser") || list.get(i3).activityInfo.packageName.toLowerCase().contains("chrome")) {
list.remove(i3);
i3--;
}
i3++;
}
}
if (BuildVars.LOGS_ENABLED) {
for (int i5 = 0; i5 < list.size(); i5++) {
FileLog.d("device has " + list.get(i5).activityInfo.packageName + " to open " + uri2.toString());
}
}
if (!zArr[0] || list == null || list.isEmpty()) {
Intent intent = new Intent(ApplicationLoader.applicationContext, (Class<?>) ShareBroadcastReceiver.class);
intent.setAction("android.intent.action.SEND");
PendingIntent broadcast = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, (Class<?>) CustomTabsCopyReceiver.class), 134217728);
sr0.b bVar = new sr0.b(h());
bVar.a(LocaleController.getString("CopyLink", R.string.CopyLink), broadcast);
bVar.e(org.telegram.ui.ActionBar.w.r1("actionBarBrowser"));
bVar.d(true);
bVar.c(BitmapFactory.decodeResource(context.getResources(), R.drawable.abc_ic_menu_share_mtrl_alpha), LocaleController.getString("ShareFile", R.string.ShareFile), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 0, intent, 0), true);
sr0 b2 = bVar.b();
b2.b();
b2.a(context, uri2);
return;
}
}
strArr = null;
list = context.getPackageManager().queryIntentActivities(new Intent("android.intent.action.VIEW", uri2), 0);
int i32 = 0;
if (strArr == null) {
}
if (BuildVars.LOGS_ENABLED) {
}
if (!zArr[0]) {
}
Intent intent2 = new Intent(ApplicationLoader.applicationContext, (Class<?>) ShareBroadcastReceiver.class);
intent2.setAction("android.intent.action.SEND");
PendingIntent broadcast2 = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, (Class<?>) CustomTabsCopyReceiver.class), 134217728);
sr0.b bVar2 = new sr0.b(h());
bVar2.a(LocaleController.getString("CopyLink", R.string.CopyLink), broadcast2);
bVar2.e(org.telegram.ui.ActionBar.w.r1("actionBarBrowser"));
bVar2.d(true);
bVar2.c(BitmapFactory.decodeResource(context.getResources(), R.drawable.abc_ic_menu_share_mtrl_alpha), LocaleController.getString("ShareFile", R.string.ShareFile), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 0, intent2, 0), true);
sr0 b22 = bVar2.b();
b22.b();
b22.a(context, uri2);
return;
}
} catch (Exception e3) {
FileLog.e(e3);
}
try {
Intent intent3 = new Intent("android.intent.action.VIEW", uri2);
if (j) {
intent3.setComponent(new ComponentName(context.getPackageName(), LaunchActivity.class.getName()));
}
intent3.putExtra("create_new_tab", true);
intent3.putExtra("com.android.browser.application_id", context.getPackageName());
context.startActivity(intent3);
} catch (Exception e4) {
FileLog.e(e4);
}
}
public static void w(Context context, String str) {
if (str == null) {
return;
}
u(context, Uri.parse(str), true);
}
public static void x(Context context, String str, boolean z) {
if (context == null || str == null) {
return;
}
u(context, Uri.parse(str), z);
}
public static void y(Context context, String str, boolean z, boolean z2) {
v(context, Uri.parse(str), z, z2);
}
private static void z(wr0 wr0Var) {
new WeakReference(wr0Var);
}
}