MD5 校验值:fb6e23fdb724aab8923e2df3c62d34cc
tool.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package ginlemon.iconpackstudio.exported; import android.app.AlertDialog; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.AssetManager; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.media.ExifInterface; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri; import android.os.Build; import android.os.Environment; import android.os.PowerManager; import android.os.SystemClock; import android.text.TextUtils; import android.text.format.DateFormat; import android.util.DisplayMetrics; import android.util.Log; import android.util.Patterns; import android.view.Display; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import androidx.core.view.MotionEventCompat; import androidx.core.view.ViewCompat; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collections; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; public class tool { private static final String TAG = "ginlemon.iconpackstudio.exported.tool"; public static int WHITE = 1; public static boolean appHasAction(Context context, String str, String str2) { return true; } public static int between(int i, int i2, int i3) { return i2 > i3 ? i3 : i2 < i ? i : i2; } public static int changeColorAlpha(float f, int i) { return (((int) (f * 255.0f)) << 24) | (i & ViewCompat.MEASURED_SIZE_MASK); } public static int changeColorAlpha(int i, int i2) { return (i << 24) | (i2 & ViewCompat.MEASURED_SIZE_MASK); } public static boolean isInstalled(Context context, String str) { try { context.getPackageManager().getApplicationInfo(str, 1); return true; } catch (Exception unused) { return false; } } public static AlertDialog.Builder createBuilder(Context context) { if (atLeast(21)) { return new AlertDialog.Builder(context, 5); } return new AlertDialog.Builder(context); } public static Typeface getFontFromFile(Context context, String str) { if (context.getFileStreamPath(str).exists()) { return Typeface.createFromFile(context.getFileStreamPath(str)); } return null; } public void setFont(ViewGroup viewGroup, Typeface typeface) { int childCount = viewGroup.getChildCount(); for (int i = 0; i < childCount; i++) { View childAt = viewGroup.getChildAt(i); if ((childAt instanceof TextView) || (childAt instanceof EditText) || (childAt instanceof Button)) { ((TextView) childAt).setTypeface(typeface); } else if (childAt instanceof ViewGroup) { setFont((ViewGroup) childAt, typeface); } } } public static void deleteFiles(Context context) { for (File file : new File(context.getFilesDir(), "").listFiles()) { file.delete(); } } public static boolean setFont(Context context, String str, AssetManager assetManager, String str2) { if (context == null) { return false; } if (str2 == null) { context.deleteFile(str); return false; } try { InputStream open = assetManager.open(str2); FileOutputStream openFileOutput = context.openFileOutput(str, 0); copyFile(open, openFileOutput); open.close(); openFileOutput.close(); return true; } catch (IOException | NullPointerException e) { Log.e("setFont", "Failed to copy asset file: " + str2 + " key " + str, e.fillInStackTrace()); context.deleteFile(str); return false; } } private static void copyFile(InputStream inputStream, OutputStream outputStream) throws IOException { byte[] bArr = new byte[1024]; while (true) { int read = inputStream.read(bArr); if (read == -1) { return; } else { outputStream.write(bArr, 0, read); } } } public static int getDpi(Context context) { return (int) (context.getResources().getDisplayMetrics().density * 160.0f); } public static final void copyFile(File file, File file2) throws IOException, FileNotFoundException { FileInputStream fileInputStream = new FileInputStream(file); file2.delete(); FileOutputStream fileOutputStream = new FileOutputStream(file2); byte[] bArr = new byte[1024]; while (true) { int read = fileInputStream.read(bArr); if (read > 0) { fileOutputStream.write(bArr, 0, read); } else { fileInputStream.close(); fileOutputStream.close(); Log.d(TAG, "File copied to " + file2.getAbsolutePath()); return; } } } public static Resources getThemeResources(Context context, String str) { try { return context.getPackageManager().getResourcesForApplication(str); } catch (PackageManager.NameNotFoundException unused) { return null; } } public static Drawable getExternalResId(String str, String str2, Context context) { Resources resources; int i = 0; String string = context.getSharedPreferences(context.getPackageName(), 0).getString(str2, context.getPackageName()); try { resources = context.getPackageManager().getResourcesForApplication(string); try { i = resources.getIdentifier(str, "drawable", string); } catch (Exception unused) { } } catch (Exception unused2) { resources = null; } if (i <= 0) { return null; } return resources.getDrawable(i); } public static String getVersion(Context context) { try { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return "unknow"; } } public static int pxToDp(int i) { return (int) (i / Resources.getSystem().getDisplayMetrics().density); } public static int dpToPx(float f) { return (int) (f * Resources.getSystem().getDisplayMetrics().density); } public static int getScreenWidthPixel(Context context) { return context.getResources().getDisplayMetrics().widthPixels; } public static int getScreenHeightPixel(Context context) { return context.getResources().getDisplayMetrics().heightPixels; } public static Bitmap readBitmapFromFile(Context context, String str) { return readBitmapFromFile(new File(context.getFilesDir(), str)); } public static Bitmap readBitmapFromFile(File file) { try { FileInputStream fileInputStream = new FileInputStream(file); Bitmap decodeStream = BitmapFactory.decodeStream(fileInputStream); fileInputStream.close(); return decodeStream; } catch (Exception unused) { Log.e(TAG, "readBitmapFromFile: " + file.getName() + " not found"); return null; } } public static int calculateInSampleSize(BitmapFactory.Options options, int i, int i2) { int i3 = options.outHeight; int i4 = options.outWidth; int i5 = 1; if (i3 > i2 || i4 > i) { int i6 = i3 / 2; int i7 = i4 / 2; while (i6 / i5 > i2 && i7 / i5 > i) { i5 *= 2; } } return i5; } public static Bitmap decodeSampledBitmapFromResource(Resources resources, int i, int i2, int i3) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(resources, i, options); options.inSampleSize = calculateInSampleSize(options, i2, i3); options.inJustDecodeBounds = false; return BitmapFactory.decodeResource(resources, i, options); } public static boolean writeBitmapToFile(Context context, String str, Bitmap bitmap) { BufferedOutputStream bufferedOutputStream; BufferedOutputStream bufferedOutputStream2 = null; try { try { File file = new File(context.getFilesDir(), str); file.getParentFile().mkdirs(); bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file)); } catch (Throwable th) { th = th; } } catch (Exception unused) { } try { bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bufferedOutputStream); try { bufferedOutputStream.flush(); bufferedOutputStream.close(); } catch (IOException e) { e.printStackTrace(); } return true; } catch (Exception unused2) { bufferedOutputStream2 = bufferedOutputStream; Log.e(TAG, "writeBitmapToFile: Error"); if (bufferedOutputStream2 != null) { try { bufferedOutputStream2.flush(); bufferedOutputStream2.close(); } catch (IOException e2) { e2.printStackTrace(); } } return false; } catch (Throwable th2) { th = th2; bufferedOutputStream2 = bufferedOutputStream; if (bufferedOutputStream2 != null) { try { bufferedOutputStream2.flush(); bufferedOutputStream2.close(); } catch (IOException e3) { e3.printStackTrace(); } } throw th; } } public static boolean writeBitmapToPNGFile(Context context, String str, Bitmap bitmap) { return writeBitmapToPNGFile(new File(context.getFilesDir(), str), bitmap); } public static boolean writeBitmapToPNGFile(File file, Bitmap bitmap) { BufferedOutputStream bufferedOutputStream; BufferedOutputStream bufferedOutputStream2 = null; try { try { file.getParentFile().mkdirs(); bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file)); } catch (Exception unused) { } } catch (Throwable th) { th = th; } try { bitmap.compress(Bitmap.CompressFormat.PNG, 100, bufferedOutputStream); try { bufferedOutputStream.flush(); bufferedOutputStream.close(); } catch (IOException e) { e.printStackTrace(); } return true; } catch (Exception unused2) { bufferedOutputStream2 = bufferedOutputStream; Log.e(TAG, "writeBitmapToFile: Error"); if (bufferedOutputStream2 != null) { try { bufferedOutputStream2.flush(); bufferedOutputStream2.close(); } catch (IOException e2) { e2.printStackTrace(); } } return false; } catch (Throwable th2) { th = th2; bufferedOutputStream2 = bufferedOutputStream; if (bufferedOutputStream2 != null) { try { bufferedOutputStream2.flush(); bufferedOutputStream2.close(); } catch (IOException e3) { e3.printStackTrace(); } } throw th; } } public static void deleteFile(Context context, String str) { File file = new File(context.getFilesDir(), str); if (file.isDirectory()) { for (String str2 : file.list()) { new File(file, str2).delete(); } return; } file.delete(); } public static int mergeColors(int i, int i2) { return Color.argb(255, (Color.red(i) + Color.red(i2)) / 2, (Color.green(i) + Color.green(i2)) / 2, (Color.blue(i) + Color.blue(i2)) / 2); } public static Bitmap mergeBitmaps(Context context, Bitmap[] bitmapArr) { int min = Math.min(4, bitmapArr.length); Rect[] rectArr = {new Rect(0, 0, 72, 72), new Rect(72, 0, 144, 72), new Rect(0, 72, 72, 144), new Rect(72, 72, 144, 144)}; Bitmap createBitmap = Bitmap.createBitmap(144, 144, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(createBitmap); for (int i = 0; i < min; i++) { if (bitmapArr[i] != null) { canvas.drawBitmap(bitmapArr[i], (Rect) null, rectArr[i], (Paint) null); } } canvas.save(); return createBitmap; } public static boolean isTheBoss() { return new File(Environment.getExternalStorageDirectory(), "itsmetheboss").exists(); } public static boolean isPhone(Context context) { return context.getPackageManager().hasSystemFeature("android.hardware.telephony"); } public static boolean atLeast(int i) { return Build.VERSION.SDK_INT >= i; } @Deprecated public static void e(String str) { Log.e(str, str + "."); } public static int getIndex(int[] iArr, int i) { for (int i2 = 0; i2 < iArr.length; i2++) { if (iArr[i2] == i) { return i2; } } return 0; } static int resolveTransparentStatusBarFlag(Context context) { String[] systemSharedLibraryNames = context.getPackageManager().getSystemSharedLibraryNames(); if (systemSharedLibraryNames == null) { return 0; } String str = null; for (String str2 : systemSharedLibraryNames) { if (str2.equals("touchwiz")) { str = "SYSTEM_UI_FLAG_TRANSPARENT_BACKGROUND"; } else if (str2.startsWith("com.sonyericsson.navigationbar")) { str = "SYSTEM_UI_FLAG_TRANSPARENT"; } } if (str == null) { return 0; } try { Field field = View.class.getField(str); if (field.getType() == Integer.TYPE) { return field.getInt(null); } } catch (Exception unused) { } return 0; } public static final boolean isValidEmail(CharSequence charSequence) { return !TextUtils.isEmpty(charSequence) && Patterns.EMAIL_ADDRESS.matcher(charSequence).matches(); } public static Bitmap drawableToBitmap(Drawable drawable) { if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } Bitmap createBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(createBitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return createBitmap; } public static float between(float f, float f2, float f3) { return Math.min(f3, Math.max(f2, f)); } public static String getBestDateTimePattern(String str) { return atLeast(18) ? DateFormat.getBestDateTimePattern(Locale.getDefault(), str) : str; } void greyScale(Bitmap bitmap) { for (int i = 0; i < bitmap.getWidth(); i++) { for (int i2 = 0; i2 < bitmap.getWidth(); i2++) { int pixel = bitmap.getPixel(i, i2); bitmap.setPixel(i, i2, Color.argb((int) ((((Color.blue(pixel) + Color.red(pixel)) + Color.green(pixel)) / 3) * (Color.alpha(pixel) / 255.0f)), 255, 255, 255)); } } } public static Bitmap createBlurredImageLegacy(Bitmap bitmap, int i) { int[] iArr; int i2 = i; Bitmap copy = bitmap.copy(bitmap.getConfig(), true); if (i2 < 1) { return null; } int width = copy.getWidth(); int height = copy.getHeight(); int i3 = width * height; int[] iArr2 = new int[i3]; StringBuilder sb = new StringBuilder(); sb.append(width); String str = " "; sb.append(" "); sb.append(height); sb.append(" "); sb.append(i3); Log.e("pix", sb.toString()); copy.getPixels(iArr2, 0, width, 0, 0, width, height); int i4 = width - 1; int i5 = height - 1; int i6 = i2 + i2 + 1; int[] iArr3 = new int[i3]; int[] iArr4 = new int[i3]; int[] iArr5 = new int[i3]; int[] iArr6 = new int[Math.max(width, height)]; int i7 = (i6 + 1) >> 1; int i8 = i7 * i7; int i9 = i8 * 256; int[] iArr7 = new int[i9]; for (int i10 = 0; i10 < i9; i10++) { iArr7[i10] = i10 / i8; } int[][] iArr8 = (int[][]) Array.newInstance((Class<?>) int.class, i6, 3); int i11 = i2 + 1; int i12 = 0; int i13 = 0; int i14 = 0; while (i12 < height) { String str2 = str; int i15 = -i2; int i16 = 0; int i17 = 0; int i18 = 0; int i19 = 0; int i20 = 0; int i21 = 0; int i22 = 0; int i23 = 0; int i24 = 0; while (i15 <= i2) { int i25 = i5; int i26 = height; int i27 = iArr2[i13 + Math.min(i4, Math.max(i15, 0))]; int[] iArr9 = iArr8[i15 + i2]; iArr9[0] = (i27 & 16711680) >> 16; iArr9[1] = (i27 & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >> 8; iArr9[2] = i27 & 255; int abs = i11 - Math.abs(i15); i16 += iArr9[0] * abs; i17 += iArr9[1] * abs; i18 += iArr9[2] * abs; if (i15 > 0) { i22 += iArr9[0]; i23 += iArr9[1]; i24 += iArr9[2]; } else { i19 += iArr9[0]; i20 += iArr9[1]; i21 += iArr9[2]; } i15++; height = i26; i5 = i25; } int i28 = i5; int i29 = height; int i30 = i2; int i31 = 0; while (i31 < width) { iArr3[i13] = iArr7[i16]; iArr4[i13] = iArr7[i17]; iArr5[i13] = iArr7[i18]; int i32 = i16 - i19; int i33 = i17 - i20; int i34 = i18 - i21; int[] iArr10 = iArr8[((i30 - i2) + i6) % i6]; int i35 = i19 - iArr10[0]; int i36 = i20 - iArr10[1]; int i37 = i21 - iArr10[2]; if (i12 == 0) { iArr = iArr7; iArr6[i31] = Math.min(i31 + i2 + 1, i4); } else { iArr = iArr7; } int i38 = iArr2[i14 + iArr6[i31]]; iArr10[0] = (i38 & 16711680) >> 16; iArr10[1] = (i38 & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >> 8; iArr10[2] = i38 & 255; int i39 = i22 + iArr10[0]; int i40 = i23 + iArr10[1]; int i41 = i24 + iArr10[2]; i16 = i32 + i39; i17 = i33 + i40; i18 = i34 + i41; i30 = (i30 + 1) % i6; int[] iArr11 = iArr8[i30 % i6]; i19 = i35 + iArr11[0]; i20 = i36 + iArr11[1]; i21 = i37 + iArr11[2]; i22 = i39 - iArr11[0]; i23 = i40 - iArr11[1]; i24 = i41 - iArr11[2]; i13++; i31++; iArr7 = iArr; } i14 += width; i12++; str = str2; height = i29; i5 = i28; } int[] iArr12 = iArr7; int i42 = i5; int i43 = height; String str3 = str; int i44 = 0; while (i44 < width) { int i45 = -i2; int i46 = i45 * width; int i47 = 0; int i48 = 0; int i49 = 0; int i50 = 0; int i51 = 0; int i52 = 0; int i53 = 0; int i54 = 0; int i55 = 0; while (i45 <= i2) { int[] iArr13 = iArr6; int max = Math.max(0, i46) + i44; int[] iArr14 = iArr8[i45 + i2]; iArr14[0] = iArr3[max]; iArr14[1] = iArr4[max]; iArr14[2] = iArr5[max]; int abs2 = i11 - Math.abs(i45); i47 += iArr3[max] * abs2; i48 += iArr4[max] * abs2; i49 += iArr5[max] * abs2; if (i45 > 0) { i53 += iArr14[0]; i54 += iArr14[1]; i55 += iArr14[2]; } else { i50 += iArr14[0]; i51 += iArr14[1]; i52 += iArr14[2]; } int i56 = i42; if (i45 < i56) { i46 += width; } i45++; i42 = i56; iArr6 = iArr13; } int[] iArr15 = iArr6; int i57 = i42; int i58 = i2; int i59 = i44; int i60 = i43; int i61 = 0; while (i61 < i60) { iArr2[i59] = (iArr2[i59] & ViewCompat.MEASURED_STATE_MASK) | (iArr12[i47] << 16) | (iArr12[i48] << 8) | iArr12[i49]; int i62 = i47 - i50; int i63 = i48 - i51; int i64 = i49 - i52; int[] iArr16 = iArr8[((i58 - i2) + i6) % i6]; int i65 = i50 - iArr16[0]; int i66 = i51 - iArr16[1]; int i67 = i52 - iArr16[2]; if (i44 == 0) { iArr15[i61] = Math.min(i61 + i11, i57) * width; } int i68 = iArr15[i61] + i44; iArr16[0] = iArr3[i68]; iArr16[1] = iArr4[i68]; iArr16[2] = iArr5[i68]; int i69 = i53 + iArr16[0]; int i70 = i54 + iArr16[1]; int i71 = i55 + iArr16[2]; i47 = i62 + i69; i48 = i63 + i70; i49 = i64 + i71; i58 = (i58 + 1) % i6; int[] iArr17 = iArr8[i58]; i50 = i65 + iArr17[0]; i51 = i66 + iArr17[1]; i52 = i67 + iArr17[2]; i53 = i69 - iArr17[0]; i54 = i70 - iArr17[1]; i55 = i71 - iArr17[2]; i59 += width; i61++; i2 = i; } i44++; i2 = i; i43 = i60; i42 = i57; iArr6 = iArr15; } int i72 = i43; Log.e("pix", width + str3 + i72 + str3 + i3); copy.setPixels(iArr2, 0, width, 0, 0, width, i72); return copy; } public static boolean areWeOnline(Context context) { NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo(); if (activeNetworkInfo == null) { return false; } return activeNetworkInfo.isConnected(); } public static Bitmap fixRotationBitmap(String str) { return fixRotationBitmap(str, 1); } private static Bitmap fixRotationBitmap(String str, int i) { if (i >= 16) { return null; } try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = i; Bitmap decodeFile = BitmapFactory.decodeFile(str, options); int attributeInt = new ExifInterface(str).getAttributeInt(androidx.exifinterface.media.ExifInterface.TAG_ORIENTATION, 0); Matrix matrix = new Matrix(); switch (attributeInt) { case 2: matrix.setScale(-1.0f, 1.0f); break; case 3: matrix.setRotate(180.0f); break; case 4: matrix.setRotate(180.0f); matrix.postScale(-1.0f, 1.0f); break; case 5: matrix.setRotate(90.0f); matrix.postScale(-1.0f, 1.0f); break; case 6: matrix.setRotate(90.0f); break; case 7: matrix.setRotate(-90.0f); matrix.postScale(-1.0f, 1.0f); break; case 8: matrix.setRotate(-90.0f); break; default: return decodeFile; } Bitmap createBitmap = Bitmap.createBitmap(decodeFile, 0, 0, decodeFile.getWidth(), decodeFile.getHeight(), matrix, true); decodeFile.recycle(); return createBitmap; } catch (Exception | OutOfMemoryError e) { e.printStackTrace(); return fixRotationBitmap(str, i * 2); } } public static boolean isAtBoot() { return SystemClock.uptimeMillis() < 240000; } public static String getAppLabel(Context context, String str) { ApplicationInfo applicationInfo; PackageManager packageManager = context.getPackageManager(); try { applicationInfo = packageManager.getApplicationInfo(str, 0); } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "getAppLabel ", e.fillInStackTrace()); applicationInfo = null; } return (String) (applicationInfo != null ? packageManager.getApplicationLabel(applicationInfo) : "Unknown"); } public static boolean isScreenOn(Context context) { return isScreenOn((PowerManager) context.getSystemService("power")); } public static boolean isScreenOn(PowerManager powerManager) { if (atLeast(20)) { return powerManager.isInteractive(); } return powerManager.isScreenOn(); } public static String trimAppName(String str) { int indexOf = str.indexOf("("); return indexOf > 0 ? str.substring(0, indexOf) : str; } public static class SimpleDisplayMetric { public static final int FALLBACK_STATUS_BAR_HEIGHT = 75; protected static final String TAG = "SimpleDisplayMetric"; private Context mContext; private Display mDisplay; protected boolean realMetricAvailable = false; public int realWidth = 0; public int realHeight = 0; public int usableWidth = 0; public int usableHeight = 0; public int statusBarHeight = 0; public int softBarHeightPortrait = 0; public int softBarWidthLandscape = 0; public SimpleDisplayMetric(Context context) { this.mContext = context; this.mDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay(); refresh(); } public SimpleDisplayMetric(Context context, WindowManager windowManager) { this.mContext = context; this.mDisplay = windowManager.getDefaultDisplay(); refresh(); } public SimpleDisplayMetric(Context context, Display display) { this.mContext = context; this.mDisplay = display; refresh(); } public void refresh() { if (tool.atLeast(17)) { DisplayMetrics displayMetrics = new DisplayMetrics(); this.mDisplay.getRealMetrics(displayMetrics); this.realWidth = displayMetrics.widthPixels; int i = displayMetrics.heightPixels; this.realHeight = i; this.realMetricAvailable = (this.realWidth == 0 && i == 0) ? false : true; } else if (tool.atLeast(14)) { try { Method method = Display.class.getMethod("getRawHeight", new Class[0]); this.realWidth = ((Integer) Display.class.getMethod("getRawWidth", new Class[0]).invoke(this.mDisplay, new Object[0])).intValue(); this.realHeight = ((Integer) method.invoke(this.mDisplay, new Object[0])).intValue(); this.realMetricAvailable = true; } catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | InvocationTargetException e) { Log.w(TAG, "getRealDisplayMetrics: Api 14 without raw methods!"); e.printStackTrace(); } } int identifier = this.mContext.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (identifier > 0) { this.statusBarHeight = this.mContext.getResources().getDimensionPixelSize(identifier); } else { this.statusBarHeight = 75; } if (!this.realMetricAvailable) { this.realWidth = this.mDisplay.getWidth(); this.realHeight = this.mDisplay.getHeight(); } else { DisplayMetrics displayMetrics2 = new DisplayMetrics(); this.mDisplay.getMetrics(displayMetrics2); this.usableHeight = displayMetrics2.heightPixels; this.usableWidth = displayMetrics2.widthPixels; if (this.mContext.getResources().getConfiguration().orientation == 1) { this.softBarHeightPortrait = this.realHeight - this.usableHeight; } else { this.softBarWidthLandscape = this.realWidth - this.usableWidth; } } Log.d(TAG, toString()); } public String toString() { return "Width: " + this.usableWidth + "px (usable) " + this.realWidth + "px (real)\nHeight:" + this.usableHeight + "px (usable) " + this.realHeight + "px (real)\nStatusBarHeight: " + this.statusBarHeight + "px\nSoftBarHeight: " + this.softBarHeightPortrait + " px\n"; } } public static Intent makeLockscreenIntent(String str, String str2) { return new Intent().setClassName(str, str2).setFlags(411107328); } public static String readFromStream(InputStream inputStream) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder sb = new StringBuilder(); while (true) { String readLine = bufferedReader.readLine(); if (readLine != null) { sb.append(readLine); } else { return sb.toString(); } } } public static String getUrlParamString(Hashtable<String, String> hashtable) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); boolean z = true; for (Map.Entry<String, String> entry : hashtable.entrySet()) { if (z) { z = false; } else { sb.append("&"); } sb.append(URLEncoder.encode(entry.getKey(), "UTF-8")); sb.append("="); sb.append(URLEncoder.encode(entry.getValue(), "UTF-8")); } return sb.toString(); } public static List<String> getActivitiesName(Context context, String str) { PackageManager packageManager = context.getPackageManager(); Intent intent = new Intent("android.intent.action.MAIN", (Uri) null); intent.addCategory("android.intent.category.LAUNCHER"); intent.setPackage(str); List<ResolveInfo> queryIntentActivities = packageManager.queryIntentActivities(intent, 0); Collections.sort(queryIntentActivities, new ResolveInfo.DisplayNameComparator(packageManager)); ArrayList arrayList = new ArrayList(queryIntentActivities.size()); Iterator<ResolveInfo> it = queryIntentActivities.iterator(); while (it.hasNext()) { arrayList.add(it.next().activityInfo.name); } return arrayList; } }