Closed zezung27 closed 1 year ago
public static Bitmap scaleUpImage(Bitmap bitmap, int n, int n2) { block4 : { Bitmap bitmap2; block3 : { try { float f = bitmap.getWidth(); if (bitmap.getWidth() > n) { bitmap2 = Bitmap.createBitmap((Bitmap)bitmap, (int)((int)(f / 2.0f - (float)(n / 2))), (int)0, (int)n, (int)bitmap.getHeight()); bitmap.recycle(); break block3; } if (bitmap.getHeight() <= n2) break block4; bitmap2 = Bitmap.createBitmap((Bitmap)bitmap, (int)0, (int)0, (int)bitmap.getWidth(), (int)n2); bitmap.recycle(); } catch (OutOfMemoryError outOfMemoryError) { outOfMemoryError.printStackTrace(); return null; } } bitmap = bitmap2; } Bitmap bitmap3 = null; if (bitmap == null) return bitmap3; Bitmap bitmap4 = bitmap.getWidth() <= n ? Bitmap.createScaledBitmap((Bitmap)bitmap, (int)n, (int)((int)((float)bitmap.getHeight() / (float)bitmap.getWidth() (float)n)), (boolean)true) : (bitmap.getHeight() < n2 ? Bitmap.createScaledBitmap((Bitmap)bitmap, (int)((int)((float)bitmap.getHeight() / (float)bitmap.getWidth() (float)n2)), (int)n2, (boolean)true) : null); bitmap.recycle(); return bitmap4; }
public static float convertDpToPixel(float f, Context context) {
Resources resources = context == null ? Resources.getSystem() : context.getResources();
return f * ((float)resources.getDisplayMetrics().densityDpi / 160.0f);
}
public static Bitmap drawableToBmp(Context context, Drawable drawable2, int n) {
Bitmap bitmap;
if (drawable2 == null) return null;
if (drawable2.getIntrinsicWidth() > 0 && drawable2.getIntrinsicHeight() > 0) {
if (n <= 0) return getCroppedBitmap(drawable2, context);
int n2 = (int)convertDpToPixel(n, context);
bitmap = Bitmap.createBitmap((int)n2, (int)n2, (Bitmap.Config)Bitmap.Config.ARGB_4444);
} else {
bitmap = Bitmap.createBitmap((int)1, (int)1, (Bitmap.Config)Bitmap.Config.ARGB_4444);
}
Canvas canvas = new Canvas(bitmap);
drawable2.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable2.draw(canvas);
return bitmap;
}
public static void saveArrayList(ArrayList<PackageModalPref> list, String key, Context context){
// save the task list to preference
SharedPreferences prefs = context.getSharedPreferences(Contanst.PREF_NAME_PACKAGE, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
Gson gson = new Gson();
String json = gson.toJson(list);
editor.putString(key, json);
editor.commit();
}
public static ArrayList<PackageModalPref> getArrayList(String key, Context context){
SharedPreferences sharedPrefs = context.getSharedPreferences(Contanst.PREF_NAME_PACKAGE, Context.MODE_PRIVATE);;
Gson gson = new Gson();
String json = sharedPrefs.getString(key, "");
Type type = new TypeToken<ArrayList<PackageModalPref>>() {}.getType();
ArrayList<PackageModalPref> arrayList = gson.fromJson(json, type);
return arrayList;
}
public static String getFormattedTime(long l) {
long l2 = l / 1000L;
long l3 = l2 / 60L;
long l4 = l2 % 60L;
DecimalFormat decimalFormat = new DecimalFormat("00");;
String string2 = decimalFormat.format(l3);
String string3 = decimalFormat.format(l4);
return string2 + ":" + string3;
}
}
package com.matcos.dynamicislandlight.utils;
import android.content.ContentResolver; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.provider.Settings; import android.util.DisplayMetrics; import android.view.Display; import android.view.WindowManager;
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.matcos.dynamicislandlight.R; import com.matcos.dynamicislandlight.noti.PackageModalPref;
import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.lang.reflect.Type; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Iterator;
public class Utils {