version:1.0
fix: update:基本布局实现
This commit is contained in:
@@ -63,7 +63,7 @@ public class ApkUtils {
|
||||
}};
|
||||
|
||||
private static HashSet<String> showPackageName = new HashSet<String>() {{
|
||||
this.add("com.uiui.sn");
|
||||
this.add("com.uiui.zysn");
|
||||
this.add("com.android.dialer");
|
||||
this.add("com.android.gallery3d");
|
||||
this.add("com.android.settings");
|
||||
@@ -144,7 +144,7 @@ public class ApkUtils {
|
||||
this.add("com.android.gallery3d");
|
||||
this.add("com.android.camera2");
|
||||
this.add("com.android.settings");
|
||||
this.add("com.uiui.sn");
|
||||
this.add("com.uiui.zysn");
|
||||
this.add("com.uiui.appstore");
|
||||
}};
|
||||
|
||||
@@ -200,7 +200,7 @@ public class ApkUtils {
|
||||
}
|
||||
if (Settings.Global.getInt(context.getContentResolver(), "is_activity", 0) == 0) {
|
||||
resolveInfos.removeIf(resolveInfo -> "com.uiui.city".equals(resolveInfo.activityInfo.packageName));
|
||||
// resolveInfos.removeIf(applicationInfo -> "com.uiui.sn".equals(applicationInfo.packageName));
|
||||
// resolveInfos.removeIf(applicationInfo -> "com.uiui.zysn".equals(applicationInfo.packageName));
|
||||
}
|
||||
resolveInfos.sort(new Comparator<ResolveInfo>() {
|
||||
@Override
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class AppUsedTimeUtils {
|
||||
private static final String TAG = AppUsedTimeUtils.class.getSimpleName();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static AppUsedTimeUtils sInstance;
|
||||
private Context mContext;
|
||||
|
||||
private SimpleDateFormat ruleSDF = new SimpleDateFormat("HH:mm:ss");
|
||||
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
private AppTimeinfo appTimeinfo;
|
||||
|
||||
private AppUsedTimeUtils(Context context) {
|
||||
this.mContext = context;
|
||||
appTimeinfo = getAppTimeinfo();
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new AppUsedTimeUtils(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static AppUsedTimeUtils getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init TimeUtils first");
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private static String normalStartTime = "8:00:00";
|
||||
private static String unusualStartTime = "22:00:00";
|
||||
|
||||
static class AppTimeinfo implements Serializable {
|
||||
private static final long serialVersionUID = 5373751133823666192L;
|
||||
|
||||
AppTimeinfo() {
|
||||
this.appPackageName = "";
|
||||
this.endTime = 0;
|
||||
this.startTime = 0;
|
||||
}
|
||||
|
||||
private String appPackageName;
|
||||
private long endTime;
|
||||
private long startTime;
|
||||
|
||||
public String getAppPackageName() {
|
||||
return appPackageName;
|
||||
}
|
||||
|
||||
public void setAppPackageName(String appPackageName) {
|
||||
this.appPackageName = appPackageName;
|
||||
}
|
||||
|
||||
public long getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(long endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
}
|
||||
}
|
||||
|
||||
synchronized public void setAppPackageName(String name) {
|
||||
appTimeinfo.setAppPackageName(name);
|
||||
setAppTimeinfo();
|
||||
}
|
||||
|
||||
synchronized public String getAppPackageName() {
|
||||
return appTimeinfo.getAppPackageName();
|
||||
}
|
||||
|
||||
synchronized public void setStartTime(long time) {
|
||||
appTimeinfo.setStartTime(time);
|
||||
setAppTimeinfo();
|
||||
}
|
||||
|
||||
synchronized public long getStartTime() {
|
||||
return appTimeinfo.getStartTime();
|
||||
}
|
||||
|
||||
synchronized public void setEndTime(long time) {
|
||||
appTimeinfo.setEndTime(time);
|
||||
setAppTimeinfo();
|
||||
}
|
||||
|
||||
synchronized public long getEndTime() {
|
||||
return appTimeinfo.getEndTime();
|
||||
}
|
||||
|
||||
synchronized private AppTimeinfo getAppTimeinfo() {
|
||||
String jsonString = Settings.System.getString(mContext.getContentResolver(), "runningAppInfo");
|
||||
if (TextUtils.isEmpty(jsonString)) {
|
||||
return new AppTimeinfo();
|
||||
}
|
||||
Log.e(TAG, "getAppTimeinfo: " + jsonString);
|
||||
Type type = new TypeToken<AppTimeinfo>() {
|
||||
}.getType();
|
||||
Gson gson = new Gson();
|
||||
AppTimeinfo appTimeinfo = gson.fromJson(jsonString, type);
|
||||
return appTimeinfo;
|
||||
}
|
||||
|
||||
synchronized private void setAppTimeinfo() {
|
||||
String jsonString = JsonParser.parseString(appTimeinfo.toString()).getAsJsonObject().toString();
|
||||
Settings.System.putString(mContext.getContentResolver(), "runningAppInfo", jsonString);
|
||||
}
|
||||
|
||||
private static final long DAY_TIME = 1000 * 60 * 60 * 24;
|
||||
|
||||
public boolean isNormalTime() {
|
||||
long nowTime = System.currentTimeMillis();
|
||||
String nowTimeString = ruleSDF.format(new Date(nowTime)); // 时间戳转换日期
|
||||
try {
|
||||
Date startDate = ruleSDF.parse(normalStartTime);
|
||||
Date endDate = ruleSDF.parse(unusualStartTime);
|
||||
Date now = ruleSDF.parse(nowTimeString);
|
||||
Log.e(TAG, "isScreenshot: startDate = " + startDate);
|
||||
Log.e(TAG, "isScreenshot: endDate = " + endDate);
|
||||
Log.e(TAG, "isScreenshot: now = " + now);
|
||||
if (startDate.getTime() <= now.getTime() && now.getTime() <= endDate.getTime()) {
|
||||
return true;
|
||||
} else if (endDate.getTime() < now.getTime() && now.getTime() <= startDate.getTime() + DAY_TIME) {
|
||||
return false;
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "isScreenshot: " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 www.amsoft.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
|
||||
public class AppUtil {
|
||||
private static String TAG = AppUtil.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* 描述:获取可用内存.
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static long getAvailMemory(Context context) {
|
||||
// 获取android当前可用内存大小
|
||||
ActivityManager activityManager = (ActivityManager) context
|
||||
.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
||||
activityManager.getMemoryInfo(memoryInfo);
|
||||
// 当前系统可用内存 ,将获得的内存大小规格化
|
||||
|
||||
return memoryInfo.availMem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @return 可用的内存大小
|
||||
*/
|
||||
public static long getFreeMemory(Context context) {
|
||||
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
||||
activityManager.getMemoryInfo(memoryInfo);
|
||||
long freeMem = memoryInfo.totalMem - memoryInfo.availMem;
|
||||
// Log.e("getHardware", "getFreeMemory: " + freeMem);
|
||||
return freeMem;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述:总内存.
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static long getTotalMemory(Context context) {
|
||||
// 系统内存信息文件
|
||||
String file = "/proc/meminfo";
|
||||
String memInfo;
|
||||
String[] strs;
|
||||
long memory = 0;
|
||||
|
||||
try {
|
||||
FileReader fileReader = new FileReader(file);
|
||||
BufferedReader bufferedReader = new BufferedReader(fileReader, 8192);
|
||||
// 读取meminfo第一行,系统内存大小
|
||||
memInfo = bufferedReader.readLine();
|
||||
strs = memInfo.split("\\s+");
|
||||
for (String str : strs) {
|
||||
Log.e(TAG, "getTotalMemory: " + str + "\t");
|
||||
}
|
||||
// 获得系统总内存,单位KB
|
||||
memory = Integer.valueOf(strs[1]).intValue();
|
||||
bufferedReader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Byte转位KB或MB
|
||||
return memory * 1024;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.AdaptiveIconDrawable;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
public class BitmapUtils {
|
||||
public static Bitmap Bytes2Bimap(byte[] b) {
|
||||
if (b.length != 0) {
|
||||
return BitmapFactory.decodeByteArray(b, 0, b.length);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] Bitmap2Bytes(Bitmap bitmap) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
|
||||
byte[] data = baos.toByteArray();
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drawable转换成一个Bitmap
|
||||
*
|
||||
* @param drawable drawable对象
|
||||
* @return
|
||||
*/
|
||||
public static final Bitmap drawableToBitmap(Drawable drawable) {
|
||||
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
|
||||
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
drawable.draw(canvas);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
public static Bitmap drawableToBitamp(Drawable drawable) {
|
||||
Bitmap bitmap;
|
||||
BitmapDrawable bd = (BitmapDrawable) drawable;
|
||||
bitmap = bd.getBitmap();
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static Bitmap getIconBitmap(Context context, Drawable drawable) {
|
||||
try {
|
||||
if (drawable == null) {
|
||||
return null;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && drawable instanceof AdaptiveIconDrawable) {
|
||||
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
return Utils.getRoundedBitmap(bitmap, context);
|
||||
} else {
|
||||
return Utils.getRoundedBitmap(((BitmapDrawable) drawable).getBitmap(), context);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
import android.util.MathUtils;
|
||||
|
||||
public class BrightnessUtils {
|
||||
|
||||
public static final int GAMMA_SPACE_MIN = 0;
|
||||
public static final int GAMMA_SPACE_MAX = 65535;
|
||||
|
||||
// Hybrid Log Gamma constant values
|
||||
private static final float R = 0.5f;
|
||||
private static final float A = 0.17883277f;
|
||||
private static final float B = 0.28466892f;
|
||||
private static final float C = 0.55991073f;
|
||||
|
||||
/**
|
||||
* A function for converting from the gamma space that the slider works in to the
|
||||
* linear space that the setting works in.
|
||||
* <p>
|
||||
* The gamma space effectively provides us a way to make linear changes to the slider that
|
||||
* result in linear changes in perception. If we made changes to the slider in the linear space
|
||||
* then we'd see an approximately logarithmic change in perception (c.f. Fechner's Law).
|
||||
* <p>
|
||||
* Internally, this implements the Hybrid Log Gamma electro-optical transfer function, which is
|
||||
* a slight improvement to the typical gamma transfer function for displays whose max
|
||||
* brightness exceeds the 120 nit reference point, but doesn't set a specific reference
|
||||
* brightness like the PQ function does.
|
||||
* <p>
|
||||
* Note that this transfer function is only valid if the display's backlight value is a linear
|
||||
* control. If it's calibrated to be something non-linear, then a different transfer function
|
||||
* should be used.
|
||||
*
|
||||
* @param val The slider value.
|
||||
* @param min The minimum acceptable value for the setting.
|
||||
* @param max The maximum acceptable value for the setting.
|
||||
* @return The corresponding setting value.
|
||||
*/
|
||||
public static final int convertGammaToLinear(int val, int min, int max) {
|
||||
final float normalizedVal = MathUtils.norm(GAMMA_SPACE_MIN, GAMMA_SPACE_MAX, val);
|
||||
final float ret;
|
||||
if (normalizedVal <= R) {
|
||||
ret = MathUtils.sq(normalizedVal / R);
|
||||
} else {
|
||||
ret = MathUtils.exp((normalizedVal - C) / A) + B;
|
||||
}
|
||||
|
||||
// HLG is normalized to the range [0, 12], so we need to re-normalize to the range [0, 1]
|
||||
// in order to derive the correct setting value.
|
||||
return Math.round(MathUtils.lerp(min, max, ret / 12));
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of {@link #convertGammaToLinear} that takes and returns float values.
|
||||
* TODO(flc): refactor Android Auto to use float version
|
||||
*
|
||||
* @param val The slider value.
|
||||
* @param min The minimum acceptable value for the setting.
|
||||
* @param max The maximum acceptable value for the setting.
|
||||
* @return The corresponding setting value.
|
||||
*/
|
||||
public static final float convertGammaToLinearFloat(int val, float min, float max) {
|
||||
final float normalizedVal = MathUtils.norm(GAMMA_SPACE_MIN, GAMMA_SPACE_MAX, val);
|
||||
final float ret;
|
||||
if (normalizedVal <= R) {
|
||||
ret = MathUtils.sq(normalizedVal / R);
|
||||
} else {
|
||||
ret = MathUtils.exp((normalizedVal - C) / A) + B;
|
||||
}
|
||||
|
||||
// HLG is normalized to the range [0, 12], ensure that value is within that range,
|
||||
// it shouldn't be out of bounds.
|
||||
final float normalizedRet = MathUtils.constrain(ret, 0, 12);
|
||||
|
||||
// Re-normalize to the range [0, 1]
|
||||
// in order to derive the correct setting value.
|
||||
return MathUtils.lerp(min, max, normalizedRet / 12);
|
||||
}
|
||||
|
||||
/**
|
||||
* A function for converting from the linear space that the setting works in to the
|
||||
* gamma space that the slider works in.
|
||||
* <p>
|
||||
* The gamma space effectively provides us a way to make linear changes to the slider that
|
||||
* result in linear changes in perception. If we made changes to the slider in the linear space
|
||||
* then we'd see an approximately logarithmic change in perception (c.f. Fechner's Law).
|
||||
* <p>
|
||||
* Internally, this implements the Hybrid Log Gamma opto-electronic transfer function, which is
|
||||
* a slight improvement to the typical gamma transfer function for displays whose max
|
||||
* brightness exceeds the 120 nit reference point, but doesn't set a specific reference
|
||||
* brightness like the PQ function does.
|
||||
* <p>
|
||||
* Note that this transfer function is only valid if the display's backlight value is a linear
|
||||
* control. If it's calibrated to be something non-linear, then a different transfer function
|
||||
* should be used.
|
||||
*
|
||||
* @param val The brightness setting value.
|
||||
* @param min The minimum acceptable value for the setting.
|
||||
* @param max The maximum acceptable value for the setting.
|
||||
* @return The corresponding slider value
|
||||
*/
|
||||
public static final int convertLinearToGamma(int val, int min, int max) {
|
||||
return convertLinearToGammaFloat((float) val, (float) min, (float) max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of {@link #convertLinearToGamma} that takes float values.
|
||||
* TODO: brightnessfloat merge with above method(?)
|
||||
*
|
||||
* @param val The brightness setting value.
|
||||
* @param min The minimum acceptable value for the setting.
|
||||
* @param max The maximum acceptable value for the setting.
|
||||
* @return The corresponding slider value
|
||||
*/
|
||||
public static final int convertLinearToGammaFloat(float val, float min, float max) {
|
||||
// For some reason, HLG normalizes to the range [0, 12] rather than [0, 1]
|
||||
final float normalizedVal = MathUtils.norm(min, max, val) * 12;
|
||||
final float ret;
|
||||
if (normalizedVal <= 1f) {
|
||||
ret = MathUtils.sqrt(normalizedVal) * R;
|
||||
} else {
|
||||
ret = A * MathUtils.log(normalizedVal - B) + C;
|
||||
}
|
||||
|
||||
return Math.round(MathUtils.lerp(GAMMA_SPACE_MIN, GAMMA_SPACE_MAX, ret));
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 作者 mjsheng
|
||||
* 日期 2018/8/31 09:50
|
||||
* 邮箱 501802639@qq.com
|
||||
* 来自:
|
||||
*/
|
||||
|
||||
public class DataUtil {
|
||||
private static SimpleDateFormat day = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
private static SimpleDateFormat hour = new SimpleDateFormat("HH:mm");
|
||||
private static SimpleDateFormat minute = new SimpleDateFormat("mm");
|
||||
|
||||
/**
|
||||
* 格式化日期(精确到天)
|
||||
*/
|
||||
public static String formatDateDay() {
|
||||
return day.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期(hour)
|
||||
*/
|
||||
public static String formatDateHour() {
|
||||
return hour.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期(minute)
|
||||
*/
|
||||
public static String formatDateMinute() {
|
||||
return minute.format(new Date());
|
||||
}
|
||||
}
|
||||
183
app/src/main/java/com/uiui/zyos/utils/DimenTool.java
Normal file
183
app/src/main/java/com/uiui/zyos/utils/DimenTool.java
Normal file
@@ -0,0 +1,183 @@
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2016/11/25.
|
||||
* 华为版本 sw480 的内容替换成sw400
|
||||
*/
|
||||
|
||||
public class DimenTool {
|
||||
|
||||
public static void gen() {
|
||||
|
||||
File file = new File("./app/src/main/res/values/dimens.xml");
|
||||
BufferedReader reader = null;
|
||||
StringBuilder sw320 = new StringBuilder();
|
||||
StringBuilder sw360 = new StringBuilder();
|
||||
StringBuilder sw400 = new StringBuilder();
|
||||
StringBuilder sw460 = new StringBuilder();
|
||||
StringBuilder sw480 = new StringBuilder();
|
||||
StringBuilder sw560 = new StringBuilder();
|
||||
StringBuilder sw600 = new StringBuilder();
|
||||
StringBuilder sw609 = new StringBuilder();
|
||||
StringBuilder sw640 = new StringBuilder();
|
||||
StringBuilder sw720 = new StringBuilder();
|
||||
StringBuilder sw760 = new StringBuilder();
|
||||
StringBuilder sw800 = new StringBuilder();
|
||||
StringBuilder sw860 = new StringBuilder();
|
||||
StringBuilder sw900 = new StringBuilder();
|
||||
// StringBuilder mdpi = new StringBuilder();
|
||||
// StringBuilder hdpi = new StringBuilder();
|
||||
// StringBuilder xhdpi = new StringBuilder();
|
||||
// StringBuilder xxhdpi = new StringBuilder();
|
||||
|
||||
|
||||
try {
|
||||
System.out.println("生成不同分辨率:");
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
String tempString;
|
||||
int line = 1;
|
||||
// 一次读入一行,直到读入null为文件结束
|
||||
|
||||
java.text.DecimalFormat df = new java.text.DecimalFormat("#.##");
|
||||
while ((tempString = reader.readLine()) != null) {
|
||||
|
||||
if (tempString.contains("</dimen>")) {
|
||||
//tempString = tempString.replaceAll(" ", "");
|
||||
String start = tempString.substring(0, tempString.indexOf(">") + 1);
|
||||
String end = tempString.substring(tempString.lastIndexOf("<") - 2);
|
||||
double num = Double.valueOf(tempString.substring(tempString.indexOf(">") + 1, tempString.indexOf("</dimen>") - 2));
|
||||
|
||||
sw320.append(start).append(df.format((double) num * 0.4)).append(end).append("\n");
|
||||
sw360.append(start).append(df.format((double) num * 0.45)).append(end).append("\n");
|
||||
sw400.append(start).append(df.format((double) num * 0.5)).append(end).append("\n");
|
||||
sw460.append(start).append(df.format((double) num * 0.575)).append(end).append("\n");
|
||||
sw480.append(start).append(df.format((double) num * 0.6)).append(end).append("\n");
|
||||
|
||||
|
||||
sw560.append(start).append(df.format((double) num * 0.7)).append(end).append("\n");
|
||||
sw600.append(start).append(df.format((double) num * 0.75)).append(end).append("\n");
|
||||
sw609.append(start).append(df.format((double) num * 0.76125)).append(end).append("\n");
|
||||
sw640.append(start).append(df.format((double) num * 0.85)).append(end).append("\n"); // 适配学仕宝
|
||||
sw720.append(start).append(df.format((double) num * 0.9)).append(end).append("\n");
|
||||
sw760.append(start).append(df.format((double) num * 0.95)).append(end).append("\n");
|
||||
sw800.append(tempString).append("\n");
|
||||
sw860.append(start).append(df.format((double) num * 1.06)).append(end).append("\n");
|
||||
sw900.append(start).append(df.format((double) num * 1.125)).append(end).append("\n");
|
||||
|
||||
// mdpi.append(start).append(df.format((double) num * 0.75)).append(end).append("\n");
|
||||
// hdpi.append(start).append(df.format((double) num * 1)).append(end).append("\n");
|
||||
// xhdpi.append(start).append(df.format((double) num * 1.5)).append(end).append("\n");
|
||||
// xxhdpi.append(start).append(df.format((double) num * 2)).append(end).append("\n");
|
||||
|
||||
} else {
|
||||
sw320.append(tempString).append("\n");
|
||||
sw360.append(tempString).append("\n");
|
||||
sw400.append(tempString).append("\n");
|
||||
sw460.append(tempString).append("\n");
|
||||
sw480.append(tempString).append("\n");
|
||||
sw560.append(tempString).append("\n");
|
||||
sw600.append(tempString).append("\n");
|
||||
sw609.append(tempString).append("\n");
|
||||
sw640.append(tempString).append("\n");
|
||||
sw760.append(tempString).append("\n");
|
||||
sw720.append(tempString).append("\n");
|
||||
sw800.append(tempString).append("\n");
|
||||
sw860.append(tempString).append("\n");
|
||||
sw900.append(tempString).append("\n");
|
||||
// mdpi.append(tempString).append("\n");
|
||||
// hdpi.append(tempString).append("\n");
|
||||
// xhdpi.append(tempString).append("\n");
|
||||
// xxhdpi.append(tempString).append("\n");
|
||||
}
|
||||
line++;
|
||||
}
|
||||
reader.close();
|
||||
System.out.println("<!-- sw480 -->");
|
||||
System.out.println(sw480);
|
||||
System.out.println("<!-- sw600 -->");
|
||||
System.out.println(sw600);
|
||||
|
||||
System.out.println("<!-- sw720 -->");
|
||||
System.out.println(sw720);
|
||||
System.out.println("<!-- sw800 -->");
|
||||
System.out.println(sw800);
|
||||
|
||||
String sw320file = "./app/src/main/res/values-sw310dp/dimens.xml";
|
||||
String sw360file = "./app/src/main/res/values-sw350dp/dimens.xml";
|
||||
String sw400file = "./app/src/main/res/values-sw390dp/dimens.xml";
|
||||
String sw460file = "./app/src/main/res/values-sw450dp/dimens.xml";
|
||||
String sw480file = "./app/src/main/res/values-sw470dp/dimens.xml";
|
||||
String sw560file = "./app/src/main/res/values-sw550dp/dimens.xml";
|
||||
String sw600file = "./app/src/main/res/values-sw500dp/dimens.xml";
|
||||
String sw609file = "./app/src/main/res/values-sw609dp/dimens.xml";
|
||||
String sw640file = "./app/src/main/res/values-sw630dp/dimens.xml";
|
||||
String sw720file = "./app/src/main/res/values-sw710dp/dimens.xml";
|
||||
String sw760file = "./app/src/main/res/values-sw760dp/dimens.xml";
|
||||
String sw800file = "./app/src/main/res/values-sw800dp/dimens.xml";
|
||||
String sw860file = "./app/src/main/res/values-sw850dp/dimens.xml";
|
||||
String sw900file = "./app/src/main/res/values-sw890dp/dimens.xml";
|
||||
// String mdpifile = "./app/src/main/res/values-mdpi/dimens.xml";
|
||||
// String hdpifile = "./app/src/main/res/values-hdpi/dimens.xml";
|
||||
// String xhdpifile = "./app/src/main/res/values-xhdpi/dimens.xml";
|
||||
// String xxhdpifile = "./app/src/main/res/values-xxhdpi/dimens.xml";
|
||||
writeFile(sw320file, sw320.toString());
|
||||
writeFile(sw360file, sw360.toString());
|
||||
writeFile(sw400file, sw400.toString());
|
||||
writeFile(sw460file, sw460.toString());
|
||||
writeFile(sw480file, sw480.toString());
|
||||
writeFile(sw560file, sw560.toString());
|
||||
writeFile(sw600file, sw600.toString());
|
||||
|
||||
writeFile(sw609file, sw609.toString());
|
||||
|
||||
writeFile(sw640file, sw640.toString());
|
||||
writeFile(sw720file, sw720.toString());
|
||||
writeFile(sw760file, sw720.toString());
|
||||
writeFile(sw800file, sw800.toString());
|
||||
writeFile(sw860file, sw860.toString());
|
||||
writeFile(sw900file, sw900.toString());
|
||||
// writeFile(mdpifile, mdpi.toString());
|
||||
// writeFile(hdpifile, hdpi.toString());
|
||||
// writeFile(xhdpifile, xhdpi.toString());
|
||||
// writeFile(xxhdpifile, xxhdpi.toString());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeFile(String file, String text) {
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
File file1 = new File(file.replace("/dimens.xml","").trim());
|
||||
if (!file1.exists()) {
|
||||
file1.mkdirs();
|
||||
}
|
||||
out = new PrintWriter(new BufferedWriter(new FileWriter(file)));
|
||||
out.println(text);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
out.close();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
gen();
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class FileUtil {
|
||||
public static String getFileType(String url) {
|
||||
if (url.indexOf("/") == -1) {
|
||||
return url.substring(url.indexOf("."), url.length());
|
||||
} else {
|
||||
String fileName = url.substring(url.lastIndexOf("/"));
|
||||
return fileName.substring(fileName.indexOf("."), fileName.length());
|
||||
}
|
||||
}
|
||||
|
||||
private static HashSet<String> videoFormat = new HashSet<String>() {{
|
||||
this.add(".mp4");
|
||||
this.add(".avi");
|
||||
this.add(".nkv");
|
||||
this.add(".flv");
|
||||
}};
|
||||
private static HashSet<String> pictureFormat = new HashSet<String>() {{
|
||||
this.add(".png");
|
||||
this.add(".jpg");
|
||||
this.add(".jpeg");
|
||||
this.add(".bmp");
|
||||
}};
|
||||
|
||||
public static boolean isVideoFile(String fileName) {
|
||||
if (TextUtils.isEmpty(fileName)) {
|
||||
return false;
|
||||
} else {
|
||||
if (!fileName.startsWith(".")) {
|
||||
return videoFormat.contains(getFileType(fileName));
|
||||
} else {
|
||||
return videoFormat.contains(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPictureFile(String fileName) {
|
||||
if (TextUtils.isEmpty(fileName)) {
|
||||
return false;
|
||||
} else {
|
||||
if (!fileName.startsWith(".")) {
|
||||
return pictureFormat.contains(getFileType(fileName));
|
||||
} else {
|
||||
return pictureFormat.contains(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IconUtils {
|
||||
public static List<String> appClassNameList = new ArrayList<String>() {{
|
||||
this.add("com.uiui.sn");//设别信息
|
||||
this.add("com.uiui.appstore");//应用市场
|
||||
this.add("com.uiui.weather");//天气
|
||||
this.add("com.android.browser");//浏览器
|
||||
this.add("com.uiui.browser");//浏览器
|
||||
this.add("com.aoleyun.browser");//浏览器
|
||||
this.add("com.android.calculator2");//计算器
|
||||
this.add("com.android.calendar");//日历
|
||||
this.add("com.android.camera");//相机
|
||||
this.add("com.mediatek.camera");//相机
|
||||
this.add("com.android.camera2");//相机
|
||||
this.add("com.android.contacts");//通讯录
|
||||
this.add("com.android.deskclock");//时钟
|
||||
this.add("com.android.dialer");//电话
|
||||
this.add("com.android.dialer");//电话
|
||||
this.add("com.android.gallery3d");//图库
|
||||
this.add("com.android.mms");//信息
|
||||
this.add("com.android.mms.ui");//信息
|
||||
this.add("com.android.messaging");//信息
|
||||
this.add("com.android.music");//音乐
|
||||
this.add("com.android.providers.downloads.ui");//下载
|
||||
this.add("com.android.quicksearchbox");//搜索
|
||||
this.add("com.android.settings");//设置
|
||||
this.add("com.android.soundrecorder");//录音机
|
||||
this.add("com.android.stk.StkMain");//sim卡
|
||||
this.add("com.android.stk");//sim卡
|
||||
this.add("com.android.vdieo");//视频
|
||||
this.add("com.mediatek.filemanager");//文件管理
|
||||
this.add("com.android.documentsui");//下载
|
||||
this.add("com.mediatek.fmradio");//收音机
|
||||
this.add("com.android.fmradio");//收音机
|
||||
this.add("com.android.email");//电子邮件
|
||||
// this.add("com.ss.android.ugc.aweme");//抖音
|
||||
// this.add("com.ss.android.article.news");//头条
|
||||
// this.add("com.tencent.mm");//微信
|
||||
}};
|
||||
|
||||
public static List<String> appIconList = new ArrayList<String>() {{
|
||||
this.add("com_uiui_sn");
|
||||
this.add("com_android_appstore");
|
||||
this.add("com_uiui_weather");
|
||||
this.add("com_android_browser");
|
||||
this.add("com_android_browser");
|
||||
this.add("com_android_browser");
|
||||
this.add("com_android_calculator2");
|
||||
this.add("com_android_calendar");
|
||||
this.add("com_android_camera");
|
||||
this.add("com_android_camera");
|
||||
this.add("com_android_camera");
|
||||
this.add("com_android_contacts");
|
||||
this.add("com_android_deskclock");
|
||||
this.add("com_android_dialer");
|
||||
this.add("com_android_dialer");
|
||||
this.add("com_android_gallery3d_app");
|
||||
this.add("com_android_mms_ui");
|
||||
this.add("com_android_mms_ui");
|
||||
this.add("com_android_mms_ui");
|
||||
this.add("com_android_music");
|
||||
this.add("com_android_providers_downloads_ui");
|
||||
this.add("com_android_quicksearchbox");
|
||||
this.add("com_android_settings");
|
||||
this.add("com_android_soundrecorder");
|
||||
this.add("com_android_stk_stkmain");
|
||||
this.add("com_android_stk_stkmain");
|
||||
this.add("com_android_vdieo");
|
||||
this.add("com_mediatek_filemanager");
|
||||
this.add("com_mediatek_filemanager");
|
||||
this.add("com_mediatek_fmradio");
|
||||
this.add("com_mediatek_fmradio");//收音机
|
||||
this.add("com_android_email");
|
||||
// this.add("com_android_aweme2");
|
||||
// this.add("com_android_news2");
|
||||
// this.add("com_tencent_mm2");
|
||||
}};
|
||||
|
||||
public static List<String> appIconList2 = new ArrayList<String>() {{
|
||||
this.add("com_uiui_sn2");
|
||||
this.add("com_android_appstore2");
|
||||
this.add("com_uiui_weather2");
|
||||
this.add("com_android_browser2");
|
||||
this.add("com_android_browser2");
|
||||
this.add("com_android_browser2");
|
||||
this.add("com_android_calculator2");
|
||||
this.add("com_android_calendar");
|
||||
this.add("com_android_camera2");
|
||||
this.add("com_android_camera2");
|
||||
this.add("com_android_camera2");
|
||||
this.add("com_android_contacts");
|
||||
this.add("com_android_deskclock");
|
||||
this.add("com_android_dialer2");
|
||||
this.add("com_android_dialer2");
|
||||
this.add("com_android_gallery3d_app2");
|
||||
this.add("com_android_mms_ui2");
|
||||
this.add("com_android_mms_ui2");
|
||||
this.add("com_android_mms_ui2");
|
||||
this.add("com_android_music");
|
||||
this.add("com_android_providers_downloads_ui");
|
||||
this.add("com_android_quicksearchbox");
|
||||
this.add("com_android_settings2");
|
||||
this.add("com_android_soundrecorder");
|
||||
this.add("com_android_stk_stkmain");
|
||||
this.add("com_android_stk_stkmain");
|
||||
this.add("com_android_vdieo");
|
||||
this.add("com_mediatek_filemanager");
|
||||
this.add("com_mediatek_filemanager");
|
||||
this.add("com_mediatek_fmradio");
|
||||
this.add("com_mediatek_fmradio");//收音机
|
||||
this.add("com_android_email");
|
||||
this.add("com_android_aweme2");
|
||||
this.add("com_android_news2");
|
||||
this.add("com_tencent_mm2");
|
||||
}};
|
||||
|
||||
static {
|
||||
Log.e("IconUtils", "appClassNameList size: " + appClassNameList.size());
|
||||
Log.e("IconUtils", "appIconList size: " + appIconList.size());
|
||||
Log.e("IconUtils", "appIconList2 size: " + appIconList2.size());
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
import android.app.role.RoleManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Build;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class LauncherUtils {
|
||||
private static final String TAG = LauncherUtils.class.getSimpleName();
|
||||
|
||||
public static void openLauncher3(Context context) {
|
||||
setDefaultDesktop(context, Launcher3, Launcher3Class);
|
||||
if (!ApkUtils.openPackage(context, Launcher3)) {
|
||||
setDefaultDesktop(context, Launcher3, Launcher3Class);
|
||||
gotoLauncher(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static void gotoLauncher(Context context) {
|
||||
Intent i = new Intent(Intent.ACTION_MAIN);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //android123提示如果是服务里调用,必须加入new task标识
|
||||
i.addCategory(Intent.CATEGORY_HOME);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
public static final String Launcher3 = "com.android.launcher3";
|
||||
public static final String Launcher3Class = "com.android.launcher3.Launcher";
|
||||
|
||||
public static void setDefaultDesktop(Context context, String pkg, String className) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
setRoleHolderAsUser(context, pkg);
|
||||
Log.e(TAG, "setDefaultDesktop: setRoleHolderAsUser");
|
||||
} else {
|
||||
//爱华设置,暂时屏蔽
|
||||
// setDefaultLauncher(mContext, pkg, className);
|
||||
Log.e(TAG, "setDefaultDesktop: setDefaultLauncher");
|
||||
}
|
||||
// String oldDesktop = (String) SPUtils.get(mContext, "default_launcher", "");
|
||||
// if (Objects.equals(oldDesktop, pkg)) {
|
||||
// Log.e(TAG, "setDefaultDesktop: " + "数据一致");
|
||||
// return;
|
||||
// }
|
||||
Intent intent = new Intent("setDefaultLauncher");
|
||||
intent.putExtra("package", pkg);
|
||||
intent.putExtra("className", className);
|
||||
// if (JGYUtils.getInstance().checkAppPlatform() == MTKPlatform) {
|
||||
Log.e(TAG, "setDefaultDesktop: MTK");
|
||||
//爱华定制
|
||||
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.AoleReceiver"));
|
||||
// TODO: 2022/7/6 有问题
|
||||
setDefaultLauncher(context, "com.android.transfer", "com.android.transfer.MainActivity");
|
||||
SystemProperties.set("persist.sys.launcher.pkgname", pkg);
|
||||
SystemProperties.set("persist.sys.launcher.classname", className);
|
||||
// }
|
||||
intent.setPackage("com.android.settings");
|
||||
context.sendBroadcast(intent);
|
||||
// ApkUtils.openPackage(mContext, pkg);
|
||||
Log.e(TAG, "setDefaultDesktop: " + pkg + ":" + className);
|
||||
Log.e(TAG, "setDefaultDesktop: " + "persist.sys.launcher.pkgname = " + SystemProperties.get("persist.sys.launcher.pkgname"));
|
||||
Log.e(TAG, "setDefaultDesktop: " + "persist.sys.launcher.classname = " + SystemProperties.get("persist.sys.launcher.classname"));
|
||||
}
|
||||
|
||||
public static void setDefaultLauncher(Context context, String defPackageName, String defClassName) {
|
||||
try {
|
||||
if (!TextUtils.isEmpty(defPackageName) && !TextUtils.isEmpty(defClassName)) {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction("android.intent.action.MAIN");
|
||||
filter.addCategory("android.intent.category.HOME");
|
||||
filter.addCategory("android.intent.category.DEFAULT");
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
// 返回给定条件的所有ResolveInfo对象(本质上是Activity)
|
||||
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
int bestMatch = 0;
|
||||
final int size = list.size();
|
||||
ComponentName[] set = new ComponentName[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
ResolveInfo ri = list.get(i);
|
||||
set[i] = new ComponentName(ri.activityInfo.packageName, ri.activityInfo.name);
|
||||
if (ri.match > bestMatch) {
|
||||
bestMatch = ri.match;
|
||||
}
|
||||
}
|
||||
ComponentName preActivity = new ComponentName(defPackageName, defClassName);
|
||||
context.getPackageManager().addPreferredActivity(filter, bestMatch, set, preActivity);
|
||||
}
|
||||
} catch (java.lang.SecurityException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "setDefaultLauncher: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void setRoleHolderAsUser(Context context, String packageName) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
String roleName = "android.app.role.HOME";
|
||||
boolean add = true;
|
||||
int flags = 0;
|
||||
UserHandle user = android.os.Process.myUserHandle();
|
||||
Log.i("settingssssssstemf", (add ? "Adding" : "Removing") + " package as role holder, role: "
|
||||
+ roleName + ", package: " + packageName);
|
||||
// if (JGYUtils.getInstance().checkAppPlatform() != JGYUtils.MTKPlatform) {
|
||||
RoleManager roleManager = context.getSystemService(RoleManager.class);
|
||||
Executor executor = context.getMainExecutor();
|
||||
Consumer<Boolean> callback = successful -> {
|
||||
if (successful) {
|
||||
Log.d("settingssssssstemf", "Package " + (add ? "added" : "removed")
|
||||
+ " as role holder, role: " + roleName + ", package: " + packageName);
|
||||
} else {
|
||||
Log.d("settingssssssstemf", "Failed to " + (add ? "add" : "remove")
|
||||
+ " package as role holder, role: " + roleName + ", package: "
|
||||
+ packageName);
|
||||
}
|
||||
};
|
||||
roleManager.addRoleHolderAsUser(roleName, packageName, flags, user, executor, callback);
|
||||
Log.i("settingssssssstemf", "addRoleHolderAsUser done");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isDefaultHome(Context context) {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);//Intent.ACTION_VIEW
|
||||
intent.addCategory("android.intent.category.HOME");
|
||||
intent.addCategory("android.intent.category.DEFAULT");
|
||||
PackageManager pm = context.getPackageManager();
|
||||
ResolveInfo info = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
boolean isDefault = context.getPackageName().equals(info.activityInfo.packageName);
|
||||
return isDefault;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
public class SchemeUtils {
|
||||
private static String TAG = SchemeUtils.class.getSimpleName();
|
||||
|
||||
public static final String SCHEME_TONGUE = "uiuihealth://tongue";
|
||||
public static final String SCHEME_FACE = "uiuihealth://face";
|
||||
public static final String SCHEME_HAND = "uiuihealth://hand";
|
||||
|
||||
public static void openScheme(Activity context, String uri) {
|
||||
if (TextUtils.isEmpty(uri)) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "openScheme: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.util.Log;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
public class WakeUpUtils {
|
||||
|
||||
/**
|
||||
* 唤醒手机屏幕并解锁
|
||||
*/
|
||||
public static void wakeUpAndUnlock(Activity activity) {
|
||||
// 获取电源管理器对象
|
||||
PowerManager pm = (PowerManager) activity.getApplicationContext()
|
||||
.getSystemService(Context.POWER_SERVICE);
|
||||
boolean screenOn = pm.isScreenOn();
|
||||
Log.d("WakeScreen0", "screenOn: " + screenOn);
|
||||
if (!screenOn) {
|
||||
// 获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是LogCat里用的Tag
|
||||
@SuppressLint("InvalidWakeLockTag") PowerManager.WakeLock wl = pm.newWakeLock(
|
||||
PowerManager.ACQUIRE_CAUSES_WAKEUP |
|
||||
PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");
|
||||
wl.acquire(10000); // 点亮屏幕
|
||||
wl.release(); // 释放
|
||||
}
|
||||
// 屏幕解锁
|
||||
KeyguardManager keyguardManager = (KeyguardManager) activity.getApplicationContext()
|
||||
.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("unLock");
|
||||
// 屏幕锁定
|
||||
// keyguardLock.reenableKeyguard();
|
||||
keyguardLock.disableKeyguard(); // 解锁
|
||||
unLockScreen(activity);
|
||||
}
|
||||
|
||||
private static void unLockScreen(Activity activity) {
|
||||
final Window win = activity.getWindow();
|
||||
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
||||
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
|
||||
|
||||
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
|
||||
}
|
||||
|
||||
/**
|
||||
* 唤醒手机屏幕并解锁
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public static void wakeUpAndUnlockScreen(Activity activity) {
|
||||
|
||||
Window win = activity.getWindow();
|
||||
win.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
|
||||
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
||||
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
|
||||
|
||||
PowerManager pm = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
|
||||
@SuppressLint("InvalidWakeLockTag")
|
||||
PowerManager.WakeLock wakelock = pm.newWakeLock(
|
||||
PowerManager.FULL_WAKE_LOCK
|
||||
| PowerManager.ACQUIRE_CAUSES_WAKEUP, "xx");
|
||||
wakelock.acquire();
|
||||
wakelock.release();
|
||||
|
||||
KeyguardManager keyguardManager = (KeyguardManager) activity.getApplicationContext()
|
||||
.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
|
||||
if (activity == null) return;
|
||||
keyguardManager.requestDismissKeyguard(activity, new KeyguardManager.KeyguardDismissCallback() {
|
||||
@Override
|
||||
public void onDismissError() {
|
||||
super.onDismissError();
|
||||
Log.d("xxx-->", "1 onDismissError");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismissSucceeded() {
|
||||
super.onDismissSucceeded();
|
||||
Log.d("xxx-->", "1 onDismissSucceeded");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismissCancelled() {
|
||||
super.onDismissCancelled();
|
||||
Log.d("xxx-->", "1 onDismissCancelled");
|
||||
}
|
||||
});
|
||||
|
||||
if (activity == null) return;
|
||||
keyguardManager.requestDismissKeyguard(activity, new KeyguardManager.KeyguardDismissCallback() {
|
||||
@Override
|
||||
public void onDismissError() {
|
||||
super.onDismissError();
|
||||
Log.d("xxx-->", "2 onDismissError");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismissSucceeded() {
|
||||
super.onDismissSucceeded();
|
||||
Log.d("xxx-->", "2 onDismissSucceeded");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismissCancelled() {
|
||||
super.onDismissCancelled();
|
||||
Log.d("xxx-->", "2 onDismissCancelled");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user