web移动端项目 v2.0版本的 MD5 值为:d6e917484f74532fa46bea60e2f4f1ad
以下内容为反编译后的 PdrUtil.java 源代码,内容仅作参考
package io.dcloud.common.util;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.Display;
import android.view.KeyCharacterMap;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.MimeTypeMap;
import android.webkit.URLUtil;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.webkit.ProxyConfig;
import com.alipay.sdk.m.l.c;
import com.alipay.sdk.m.u.i;
import com.dcloud.android.widget.toast.ToastCompat;
import com.nostra13.dcloudimageloader.core.download.ImageDownloader;
import io.dcloud.base.R;
import io.dcloud.common.DHInterface.IApp;
import io.dcloud.common.DHInterface.IWebview;
import io.dcloud.common.adapter.io.DHFile;
import io.dcloud.common.adapter.util.DeviceInfo;
import io.dcloud.common.adapter.util.Logger;
import io.dcloud.common.adapter.util.MobilePhoneModel;
import io.dcloud.common.adapter.util.PlatformUtil;
import io.dcloud.common.constant.AbsoluteConst;
import io.dcloud.common.util.XmlUtil;
import io.dcloud.common.util.language.LanguageUtil;
import io.dcloud.e.c.b;
import io.dcloud.f.a;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.lingala.zip4j.util.InternalZipConstants;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class PdrUtil {
public static final String FILE_PATH_ENTRY_BACK = "..";
public static final String FILE_PATH_ENTRY_SEPARATOR2 = "%";
private static final String NAVIGATION = "navigationBarBackground";
private static volatile boolean mHasCheckAllScreen;
private static volatile boolean mIsAllScreenDevice;
public static void alert(Activity activity, String str, Bitmap bitmap) {
final AlertDialog create = new AlertDialog.Builder(activity).create();
LinearLayout linearLayout = new LinearLayout(activity);
linearLayout.setOrientation(1);
linearLayout.setGravity(17);
TextView textView = new TextView(activity);
textView.setText(str);
linearLayout.addView(textView);
ImageView imageView = new ImageView(activity);
imageView.setBackgroundDrawable(new BitmapDrawable(bitmap));
linearLayout.addView(imageView, new ViewGroup.LayoutParams(-2, -2));
create.setView(linearLayout);
create.setCanceledOnTouchOutside(false);
create.setButton(activity.getString(R.string.dcloud_common_ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
create.dismiss();
}
});
create.show();
}
public static String appendByDeviceRootDir(String str) {
if (str == null || str.startsWith(DeviceInfo.sDeviceRootDir)) {
return str;
}
if (str.startsWith(DeviceInfo.FILE_PROTOCOL)) {
str = str.substring(7);
}
if (str.indexOf("sdcard/") > -1) {
str = str.substring(str.indexOf("sdcard/") + 7);
}
if (!str.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
str = str + InternalZipConstants.ZIP_FILE_SEPARATOR;
}
return DeviceInfo.sDeviceRootDir + InternalZipConstants.ZIP_FILE_SEPARATOR + str;
}
public static boolean checkAlphaTransparent(int i) {
return (i == -1 || (i >>> 24) == 255) ? false : true;
}
public static boolean checkIntl() {
return PlatformUtil.checkClass("io.dcloud.common.DHInterface.IntlCallback");
}
public static boolean checkStatusbarColor(int i) {
String str = Build.BRAND;
if (str.equals(MobilePhoneModel.GOOGLE)) {
str = Build.MANUFACTURER;
}
if ((Build.VERSION.SDK_INT >= 23 || str.equalsIgnoreCase(MobilePhoneModel.XIAOMI) || str.equalsIgnoreCase(MobilePhoneModel.MEIZU)) && !str.equalsIgnoreCase(MobilePhoneModel.DUOWEI)) {
return true;
}
int i2 = (i >> 16) & 255;
int i3 = (i >> 8) & 255;
int i4 = i & 255;
if (i2 >= 30 || i3 >= 30 || i4 >= 30) {
return i2 <= 235 || i3 <= 235 || i4 <= 235;
}
return false;
}
public static void closeAndroidPDialog() {
if (Build.VERSION.SDK_INT < 28) {
return;
}
try {
PlatformUtil.invokeSetFieldValue(PlatformUtil.invokeMethod(Base64.decode2String("YW5kcm9pZC5hcHAuQWN0aXZpdHlUaHJlYWQ="), "currentActivityThread"), "mHiddenApiWarningShown", Boolean.TRUE);
} catch (Exception e) {
Logger.e("PdrUtil", "closeAndroidPDialog--" + e.getMessage());
}
}
public static String convertAppPath(IWebview iWebview, String str) {
IApp obtainApp = iWebview.obtainApp();
if (!isNetPath(str) && !str.startsWith("file:") && !str.contains("/storage") && obtainApp.obtainRunningAppMode() == 1) {
String convert2AbsFullPath = iWebview.obtainApp().convert2AbsFullPath(iWebview.obtainFullUrl(), str);
if (convert2AbsFullPath.startsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
convert2AbsFullPath = convert2AbsFullPath.substring(1, convert2AbsFullPath.length());
}
if (convert2AbsFullPath.contains("android_asset/")) {
convert2AbsFullPath = convert2AbsFullPath.replace("android_asset/", "");
}
return ImageDownloader.Scheme.ASSETS.wrap(convert2AbsFullPath);
}
return obtainApp.convert2WebviewFullPath(iWebview.obtainFullUrl(), str);
}
public static int convertToScreenInt(String str, int i, int i2, float f) {
return convertToScreenInt(str, i, i2, f, false);
}
public static String dealString(String str) throws UnsupportedEncodingException {
byte[] bytes = str.getBytes("GBK");
for (int i = 0; i < bytes.length; i++) {
bytes[i] = (byte) (bytes[i] ^ 8);
}
return new String(bytes, "GBK");
}
public static float dpiFromPx(int i, DisplayMetrics displayMetrics) {
return i / (displayMetrics.densityDpi / 160.0f);
}
public static String encodeURL(String str) {
if (TextUtils.isEmpty(str)) {
return null;
}
try {
return URLEncoder.encode(str, "utf-8");
} catch (UnsupportedEncodingException unused) {
Logger.e("URLEncode error str=" + str);
return URLEncoder.encode(str);
}
}
public static boolean getAdEnv(Context context) {
return !LanguageUtil.getDeviceDefCountry().equalsIgnoreCase(b.c().decryptStr("GJ", (byte) 4));
}
public static JSONObject getConfigData(Context context, String str, String str2, boolean z) {
InputStream inputStream;
try {
if (z) {
inputStream = PlatformUtil.getResInputStream(str2);
} else {
inputStream = DHFile.getInputStream(DHFile.createFileHandler(str2));
}
if (inputStream != null) {
byte[] bytes = IOUtil.getBytes(inputStream);
String a = a.a(context, bytes);
if (TextUtils.isEmpty(a)) {
a = new String(bytes);
}
return new JSONObject(a);
}
return null;
} catch (Exception unused) {
return null;
}
}
public static int getConfigOrientation(JSONObject jSONObject) throws JSONException {
if (jSONObject == null || !jSONObject.has("screenOrientation")) {
return 2;
}
JSONArray optJSONArray = jSONObject.optJSONArray("screenOrientation");
boolean z = false;
boolean z2 = false;
boolean z3 = false;
boolean z4 = false;
for (int i = 0; i < optJSONArray.length(); i++) {
String string = optJSONArray.getString(i);
string.hashCode();
string.hashCode();
char c = 65535;
switch (string.hashCode()) {
case -1228021296:
if (string.equals("portrait-primary")) {
c = 0;
break;
}
break;
case -147105566:
if (string.equals("landscape-secondary")) {
c = 1;
break;
}
break;
case 1862465776:
if (string.equals("landscape-primary")) {
c = 2;
break;
}
break;
case 2012187074:
if (string.equals("portrait-secondary")) {
c = 3;
break;
}
break;
}
switch (c) {
case 0:
z3 = true;
break;
case 1:
z2 = true;
break;
case 2:
z = true;
break;
case 3:
z4 = true;
break;
}
}
if ((z || z2) && (z3 || z4)) {
return 2;
}
if (z && z2) {
return 6;
}
if (z3 && z4) {
return 7;
}
if (z) {
return 0;
}
if (z2) {
return 8;
}
if (z3) {
return 1;
}
return z4 ? 9 : 2;
}
public static String getDefaultPrivateDocPath(String str, String str2) {
if (isEmpty(str)) {
str = AbsoluteConst.MINI_SERVER_APP_DOC + System.currentTimeMillis();
} else if (str.endsWith(InternalZipConstants.ZIP_FILE_SEPARATOR)) {
str = str + System.currentTimeMillis();
}
if (str.endsWith("." + str2)) {
return str;
}
return str + "." + str2;
}
public static String getDownloadFilename(String str, String str2, String str3) {
String[] stringSplit;
String[] stringSplit2;
String str4 = null;
try {
str3 = URLDecoder.decode(str3, "utf-8");
Uri parse = Uri.parse(str3);
if (parse != null) {
String path = parse.getPath();
if (!isEmpty(path)) {
str3 = path;
}
}
if (!isEmpty(str) && (stringSplit = stringSplit(str, i.b)) != null) {
int i = 0;
while (true) {
if (i >= stringSplit.length) {
break;
}
if (stringSplit[i] != null && stringSplit[i].contains(AbsoluteConst.JSON_KEY_FILENAME) && (stringSplit2 = stringSplit(stringSplit[i].trim(), "=")) != null) {
String replace = stringSplit2[0].replace("\"", "");
String replace2 = stringSplit2[1].replace("\"", "");
if (!isEmpty(stringSplit2[1]) && isEquals(AbsoluteConst.JSON_KEY_FILENAME, replace) && !isEmpty(replace2)) {
str4 = replace2;
break;
}
}
i++;
}
}
} catch (Exception unused) {
Logger.d("PdrUtil.getDownloadFilename " + str + " not found filename");
}
if (isEmpty(str4)) {
int lastIndexOf = str3.lastIndexOf(47);
if (lastIndexOf > 0 && lastIndexOf < str3.length() - 1) {
str4 = str3.substring(lastIndexOf + 1);
int indexOf = str4.indexOf("?");
if (indexOf > 0) {
if (indexOf < str4.length() - 1) {
str4 = str4.substring(0, indexOf);
} else {
str4 = String.valueOf(System.currentTimeMillis());
}
}
} else {
str4 = String.valueOf(System.currentTimeMillis());
}
}
if (str4.indexOf(".") < 0) {
String extensionFromMimeType = getExtensionFromMimeType(str2);
if (!isEmpty(extensionFromMimeType)) {
str4 = str4 + "." + extensionFromMimeType;
}
}
try {
String replaceAll = URLDecoder.decode(str4, "UTF-8").replaceAll(File.separator, "");
if (replaceAll.contains("?")) {
replaceAll = replaceAll.replaceAll("\\?", "0");
}
if (replaceAll.length() > 80) {
return replaceAll.substring(0, 80) + System.currentTimeMillis();
}
return replaceAll;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return str4;
}
}
public static String getExtensionFromMimeType(String str) {
return MimeTypeMap.getSingleton().getExtensionFromMimeType(str);
}
public static String getFileNameByUrl(String str, String str2, String str3) {
if (TextUtils.isEmpty(str2)) {
Matcher matcher = Pattern.compile("[\\w\\.]+[\\.](avi|mpeg|3gp|mp3|mp4|wav|jpeg|gif|jpg|png|apk|exe|pdf|rar|zip|docx|doc)").matcher(str);
if (matcher.find()) {
return matcher.group();
}
if (TextUtils.isEmpty(str3)) {
return String.valueOf(System.currentTimeMillis()) + ".dat";
}
return str3;
}
String lastPathSegment = Uri.parse(str).getLastPathSegment();
if (lastPathSegment == null || !lastPathSegment.contains(str2)) {
if (TextUtils.isEmpty(str3)) {
return String.valueOf(System.currentTimeMillis()) + str2;
}
return str3;
}
return lastPathSegment;
}
public static Object getKeyByIndex(HashMap hashMap, int i) {
if (i < 0) {
return null;
}
int i2 = 0;
for (Object obj : hashMap.keySet()) {
if (i == i2) {
return obj;
}
i2++;
}
return null;
}
public static Object getKeyByValue(HashMap hashMap, Object obj, boolean z) {
if (!z || hashMap.containsValue(obj)) {
for (Object obj2 : hashMap.keySet()) {
Object obj3 = hashMap.get(obj2);
if (obj3 != null && obj3.equals(obj)) {
return obj2;
}
}
return null;
}
return null;
}
public static String getMimeType(String str) {
MimeTypeMap singleton = MimeTypeMap.getSingleton();
String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
if (isEmpty(fileExtensionFromUrl) && str.lastIndexOf(".") >= 0) {
fileExtensionFromUrl = str.substring(str.lastIndexOf(".") + 1);
}
String mimeTypeFromExtension = singleton.getMimeTypeFromExtension(fileExtensionFromUrl);
if (TextUtils.isEmpty(mimeTypeFromExtension)) {
if (TextUtils.isEmpty(fileExtensionFromUrl)) {
return "*/*";
}
return "application/" + fileExtensionFromUrl;
}
return mimeTypeFromExtension;
}
private static String getNavBarOverride() {
if (Build.VERSION.SDK_INT >= 19) {
try {
Method declaredMethod = Class.forName("android.os.SystemProperties").getDeclaredMethod("get", String.class);
declaredMethod.setAccessible(true);
return (String) declaredMethod.invoke(null, "qemu.hw.mainkeys");
} catch (Throwable unused) {
return null;
}
}
return null;
}
public static int getNavigationBarHeight(Context context) {
Resources resources;
int identifier;
if (!hasNavBar(context) || (identifier = (resources = context.getResources()).getIdentifier("navigation_bar_height", "dimen", "android")) <= 0) {
return 0;
}
return resources.getDimensionPixelSize(identifier);
}
public static String getNonString(String str, String str2) {
return isEmpty(str) ? str2 : str;
}
public static Object getObject(Object[] objArr, int i) {
try {
return objArr[i];
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static JSONObject getSitemapParameters(JSONObject jSONObject, String str, String str2) {
String optString;
String str3;
JSONArray optJSONArray;
String str4;
JSONArray jSONArray;
String str5;
String ref;
JSONArray jSONArray2;
String sb;
JSONObject optJSONObject;
JSONObject optJSONObject2;
JSONObject optJSONObject3;
String str6 = str2;
String str7 = "port";
String str8 = "matchUrls";
String str9 = "webviewId";
try {
JSONArray optJSONArray2 = jSONObject.optJSONArray("pages");
String optString2 = jSONObject.optString(IApp.ConfigProperty.CONFIG_LAUNCH_PATH);
int i = 0;
while (i < optJSONArray2.length()) {
JSONObject optJSONObject4 = optJSONArray2.optJSONObject(i);
int i2 = i;
if (optJSONObject4.has(str9)) {
optString = optJSONObject4.optString(str9);
} else {
optString = optJSONObject4.optString("webviewid");
}
String str10 = str9;
String str11 = optString;
if (optJSONObject4.has(str8)) {
str3 = str8;
optJSONArray = optJSONObject4.optJSONArray(str8);
} else {
str3 = str8;
optJSONArray = optJSONObject4.optJSONArray("matchurls");
}
JSONArray jSONArray3 = optJSONArray2;
int i3 = 0;
boolean z = false;
while (i3 < optJSONArray.length()) {
Object opt = optJSONArray.opt(i3);
JSONArray jSONArray4 = optJSONArray;
if (opt instanceof String) {
z = match((String) opt, str6);
} else if (opt instanceof JSONObject) {
JSONObject jSONObject2 = (JSONObject) opt;
URL url = new URL(str6);
Iterator<String> keys = jSONObject2.keys();
while (keys.hasNext()) {
String next = keys.next();
if ("protocol".equals(next)) {
jSONArray = jSONObject2.optJSONArray("protocol");
ref = url.getProtocol();
} else if ("hostname".equals(next)) {
jSONArray = jSONObject2.optJSONArray("hostname");
ref = url.getHost();
} else {
if (str7.equals(next)) {
jSONArray2 = jSONObject2.optJSONArray(str7);
StringBuilder sb2 = new StringBuilder();
str4 = str7;
sb2.append("");
sb2.append(url.getPort());
sb = sb2.toString();
} else {
str4 = str7;
if (c.f.equals(next)) {
JSONArray optJSONArray3 = jSONObject2.optJSONArray(c.f);
StringBuilder sb3 = new StringBuilder();
jSONArray2 = optJSONArray3;
sb3.append(url.getHost());
sb3.append(":");
sb3.append(url.getPort());
sb = sb3.toString();
} else {
if ("pathname".equals(next)) {
jSONArray = jSONObject2.optJSONArray("pathname");
ref = url.getPath();
} else if (AbsoluteConst.EVENTS_SEARCH.equals(next)) {
jSONArray = jSONObject2.optJSONArray(AbsoluteConst.EVENTS_SEARCH);
ref = url.getQuery();
} else if ("hash".equals(next)) {
jSONArray = jSONObject2.optJSONArray("hash");
ref = url.getRef();
} else {
if ("href".equals(next)) {
jSONArray = jSONObject2.optJSONArray("href");
str5 = str2;
} else {
jSONArray = null;
str5 = null;
}
if (jSONArray == null && str5 != null && !(z = matchArray(jSONArray, str5))) {
break;
}
str7 = str4;
}
str5 = ref;
if (jSONArray == null) {
}
str7 = str4;
}
}
JSONArray jSONArray5 = jSONArray2;
ref = sb;
jSONArray = jSONArray5;
str5 = ref;
if (jSONArray == null) {
}
str7 = str4;
}
str4 = str7;
str5 = ref;
if (jSONArray == null) {
}
str7 = str4;
}
}
str4 = str7;
if (z) {
if (optJSONObject4.has("webviewParameter")) {
optJSONObject = optJSONObject4.optJSONObject("webviewParameter");
} else {
optJSONObject = optJSONObject4.optJSONObject("__html5plusWebviewParameter ");
}
if (optJSONObject == null) {
optJSONObject = new JSONObject();
}
JSONObject jSONObject3 = optJSONObject;
jSONObject3.put(IApp.ConfigProperty.CONFIG_LAUNCH_PATH, optString2);
jSONObject3.put("webviewid", str11);
jSONObject3.put("appid", str);
try {
if (jSONObject.has("global") && (optJSONObject2 = jSONObject.optJSONObject("global")) != null) {
if (optJSONObject2.has("webviewParameter")) {
optJSONObject3 = optJSONObject2.optJSONObject("webviewParameter");
} else {
optJSONObject3 = optJSONObject2.optJSONObject("__html5plusWebviewParameter ");
}
if (optJSONObject3 != null) {
jSONObject3 = JSONUtil.combinSitemapHtmlJSONObject(new JSONObject(optJSONObject3.toString()), jSONObject3);
}
if (!jSONObject3.has(AbsoluteConst.JSONKEY_STATUSBAR) && optJSONObject2.has(AbsoluteConst.JSONKEY_STATUSBAR) && !optJSONObject2.isNull(AbsoluteConst.JSONKEY_STATUSBAR)) {
jSONObject3.put(AbsoluteConst.JSONKEY_STATUSBAR, new JSONObject(optJSONObject2.optJSONObject(AbsoluteConst.JSONKEY_STATUSBAR).toString()));
}
}
if (!jSONObject3.has(AbsoluteConst.JSONKEY_STATUSBAR) && jSONObject.has(AbsoluteConst.JSONKEY_STATUSBAR) && !jSONObject.isNull(AbsoluteConst.JSONKEY_STATUSBAR)) {
jSONObject3.put(AbsoluteConst.JSONKEY_STATUSBAR, new JSONObject(jSONObject.optJSONObject(AbsoluteConst.JSONKEY_STATUSBAR).toString()));
}
} catch (Exception e) {
e.printStackTrace();
}
return jSONObject3;
}
i3++;
optJSONArray = jSONArray4;
str7 = str4;
str6 = str2;
}
i = i2 + 1;
str8 = str3;
str9 = str10;
optJSONArray2 = jSONArray3;
str6 = str2;
}
return null;
} catch (Exception e2) {
Logger.e("PdrUtil", "getSitemapParameters e==" + e2.getMessage());
return null;
}
}
public static String getUrlPathName(String str) {
return str != null ? URLUtil.stripAnchor(stripQuery(str)) : str;
}
public static boolean hasNavBar(Context context) {
Resources resources = context.getResources();
int identifier = resources.getIdentifier("config_showNavigationBar", "bool", "android");
if (identifier != 0) {
boolean z = resources.getBoolean(identifier);
String navBarOverride = getNavBarOverride();
if ("1".equals(navBarOverride)) {
return false;
}
if ("0".equals(navBarOverride)) {
return true;
}
return z;
}
return !ViewConfiguration.get(context).hasPermanentMenuKey();
}
public static String int2DecimalStr(int i, int i2) {
return String.valueOf(BigDecimal.valueOf(i).divide(BigDecimal.valueOf(i2)));
}
public static boolean isAllScreenDevice(Activity activity) {
float f;
float f2;
if (mHasCheckAllScreen) {
return mIsAllScreenDevice;
}
mHasCheckAllScreen = true;
mIsAllScreenDevice = false;
int i = Build.VERSION.SDK_INT;
if (i < 21) {
return false;
}
if (i >= 28 && activity.getWindow().getDecorView().getRootWindowInsets() != null && activity.getWindow().getDecorView().getRootWindowInsets().getDisplayCutout() != null) {
mIsAllScreenDevice = true;
return mIsAllScreenDevice;
}
WindowManager windowManager = (WindowManager) activity.getSystemService("window");
if (windowManager != null) {
Display defaultDisplay = windowManager.getDefaultDisplay();
Point point = new Point();
defaultDisplay.getRealSize(point);
int i2 = point.x;
int i3 = point.y;
if (i2 < i3) {
f2 = i2;
f = i3;
} else {
float f3 = i3;
f = i2;
f2 = f3;
}
if (f / f2 >= 1.97f) {
mIsAllScreenDevice = true;
}
}
return mIsAllScreenDevice;
}
public static boolean isBase64ImagePath(String str) {
return !TextUtils.isEmpty(str) && str.startsWith("data:image");
}
public static boolean isContains(String str, String str2) {
if (isEmpty(str) || isEmpty(str2)) {
return false;
}
return str.contains(str2);
}
public static boolean isDeviceRootDir(String str) {
try {
if (!str.startsWith(DeviceInfo.sDeviceRootDir) && !str.startsWith(DeviceInfo.sCacheRootDir) && !str.startsWith("/sdcard/") && !str.startsWith(DeviceInfo.sDeviceRootDir.substring(1))) {
if (!str.startsWith("sdcard/")) {
return false;
}
}
return true;
} catch (Exception unused) {
return false;
}
}
public static boolean isEmpty(Object obj) {
return obj == null || obj.equals("") || (obj.toString().length() == 4 && obj.toString().toLowerCase(Locale.ENGLISH).equals("null"));
}
public static boolean isEquals(String str, String str2) {
if (str == null || str2 == null) {
return false;
}
return str.equalsIgnoreCase(str2);
}
public static boolean isFilePath(String str) {
return !TextUtils.isEmpty(str) && str.startsWith("file:/");
}
public static boolean isFullScreen(Activity activity) {
return (activity.getWindow().getAttributes().flags & 1024) == 1024;
}
public static boolean isLightColor(int i) {
double red = Color.red(i);
Double.isNaN(red);
double green = Color.green(i);
Double.isNaN(green);
double d = (red * 0.299d) + (green * 0.587d);
double blue = Color.blue(i);
Double.isNaN(blue);
return ((int) (d + (blue * 0.114d))) >= 192;
}
public static boolean isNavigationBarExist(Activity activity) {
ViewGroup viewGroup = (ViewGroup) activity.getWindow().getDecorView();
if (viewGroup != null) {
for (int i = 0; i < viewGroup.getChildCount(); i++) {
viewGroup.getChildAt(i).getContext().getPackageName();
try {
if (viewGroup.getChildAt(i).getId() != -1 && NAVIGATION.equals(activity.getResources().getResourceEntryName(viewGroup.getChildAt(i).getId())) && viewGroup.getChildAt(i).getVisibility() == 0) {
return true;
}
} catch (Exception unused) {
}
}
}
return false;
}
public static boolean isNavigationBarShow(Activity activity) {
if (Build.VERSION.SDK_INT < 17) {
return (ViewConfiguration.get(activity).hasPermanentMenuKey() || KeyCharacterMap.deviceHasKey(4)) ? false : true;
}
Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
Point point = new Point();
Point point2 = new Point();
defaultDisplay.getSize(point);
defaultDisplay.getRealSize(point2);
return point2.y != point.y;
}
public static boolean isNavigationBarShowing(Context context) {
String str;
if (!hasNavBar(context) || Build.VERSION.SDK_INT < 17) {
return false;
}
String str2 = Build.BRAND;
if (!str2.equalsIgnoreCase("HUAWEI")) {
if (str2.equalsIgnoreCase("XIAOMI")) {
str = "force_fsg_nav_bar";
} else if (str2.equalsIgnoreCase("VIVO") || str2.equalsIgnoreCase("OPPO")) {
str = "navigation_gesture_on";
}
return Settings.Global.getInt(context.getContentResolver(), str, 0) != 0;
}
str = "navigationbar_is_min";
if (Settings.Global.getInt(context.getContentResolver(), str, 0) != 0) {
}
}
public static boolean isNetPath(String str) {
return str != null && ((str.startsWith(DeviceInfo.HTTP_PROTOCOL) && !str.startsWith("http://localhost")) || ((str.startsWith(DeviceInfo.HTTPS_PROTOCOL) && !str.startsWith("https://localhost")) || ((str.startsWith("rtmp://") && !str.startsWith("rtmp://localhost")) || (str.startsWith("rtsp://") && !str.startsWith("rtsp://localhost")))));
}
public static boolean isSafeEntryName(String str) {
return (str.contains(FILE_PATH_ENTRY_BACK) || str.contains(FILE_PATH_ENTRY_SEPARATOR2)) ? false : true;
}
public static boolean isSameDay(long j, long j2) {
GregorianCalendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTimeInMillis(j);
GregorianCalendar gregorianCalendar2 = new GregorianCalendar();
gregorianCalendar2.setTimeInMillis(j2);
return gregorianCalendar.get(1) == gregorianCalendar2.get(1) && gregorianCalendar.get(2) == gregorianCalendar2.get(2) && gregorianCalendar.get(5) == gregorianCalendar2.get(5);
}
public static boolean isSupportOaid() {
String str = Build.BRAND;
int i = Build.VERSION.SDK_INT;
if ((str.equalsIgnoreCase("honor") || str.equalsIgnoreCase("huawei")) && i >= 23) {
return true;
}
if (!str.equalsIgnoreCase("vivo") || i < 28) {
return (str.equalsIgnoreCase("xiaomi") && i >= 28) || i >= 29;
}
return true;
}
public static boolean isUniMPHostForUniApp() {
return PlatformUtil.checkClass("io.dcloud.feature.sdk.Interface.DCUniAppHost");
}
private static void loadProperties2HashMap(HashMap<String, String> hashMap, String str) {
InputStream resInputStream = PlatformUtil.getResInputStream(str);
Properties properties = new Properties();
try {
try {
properties.load(resInputStream);
Enumeration<?> propertyNames = properties.propertyNames();
if (propertyNames != null) {
while (propertyNames.hasMoreElements()) {
String str2 = (String) propertyNames.nextElement();
hashMap.put(str2.toLowerCase(Locale.ENGLISH), (String) properties.get(str2));
}
}
} catch (IOException e) {
e.printStackTrace();
}
} finally {
IOUtil.close(resInputStream);
}
}
public static String makeQueryStringAllRegExp(String str) {
return TextUtils.isEmpty(str) ? str : str.replace("\\", "\\\\").replace(ProxyConfig.MATCH_ALL_SCHEMES, "\\*").replace("+", "\\+").replace("|", "\\|").replace("{", "\\{").replace(i.d, "\\}").replace("(", "\\(").replace(")", "\\)").replace("^", "\\^").replace("$", "\\$").replace("[", "\\[").replace("]", "\\]").replace("?", "\\?").replace(JSUtil.COMMA, "\\,").replace(".", "\\.").replace(com.alipay.sdk.m.s.a.n, "\\&").replace("'", "\\'");
}
private static boolean match(String str, String str2) {
return Pattern.compile(str).matcher(str2).find();
}
private static boolean matchArray(JSONArray jSONArray, String str) {
if (jSONArray != null) {
for (int i = 0; i < jSONArray.length(); i++) {
if (match(jSONArray.optString(i), str)) {
return true;
}
}
}
return false;
}
public static boolean navigationGestureEnabled(Context context) {
int i;
if (DeviceInfo.sBrand.toLowerCase(Locale.ENGLISH).equals("xiaomi")) {
i = Build.VERSION.SDK_INT >= 26 ? Settings.Global.getInt(context.getContentResolver(), "force_fsg_nav_bar", 0) : 0;
} else {
i = Settings.Secure.getInt(context.getContentResolver(), "navigation_gesture_on", 0);
}
return i != 0;
}
public static boolean parseBoolean(String str, boolean z, boolean z2) {
return isEmpty(str) ? z : str.equalsIgnoreCase(AbsoluteConst.TRUE) ? (!z2) & true : str.equalsIgnoreCase(AbsoluteConst.FALSE) ? z2 | false : z;
}
public static float parseFloat(String str, float f) {
if (str == null) {
return f;
}
try {
return Float.parseFloat(str);
} catch (Exception unused) {
return f;
}
}
public static int parseInt(String str, int i) {
if (str == null) {
return i;
}
try {
return Integer.parseInt(str);
} catch (Exception unused) {
return i;
}
}
public static long parseLong(String str, long j) {
try {
return Long.parseLong(str);
} catch (Exception unused) {
return j;
}
}
public static int pxFromDp(float f, DisplayMetrics displayMetrics) {
return Math.round(TypedValue.applyDimension(1, f, displayMetrics));
}
public static int pxFromSp(float f, DisplayMetrics displayMetrics) {
return Math.round(TypedValue.applyDimension(2, f, displayMetrics));
}
public static Bitmap renderCroppedGreyscaleBitmap(byte[] bArr, int i, int i2, int i3, int i4, int i5, int i6) {
int[] iArr = new int[i5 * i6];
int i7 = (i4 * i) + i3;
for (int i8 = 0; i8 < i6; i8++) {
int i9 = i8 * i5;
for (int i10 = 0; i10 < i5; i10++) {
iArr[i9 + i10] = ((bArr[i7 + i10] & IApp.ABS_PRIVATE_WWW_DIR_APP_MODE) * 65793) | (-16777216);
}
i7 += i;
}
Bitmap createBitmap = Bitmap.createBitmap(i5, i6, Bitmap.Config.ARGB_8888);
createBitmap.setPixels(iArr, 0, i5, 0, 0, i5, i6);
return createBitmap;
}
public static boolean saveBitmapToFile(Bitmap bitmap, String str) {
try {
File file = new File(str);
File parentFile = file.getParentFile();
if (!parentFile.exists()) {
parentFile.mkdirs();
}
if (file.exists()) {
file.delete();
}
file.createNewFile();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(file));
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public static String standardizedURL(String str, String str2) {
String stripQuery = stripQuery(stripAnchor(str));
if (str2.startsWith("./")) {
str2 = str2.substring(2);
int lastIndexOf = stripQuery.lastIndexOf(47);
if (lastIndexOf >= 0) {
return stripQuery.substring(0, lastIndexOf + 1) + str2;
}
}
int indexOf = str2.indexOf("../");
int lastIndexOf2 = stripQuery.lastIndexOf(47);
if (lastIndexOf2 > -1) {
String substring = stripQuery.substring(0, lastIndexOf2);
while (indexOf > -1) {
str2 = str2.substring(3);
substring = substring.substring(0, substring.lastIndexOf(47));
indexOf = str2.indexOf("../");
}
return substring + '/' + str2;
}
return str2;
}
public static String[] stringSplit(String str, String str2) {
if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
return null;
}
int i = 0;
StringTokenizer stringTokenizer = new StringTokenizer(str, str2, false);
String[] strArr = new String[stringTokenizer.countTokens()];
while (stringTokenizer.hasMoreElements()) {
strArr[i] = stringTokenizer.nextToken().trim();
i++;
}
return strArr;
}
public static int stringToColor(String str) {
String[] stringSplit;
int i;
int i2;
try {
if (!isEmpty(str)) {
str = str.trim();
}
int length = str.length();
int i3 = 0;
if (length != 4 && length != 7 && length != 3 && length != 6) {
if (str.startsWith("#") && length > 1 && length < 10) {
return Color.parseColor(str);
}
if (str.startsWith("rgba")) {
stringSplit = stringSplit(str.substring(5, str.length() - 1), JSUtil.COMMA);
i = 1;
} else {
stringSplit = str.startsWith("rgb") ? stringSplit(str.substring(4, str.length() - 1), JSUtil.COMMA) : null;
i = 0;
}
int i4 = 255;
if (stringSplit != null) {
try {
try {
try {
if (i == 0) {
i = Integer.parseInt(stringSplit[0]);
i3 = Integer.parseInt(stringSplit[1]);
i2 = Integer.parseInt(stringSplit[2]);
} else {
i = Integer.parseInt(stringSplit[0]);
i3 = Integer.parseInt(stringSplit[1]);
i2 = Integer.parseInt(stringSplit[2]);
try {
i4 = (int) (255 * Float.parseFloat(stringSplit[3]));
} catch (Exception unused) {
}
}
} catch (Exception unused2) {
}
} catch (Exception unused3) {
i2 = 255;
}
} catch (Exception unused4) {
}
return (i4 << 24) + (i << 16) + (i3 << 8) + i2;
}
i = 255;
i2 = 255;
i3 = 255;
return (i4 << 24) + (i << 16) + (i3 << 8) + i2;
}
str = str.substring(1);
if (str.length() == 3) {
StringBuffer stringBuffer = new StringBuffer();
while (i3 < 3) {
stringBuffer.append(str.charAt(i3));
stringBuffer.append(str.charAt(i3));
i3++;
}
str = stringBuffer.toString();
}
return Integer.parseInt(str, 16) - 16777216;
} catch (Exception unused5) {
return -1;
}
}
public static String stripAnchor(String str) {
return URLUtil.stripAnchor(str);
}
public static String stripQuery(String str) {
int indexOf = str.indexOf(63);
return indexOf != -1 ? str.substring(0, indexOf) : str;
}
public static String toHexFromColor(int i) {
StringBuilder sb = new StringBuilder();
String hexString = Integer.toHexString(Color.red(i));
String hexString2 = Integer.toHexString(Color.green(i));
String hexString3 = Integer.toHexString(Color.blue(i));
if (hexString.length() == 1) {
hexString = "0" + hexString;
}
if (hexString2.length() == 1) {
hexString2 = "0" + hexString2;
}
if (hexString3.length() == 1) {
hexString3 = "0" + hexString3;
}
String upperCase = hexString.toUpperCase();
String upperCase2 = hexString2.toUpperCase();
String upperCase3 = hexString3.toUpperCase();
sb.append("#");
sb.append(upperCase);
sb.append(upperCase2);
sb.append(upperCase3);
return sb.toString();
}
public static void toast(Context context, String str, Bitmap bitmap) {
ToastCompat makeText = ToastCompat.makeText(context, (CharSequence) str, 1);
if (bitmap != null) {
int height = bitmap.getHeight();
int width = bitmap.getWidth();
View view = makeText.getView();
ImageView imageView = new ImageView(context);
imageView.setImageBitmap(bitmap);
((ViewGroup) view).addView(imageView, 0);
makeText.setText(str + " w=" + width + ";h=" + height);
}
makeText.setDuration(1);
makeText.show();
}
public static int convertToScreenInt(String str, int i, int i2, float f, boolean z) {
float parseInt;
if (str == null) {
return i2;
}
try {
if (str.endsWith("px")) {
String substring = str.substring(0, str.length() - 2);
if (substring != null && substring.contains(".")) {
parseInt = Float.parseFloat(substring);
} else {
parseInt = Integer.parseInt(substring);
}
float f2 = parseInt * f;
return z ? Math.round(f2) : (int) f2;
} else if (str.endsWith(FILE_PATH_ENTRY_SEPARATOR2)) {
String substring2 = str.substring(0, str.length() - 1);
try {
if (substring2.contains(".")) {
float parseFloat = (i * Float.parseFloat(substring2)) / 100.0f;
return z ? Math.round(parseFloat) : (int) parseFloat;
}
return (i * Integer.parseInt(substring2)) / 100;
} catch (NumberFormatException unused) {
return i2;
}
} else {
double parseDouble = Double.parseDouble(str);
double d = f;
Double.isNaN(d);
double d2 = parseDouble * d;
return z ? (int) Math.round(d2) : (int) d2;
}
} catch (Exception unused2) {
return i2;
}
}
public static float parseFloat(String str, float f, float f2) {
return parseFloat(str, f, f2, 1.0f);
}
public static int parseInt(String str, int i, int i2) {
if (str == null) {
return i2;
}
try {
String lowerCase = str.toLowerCase(Locale.ENGLISH);
if (lowerCase.endsWith("px")) {
return Integer.parseInt(lowerCase.substring(0, lowerCase.length() - 2));
}
if (lowerCase.endsWith(FILE_PATH_ENTRY_SEPARATOR2)) {
String substring = lowerCase.substring(0, lowerCase.length() - 1);
try {
if (substring.contains(".")) {
return (int) ((i * Float.parseFloat(substring)) / 100.0f);
}
return (i * Integer.parseInt(substring)) / 100;
} catch (NumberFormatException unused) {
return i2;
}
}
if (lowerCase.startsWith("#")) {
lowerCase = "0x" + lowerCase.substring(1);
}
if (lowerCase.startsWith("0x")) {
return Integer.valueOf(lowerCase.substring(2), 16).intValue();
}
return Integer.parseInt(lowerCase);
} catch (Exception unused2) {
return i2;
}
}
public static float parseFloat(String str, float f, float f2, float f3) {
if (str == null) {
return f2;
}
String lowerCase = str.toLowerCase(Locale.ENGLISH);
if (lowerCase.endsWith("px")) {
lowerCase = lowerCase.substring(0, lowerCase.length() - 2);
}
try {
return Float.parseFloat(lowerCase) * f3;
} catch (NumberFormatException unused) {
if (lowerCase.endsWith(FILE_PATH_ENTRY_SEPARATOR2)) {
try {
return (f * Float.parseFloat(lowerCase.substring(0, lowerCase.length() - 1))) / 100.0f;
} catch (Exception unused2) {
return f2;
}
}
return f2;
}
}
public static boolean parseBoolean(String str, boolean z) {
return isEmpty(str) ? z : str.equalsIgnoreCase(AbsoluteConst.TRUE);
}
public static Object getKeyByValue(HashMap hashMap, Object obj) {
return getKeyByValue(hashMap, obj, false);
}
public static void loadProperties2HashMap(HashMap<String, String> hashMap, HashMap<String, String> hashMap2, HashMap<String, HashMap<String, String>> hashMap3, String str) {
XmlUtil.DHNode XML_Parser;
InputStream resInputStream = PlatformUtil.getResInputStream(str);
if (resInputStream == null || (XML_Parser = XmlUtil.XML_Parser(resInputStream)) == null) {
return;
}
ArrayList<XmlUtil.DHNode> elements = XmlUtil.getElements(XmlUtil.getElement(XML_Parser, IApp.ConfigProperty.CONFIG_FEATURES), IApp.ConfigProperty.CONFIG_FEATURE);
if (elements != null && !elements.isEmpty()) {
Iterator<XmlUtil.DHNode> it = elements.iterator();
while (it.hasNext()) {
XmlUtil.DHNode next = it.next();
String lowerCase = XmlUtil.getAttributeValue(next, "name").toLowerCase(Locale.ENGLISH);
String attributeValue = XmlUtil.getAttributeValue(next, "value");
if (AbsoluteConst.F_UI.equals(lowerCase)) {
hashMap2.put("webview", attributeValue);
}
hashMap2.put(lowerCase, attributeValue);
ArrayList<XmlUtil.DHNode> elements2 = XmlUtil.getElements(next, IApp.ConfigProperty.CONFIG_MODULE);
if (elements2 != null && !elements2.isEmpty()) {
HashMap<String, String> hashMap4 = hashMap3.get(lowerCase);
if (hashMap4 == null) {
hashMap4 = new LinkedHashMap<>(2);
hashMap3.put(lowerCase, hashMap4);
}
Iterator<XmlUtil.DHNode> it2 = elements2.iterator();
while (it2.hasNext()) {
XmlUtil.DHNode next2 = it2.next();
hashMap4.put(XmlUtil.getAttributeValue(next2, "name").toLowerCase(Locale.ENGLISH), XmlUtil.getAttributeValue(next2, "value"));
}
}
}
}
ArrayList<XmlUtil.DHNode> elements3 = XmlUtil.getElements(XmlUtil.getElement(XML_Parser, IApp.ConfigProperty.CONFIG_SERVICES), "service");
if (elements3 == null || elements3.isEmpty()) {
return;
}
Iterator<XmlUtil.DHNode> it3 = elements3.iterator();
while (it3.hasNext()) {
XmlUtil.DHNode next3 = it3.next();
hashMap.put(XmlUtil.getAttributeValue(next3, "name").toLowerCase(Locale.ENGLISH), XmlUtil.getAttributeValue(next3, "value"));
}
}
}