This commit is contained in:
gdlbo
2023-02-28 18:22:36 +03:00
parent 1dd12c45ef
commit 60336238f2
6 changed files with 11 additions and 8 deletions
@@ -1,11 +1,13 @@
package ru.vtosters.lite.themes.loaders;
import android.annotation.SuppressLint;
import android.content.res.AssetManager;
import ru.vtosters.lite.utils.ReflectionUtils;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@SuppressLint("PrivateApi")
public class AssetManagerHelper {
@@ -32,9 +34,9 @@ public class AssetManagerHelper {
throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Object[] apkAssetsArr = (Object[]) getAssetPathMtd.invoke(assetManager);
// By default, base apk is the last element of array if is not, for execution speed, we should iterate array from the end to the beginning
for (int i = apkAssetsArr.length - 1; i >= 0; i--) {
for (int i = (apkAssetsArr != null ? apkAssetsArr.length : 0) - 1; i >= 0; i--) {
final String pathname = (String) getApkAssetsMtd.invoke(apkAssetsArr[i]);
if (pathname.contains(packagename)) return pathname;
if (pathname != null && pathname.contains(packagename)) return pathname;
}
throw new NullPointerException();
@@ -1,5 +1,6 @@
package ru.vtosters.lite.ui.dialogs;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -24,6 +25,7 @@ public class DisableBattery {
.setMessage(R.string.batteryissuesumm)
.setCancelable(false)
.setPositiveButton(R.string.batteryissuebtn1, (dialogInterface, i) -> {
@SuppressLint("BatteryLife")
var intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.setData(Uri.parse("package:" + packName));
@@ -32,7 +32,7 @@ public class Translate {
var translation = translator.getTranslation(text);
MAIN_EXECUTOR.execute(() -> showDialog(context, translation));
} catch (Exception e) {
Log.e("Translate", e + "");
Log.e("Translate", String.valueOf(e));
}
});
}
@@ -12,8 +12,8 @@ import ru.vtosters.lite.utils.LayoutUtils;
public class VTColorPickerBottomSheetDialog extends ModalBottomSheetWrapper<VTColorPickerBottomSheetDialog> {
private Activity mActivity;
private LinearLayout mContainer;
private final Activity mActivity;
private final LinearLayout mContainer;
public VTColorPickerBottomSheetDialog(Activity activity) {
super(activity);
@@ -112,7 +112,7 @@ public class IOUtils {
public static void deleteRecursive(File f, boolean selfDeletion) {
if (f.isDirectory()) {
var fs = f.listFiles();
if (fs != null && fs.length > 0)
if (fs != null)
for (var child : fs)
deleteRecursive(child, true);
}
@@ -78,8 +78,7 @@ public class ReflectionUtils {
return findMethod(instance.getClass(), methodName, params);
}
public static Object getActivityThread(Context context, Class<?> clz)
throws InvocationTargetException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException {
public static Object getActivityThread(Context context, Class<?> clz) {
try {
if(clz == null) clz = findClass("android.app.ActivityThread");
final Method currentActivityThreadMtd = findMethod(clz, "currentActivityThread");