package im.guobwnxjuc.messenger; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.Activity; import android.app.ActivityManager; import android.content.ClipData; import android.content.ClipboardManager; import android.content.ContentUris; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.database.ContentObserver; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.hardware.camera2.CameraManager; import android.net.Uri; import android.os.Build; import android.os.Environment; import android.os.PowerManager; import android.provider.CallLog; import android.provider.DocumentsContract; import android.provider.MediaStore; import android.provider.Settings; import android.renderscript.Allocation; import android.renderscript.Element; import android.renderscript.RenderScript; import android.renderscript.ScriptIntrinsicBlur; import android.telephony.PhoneNumberUtils; import android.telephony.TelephonyManager; import android.text.Selection; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.SpannedString; import android.text.TextUtils; import android.text.method.LinkMovementMethod; import android.text.method.PasswordTransformationMethod; import android.text.style.ForegroundColorSpan; import android.util.DisplayMetrics; import android.util.StateSet; import android.view.Display; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.view.animation.OvershootInterpolator; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; import android.webkit.MimeTypeMap; import android.widget.EdgeEffect; import android.widget.EditText; import android.widget.HorizontalScrollView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.ScrollView; import android.widget.TextView; import androidx.core.content.FileProvider; import androidx.core.internal.view.SupportMenu; import androidx.exifinterface.media.ExifInterface; import androidx.viewpager.widget.ViewPager; import com.android.internal.telephony.ITelephony; import com.bjz.comm.net.premission.PermissionUtils; import com.bumptech.glide.load.resource.bitmap.HardwareConfigState; import com.google.android.exoplayer2.source.hls.DefaultHlsExtractorFactory; import com.google.android.exoplayer2.text.ttml.TtmlNode; import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.gms.auth.api.phone.SmsRetriever; import com.google.firebase.remoteconfig.FirebaseRemoteConfig; import com.king.zxing.util.LogUtils; import com.litesuits.orm.db.assit.SQLBuilder; import im.guobwnxjuc.messenger.LocaleController; import im.guobwnxjuc.messenger.SharedConfig; import im.guobwnxjuc.phoneformat.PhoneFormat; import im.guobwnxjuc.tgnet.ConnectionsManager; import im.guobwnxjuc.tgnet.TLObject; import im.guobwnxjuc.tgnet.TLRPC; import im.guobwnxjuc.ui.ThemePreviewActivity; import im.guobwnxjuc.ui.WallpapersListActivity; import im.guobwnxjuc.ui.actionbar.AlertDialog; import im.guobwnxjuc.ui.actionbar.BaseFragment; import im.guobwnxjuc.ui.actionbar.BottomSheet; import im.guobwnxjuc.ui.actionbar.Theme; import im.guobwnxjuc.ui.cells.TextDetailSettingsCell; import im.guobwnxjuc.ui.components.AlertsCreator; import im.guobwnxjuc.ui.components.BackgroundGradientDrawable; import im.guobwnxjuc.ui.components.ForegroundDetector; import im.guobwnxjuc.ui.components.LayoutHelper; import im.guobwnxjuc.ui.components.PickerBottomLayout; import im.guobwnxjuc.ui.components.TypefaceSpan; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.RandomAccessFile; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.security.MessageDigest; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.Hashtable; import java.util.List; import java.util.Locale; import java.util.regex.Pattern; import kotlin.UByte; import org.slf4j.Marker; public class AndroidUtilities { public static final int FLAG_TAG_ALL = 11; public static final int FLAG_TAG_BOLD = 2; public static final int FLAG_TAG_BR = 1; public static final int FLAG_TAG_COLOR = 4; public static final int FLAG_TAG_URL = 8; public static Pattern WEB_URL; public static AccelerateInterpolator accelerateInterpolator = new AccelerateInterpolator(); private static int adjustOwnerClassGuid = 0; private static RectF bitmapRect; private static final Object callLock = new Object(); private static ContentObserver callLogContentObserver; public static DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(); public static float density = 1.0f; public static DisplayMetrics displayMetrics = new DisplayMetrics(); public static Point displaySize = new Point(); private static int[] documentIcons = {R.drawable.media_doc_blue, R.drawable.media_doc_green, R.drawable.media_doc_red, R.drawable.media_doc_yellow}; private static int[] documentMediaIcons = {R.drawable.media_doc_blue_b, R.drawable.media_doc_green_b, R.drawable.media_doc_red_b, R.drawable.media_doc_yellow_b}; public static boolean firstConfigurationWas; private static boolean hasCallPermissions; public static boolean incorrectDisplaySizeFix; public static boolean isInMultiwindow; private static Boolean isTablet = null; public static int leftBaseline = (isTablet() ? 80 : 72); private static Field mAttachInfoField; private static Field mStableInsetsField; public static OvershootInterpolator overshootInterpolator = new OvershootInterpolator(); public static Integer photoSize = null; private static int prevOrientation = -10; public static int roundMessageSize; private static Paint roundPaint; private static final Object smsLock = new Object(); public static int statusBarHeight = 0; private static final Hashtable<String, Typeface> typefaceCache = new Hashtable<>(); private static Runnable unregisterRunnable; public static boolean usingHardwareInput; private static boolean waitingForCall = false; private static boolean waitingForSms = false; public static float[] RGBtoHSB(int i, int i2, int i3) { float[] fArr = new float[3]; int i4 = i > i2 ? i : i2; if (i3 > i4) { i4 = i3; } int i5 = i < i2 ? i : i2; if (i3 < i5) { i5 = i3; } float f = (float) i4; float f2 = f / 255.0f; float f3 = 0.0f; float f4 = i4 != 0 ? ((float) (i4 - i5)) / f : 0.0f; if (f4 != 0.0f) { float f5 = (float) (i4 - i5); float f6 = ((float) (i4 - i)) / f5; float f7 = ((float) (i4 - i2)) / f5; float f8 = ((float) (i4 - i3)) / f5; float f9 = (i == i4 ? f8 - f7 : i2 == i4 ? (f6 + 2.0f) - f8 : (f7 + 4.0f) - f6) / 6.0f; f3 = f9 < 0.0f ? f9 + 1.0f : f9; } fArr[0] = f3; fArr[1] = f4; fArr[2] = f2; return fArr; } public static int alphaColor(float f, int i) { return (((int) (f * 256.0f)) << 24) | (((i >> 16) & 255) << 16) | (((i >> 8) & 255) << 8) | (i & 255); } public static void checkForCrashes(Activity activity) { } public static int compare(int i, int i2) { if (i == i2) { return 0; } return i > i2 ? 1 : -1; } public static int getMyLayerVersion(int i) { return i & 65535; } public static int getPeerLayerVersion(int i) { return (i >> 16) & 65535; } public static boolean isEmojiCharacter(char c) { return c == 0 || c == '\t' || c == '\n' || c == '\r' || (c >= ' ' && c <= 55295) || ((c >= 57344 && c <= 65533) || (c >= 0 && c <= 65535)); } public static int setMyLayerVersion(int i, int i2) { return (i & SupportMenu.CATEGORY_MASK) | i2; } public static int setPeerLayerVersion(int i, int i2) { return (i & 65535) | (i2 << 16); } static { boolean z = false; WEB_URL = null; try { Pattern compile = Pattern.compile("((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[0-9]))"); Pattern compile2 = Pattern.compile("(([a-zA-Z0-9 -豈-﷏ﷰ-]([a-zA-Z0-9 -豈-﷏ﷰ-\\-]{0,61}[a-zA-Z0-9 -豈-﷏ﷰ-]){0,1}\\.)+[a-zA-Z -豈-﷏ﷰ-]{2,63}|" + compile + SQLBuilder.PARENTHESES_RIGHT); WEB_URL = Pattern.compile("((?:(http|https|Http|Https):\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?(?:" + compile2 + ")(?:\\:\\d{1,5})?)(\\/(?:(?:[" + "a-zA-Z0-9 -豈-﷏ﷰ-" + "\\;\\/\\?\\:\\@\\&\\=\\#\\~\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])|(?:\\%[a-fA-F0-9]{2}))*)?(?:\\b|$)"); } catch (Exception e) { FileLog.e(e); } checkDisplaySize(ApplicationLoader.applicationContext, null); if (Build.VERSION.SDK_INT >= 23) { z = true; } hasCallPermissions = z; } public static int getThumbForNameOrMime(String str, String str2, boolean z) { if (str == null || str.length() == 0) { return z ? documentMediaIcons[0] : documentIcons[0]; } int i = (str.contains(".doc") || str.contains(".txt") || str.contains(".psd")) ? 0 : (str.contains(".xls") || str.contains(".csv")) ? 1 : (str.contains(".pdf") || str.contains(".ppt") || str.contains(".key")) ? 2 : (str.contains(".zip") || str.contains(".rar") || str.contains(".ai") || str.contains(DefaultHlsExtractorFactory.MP3_FILE_EXTENSION) || str.contains(".mov") || str.contains(".avi")) ? 3 : -1; if (i == -1) { int lastIndexOf = str.lastIndexOf(46); String substring = lastIndexOf == -1 ? "" : str.substring(lastIndexOf + 1); if (substring.length() != 0) { i = substring.charAt(0) % documentIcons.length; } else { i = str.charAt(0) % documentIcons.length; } } return z ? documentMediaIcons[i] : documentIcons[i]; } public static int[] calcDrawableColor(Drawable drawable) { int[] colorsList; Bitmap createScaledBitmap; int[] iArr = new int[4]; int i = -16777216; try { if (drawable instanceof BitmapDrawable) { Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); if (!(bitmap == null || (createScaledBitmap = Bitmaps.createScaledBitmap(bitmap, 1, 1, true)) == null)) { i = createScaledBitmap.getPixel(0, 0); if (bitmap != createScaledBitmap) { createScaledBitmap.recycle(); } } } else if (drawable instanceof ColorDrawable) { i = ((ColorDrawable) drawable).getColor(); } else if ((drawable instanceof BackgroundGradientDrawable) && (colorsList = ((BackgroundGradientDrawable) drawable).getColorsList()) != null && colorsList.length > 0) { i = colorsList[0]; } } catch (Exception e) { FileLog.e(e); } double[] rgbToHsv = rgbToHsv((i >> 16) & 255, (i >> 8) & 255, i & 255); rgbToHsv[1] = Math.min(1.0d, rgbToHsv[1] + 0.05d + ((1.0d - rgbToHsv[1]) * 0.1d)); int[] hsvToRgb = hsvToRgb(rgbToHsv[0], rgbToHsv[1], Math.max((double) FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE, rgbToHsv[2] * 0.65d)); iArr[0] = Color.argb(102, hsvToRgb[0], hsvToRgb[1], hsvToRgb[2]); iArr[1] = Color.argb(136, hsvToRgb[0], hsvToRgb[1], hsvToRgb[2]); int[] hsvToRgb2 = hsvToRgb(rgbToHsv[0], rgbToHsv[1], Math.max((double) FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE, rgbToHsv[2] * 0.72d)); iArr[2] = Color.argb(102, hsvToRgb2[0], hsvToRgb2[1], hsvToRgb2[2]); iArr[3] = Color.argb(136, hsvToRgb2[0], hsvToRgb2[1], hsvToRgb2[2]); return iArr; } public static double[] rgbToHsv(int i, int i2, int i3) { double d; double d2; double d3; double d4 = (double) i; Double.isNaN(d4); double d5 = d4 / 255.0d; double d6 = (double) i2; Double.isNaN(d6); double d7 = d6 / 255.0d; double d8 = (double) i3; Double.isNaN(d8); double d9 = d8 / 255.0d; double d10 = (d5 <= d7 || d5 <= d9) ? d7 > d9 ? d7 : d9 : d5; double d11 = (d5 >= d7 || d5 >= d9) ? d7 < d9 ? d7 : d9 : d5; double d12 = d10 - d11; double d13 = FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE; double d14 = d10 == FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE ? 0.0d : d12 / d10; if (d10 != d11) { if (d5 > d7 && d5 > d9) { d3 = (d7 - d9) / d12; d2 = (double) (d7 < d9 ? 6 : 0); Double.isNaN(d2); } else if (d7 > d9) { d = 2.0d + ((d9 - d5) / d12); d13 = d / 6.0d; } else { d3 = (d5 - d7) / d12; d2 = 4.0d; } d = d3 + d2; d13 = d / 6.0d; } return new double[]{d13, d14, d10}; } private static int[] hsvToRgb(double d, double d2, double d3) { double d4 = 6.0d * d; double floor = (double) ((int) Math.floor(d4)); Double.isNaN(floor); double d5 = d4 - floor; double d6 = (1.0d - d2) * d3; double d7 = (1.0d - (d5 * d2)) * d3; double d8 = d3 * (1.0d - ((1.0d - d5) * d2)); int i = ((int) floor) % 6; double d9 = FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE; if (i != 0) { if (i == 1) { d9 = d3; d8 = d6; d6 = d7; } else if (i == 2) { d9 = d3; } else if (i == 3) { d8 = d3; d9 = d7; } else if (i == 4) { d9 = d6; d6 = d8; d8 = d3; } else if (i != 5) { d8 = 0.0d; d6 = 0.0d; } else { d9 = d6; d8 = d7; } return new int[]{(int) (d6 * 255.0d), (int) (d9 * 255.0d), (int) (d8 * 255.0d)}; } d9 = d8; d8 = d6; d6 = d3; return new int[]{(int) (d6 * 255.0d), (int) (d9 * 255.0d), (int) (d8 * 255.0d)}; } public static void requestAdjustResize(Activity activity, int i) { if (activity != null && !isTablet()) { activity.getWindow().setSoftInputMode(16); adjustOwnerClassGuid = i; } } public static void setAdjustResizeToNothing(Activity activity, int i) { if (activity != null && !isTablet() && adjustOwnerClassGuid == i) { activity.getWindow().setSoftInputMode(48); } } public static void removeAdjustResize(Activity activity, int i) { if (activity != null && !isTablet() && adjustOwnerClassGuid == i) { activity.getWindow().setSoftInputMode(32); } } public static boolean isGoogleMapsInstalled(BaseFragment baseFragment) { try { ApplicationLoader.applicationContext.getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0); return true; } catch (PackageManager.NameNotFoundException unused) { if (baseFragment.getParentActivity() == null) { return false; } AlertDialog.Builder builder = new AlertDialog.Builder(baseFragment.getParentActivity()); builder.setMessage(LocaleController.getString("InstallGoogleMaps", R.string.InstallGoogleMaps)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { /* class im.guobwnxjuc.messenger.$$Lambda$AndroidUtilities$lVFwtJb__EJzCLdRn_CTtBr6KVQ */ public final void onClick(DialogInterface dialogInterface, int i) { AndroidUtilities.lambda$isGoogleMapsInstalled$0(BaseFragment.this, dialogInterface, i); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); baseFragment.showDialog(builder.create()); return false; } } static /* synthetic */ void lambda$isGoogleMapsInstalled$0(BaseFragment baseFragment, DialogInterface dialogInterface, int i) { try { baseFragment.getParentActivity().startActivityForResult(new Intent("android.intent.action.VIEW", Uri.parse("market://details?id=com.google.android.apps.maps")), 500); } catch (Exception e) { FileLog.e(e); } } public static int[] toIntArray(List<Integer> list) { int size = list.size(); int[] iArr = new int[size]; for (int i = 0; i < size; i++) { iArr[i] = list.get(i).intValue(); } return iArr; } /* JADX WARNING: Removed duplicated region for block: B:22:0x005a A[SYNTHETIC, Splitter:B:22:0x005a] */ public static boolean isInternalUri(Uri uri) { String path = uri.getPath(); if (path == null) { return false; } if (path.matches(Pattern.quote(new File(ApplicationLoader.applicationContext.getCacheDir(), "voip_logs").getAbsolutePath()) + "/\\d+\\.log")) { return false; } int i = 0; while (true) { if (path != null && path.length() > 4096) { return true; } try { String readlink = Utilities.readlink(path); if (readlink != null && !readlink.equals(path)) { i++; if (i >= 10) { return true; } path = readlink; } else if (path != null) { try { String canonicalPath = new File(path).getCanonicalPath(); if (canonicalPath != null) { path = canonicalPath; } } catch (Exception unused) { path.replace("/./", "/"); } } } catch (Throwable unused2) { return true; } } if (path != null) { } if (path.endsWith(".attheme") || path == null) { return false; } String lowerCase = path.toLowerCase(); if (lowerCase.contains("/data/data/" + ApplicationLoader.applicationContext.getPackageName())) { return true; } return false; } public static void lockOrientation(Activity activity) { if (activity != null && prevOrientation == -10) { try { prevOrientation = activity.getRequestedOrientation(); WindowManager windowManager = (WindowManager) activity.getSystemService("window"); if (windowManager != null && windowManager.getDefaultDisplay() != null) { int rotation = windowManager.getDefaultDisplay().getRotation(); int i = activity.getResources().getConfiguration().orientation; if (rotation == 3) { if (i == 1) { activity.setRequestedOrientation(1); } else { activity.setRequestedOrientation(8); } } else if (rotation == 1) { if (i == 1) { activity.setRequestedOrientation(9); } else { activity.setRequestedOrientation(0); } } else if (rotation == 0) { if (i == 2) { activity.setRequestedOrientation(0); } else { activity.setRequestedOrientation(1); } } else if (i == 2) { activity.setRequestedOrientation(8); } else { activity.setRequestedOrientation(9); } } } catch (Exception e) { FileLog.e(e); } } } public static void unlockOrientation(Activity activity) { if (activity != null) { try { if (prevOrientation != -10) { activity.setRequestedOrientation(prevOrientation); prevOrientation = -10; } } catch (Exception e) { FileLog.e(e); } } } private static class VcardData { String name; ArrayList<String> phones; StringBuilder vcard; private VcardData() { this.phones = new ArrayList<>(); this.vcard = new StringBuilder(); } } public static class VcardItem { public boolean checked = true; public String fullData = ""; public int type; public ArrayList<String> vcardData = new ArrayList<>(); public String[] getRawValue() { String[] split; byte[] decodeQuotedPrintable; int indexOf = this.fullData.indexOf(58); if (indexOf < 0) { return new String[0]; } String substring = this.fullData.substring(0, indexOf); String substring2 = this.fullData.substring(indexOf + 1); String str = null; String str2 = "UTF-8"; for (String str3 : substring.split(";")) { String[] split2 = str3.split("="); if (split2.length == 2) { if (split2[0].equals("CHARSET")) { str2 = split2[1]; } else if (split2[0].equals("ENCODING")) { str = split2[1]; } } } String[] split3 = substring2.split(";"); for (int i = 0; i < split3.length; i++) { if (!(TextUtils.isEmpty(split3[i]) || str == null || !str.equalsIgnoreCase("QUOTED-PRINTABLE") || (decodeQuotedPrintable = AndroidUtilities.decodeQuotedPrintable(AndroidUtilities.getStringBytes(split3[i]))) == null || decodeQuotedPrintable.length == 0)) { try { split3[i] = new String(decodeQuotedPrintable, str2); } catch (Exception unused) { } } } return split3; } public String getValue(boolean z) { String[] split; byte[] decodeQuotedPrintable; StringBuilder sb = new StringBuilder(); int indexOf = this.fullData.indexOf(58); if (indexOf < 0) { return ""; } if (sb.length() > 0) { sb.append(", "); } String substring = this.fullData.substring(0, indexOf); String substring2 = this.fullData.substring(indexOf + 1); String str = null; String str2 = "UTF-8"; for (String str3 : substring.split(";")) { String[] split2 = str3.split("="); if (split2.length == 2) { if (split2[0].equals("CHARSET")) { str2 = split2[1]; } else if (split2[0].equals("ENCODING")) { str = split2[1]; } } } String[] split3 = substring2.split(";"); boolean z2 = false; for (int i = 0; i < split3.length; i++) { if (!TextUtils.isEmpty(split3[i])) { if (!(str == null || !str.equalsIgnoreCase("QUOTED-PRINTABLE") || (decodeQuotedPrintable = AndroidUtilities.decodeQuotedPrintable(AndroidUtilities.getStringBytes(split3[i]))) == null || decodeQuotedPrintable.length == 0)) { try { split3[i] = new String(decodeQuotedPrintable, str2); } catch (Exception unused) { } } if (z2 && sb.length() > 0) { sb.append(" "); } sb.append(split3[i]); if (!z2) { z2 = split3[i].length() > 0; } } } if (z) { int i2 = this.type; if (i2 == 0) { return PhoneFormat.getInstance().format(sb.toString()); } if (i2 == 5) { String[] split4 = sb.toString().split(ExifInterface.GPS_DIRECTION_TRUE); if (split4.length > 0) { String[] split5 = split4[0].split("-"); if (split5.length == 3) { Calendar instance = Calendar.getInstance(); instance.set(1, Utilities.parseInt(split5[0]).intValue()); instance.set(2, Utilities.parseInt(split5[1]).intValue() - 1); instance.set(5, Utilities.parseInt(split5[2]).intValue()); return LocaleController.getInstance().formatterYearMax.format(instance.getTime()); } } } } return sb.toString(); } public String getRawType(boolean z) { int indexOf = this.fullData.indexOf(58); if (indexOf < 0) { return ""; } String substring = this.fullData.substring(0, indexOf); if (this.type == 20) { String[] split = substring.substring(2).split(";"); if (z) { return split[0]; } if (split.length > 1) { return split[split.length - 1]; } return ""; } String[] split2 = substring.split(";"); for (int i = 0; i < split2.length; i++) { if (split2[i].indexOf(61) < 0) { substring = split2[i]; } } return substring; } public String getType() { int i = this.type; if (i == 5) { return LocaleController.getString("ContactBirthday", R.string.ContactBirthday); } if (i != 6) { int indexOf = this.fullData.indexOf(58); if (indexOf < 0) { return ""; } String substring = this.fullData.substring(0, indexOf); if (this.type == 20) { substring = substring.substring(2).split(";")[0]; } else { String[] split = substring.split(";"); for (int i2 = 0; i2 < split.length; i2++) { if (split[i2].indexOf(61) < 0) { substring = split[i2]; } } if (substring.startsWith("X-")) { substring = substring.substring(2); } char c = 65535; switch (substring.hashCode()) { case -2015525726: if (substring.equals("MOBILE")) { c = 2; break; } break; case 2064738: if (substring.equals("CELL")) { c = 3; break; } break; case 2223327: if (substring.equals("HOME")) { c = 1; break; } break; case 2464291: if (substring.equals("PREF")) { c = 0; break; } break; case 2670353: if (substring.equals("WORK")) { c = 5; break; } break; case 75532016: if (substring.equals("OTHER")) { c = 4; break; } break; } if (c == 0) { substring = LocaleController.getString("PhoneMain", R.string.PhoneMain); } else if (c == 1) { substring = LocaleController.getString("PhoneHome", R.string.PhoneHome); } else if (c == 2 || c == 3) { substring = LocaleController.getString("PhoneMobile", R.string.PhoneMobile); } else if (c == 4) { substring = LocaleController.getString("PhoneOther", R.string.PhoneOther); } else if (c == 5) { substring = LocaleController.getString("PhoneWork", R.string.PhoneWork); } } return substring.substring(0, 1).toUpperCase() + substring.substring(1).toLowerCase(); } else if ("ORG".equalsIgnoreCase(getRawType(true))) { return LocaleController.getString("ContactJob", R.string.ContactJob); } else { return LocaleController.getString("ContactJobTitle", R.string.ContactJobTitle); } } } public static byte[] getStringBytes(String str) { try { return str.getBytes("UTF-8"); } catch (Exception unused) { return new byte[0]; } } /* JADX DEBUG: Failed to insert an additional move for type inference into block B:152:0x003d */ /* JADX DEBUG: Failed to insert an additional move for type inference into block B:155:0x003d */ /* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: im.guobwnxjuc.messenger.AndroidUtilities$1 */ /* JADX DEBUG: Multi-variable search result rejected for r3v3, resolved type: im.guobwnxjuc.messenger.AndroidUtilities$1 */ /* JADX DEBUG: Multi-variable search result rejected for r3v9, resolved type: im.guobwnxjuc.messenger.AndroidUtilities$1 */ /* JADX DEBUG: Multi-variable search result rejected for r3v15, resolved type: im.guobwnxjuc.messenger.AndroidUtilities$1 */ /* JADX DEBUG: Multi-variable search result rejected for r3v48, resolved type: im.guobwnxjuc.messenger.AndroidUtilities$1 */ /* JADX WARN: Multi-variable type inference failed */ public static ArrayList<TLRPC.User> loadVCardFromStream(Uri uri, int i, boolean z, ArrayList<VcardItem> arrayList, String str) { Throwable th; InputStream inputStream; char c; String[] strArr; byte[] decodeQuotedPrintable; VcardItem vcardItem; ArrayList<VcardItem> arrayList2 = arrayList; AnonymousClass1 r3 = 0; ArrayList<TLRPC.User> arrayList3 = null; if (z) { try { inputStream = ApplicationLoader.applicationContext.getContentResolver().openAssetFileDescriptor(uri, "r").createInputStream(); } catch (Throwable th2) { th = th2; } } else { try { inputStream = ApplicationLoader.applicationContext.getContentResolver().openInputStream(uri); } catch (Throwable th3) { th = th3; arrayList3 = null; FileLog.e(th); return arrayList3; } } ArrayList arrayList4 = new ArrayList(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); int i2 = 0; VcardData vcardData = null; String str2 = null; VcardItem vcardItem2 = null; boolean z2 = false; while (true) { String readLine = bufferedReader.readLine(); if (readLine == null) { try { break; } catch (Exception e) { FileLog.e(e); } } else if (readLine.startsWith("PHOTO")) { z2 = true; } else { if (readLine.indexOf(58) >= 0) { if (readLine.startsWith("BEGIN:VCARD")) { vcardData = new VcardData(); arrayList4.add(vcardData); vcardData.name = str; } else if (!readLine.startsWith("END:VCARD") && arrayList2 != null) { if (readLine.startsWith("TEL")) { vcardItem = new VcardItem(); vcardItem.type = i2; } else if (readLine.startsWith("EMAIL")) { vcardItem = new VcardItem(); vcardItem.type = 1; } else if (readLine.startsWith("ADR") || readLine.startsWith("LABEL") || readLine.startsWith("GEO")) { vcardItem = new VcardItem(); vcardItem.type = 2; } else if (readLine.startsWith("URL")) { vcardItem = new VcardItem(); vcardItem.type = 3; } else if (readLine.startsWith("NOTE")) { vcardItem = new VcardItem(); vcardItem.type = 4; } else if (readLine.startsWith("BDAY")) { vcardItem = new VcardItem(); vcardItem.type = 5; } else if (readLine.startsWith("ORG") || readLine.startsWith("TITLE") || readLine.startsWith("ROLE")) { vcardItem = new VcardItem(); vcardItem.type = 6; } else if (readLine.startsWith("X-ANDROID")) { vcardItem = new VcardItem(); vcardItem.type = -1; } else if (!readLine.startsWith("X-PHONETIC") && readLine.startsWith("X-")) { vcardItem = new VcardItem(); vcardItem.type = 20; } else { vcardItem2 = r3; if (vcardItem2 != null && vcardItem2.type >= 0) { arrayList2.add(vcardItem2); } z2 = false; } vcardItem2 = vcardItem; arrayList2.add(vcardItem2); z2 = false; } vcardItem2 = r3; z2 = false; } if (!z2 && vcardData != null) { if (vcardItem2 == null) { if (vcardData.vcard.length() > 0) { vcardData.vcard.append('\n'); } vcardData.vcard.append(readLine); } else { vcardItem2.vcardData.add(readLine); } } if (str2 != null) { readLine = str2 + readLine; str2 = null; } String str3 = "="; if (!readLine.contains("=QUOTED-PRINTABLE") || !readLine.endsWith(str3)) { if (!(z2 || vcardData == null || vcardItem2 == null)) { vcardItem2.fullData = readLine; } int indexOf = readLine.indexOf(LogUtils.COLON); if (indexOf >= 0) { strArr = new String[]{readLine.substring(0, indexOf), readLine.substring(indexOf + 1).trim()}; c = 0; } else { c = 0; strArr = new String[]{readLine.trim()}; } if (strArr.length >= 2 && vcardData != null) { if (strArr[c].startsWith("FN") || (strArr[c].startsWith("ORG") && TextUtils.isEmpty(vcardData.name))) { String[] split = strArr[0].split(";"); int length = split.length; int i3 = 0; String str4 = null; String str5 = null; while (i3 < length) { String[] split2 = split[i3].split(str3); if (split2.length == 2) { if (split2[0].equals("CHARSET")) { str5 = split2[1]; } else if (split2[0].equals("ENCODING")) { str4 = split2[1]; } } i3++; length = length; split = split; str3 = str3; } vcardData.name = strArr[1]; if (!(str4 == null || !str4.equalsIgnoreCase("QUOTED-PRINTABLE") || (decodeQuotedPrintable = decodeQuotedPrintable(getStringBytes(vcardData.name))) == null || decodeQuotedPrintable.length == 0)) { vcardData.name = new String(decodeQuotedPrintable, str5); } arrayList2 = arrayList; r3 = 0; i2 = 0; } else if (strArr[0].startsWith("TEL")) { vcardData.phones.add(strArr[1]); } } arrayList2 = arrayList; r3 = 0; i2 = 0; } else { str2 = readLine.substring(i2, readLine.length() - 1); r3 = 0; } } } bufferedReader.close(); inputStream.close(); arrayList3 = null; for (int i4 = 0; i4 < arrayList4.size(); i4++) { VcardData vcardData2 = (VcardData) arrayList4.get(i4); if (vcardData2.name != null && !vcardData2.phones.isEmpty()) { if (arrayList3 == null) { arrayList3 = new ArrayList<>(); } String str6 = vcardData2.phones.get(0); int i5 = 0; while (true) { if (i5 >= vcardData2.phones.size()) { break; } String str7 = vcardData2.phones.get(i5); if (ContactsController.getInstance(i).contactsByShortPhone.get(str7.substring(Math.max(0, str7.length() - 7))) != null) { str6 = str7; break; } i5++; } TLRPC.TL_userContact_old2 tL_userContact_old2 = new TLRPC.TL_userContact_old2(); tL_userContact_old2.phone = str6; tL_userContact_old2.first_name = vcardData2.name; tL_userContact_old2.last_name = ""; tL_userContact_old2.id = 0; TLRPC.TL_restrictionReason tL_restrictionReason = new TLRPC.TL_restrictionReason(); tL_restrictionReason.text = vcardData2.vcard.toString(); tL_restrictionReason.platform = ""; tL_restrictionReason.reason = ""; tL_userContact_old2.restriction_reason.add(tL_restrictionReason); arrayList3.add(tL_userContact_old2); } } return arrayList3; } public static Typeface getTypeface(String str) { Typeface typeface; Typeface typeface2; synchronized (typefaceCache) { if (!typefaceCache.containsKey(str)) { try { if (Build.VERSION.SDK_INT >= 26) { Typeface.Builder builder = new Typeface.Builder(ApplicationLoader.applicationContext.getAssets(), str); if (str.contains("medium")) { builder.setWeight(HardwareConfigState.DEFAULT_MAXIMUM_FDS_FOR_HARDWARE_CONFIGS); } if (str.contains(TtmlNode.ITALIC)) { builder.setItalic(true); } typeface2 = builder.build(); } else { typeface2 = Typeface.createFromAsset(ApplicationLoader.applicationContext.getAssets(), str); } typefaceCache.put(str, typeface2); } catch (Exception e) { if (BuildVars.LOGS_ENABLED) { FileLog.e("Could not get typeface '" + str + "' because " + e.getMessage()); } return null; } } typeface = typefaceCache.get(str); } return typeface; } public static boolean isWaitingForSms() { boolean z; synchronized (smsLock) { z = waitingForSms; } return z; } public static void setWaitingForSms(boolean z) { synchronized (smsLock) { waitingForSms = z; if (z) { try { SmsRetriever.getClient(ApplicationLoader.applicationContext).startSmsRetriever().addOnSuccessListener($$Lambda$AndroidUtilities$jUGZhLrr2tgJTZCatcVlGzbzdI.INSTANCE); } catch (Throwable th) { FileLog.e(th); } } } } static /* synthetic */ void lambda$setWaitingForSms$1(Void r0) { if (BuildVars.DEBUG_VERSION) { FileLog.d("sms listener registered"); } } public static int getShadowHeight() { float f = density; if (f >= 4.0f) { return 3; } return f >= 2.0f ? 2 : 1; } public static boolean isWaitingForCall() { boolean z; synchronized (callLock) { z = waitingForCall; } return z; } public static void setWaitingForCall(boolean z) { synchronized (callLock) { waitingForCall = z; } } public static boolean showKeyboard(View view) { if (view == null) { return false; } try { return ((InputMethodManager) view.getContext().getSystemService("input_method")).showSoftInput(view, 1); } catch (Exception e) { FileLog.e(e); return false; } } public static boolean isKeyboardShowed(View view) { if (view == null) { return false; } try { return ((InputMethodManager) view.getContext().getSystemService("input_method")).isActive(view); } catch (Exception e) { FileLog.e(e); return false; } } /* JADX WARNING: Removed duplicated region for block: B:38:0x008a A[Catch:{ Exception -> 0x00a8 }] */ /* JADX WARNING: Removed duplicated region for block: B:40:0x0096 A[Catch:{ Exception -> 0x00a8 }] */ public static String[] getCurrentKeyboardLanguage() { String str; try { InputMethodManager inputMethodManager = (InputMethodManager) ApplicationLoader.applicationContext.getSystemService("input_method"); InputMethodSubtype currentInputMethodSubtype = inputMethodManager.getCurrentInputMethodSubtype(); String str2 = null; if (currentInputMethodSubtype != null) { str = Build.VERSION.SDK_INT >= 24 ? currentInputMethodSubtype.getLanguageTag() : null; if (TextUtils.isEmpty(str)) { str = currentInputMethodSubtype.getLocale(); } } else { InputMethodSubtype lastInputMethodSubtype = inputMethodManager.getLastInputMethodSubtype(); if (lastInputMethodSubtype != null) { String languageTag = Build.VERSION.SDK_INT >= 24 ? lastInputMethodSubtype.getLanguageTag() : null; str = TextUtils.isEmpty(languageTag) ? lastInputMethodSubtype.getLocale() : languageTag; } else { str = null; } } if (TextUtils.isEmpty(str)) { String systemLocaleStringIso639 = LocaleController.getSystemLocaleStringIso639(); LocaleController.LocaleInfo currentLocaleInfo = LocaleController.getInstance().getCurrentLocaleInfo(); String baseLangCode = currentLocaleInfo.getBaseLangCode(); if (TextUtils.isEmpty(baseLangCode)) { baseLangCode = currentLocaleInfo.getLangCode(); } if (!systemLocaleStringIso639.contains(baseLangCode)) { if (!baseLangCode.contains(systemLocaleStringIso639)) { str2 = baseLangCode; if (TextUtils.isEmpty(str2)) { return new String[]{systemLocaleStringIso639.replace('_', '-'), str2}; } return new String[]{systemLocaleStringIso639.replace('_', '-')}; } } if (!systemLocaleStringIso639.contains("en")) { str2 = "en"; } if (TextUtils.isEmpty(str2)) { } } else { return new String[]{str.replace('_', '-')}; } } catch (Exception unused) { return new String[]{"en"}; } } public static void hideKeyboard(View view) { if (view != null) { try { InputMethodManager inputMethodManager = (InputMethodManager) view.getContext().getSystemService("input_method"); if (inputMethodManager.isActive()) { inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); } } catch (Exception e) { FileLog.e(e); } } } public static File getCacheDir() { String str; try { str = Environment.getExternalStorageState(); } catch (Exception e) { FileLog.e(e); str = null; } if (str == null || str.startsWith("mounted")) { try { File externalCacheDir = ApplicationLoader.applicationContext.getExternalCacheDir(); if (externalCacheDir != null) { return externalCacheDir; } } catch (Exception e2) { FileLog.e(e2); } } try { File cacheDir = ApplicationLoader.applicationContext.getCacheDir(); if (cacheDir != null) { return cacheDir; } } catch (Exception e3) { FileLog.e(e3); } return new File(""); } public static int dp(float f) { if (f == 0.0f) { return 0; } return (int) Math.ceil((double) (density * f)); } public static int dpr(float f) { if (f == 0.0f) { return 0; } return Math.round(density * f); } public static int dp2(float f) { if (f == 0.0f) { return 0; } return (int) Math.floor((double) (density * f)); } public static float dpf2(float f) { if (f == 0.0f) { return 0.0f; } return density * f; } public static float sp2px(float f) { if (f == 0.0f || ApplicationLoader.applicationContext == null) { return 0.0f; } return (f * ApplicationLoader.applicationContext.getResources().getDisplayMetrics().scaledDensity) + 0.5f; } public static void checkDisplaySize(Context context, Configuration configuration) { Display defaultDisplay; try { int i = (int) density; float f = context.getResources().getDisplayMetrics().density; density = f; int i2 = (int) f; if (firstConfigurationWas && i != i2) { Theme.reloadAllResources(context); } boolean z = true; firstConfigurationWas = true; if (configuration == null) { configuration = context.getResources().getConfiguration(); } if (configuration.keyboard == 1 || configuration.hardKeyboardHidden != 1) { z = false; } usingHardwareInput = z; WindowManager windowManager = (WindowManager) context.getSystemService("window"); if (!(windowManager == null || (defaultDisplay = windowManager.getDefaultDisplay()) == null)) { defaultDisplay.getMetrics(displayMetrics); defaultDisplay.getSize(displaySize); } if (configuration.screenWidthDp != 0) { int ceil = (int) Math.ceil((double) (((float) configuration.screenWidthDp) * density)); if (Math.abs(displaySize.x - ceil) > 3) { displaySize.x = ceil; } } if (configuration.screenHeightDp != 0) { int ceil2 = (int) Math.ceil((double) (((float) configuration.screenHeightDp) * density)); if (Math.abs(displaySize.y - ceil2) > 3) { displaySize.y = ceil2; } } if (roundMessageSize == 0) { if (isTablet()) { roundMessageSize = (int) (((float) getMinTabletSide()) * 0.6f); } else { roundMessageSize = (int) (((float) Math.min(displaySize.x, displaySize.y)) * 0.6f); } } if (BuildVars.LOGS_ENABLED) { FileLog.e("display size = " + displaySize.x + " " + displaySize.y + " " + displayMetrics.xdpi + "x" + displayMetrics.ydpi); } } catch (Exception e) { FileLog.e(e); } } public static double fixLocationCoord(double d) { double d2 = (double) ((long) (d * 1000000.0d)); Double.isNaN(d2); return d2 / 1000000.0d; } public static String formapMapUrl(int i, double d, double d2, int i2, int i3, boolean z, int i4) { int min = Math.min(2, (int) Math.ceil((double) density)); int i5 = MessagesController.getInstance(i).mapProvider; if (i5 == 1 || i5 == 3) { String str = null; String[] strArr = {"ru_RU", "tr_TR"}; LocaleController.LocaleInfo currentLocaleInfo = LocaleController.getInstance().getCurrentLocaleInfo(); for (int i6 = 0; i6 < 2; i6++) { if (strArr[i6].toLowerCase().contains(currentLocaleInfo.shortName)) { str = strArr[i6]; } } if (str == null) { str = "en_US"; } if (z) { return String.format(Locale.US, "https://static-maps.yandex.ru/1.x/?ll=%.6f,%.6f&z=%d&size=%d,%d&l=map&scale=%d&pt=%.6f,%.6f,vkbkm&lang=%s", Double.valueOf(d2), Double.valueOf(d), Integer.valueOf(i4), Integer.valueOf(i2 * min), Integer.valueOf(i3 * min), Integer.valueOf(min), Double.valueOf(d2), Double.valueOf(d), str); } return String.format(Locale.US, "https://static-maps.yandex.ru/1.x/?ll=%.6f,%.6f&z=%d&size=%d,%d&l=map&scale=%d&lang=%s", Double.valueOf(d2), Double.valueOf(d), Integer.valueOf(i4), Integer.valueOf(i2 * min), Integer.valueOf(i3 * min), Integer.valueOf(min), str); } String string = ApplicationLoader.applicationContext.getResources().getString(R.string.baidu_map_key); String string2 = ApplicationLoader.applicationContext.getResources().getString(R.string.baidu_map_code); if (z) { return String.format(Locale.US, "http://api.map.baidu.com/staticimage/v2?ak=%s&mcode=%s¢er=%.6f,%.6f&width=%d&height=%d&zoom=%d&scale=%d&coordtype=gcj02ll©right=1&dpiType=ph&markers=%.6f,%.6f&markerStyles=l,,red", string, string2, Double.valueOf(d2), Double.valueOf(d), Integer.valueOf(i2), Integer.valueOf(i3), Integer.valueOf(i4), Integer.valueOf(min), Double.valueOf(d2), Double.valueOf(d)); } return String.format(Locale.US, "http://api.map.baidu.com/staticimage/v2?ak=%s&mcode=%s¢er=%.6f,%.6f&width=%d&height=%d&zoom=%d&scale=%d&coordtype=gcj02ll©right=1&dpiType=ph", string, string2, Double.valueOf(d2), Double.valueOf(d), Integer.valueOf(i2), Integer.valueOf(i3), Integer.valueOf(i4), Integer.valueOf(min)); } public static float getPixelsInCM(float f, boolean z) { return (f / 2.54f) * (z ? displayMetrics.xdpi : displayMetrics.ydpi); } public static void runOnUIThread(Runnable runnable) { runOnUIThread(runnable, 0); } public static void runOnUIThread(Runnable runnable, long j) { if (j == 0) { ApplicationLoader.applicationHandler.post(runnable); } else { ApplicationLoader.applicationHandler.postDelayed(runnable, j); } } public static void cancelRunOnUIThread(Runnable runnable) { ApplicationLoader.applicationHandler.removeCallbacks(runnable); } public static boolean isTablet() { if (isTablet == null) { isTablet = Boolean.valueOf(ApplicationLoader.applicationContext.getResources().getBoolean(R.bool.isTablet)); } return isTablet.booleanValue(); } public static boolean isSmallTablet() { return ((float) Math.min(displaySize.x, displaySize.y)) / density <= 700.0f; } public static int getMinTabletSide() { if (!isSmallTablet()) { int min = Math.min(displaySize.x, displaySize.y); int i = (min * 35) / 100; if (i < dp(320.0f)) { i = dp(320.0f); } return min - i; } int min2 = Math.min(displaySize.x, displaySize.y); int max = Math.max(displaySize.x, displaySize.y); int i2 = (max * 35) / 100; if (i2 < dp(320.0f)) { i2 = dp(320.0f); } return Math.min(min2, max - i2); } public static int getPhotoSize() { if (photoSize == null) { photoSize = 1280; } return photoSize.intValue(); } public static void endIncomingCall() { if (hasCallPermissions) { try { TelephonyManager telephonyManager = (TelephonyManager) ApplicationLoader.applicationContext.getSystemService("phone"); Method declaredMethod = Class.forName(telephonyManager.getClass().getName()).getDeclaredMethod("getITelephony", new Class[0]); declaredMethod.setAccessible(true); ITelephony iTelephony = (ITelephony) declaredMethod.invoke(telephonyManager, new Object[0]); ITelephony iTelephony2 = (ITelephony) declaredMethod.invoke(telephonyManager, new Object[0]); iTelephony2.silenceRinger(); iTelephony2.endCall(); } catch (Throwable th) { FileLog.e(th); } } } /* JADX WARNING: Code restructure failed: missing block: B:24:0x006d, code lost: r2 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:25:0x006e, code lost: if (r0 != null) goto L_0x0070; */ /* JADX WARNING: Code restructure failed: missing block: B:27:?, code lost: r0.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:28:0x0074, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:29:0x0075, code lost: r8.addSuppressed(r0); */ /* JADX WARNING: Code restructure failed: missing block: B:30:0x0078, code lost: throw r2; */ public static String obtainLoginPhoneCall(String str) { if (!hasCallPermissions) { return null; } try { Cursor query = ApplicationLoader.applicationContext.getContentResolver().query(CallLog.Calls.CONTENT_URI, new String[]{"number", "date"}, "type IN (3,1,5)", null, "date DESC LIMIT 5"); while (query.moveToNext()) { String string = query.getString(0); long j = query.getLong(1); if (BuildVars.LOGS_ENABLED) { FileLog.e("number = " + string); } if (Math.abs(System.currentTimeMillis() - j) < 3600000) { if (checkPhonePattern(str, string)) { if (query != null) { query.close(); } return string; } } } if (query != null) { query.close(); } } catch (Exception e) { FileLog.e(e); } return null; } public static boolean checkPhonePattern(String str, String str2) { if (!TextUtils.isEmpty(str) && !str.equals("*")) { String[] split = str.split("\\*"); String stripExceptNumbers = PhoneFormat.stripExceptNumbers(str2); int i = 0; for (String str3 : split) { if (!TextUtils.isEmpty(str3)) { int indexOf = stripExceptNumbers.indexOf(str3, i); if (indexOf == -1) { return false; } i = indexOf + str3.length(); } } } return true; } public static int getViewInset(View view) { if (!(view == null || Build.VERSION.SDK_INT < 21 || view.getHeight() == displaySize.y || view.getHeight() == displaySize.y - statusBarHeight)) { try { if (mAttachInfoField == null) { Field declaredField = View.class.getDeclaredField("mAttachInfo"); mAttachInfoField = declaredField; declaredField.setAccessible(true); } Object obj = mAttachInfoField.get(view); if (obj != null) { if (mStableInsetsField == null) { Field declaredField2 = obj.getClass().getDeclaredField("mStableInsets"); mStableInsetsField = declaredField2; declaredField2.setAccessible(true); } return ((Rect) mStableInsetsField.get(obj)).bottom; } } catch (Exception e) { FileLog.e(e); } } return 0; } public static Point getRealScreenSize() { Point point = new Point(); try { WindowManager windowManager = (WindowManager) ApplicationLoader.applicationContext.getSystemService("window"); if (Build.VERSION.SDK_INT >= 17) { windowManager.getDefaultDisplay().getRealSize(point); } else { try { point.set(((Integer) Display.class.getMethod("getRawWidth", new Class[0]).invoke(windowManager.getDefaultDisplay(), new Object[0])).intValue(), ((Integer) Display.class.getMethod("getRawHeight", new Class[0]).invoke(windowManager.getDefaultDisplay(), new Object[0])).intValue()); } catch (Exception e) { point.set(windowManager.getDefaultDisplay().getWidth(), windowManager.getDefaultDisplay().getHeight()); FileLog.e(e); } } } catch (Exception e2) { FileLog.e(e2); } return point; } public static void setEnabled(View view, boolean z) { if (view != null) { view.setEnabled(z); if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; for (int i = 0; i < viewGroup.getChildCount(); i++) { setEnabled(viewGroup.getChildAt(i), z); } } } } public static CharSequence getTrimmedString(CharSequence charSequence) { if (!(charSequence == null || charSequence.length() == 0)) { while (charSequence.length() > 0 && (charSequence.charAt(0) == '\n' || charSequence.charAt(0) == ' ')) { charSequence = charSequence.subSequence(1, charSequence.length()); } while (charSequence.length() > 0 && (charSequence.charAt(charSequence.length() - 1) == '\n' || charSequence.charAt(charSequence.length() - 1) == ' ')) { charSequence = charSequence.subSequence(0, charSequence.length() - 1); } } return charSequence; } public static void setViewPagerEdgeEffectColor(ViewPager viewPager, int i) { if (Build.VERSION.SDK_INT >= 21) { try { Field declaredField = ViewPager.class.getDeclaredField("mLeftEdge"); declaredField.setAccessible(true); EdgeEffect edgeEffect = (EdgeEffect) declaredField.get(viewPager); if (edgeEffect != null) { edgeEffect.setColor(i); } Field declaredField2 = ViewPager.class.getDeclaredField("mRightEdge"); declaredField2.setAccessible(true); EdgeEffect edgeEffect2 = (EdgeEffect) declaredField2.get(viewPager); if (edgeEffect2 != null) { edgeEffect2.setColor(i); } } catch (Exception unused) { } } } public static void setScrollViewEdgeEffectColor(HorizontalScrollView horizontalScrollView, int i) { if (Build.VERSION.SDK_INT >= 21) { try { Field declaredField = HorizontalScrollView.class.getDeclaredField("mEdgeGlowLeft"); declaredField.setAccessible(true); EdgeEffect edgeEffect = (EdgeEffect) declaredField.get(horizontalScrollView); if (edgeEffect != null) { edgeEffect.setColor(i); } Field declaredField2 = HorizontalScrollView.class.getDeclaredField("mEdgeGlowRight"); declaredField2.setAccessible(true); EdgeEffect edgeEffect2 = (EdgeEffect) declaredField2.get(horizontalScrollView); if (edgeEffect2 != null) { edgeEffect2.setColor(i); } } catch (Exception e) { FileLog.e(e); } } } public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int i) { if (Build.VERSION.SDK_INT >= 21) { try { Field declaredField = ScrollView.class.getDeclaredField("mEdgeGlowTop"); declaredField.setAccessible(true); EdgeEffect edgeEffect = (EdgeEffect) declaredField.get(scrollView); if (edgeEffect != null) { edgeEffect.setColor(i); } Field declaredField2 = ScrollView.class.getDeclaredField("mEdgeGlowBottom"); declaredField2.setAccessible(true); EdgeEffect edgeEffect2 = (EdgeEffect) declaredField2.get(scrollView); if (edgeEffect2 != null) { edgeEffect2.setColor(i); } } catch (Exception e) { FileLog.e(e); } } } public static void clearDrawableAnimation(View view) { if (Build.VERSION.SDK_INT >= 21 && view != null) { if (view instanceof ListView) { Drawable selector = ((ListView) view).getSelector(); if (selector != null) { selector.setState(StateSet.NOTHING); return; } return; } Drawable background = view.getBackground(); if (background != null) { background.setState(StateSet.NOTHING); background.jumpToCurrentState(); } } } public static SpannableStringBuilder replaceTags(String str) { return replaceTags(str, 11, new Object[0]); } public static SpannableStringBuilder replaceTags(String str, int i, Object... objArr) { try { StringBuilder sb = new StringBuilder(str); if ((i & 1) != 0) { while (true) { int indexOf = sb.indexOf("<br>"); if (indexOf == -1) { break; } sb.replace(indexOf, indexOf + 4, "\n"); } while (true) { int indexOf2 = sb.indexOf("<br/>"); if (indexOf2 == -1) { break; } sb.replace(indexOf2, indexOf2 + 5, "\n"); } } ArrayList arrayList = new ArrayList(); if ((i & 2) != 0) { while (true) { int indexOf3 = sb.indexOf("<b>"); if (indexOf3 == -1) { break; } sb.replace(indexOf3, indexOf3 + 3, ""); int indexOf4 = sb.indexOf("</b>"); if (indexOf4 == -1) { indexOf4 = sb.indexOf("<b>"); } sb.replace(indexOf4, indexOf4 + 4, ""); arrayList.add(Integer.valueOf(indexOf3)); arrayList.add(Integer.valueOf(indexOf4)); } while (true) { int indexOf5 = sb.indexOf("**"); if (indexOf5 == -1) { break; } sb.replace(indexOf5, indexOf5 + 2, ""); int indexOf6 = sb.indexOf("**"); if (indexOf6 >= 0) { sb.replace(indexOf6, indexOf6 + 2, ""); arrayList.add(Integer.valueOf(indexOf5)); arrayList.add(Integer.valueOf(indexOf6)); } } } if ((i & 8) != 0) { while (true) { int indexOf7 = sb.indexOf("**"); if (indexOf7 == -1) { break; } sb.replace(indexOf7, indexOf7 + 2, ""); int indexOf8 = sb.indexOf("**"); if (indexOf8 >= 0) { sb.replace(indexOf8, indexOf8 + 2, ""); arrayList.add(Integer.valueOf(indexOf7)); arrayList.add(Integer.valueOf(indexOf8)); } } } SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(sb); for (int i2 = 0; i2 < arrayList.size() / 2; i2++) { int i3 = i2 * 2; spannableStringBuilder.setSpan(new TypefaceSpan(getTypeface("fonts/rmedium.ttf")), ((Integer) arrayList.get(i3)).intValue(), ((Integer) arrayList.get(i3 + 1)).intValue(), 33); } return spannableStringBuilder; } catch (Exception e) { FileLog.e(e); return new SpannableStringBuilder(str); } } public static class LinkMovementMethodMy extends LinkMovementMethod { public boolean onTouchEvent(TextView textView, Spannable spannable, MotionEvent motionEvent) { try { boolean onTouchEvent = super.onTouchEvent(textView, spannable, motionEvent); if (motionEvent.getAction() == 1 || motionEvent.getAction() == 3) { Selection.removeSelection(spannable); } return onTouchEvent; } catch (Exception e) { FileLog.e(e); return false; } } } public static boolean needShowPasscode() { return needShowPasscode(false); } public static boolean needShowPasscode(boolean z) { boolean isWasInBackground = ForegroundDetector.getInstance().isWasInBackground(z); if (z) { ForegroundDetector.getInstance().resetBackgroundVar(); } return SharedConfig.passcodeHash.length() > 0 && isWasInBackground && (SharedConfig.appLocked || ((SharedConfig.autoLockIn != 0 && SharedConfig.lastPauseTime != 0 && !SharedConfig.appLocked && SharedConfig.lastPauseTime + SharedConfig.autoLockIn <= ConnectionsManager.getInstance(UserConfig.selectedAccount).getCurrentTime()) || ConnectionsManager.getInstance(UserConfig.selectedAccount).getCurrentTime() + 5 < SharedConfig.lastPauseTime)); } public static void shakeView(final View view, final float f, final int i) { if (view != null) { if (i == 6) { view.setTranslationX(0.0f); return; } AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(view, "translationX", (float) dp(f))); animatorSet.setDuration(50L); animatorSet.addListener(new AnimatorListenerAdapter() { /* class im.guobwnxjuc.messenger.AndroidUtilities.AnonymousClass1 */ public void onAnimationEnd(Animator animator) { AndroidUtilities.shakeView(view, i == 5 ? 0.0f : -f, i + 1); } }); animatorSet.start(); } } public static void checkForUpdates(Activity activity) { boolean z = BuildVars.DEBUG_VERSION; } public static void unregisterUpdates() { boolean z = BuildVars.DEBUG_VERSION; } public static void addToClipboard(CharSequence charSequence) { try { ((ClipboardManager) ApplicationLoader.applicationContext.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("label", charSequence)); } catch (Exception e) { FileLog.e(e); } } public static void addMediaToGallery(String str) { if (str != null) { addMediaToGallery(Uri.fromFile(new File(str))); } } public static void addMediaToGallery(Uri uri) { if (uri != null) { try { Intent intent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE"); intent.setData(uri); ApplicationLoader.applicationContext.sendBroadcast(intent); } catch (Exception e) { FileLog.e(e); } } } public static File getAlbumDir(boolean z) { if (z || (Build.VERSION.SDK_INT >= 23 && ApplicationLoader.applicationContext.checkSelfPermission(PermissionUtils.EXTERNAL_STORAGE) != 0)) { return FileLoader.getDirectory(4); } if ("mounted".equals(Environment.getExternalStorageState())) { File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Hong"); if (file.mkdirs() || file.exists()) { return file; } if (BuildVars.LOGS_ENABLED) { FileLog.d("failed to create directory"); } File externalFilesDir = ApplicationLoader.applicationContext.getExternalFilesDir("Hong"); if (!externalFilesDir.mkdirs()) { externalFilesDir.exists(); } return null; } else if (!BuildVars.LOGS_ENABLED) { return null; } else { FileLog.d("External storage is not mounted READ/WRITE."); return null; } } public static String getPath(Uri uri) { Uri uri2; try { if ((Build.VERSION.SDK_INT >= 19) && DocumentsContract.isDocumentUri(ApplicationLoader.applicationContext, uri)) { if (isExternalStorageDocument(uri)) { String[] split = DocumentsContract.getDocumentId(uri).split(LogUtils.COLON); if ("primary".equalsIgnoreCase(split[0])) { return Environment.getExternalStorageDirectory() + "/" + split[1]; } } else if (isDownloadsDocument(uri)) { return getDataColumn(ApplicationLoader.applicationContext, ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(DocumentsContract.getDocumentId(uri)).longValue()), null, null); } else if (isMediaDocument(uri)) { String[] split2 = DocumentsContract.getDocumentId(uri).split(LogUtils.COLON); String str = split2[0]; char c = 65535; int hashCode = str.hashCode(); if (hashCode != 93166550) { if (hashCode != 100313435) { if (hashCode == 112202875 && str.equals(MimeTypes.BASE_TYPE_VIDEO)) { c = 1; } } else if (str.equals(TtmlNode.TAG_IMAGE)) { c = 0; } } else if (str.equals(MimeTypes.BASE_TYPE_AUDIO)) { c = 2; } if (c == 0) { uri2 = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; } else if (c == 1) { uri2 = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; } else if (c != 2) { uri2 = null; } else { uri2 = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; } return getDataColumn(ApplicationLoader.applicationContext, uri2, "_id=?", new String[]{split2[1]}); } return null; } else if ("content".equalsIgnoreCase(uri.getScheme())) { return getDataColumn(ApplicationLoader.applicationContext, uri, null, null); } else { if ("file".equalsIgnoreCase(uri.getScheme())) { return uri.getPath(); } return null; } } catch (Exception e) { FileLog.e(e); } } /* JADX WARNING: Code restructure failed: missing block: B:22:0x004a, code lost: r10 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:23:0x004b, code lost: if (r8 != null) goto L_0x004d; */ /* JADX WARNING: Code restructure failed: missing block: B:25:?, code lost: r8.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:26:0x0051, code lost: r8 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:27:0x0052, code lost: r9.addSuppressed(r8); */ /* JADX WARNING: Code restructure failed: missing block: B:28:0x0055, code lost: throw r10; */ public static String getDataColumn(Context context, Uri uri, String str, String[] strArr) { try { Cursor query = context.getContentResolver().query(uri, new String[]{"_data"}, str, strArr, null); if (query != null) { if (query.moveToFirst()) { String string = query.getString(query.getColumnIndexOrThrow("_data")); if (string.startsWith("content://") || (!string.startsWith("/") && !string.startsWith("file://"))) { if (query != null) { query.close(); } return null; } if (query != null) { query.close(); } return string; } } if (query != null) { query.close(); } } catch (Exception unused) { } return null; } public static boolean isExternalStorageDocument(Uri uri) { return "com.android.externalstorage.documents".equals(uri.getAuthority()); } public static boolean isDownloadsDocument(Uri uri) { return "com.android.providers.downloads.documents".equals(uri.getAuthority()); } public static boolean isMediaDocument(Uri uri) { return "com.android.providers.media.documents".equals(uri.getAuthority()); } public static File generatePicturePath() { return generatePicturePath(false); } public static File generatePicturePath(boolean z) { try { File albumDir = getAlbumDir(z); Date date = new Date(); date.setTime(System.currentTimeMillis() + ((long) Utilities.random.nextInt(1000)) + 1); String format = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS", Locale.US).format(date); return new File(albumDir, "IMG_" + format + ".jpg"); } catch (Exception e) { FileLog.e(e); return null; } } public static CharSequence generateSearchName(String str, String str2, String str3) { if (str == null && str2 == null) { return ""; } SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(); if (str == null || str.length() == 0) { str = str2; } else if (!(str2 == null || str2.length() == 0)) { str = str + " " + str2; } String trim = str.trim(); String str4 = " " + trim.toLowerCase(); int i = 0; while (true) { int indexOf = str4.indexOf(" " + str3, i); if (indexOf == -1) { break; } int i2 = 1; int i3 = indexOf - (indexOf == 0 ? 0 : 1); int length = str3.length(); if (indexOf == 0) { i2 = 0; } int i4 = length + i2 + i3; if (i != 0 && i != i3 + 1) { spannableStringBuilder.append((CharSequence) trim.substring(i, i3)); } else if (i == 0 && i3 != 0) { spannableStringBuilder.append((CharSequence) trim.substring(0, i3)); } String substring = trim.substring(i3, Math.min(trim.length(), i4)); if (substring.startsWith(" ")) { spannableStringBuilder.append((CharSequence) " "); } String trim2 = substring.trim(); int length2 = spannableStringBuilder.length(); spannableStringBuilder.append((CharSequence) trim2); spannableStringBuilder.setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4)), length2, trim2.length() + length2, 33); i = i4; } if (i != -1 && i < trim.length()) { spannableStringBuilder.append((CharSequence) trim.substring(i)); } return spannableStringBuilder; } public static boolean isAirplaneModeOn() { if (Build.VERSION.SDK_INT < 17) { if (Settings.System.getInt(ApplicationLoader.applicationContext.getContentResolver(), "airplane_mode_on", 0) != 0) { return true; } return false; } else if (Settings.Global.getInt(ApplicationLoader.applicationContext.getContentResolver(), "airplane_mode_on", 0) != 0) { return true; } else { return false; } } public static File generateVideoPath() { return generateVideoPath(false); } public static File generateVideoPath(boolean z) { try { File albumDir = getAlbumDir(z); Date date = new Date(); date.setTime(System.currentTimeMillis() + ((long) Utilities.random.nextInt(1000)) + 1); String format = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS", Locale.US).format(date); return new File(albumDir, "VID_" + format + ".mp4"); } catch (Exception e) { FileLog.e(e); return null; } } public static String formatFileSize(long j) { return formatFileSize(j, false); } public static String formatFileSize(long j, boolean z) { if (j < 1024) { return String.format("%d B", Long.valueOf(j)); } else if (j < 1048576) { float f = ((float) j) / 1024.0f; if (z) { int i = (int) f; if ((f - ((float) i)) * 10.0f == 0.0f) { return String.format("%d KB", Integer.valueOf(i)); } } return String.format("%.1f KB", Float.valueOf(f)); } else if (j < 1073741824) { float f2 = (((float) j) / 1024.0f) / 1024.0f; if (z) { int i2 = (int) f2; if ((f2 - ((float) i2)) * 10.0f == 0.0f) { return String.format("%d MB", Integer.valueOf(i2)); } } return String.format("%.1f MB", Float.valueOf(f2)); } else { float f3 = ((((float) j) / 1024.0f) / 1024.0f) / 1024.0f; if (z) { int i3 = (int) f3; if ((f3 - ((float) i3)) * 10.0f == 0.0f) { return String.format("%d GB", Integer.valueOf(i3)); } } return String.format("%.1f GB", Float.valueOf(f3)); } } public static byte[] decodeQuotedPrintable(byte[] bArr) { if (bArr == null) { return null; } ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); int i = 0; while (i < bArr.length) { byte b = bArr[i]; if (b == 61) { int i2 = i + 1; try { int digit = Character.digit((char) bArr[i2], 16); i = i2 + 1; byteArrayOutputStream.write((char) ((digit << 4) + Character.digit((char) bArr[i], 16))); } catch (Exception e) { FileLog.e(e); return null; } } else { byteArrayOutputStream.write(b); } i++; } byte[] byteArray = byteArrayOutputStream.toByteArray(); try { byteArrayOutputStream.close(); } catch (Exception e2) { FileLog.e(e2); } return byteArray; } public static boolean copyFile(InputStream inputStream, File file) throws IOException { FileOutputStream fileOutputStream = new FileOutputStream(file); byte[] bArr = new byte[4096]; while (true) { int read = inputStream.read(bArr); if (read > 0) { Thread.yield(); fileOutputStream.write(bArr, 0, read); } else { fileOutputStream.close(); return true; } } } /* JADX WARNING: Code restructure failed: missing block: B:17:0x0039, code lost: r1 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:19:?, code lost: r8.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:20:0x003e, code lost: r8 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:21:0x003f, code lost: r9.addSuppressed(r8); */ /* JADX WARNING: Code restructure failed: missing block: B:22:0x0042, code lost: throw r1; */ /* JADX WARNING: Code restructure failed: missing block: B:26:0x0045, code lost: r9 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:28:?, code lost: r0.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:29:0x004a, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:30:0x004b, code lost: r8.addSuppressed(r0); */ /* JADX WARNING: Code restructure failed: missing block: B:31:0x004e, code lost: throw r9; */ public static boolean copyFile(File file, File file2) throws IOException { if (file.equals(file2)) { return true; } if (!file2.exists()) { file2.createNewFile(); } try { FileInputStream fileInputStream = new FileInputStream(file); FileOutputStream fileOutputStream = new FileOutputStream(file2); fileOutputStream.getChannel().transferFrom(fileInputStream.getChannel(), 0, fileInputStream.getChannel().size()); fileOutputStream.close(); fileInputStream.close(); return true; } catch (Exception e) { FileLog.e(e); return false; } } public static byte[] calcAuthKeyHash(byte[] bArr) { byte[] bArr2 = new byte[16]; System.arraycopy(Utilities.computeSHA1(bArr), 0, bArr2, 0, 16); return bArr2; } public static void openDocument(MessageObject messageObject, Activity activity, BaseFragment baseFragment) { TLRPC.Document document; String str; String str2; String str3; if (messageObject != null && (document = messageObject.getDocument()) != null) { String attachFileName = messageObject.messageOwner.media != null ? FileLoader.getAttachFileName(document) : ""; File file = (messageObject.messageOwner.attachPath == null || messageObject.messageOwner.attachPath.length() == 0) ? null : new File(messageObject.messageOwner.attachPath); if (file == null || (file != null && !file.exists())) { file = FileLoader.getPathToMessage(messageObject.messageOwner); } if (file != null && file.exists()) { if (baseFragment == null || !file.getName().toLowerCase().endsWith("attheme")) { try { Intent intent = new Intent("android.intent.action.VIEW"); intent.setFlags(1); MimeTypeMap singleton = MimeTypeMap.getSingleton(); int lastIndexOf = attachFileName.lastIndexOf(46); if (lastIndexOf == -1 || ((str = singleton.getMimeTypeFromExtension(attachFileName.substring(lastIndexOf + 1).toLowerCase())) == null && ((str = document.mime_type) == null || str.length() == 0))) { str = null; } if (Build.VERSION.SDK_INT >= 24) { Uri uriForFile = FileProvider.getUriForFile(activity, "im.guobwnxjuc.messenger.provider", file); if (str != null) { str3 = str; } else { str3 = "text/plain"; } intent.setDataAndType(uriForFile, str3); } else { Uri fromFile = Uri.fromFile(file); if (str != null) { str2 = str; } else { str2 = "text/plain"; } intent.setDataAndType(fromFile, str2); } if (str != null) { try { activity.startActivityForResult(intent, 500); } catch (Exception unused) { if (Build.VERSION.SDK_INT >= 24) { intent.setDataAndType(FileProvider.getUriForFile(activity, "im.guobwnxjuc.messenger.provider", file), "text/plain"); } else { intent.setDataAndType(Uri.fromFile(file), "text/plain"); } activity.startActivityForResult(intent, 500); } } else { activity.startActivityForResult(intent, 500); } } catch (Exception unused2) { if (activity != null) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); builder.setMessage(LocaleController.formatString("NoHandleAppInstalled", R.string.NoHandleAppInstalled, messageObject.getDocument().mime_type)); if (baseFragment != null) { baseFragment.showDialog(builder.create()); } else { builder.show(); } } } } else { Theme.ThemeInfo applyThemeFile = Theme.applyThemeFile(file, messageObject.getDocumentName(), null, true); if (applyThemeFile != null) { baseFragment.presentFragment(new ThemePreviewActivity(applyThemeFile)); return; } AlertDialog.Builder builder2 = new AlertDialog.Builder(activity); builder2.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder2.setMessage(LocaleController.getString("IncorrectTheme", R.string.IncorrectTheme)); builder2.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); baseFragment.showDialog(builder2.create()); } } } } /* JADX WARNING: Code restructure failed: missing block: B:24:0x0073, code lost: if (r0.length() != 0) goto L_0x0076; */ /* JADX WARNING: Removed duplicated region for block: B:37:0x00db */ /* JADX WARNING: Removed duplicated region for block: B:42:0x00e8 */ /* JADX WARNING: Removed duplicated region for block: B:49:0x00f8 A[SYNTHETIC, Splitter:B:49:0x00f8] */ /* JADX WARNING: Removed duplicated region for block: B:57:0x0113 */ public static void openForView(MessageObject messageObject, Activity activity) { String str; String str2; String str3; String fileName = messageObject.getFileName(); File file = (messageObject.messageOwner.attachPath == null || messageObject.messageOwner.attachPath.length() == 0) ? null : new File(messageObject.messageOwner.attachPath); if (file == null || !file.exists()) { file = FileLoader.getPathToMessage(messageObject.messageOwner); } if (file != null && file.exists()) { Intent intent = new Intent("android.intent.action.VIEW"); intent.setFlags(1); MimeTypeMap singleton = MimeTypeMap.getSingleton(); int lastIndexOf = fileName.lastIndexOf(46); if (lastIndexOf != -1) { str = singleton.getMimeTypeFromExtension(fileName.substring(lastIndexOf + 1).toLowerCase()); if (str == null) { if (messageObject.type == 9 || messageObject.type == 0) { str = messageObject.getDocument().mime_type; } if (str != null) { } } if (Build.VERSION.SDK_INT >= 26 || str == null || !str.equals("application/vnd.android.package-archive") || ApplicationLoader.applicationContext.getPackageManager().canRequestPackageInstalls()) { if (Build.VERSION.SDK_INT < 24) { Uri uriForFile = FileProvider.getUriForFile(activity, "im.guobwnxjuc.messenger.provider", file); if (str != null) { str3 = str; } else { str3 = "text/plain"; } intent.setDataAndType(uriForFile, str3); } else { Uri fromFile = Uri.fromFile(file); if (str != null) { str2 = str; } else { str2 = "text/plain"; } intent.setDataAndType(fromFile, str2); } if (str == null) { try { activity.startActivityForResult(intent, 500); return; } catch (Exception unused) { if (Build.VERSION.SDK_INT >= 24) { intent.setDataAndType(FileProvider.getUriForFile(activity, "im.guobwnxjuc.messenger.provider", file), "text/plain"); } else { intent.setDataAndType(Uri.fromFile(file), "text/plain"); } activity.startActivityForResult(intent, 500); return; } } else { activity.startActivityForResult(intent, 500); return; } } else { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.getString("ApkRestricted", R.string.ApkRestricted)); builder.setPositiveButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), new DialogInterface.OnClickListener(activity) { /* class im.guobwnxjuc.messenger.$$Lambda$AndroidUtilities$spEM1VHwwzZERGcJSfo91fYi0Ds */ private final /* synthetic */ Activity f$0; { this.f$0 = r1; } public final void onClick(DialogInterface dialogInterface, int i) { AndroidUtilities.lambda$openForView$2(this.f$0, dialogInterface, i); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.show(); return; } } str = null; if (Build.VERSION.SDK_INT >= 26) { } if (Build.VERSION.SDK_INT < 24) { } if (str == null) { } } } static /* synthetic */ void lambda$openForView$2(Activity activity, DialogInterface dialogInterface, int i) { try { activity.startActivity(new Intent("android.settings.MANAGE_UNKNOWN_APP_SOURCES", Uri.parse("package:" + activity.getPackageName()))); } catch (Exception e) { FileLog.e(e); } } /* JADX WARNING: Code restructure failed: missing block: B:15:0x004c, code lost: if (r0.length() != 0) goto L_0x004f; */ public static void openForView(TLObject tLObject, Activity activity) { String str; String str2; if (tLObject != null && activity != null) { String attachFileName = FileLoader.getAttachFileName(tLObject); File pathToAttach = FileLoader.getPathToAttach(tLObject, true); if (pathToAttach != null && pathToAttach.exists()) { Intent intent = new Intent("android.intent.action.VIEW"); intent.setFlags(1); MimeTypeMap singleton = MimeTypeMap.getSingleton(); int lastIndexOf = attachFileName.lastIndexOf(46); String str3 = null; if (lastIndexOf != -1) { String mimeTypeFromExtension = singleton.getMimeTypeFromExtension(attachFileName.substring(lastIndexOf + 1).toLowerCase()); if (mimeTypeFromExtension == null) { if (tLObject instanceof TLRPC.TL_document) { mimeTypeFromExtension = ((TLRPC.TL_document) tLObject).mime_type; } if (mimeTypeFromExtension != null) { } } str3 = mimeTypeFromExtension; } if (Build.VERSION.SDK_INT >= 24) { Uri uriForFile = FileProvider.getUriForFile(activity, "im.guobwnxjuc.messenger.provider", pathToAttach); if (str3 != null) { str2 = str3; } else { str2 = "text/plain"; } intent.setDataAndType(uriForFile, str2); } else { Uri fromFile = Uri.fromFile(pathToAttach); if (str3 != null) { str = str3; } else { str = "text/plain"; } intent.setDataAndType(fromFile, str); } if (str3 != null) { try { activity.startActivityForResult(intent, 500); } catch (Exception unused) { if (Build.VERSION.SDK_INT >= 24) { intent.setDataAndType(FileProvider.getUriForFile(activity, "im.guobwnxjuc.messenger.provider", pathToAttach), "text/plain"); } else { intent.setDataAndType(Uri.fromFile(pathToAttach), "text/plain"); } activity.startActivityForResult(intent, 500); } } else { activity.startActivityForResult(intent, 500); } } } } public static boolean isBannedForever(TLRPC.TL_chatBannedRights tL_chatBannedRights) { return tL_chatBannedRights == null || Math.abs(((long) tL_chatBannedRights.until_date) - (System.currentTimeMillis() / 1000)) > 157680000; } public static void setRectToRect(Matrix matrix, RectF rectF, RectF rectF2, int i, boolean z) { float f; float f2; float f3; boolean z2; float f4; float f5; float f6; float f7; if (i == 90 || i == 270) { f3 = rectF2.height() / rectF.width(); f2 = rectF2.width(); f = rectF.height(); } else { f3 = rectF2.width() / rectF.width(); f2 = rectF2.height(); f = rectF.height(); } float f8 = f2 / f; if (f3 < f8) { f3 = f8; z2 = true; } else { z2 = false; } if (z) { matrix.setTranslate(rectF2.left, rectF2.top); } if (i == 90) { matrix.preRotate(90.0f); matrix.preTranslate(0.0f, -rectF2.width()); } else if (i == 180) { matrix.preRotate(180.0f); matrix.preTranslate(-rectF2.width(), -rectF2.height()); } else if (i == 270) { matrix.preRotate(270.0f); matrix.preTranslate(-rectF2.height(), 0.0f); } if (z) { f4 = (-rectF.left) * f3; f5 = (-rectF.top) * f3; } else { f4 = rectF2.left - (rectF.left * f3); f5 = rectF2.top - (rectF.top * f3); } if (z2) { f6 = rectF2.width(); f7 = rectF.width(); } else { f6 = rectF2.height(); f7 = rectF.height(); } float f9 = (f6 - (f7 * f3)) / 2.0f; if (z2) { f4 += f9; } else { f5 += f9; } matrix.preScale(f3, f3); if (z) { matrix.preTranslate(f4, f5); } } /* JADX WARNING: Removed duplicated region for block: B:47:0x00ee */ /* JADX WARNING: Removed duplicated region for block: B:48:0x00f0 */ /* JADX WARNING: Removed duplicated region for block: B:50:0x00f3 */ /* JADX WARNING: Removed duplicated region for block: B:51:0x00f5 */ /* JADX WARNING: Removed duplicated region for block: B:53:0x00f8 */ /* JADX WARNING: Removed duplicated region for block: B:54:0x00fa */ public static boolean handleProxyIntent(Activity activity, Intent intent) { Uri data; String str; String str2; String str3; String str4; String str5; String str6; String str7; String path; if (intent == null) { return false; } try { if ((intent.getFlags() & 1048576) == 0 && (data = intent.getData()) != null) { String scheme = data.getScheme(); String str8 = null; if (scheme != null) { if (scheme.equals("http") || scheme.equals("https")) { String host = data.getHost(); if (host == null || !"m12345.cc".equals(host.toLowerCase()) || (path = data.getPath()) == null || (!path.startsWith("/socks") && !path.startsWith("/proxy"))) { str5 = null; str7 = null; str6 = null; str4 = null; } else { String queryParameter = data.getQueryParameter("server"); str7 = data.getQueryParameter("port"); String queryParameter2 = data.getQueryParameter("user"); str4 = data.getQueryParameter("pass"); str6 = data.getQueryParameter("secret"); str5 = queryParameter; str8 = queryParameter2; } str3 = str5; str2 = str7; str = str6; if (!TextUtils.isEmpty(str3) && !TextUtils.isEmpty(str2)) { showProxyAlert(activity, str3, str2, str8 == null ? "" : str8, str4 == null ? "" : str4, str == null ? "" : str); return true; } } else if (scheme.equals("hchat")) { String uri = data.toString(); if (uri.startsWith("hchat:proxy") || uri.startsWith("hchat://proxy") || uri.startsWith("hchat:socks") || uri.startsWith("hchat://socks")) { Uri parse = Uri.parse(uri.replace("hchat:proxy", "hchat://m12345.cc").replace("hchat://proxy", "hchat://m12345.cc").replace("hchat://socks", "hchat://m12345.cc").replace("hchat:socks", "hchat://m12345.cc")); String queryParameter3 = parse.getQueryParameter("server"); String queryParameter4 = parse.getQueryParameter("port"); String queryParameter5 = parse.getQueryParameter("user"); str4 = parse.getQueryParameter("pass"); str = parse.getQueryParameter("secret"); str2 = queryParameter4; str3 = queryParameter3; str8 = queryParameter5; showProxyAlert(activity, str3, str2, str8 == null ? "" : str8, str4 == null ? "" : str4, str == null ? "" : str); return true; } } } str = null; str4 = null; str3 = null; str2 = null; showProxyAlert(activity, str3, str2, str8 == null ? "" : str8, str4 == null ? "" : str4, str == null ? "" : str); return true; } } catch (Exception unused) { } return false; } public static boolean shouldEnableAnimation() { if (Build.VERSION.SDK_INT < 26 || Build.VERSION.SDK_INT >= 28 || (!((PowerManager) ApplicationLoader.applicationContext.getSystemService("power")).isPowerSaveMode() && Settings.Global.getFloat(ApplicationLoader.applicationContext.getContentResolver(), "animator_duration_scale", 1.0f) > 0.0f)) { return true; } return false; } public static void showProxyAlert(Activity activity, String str, String str2, String str3, String str4, String str5) { String str6; BottomSheet.Builder builder = new BottomSheet.Builder(activity); Runnable dismissRunnable = builder.getDismissRunnable(); builder.setApplyTopPadding(false); builder.setApplyBottomPadding(false); LinearLayout linearLayout = new LinearLayout(activity); builder.setCustomView(linearLayout); linearLayout.setOrientation(1); if (!TextUtils.isEmpty(str5)) { TextView textView = new TextView(activity); textView.setText(LocaleController.getString("UseProxySettingsTips", R.string.UseProxySettingsTips)); textView.setTextColor(Theme.getColor(Theme.key_dialogTextGray4)); textView.setTextSize(1, 14.0f); textView.setGravity(49); linearLayout.addView(textView, LayoutHelper.createLinear(-2, -2, (LocaleController.isRTL ? 5 : 3) | 48, 17, 8, 17, 8)); View view = new View(activity); view.setBackgroundColor(Theme.getColor(Theme.key_divider)); linearLayout.addView(view, new LinearLayout.LayoutParams(-1, 1)); } int i = 0; while (true) { if (i >= 5) { break; } String str7 = null; if (i == 0) { str6 = LocaleController.getString("UseProxyAddress", R.string.UseProxyAddress); str7 = str; } else if (i == 1) { str7 = "" + str2; str6 = LocaleController.getString("UseProxyPort", R.string.UseProxyPort); } else if (i == 2) { str6 = LocaleController.getString("UseProxySecret", R.string.UseProxySecret); str7 = str5; } else if (i == 3) { str6 = LocaleController.getString("UseProxyUsername", R.string.UseProxyUsername); str7 = str3; } else if (i == 4) { str6 = LocaleController.getString("UseProxyPassword", R.string.UseProxyPassword); str7 = str4; } else { str6 = null; } if (!TextUtils.isEmpty(str7)) { TextDetailSettingsCell textDetailSettingsCell = new TextDetailSettingsCell(activity); textDetailSettingsCell.setTextAndValue(str7, str6, true); textDetailSettingsCell.getTextView().setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); textDetailSettingsCell.getValueTextView().setTextColor(Theme.getColor(Theme.key_dialogTextGray3)); linearLayout.addView(textDetailSettingsCell, LayoutHelper.createLinear(-1, -2)); if (i == 2) { break; } } i++; } PickerBottomLayout pickerBottomLayout = new PickerBottomLayout(activity, false); pickerBottomLayout.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground)); linearLayout.addView(pickerBottomLayout, LayoutHelper.createFrame(-1, 48, 83)); pickerBottomLayout.cancelButton.setPadding(dp(18.0f), 0, dp(18.0f), 0); pickerBottomLayout.cancelButton.setTextColor(Theme.getColor(Theme.key_dialogTextBlue2)); pickerBottomLayout.cancelButton.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase()); pickerBottomLayout.cancelButton.setOnClickListener(new View.OnClickListener(dismissRunnable) { /* class im.guobwnxjuc.messenger.$$Lambda$AndroidUtilities$FAmPSADq5eRo32l4UFYEoOZ6dpA */ private final /* synthetic */ Runnable f$0; { this.f$0 = r1; } public final void onClick(View view) { this.f$0.run(); } }); pickerBottomLayout.doneButtonTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlue2)); pickerBottomLayout.doneButton.setPadding(dp(18.0f), 0, dp(18.0f), 0); pickerBottomLayout.doneButtonBadgeTextView.setVisibility(8); pickerBottomLayout.doneButtonTextView.setText(LocaleController.getString("ConnectingConnectProxy", R.string.ConnectingConnectProxy).toUpperCase()); pickerBottomLayout.doneButton.setOnClickListener(new View.OnClickListener(str, str2, str5, str4, str3, dismissRunnable) { /* class im.guobwnxjuc.messenger.$$Lambda$AndroidUtilities$CsohfLHs1ub2NqbyS8l9yNf92mU */ private final /* synthetic */ String f$0; private final /* synthetic */ String f$1; private final /* synthetic */ String f$2; private final /* synthetic */ String f$3; private final /* synthetic */ String f$4; private final /* synthetic */ Runnable f$5; { this.f$0 = r1; this.f$1 = r2; this.f$2 = r3; this.f$3 = r4; this.f$4 = r5; this.f$5 = r6; } public final void onClick(View view) { AndroidUtilities.lambda$showProxyAlert$4(this.f$0, this.f$1, this.f$2, this.f$3, this.f$4, this.f$5, view); } }); builder.show(); } static /* synthetic */ void lambda$showProxyAlert$4(String str, String str2, String str3, String str4, String str5, Runnable runnable, View view) { SharedConfig.ProxyInfo proxyInfo; SharedPreferences.Editor edit = MessagesController.getGlobalMainSettings().edit(); edit.putBoolean("proxy_enabled", true); edit.putString("proxy_ip", str); int intValue = Utilities.parseInt(str2).intValue(); edit.putInt("proxy_port", intValue); if (TextUtils.isEmpty(str3)) { edit.remove("proxy_secret"); if (TextUtils.isEmpty(str4)) { edit.remove("proxy_pass"); } else { edit.putString("proxy_pass", str4); } if (TextUtils.isEmpty(str5)) { edit.remove("proxy_user"); } else { edit.putString("proxy_user", str5); } proxyInfo = new SharedConfig.ProxyInfo(str, intValue, str5, str4, ""); } else { edit.remove("proxy_pass"); edit.remove("proxy_user"); edit.putString("proxy_secret", str3); proxyInfo = new SharedConfig.ProxyInfo(str, intValue, "", "", str3); } edit.commit(); SharedConfig.currentProxy = SharedConfig.addProxy(proxyInfo); ConnectionsManager.setProxySettings(true, str, intValue, str5, str4, str3); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxySettingsChanged, new Object[0]); runnable.run(); } public static String getSystemProperty(String str) { try { return (String) Class.forName("android.os.SystemProperties").getMethod("get", String.class).invoke(null, str); } catch (Exception unused) { return null; } } public static CharSequence concat(CharSequence... charSequenceArr) { if (charSequenceArr.length == 0) { return ""; } int i = 0; boolean z = true; if (charSequenceArr.length == 1) { return charSequenceArr[0]; } int length = charSequenceArr.length; int i2 = 0; while (true) { if (i2 >= length) { z = false; break; } else if (charSequenceArr[i2] instanceof Spanned) { break; } else { i2++; } } if (z) { SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(); int length2 = charSequenceArr.length; while (i < length2) { CharSequence charSequence = charSequenceArr[i]; if (charSequence == null) { charSequence = "null"; } spannableStringBuilder.append(charSequence); i++; } return new SpannedString(spannableStringBuilder); } StringBuilder sb = new StringBuilder(); int length3 = charSequenceArr.length; while (i < length3) { sb.append(charSequenceArr[i]); i++; } return sb.toString(); } public static int HSBtoRGB(float f, float f2, float f3) { int i; int i2; int i3 = 0; if (f2 == 0.0f) { i3 = (int) ((f3 * 255.0f) + 0.5f); i2 = i3; i = i2; } else { float floor = (f - ((float) Math.floor((double) f))) * 6.0f; float floor2 = floor - ((float) Math.floor((double) floor)); float f4 = (1.0f - f2) * f3; float f5 = (1.0f - (f2 * floor2)) * f3; float f6 = (1.0f - (f2 * (1.0f - floor2))) * f3; int i4 = (int) floor; if (i4 == 0) { i3 = (int) ((f3 * 255.0f) + 0.5f); i2 = (int) ((f6 * 255.0f) + 0.5f); } else if (i4 == 1) { i3 = (int) ((f5 * 255.0f) + 0.5f); i2 = (int) ((f3 * 255.0f) + 0.5f); } else if (i4 != 2) { if (i4 == 3) { i3 = (int) ((f4 * 255.0f) + 0.5f); i2 = (int) ((f5 * 255.0f) + 0.5f); } else if (i4 == 4) { i3 = (int) ((f6 * 255.0f) + 0.5f); i2 = (int) ((f4 * 255.0f) + 0.5f); } else if (i4 != 5) { i2 = 0; i = 0; } else { i3 = (int) ((f3 * 255.0f) + 0.5f); i2 = (int) ((f4 * 255.0f) + 0.5f); i = (int) ((f5 * 255.0f) + 0.5f); } i = (int) ((f3 * 255.0f) + 0.5f); } else { i3 = (int) ((f4 * 255.0f) + 0.5f); i2 = (int) ((f3 * 255.0f) + 0.5f); i = (int) ((f6 * 255.0f) + 0.5f); } i = (int) ((f4 * 255.0f) + 0.5f); } return ((i2 & 255) << 8) | -16777216 | ((i3 & 255) << 16) | (i & 255); } public static int getPatternColor(int i) { float[] RGBtoHSB = RGBtoHSB(Color.red(i), Color.green(i), Color.blue(i)); if (RGBtoHSB[1] > 0.0f || (RGBtoHSB[2] < 1.0f && RGBtoHSB[2] > 0.0f)) { RGBtoHSB[1] = Math.min(1.0f, RGBtoHSB[1] + 0.05f + ((1.0f - RGBtoHSB[1]) * 0.1f)); } if (RGBtoHSB[2] > 0.5f) { RGBtoHSB[2] = Math.max(0.0f, RGBtoHSB[2] * 0.65f); } else { RGBtoHSB[2] = Math.max(0.0f, Math.min(1.0f, 1.0f - (RGBtoHSB[2] * 0.65f))); } return HSBtoRGB(RGBtoHSB[0], RGBtoHSB[1], RGBtoHSB[2]) & 1728053247; } public static int getPatternSideColor(int i) { float[] RGBtoHSB = RGBtoHSB(Color.red(i), Color.green(i), Color.blue(i)); RGBtoHSB[1] = Math.min(1.0f, RGBtoHSB[1] + 0.05f); if (RGBtoHSB[2] > 0.5f) { RGBtoHSB[2] = Math.max(0.0f, RGBtoHSB[2] * 0.9f); } else { RGBtoHSB[2] = Math.max(0.0f, RGBtoHSB[2] * 0.9f); } return HSBtoRGB(RGBtoHSB[0], RGBtoHSB[1], RGBtoHSB[2]) | -16777216; } public static String getWallPaperUrl(Object obj, int i) { String str; if (obj instanceof TLRPC.TL_wallPaper) { TLRPC.TL_wallPaper tL_wallPaper = (TLRPC.TL_wallPaper) obj; String str2 = "https://" + MessagesController.getInstance(i).linkPrefix + "/bg/" + tL_wallPaper.slug; StringBuilder sb = new StringBuilder(); if (tL_wallPaper.settings != null) { if (tL_wallPaper.settings.blur) { sb.append("blur"); } if (tL_wallPaper.settings.motion) { if (sb.length() > 0) { sb.append(Marker.ANY_NON_NULL_MARKER); } sb.append("motion"); } } if (sb.length() <= 0) { return str2; } return str2 + "?mode=" + sb.toString(); } else if (!(obj instanceof WallpapersListActivity.ColorWallpaper)) { return null; } else { WallpapersListActivity.ColorWallpaper colorWallpaper = (WallpapersListActivity.ColorWallpaper) obj; String lowerCase = String.format("%02x%02x%02x", Integer.valueOf(((byte) (colorWallpaper.color >> 16)) & UByte.MAX_VALUE), Integer.valueOf(((byte) (colorWallpaper.color >> 8)) & UByte.MAX_VALUE), Byte.valueOf((byte) (colorWallpaper.color & 255))).toLowerCase(); if (colorWallpaper.pattern != null) { str = "https://" + MessagesController.getInstance(i).linkPrefix + "/bg/" + colorWallpaper.pattern.slug + "?intensity=" + ((int) (colorWallpaper.intensity * 100.0f)) + "&bg_color=" + lowerCase; } else { str = "https://" + MessagesController.getInstance(i).linkPrefix + "/bg/" + lowerCase; } return str; } } public static float distanceInfluenceForSnapDuration(float f) { return (float) Math.sin((double) ((f - 0.5f) * 0.47123894f)); } public static void makeAccessibilityAnnouncement(CharSequence charSequence) { AccessibilityManager accessibilityManager = (AccessibilityManager) ApplicationLoader.applicationContext.getSystemService("accessibility"); if (accessibilityManager.isEnabled()) { AccessibilityEvent obtain = AccessibilityEvent.obtain(); obtain.setEventType(16384); obtain.getText().add(charSequence); accessibilityManager.sendAccessibilityEvent(obtain); } } public static int getOffsetColor(int i, int i2, float f, float f2) { int red = Color.red(i2); int green = Color.green(i2); int blue = Color.blue(i2); int alpha = Color.alpha(i2); int red2 = Color.red(i); int green2 = Color.green(i); int blue2 = Color.blue(i); int alpha2 = Color.alpha(i); return Color.argb((int) ((((float) alpha2) + (((float) (alpha - alpha2)) * f)) * f2), (int) (((float) red2) + (((float) (red - red2)) * f)), (int) (((float) green2) + (((float) (green - green2)) * f)), (int) (((float) blue2) + (((float) (blue - blue2)) * f))); } public static int indexOfIgnoreCase(String str, String str2) { if (str2.isEmpty() || str.isEmpty()) { return str.indexOf(str2); } int i = 0; while (i < str.length() && str2.length() + i <= str.length()) { int i2 = i; int i3 = 0; while (i2 < str.length() && i3 < str2.length() && Character.toLowerCase(str.charAt(i2)) == Character.toLowerCase(str2.charAt(i3))) { i3++; i2++; } if (i3 == str2.length()) { return i; } i++; } return -1; } public static float computePerceivedBrightness(int i) { return (((((float) Color.red(i)) * 0.2126f) + (((float) Color.green(i)) * 0.7152f)) + (((float) Color.blue(i)) * 0.0722f)) / 255.0f; } public static void setLightNavigationBar(Window window, boolean z) { if (Build.VERSION.SDK_INT >= 26) { View decorView = window.getDecorView(); int systemUiVisibility = decorView.getSystemUiVisibility(); decorView.setSystemUiVisibility(z ? systemUiVisibility | 16 : systemUiVisibility & -17); } } public static int getVersionCode(Context context) { try { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return 0; } } public static String getVersionName(Context context) { try { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return ""; } } /* JADX WARNING: Removed duplicated region for block: B:28:0x0033 A[SYNTHETIC, Splitter:B:28:0x0033] */ /* JADX WARNING: Removed duplicated region for block: B:35:0x003b A[SYNTHETIC, Splitter:B:35:0x003b] */ public static byte[] getBlock(long j, File file, int i) { Throwable th; IOException e; RandomAccessFile randomAccessFile; byte[] bArr = new byte[i]; RandomAccessFile randomAccessFile2 = null; try { randomAccessFile = new RandomAccessFile(file, "r"); try { randomAccessFile.seek(j); int read = randomAccessFile.read(bArr); if (read == -1) { try { randomAccessFile.close(); } catch (IOException unused) { } return null; } else if (read == i) { try { randomAccessFile.close(); } catch (IOException unused2) { } return bArr; } else { byte[] bArr2 = new byte[read]; System.arraycopy(bArr, 0, bArr2, 0, read); try { randomAccessFile.close(); } catch (IOException unused3) { } return bArr2; } } catch (IOException e2) { e = e2; try { e.printStackTrace(); if (randomAccessFile != null) { try { randomAccessFile.close(); } catch (IOException unused4) { } } return null; } catch (Throwable th2) { th = th2; randomAccessFile2 = randomAccessFile; if (randomAccessFile2 != null) { try { randomAccessFile2.close(); } catch (IOException unused5) { } } throw th; } } } catch (IOException e3) { e = e3; randomAccessFile = null; e.printStackTrace(); if (randomAccessFile != null) { } return null; } catch (Throwable th3) { th = th3; if (randomAccessFile2 != null) { } throw th; } } public static String getFileMD5(File file) { if (!file.isFile()) { return null; } byte[] bArr = new byte[1024]; try { MessageDigest instance = MessageDigest.getInstance("MD5"); FileInputStream fileInputStream = new FileInputStream(file); while (true) { int read = fileInputStream.read(bArr, 0, 1024); if (read != -1) { instance.update(bArr, 0, read); } else { fileInputStream.close(); return byteArrayToHex(instance.digest()); } } } catch (Exception e) { e.printStackTrace(); return null; } } public static String byteArrayToHex(byte[] bArr) { char[] cArr = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; char[] cArr2 = new char[(bArr.length * 2)]; int i = 0; for (byte b : bArr) { int i2 = i + 1; cArr2[i] = cArr[(b >>> 4) & 15]; i = i2 + 1; cArr2[i2] = cArr[b & 15]; } return new String(cArr2); } public static boolean checkHasExitsUserOrDeletedEverAndShowDialog(BaseFragment baseFragment, String str) { if (str == null) { return false; } for (int i = 0; i < 3; i++) { UserConfig instance = UserConfig.getInstance(i); if (UserObject.isDeleted(instance.getCurrentUser())) { AlertsCreator.showSimpleAlert(baseFragment, LocaleController.getString("ReminderDeletedEverPleaseUseOtherAccount", R.string.ReminderDeletedEverPleaseUseOtherAccount)); return true; } else if (PhoneNumberUtils.compare(str, instance.getCurrentUser().phone)) { if (i == UserConfig.selectedAccount) { AlertsCreator.showSimpleAlert(baseFragment, LocaleController.getString("AccountAlreadyLoggedIn", R.string.AccountAlreadyLoggedIn)); } else { AlertsCreator.showSimpleAlert(baseFragment, LocaleController.getString("ReminderAccountHadExitsAndSwitchAccount", R.string.ReminderAccountHadExitsAndSwitchAccount)); } return true; } } return false; } public static boolean checkCamera(Context context) { String[] strArr = new String[0]; try { strArr = ((CameraManager) context.getSystemService("camera")).getCameraIdList(); } catch (Exception e) { e.printStackTrace(); } if (strArr != null && strArr.length > 0) { String str = strArr[0]; if (strArr[1] != null) { return true; } } return false; } public static boolean isAppOnForeground(Context context) { ActivityManager activityManager = (ActivityManager) context.getApplicationContext().getSystemService("activity"); String packageName = context.getApplicationContext().getPackageName(); List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = activityManager != null ? activityManager.getRunningAppProcesses() : null; if (runningAppProcesses == null) { return false; } for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : runningAppProcesses) { if (runningAppProcessInfo.processName.equals(packageName) && runningAppProcessInfo.importance == 100) { return true; } } return false; } public static int getSystemVersion() { return Integer.parseInt(Build.VERSION.RELEASE); } public static void handleKeyboardShelterProblem(EditText editText) { handleKeyboardShelterProblem(editText, false); } public static void handleKeyboardShelterProblem(EditText editText, boolean z) { if (editText != null && isEMUI() && Build.VERSION.SDK_INT >= 27) { int inputType = editText.getInputType() & 4095; boolean z2 = false; boolean z3 = inputType == 129; boolean z4 = inputType == 225; if (inputType == 18) { z2 = true; } if (z3) { editText.setInputType(1); } else if (z4) { editText.setInputType(1); } else if (z2) { editText.setInputType(2); } if (z3 || z4 || z2) { editText.setTransformationMethod(PasswordTransformationMethod.getInstance()); } } } public static boolean isMIUI() { return "xiaomi".equalsIgnoreCase(Build.MANUFACTURER); } public static boolean isEMUI() { return "HUAWEI".equalsIgnoreCase(Build.MANUFACTURER); } public static boolean isOPPO() { return "OPPO".equalsIgnoreCase(Build.MANUFACTURER); } public static boolean isVIVO() { return "vivo".equalsIgnoreCase(Build.MANUFACTURER); } public static boolean containsEmoji(CharSequence charSequence) { int length = charSequence.length(); for (int i = 0; i < length; i++) { if (!isEmojiCharacter(charSequence.charAt(i))) { return true; } } return false; } public static boolean isScreenOriatationPortrait(Context context) { return context.getResources().getConfiguration().orientation == 1; } public static Bitmap blurBitmap(Context context, Bitmap bitmap) { Bitmap createBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); RenderScript create = RenderScript.create(context); ScriptIntrinsicBlur create2 = ScriptIntrinsicBlur.create(create, Element.U8_4(create)); Allocation createFromBitmap = Allocation.createFromBitmap(create, bitmap); Allocation createFromBitmap2 = Allocation.createFromBitmap(create, createBitmap); create2.setRadius(15.0f); create2.setInput(createFromBitmap); create2.forEach(createFromBitmap2); createFromBitmap2.copyTo(createBitmap); create.destroy(); return createBitmap; } }