version:1.5

fix:
update:增加天气预报详情,增加系统应用模块
This commit is contained in:
2022-01-22 11:53:16 +08:00
parent be302d67e2
commit 2e9b26b100
243 changed files with 1724 additions and 238 deletions

View File

@@ -29,9 +29,71 @@ public class APKUtils {
this.add("com.sprd.sprdnote");
this.add("com.android.deskclock");
this.add("com.alldocube.store");
this.add("com.android.uiuios");
}};
private static HashSet<String> showPackageName = new HashSet<String>() {{
this.add("com.android.dialer");
this.add("com.android.gallery3d");
this.add("com.android.settings");
this.add("com.android.messaging");
this.add("com.android.camera2");
}};
private static String TAG = APKUtils.class.getSimpleName();
public static ArrayList<ApplicationInfo> getSystemApp(Context context) {
PackageManager pm = context.getPackageManager();
// 查询所有已经安装的应用程序
List<ApplicationInfo> appInfos = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);// GET_UNINSTALLED_PACKAGES代表已删除但还有安装目录的
ArrayList<ApplicationInfo> applicationInfos = new ArrayList<>();
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
// 通过getPackageManager()的queryIntentActivities方法遍历,得到所有能打开的app的packageName
List<ResolveInfo> resolveinfoList = pm.queryIntentActivities(resolveIntent, 0);
Set<String> allowPackages = new HashSet();
for (ResolveInfo resolveInfo : resolveinfoList) {
Log.i(TAG, "queryFilterAppInfo: " + resolveInfo.activityInfo.packageName);
allowPackages.add(resolveInfo.activityInfo.packageName);
}
for (ApplicationInfo app : appInfos) {
if ((app.flags & ApplicationInfo.FLAG_SYSTEM) > 0)//通过flag排除系统应用会将电话、短信也排除掉
{
if (allowPackages.contains(app.packageName) && !showPackageName.contains(app.packageName)) {
applicationInfos.add(app);
}
} else {
// if(app.uid > 10000){//通过uid排除系统应用在一些手机上效果不好
// applicationInfos.add(app);
// }
// if (allowPackages.contains(app.packageName) && !excludePackageName.contains(app.packageName)) {
//// if (allowPackages.contains(app.packageName)) {
// applicationInfos.add(app);
// }
}
}
applicationInfos.sort(new Comparator<ApplicationInfo>() {
@Override
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
return Collator.getInstance(Locale.CHINESE).compare(o1.loadLabel(pm).toString(), o2.loadLabel(pm).toString());
// return o1.loadLabel(pm).toString().compareTo(o2.loadLabel(pm).toString());
}
});
applicationInfos.sort(new Comparator<ApplicationInfo>() {
@Override
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
if ((o1.flags & ApplicationInfo.FLAG_SYSTEM) <= (o2.flags & ApplicationInfo.FLAG_SYSTEM)) {
return 1;
} else {
return -1;
}
}
});
return applicationInfos;
}
public static ArrayList<ApplicationInfo> queryFilterAppInfo(Context context) {
PackageManager pm = context.getPackageManager();
@@ -52,22 +114,25 @@ public class APKUtils {
}
for (ApplicationInfo app : appInfos) {
// if((app.flags & ApplicationInfo.FLAG_SYSTEM) <= 0)//通过flag排除系统应用会将电话、短信也排除掉
// {
// applicationInfos.add(app);
// }
if ((app.flags & ApplicationInfo.FLAG_SYSTEM) > 0)//通过flag排除系统应用会将电话、短信也排除掉
{
if (showPackageName.contains(app.packageName)) {
applicationInfos.add(app);
}
} else {
// if(app.uid > 10000){//通过uid排除系统应用在一些手机上效果不好
// applicationInfos.add(app);
// }
if (allowPackages.contains(app.packageName) && !excludePackageName.contains(app.packageName)) {
if (allowPackages.contains(app.packageName) && !excludePackageName.contains(app.packageName)) {
// if (allowPackages.contains(app.packageName)) {
applicationInfos.add(app);
applicationInfos.add(app);
}
}
}
applicationInfos.sort(new Comparator<ApplicationInfo>() {
@Override
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
return Collator.getInstance(Locale.CHINESE).compare(o1.loadLabel(pm).toString(),o2.loadLabel(pm).toString());
return Collator.getInstance(Locale.CHINESE).compare(o1.loadLabel(pm).toString(), o2.loadLabel(pm).toString());
// return o1.loadLabel(pm).toString().compareTo(o2.loadLabel(pm).toString());
}
});

View File

@@ -1,5 +1,6 @@
package com.uiui.os.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
@@ -7,12 +8,22 @@ import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.tencent.mmkv.MMKV;
import java.lang.reflect.Type;
public class AmapManager {
private String TAG = AmapManager.class.getSimpleName();
private static final String AMAPLOCATION_JSON_KEY = "AMAPLOCATION_JSON_STRING";
@SuppressLint("StaticFieldLeak")
private static AmapManager sInstance;
private Context mContext;
public static AMapLocationClient locationClient = null;
private String TAG = AmapManager.class.getSimpleName();
private MMKV mMMKV = MMKV.defaultMMKV();
private AMapLocationClient locationClient = null;
private AMapLocation nowAMapLocation;
private AmapManager(Context context) {
this.mContext = context;
@@ -22,7 +33,6 @@ public class AmapManager {
if (sInstance == null) {
sInstance = new AmapManager(context);
}
}
public static AmapManager getInstance() {
@@ -57,7 +67,6 @@ public class AmapManager {
//设置定位模式为AMapLocationMode.Hight_Accuracy高精度模式。
//设置定位监听
locationClient.setLocationListener(new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
//errCode等于0代表定位成功其他的为定位失败具体的可以参照官网定位错误码说明
@@ -75,4 +84,45 @@ public class AmapManager {
locationClient.startLocation();
Log.e(TAG, "initAmap: " + "startLocation");
}
public AMapLocation getNowAMapLocation() {
if (nowAMapLocation == null) {
String aMapLocationjson = mMMKV.decodeString(AMAPLOCATION_JSON_KEY, "");
Type type = new TypeToken<AMapLocation>() {
}.getType();
AMapLocation aMapLocation = new Gson().fromJson(aMapLocationjson, type);
return aMapLocation;
}
return this.nowAMapLocation;
}
public void startLocation(AMapLocationListener aMapLocationListener) {
initAmap();
locationClient.stopLocation();
locationClient.startLocation();
locationClient.setLocationListener(new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
Log.e(TAG, "onLocationChanged: " + aMapLocation.toStr());
if (aMapLocation.getErrorCode() == 0) {
nowAMapLocation = aMapLocation;
mMMKV.encode(AMAPLOCATION_JSON_KEY, aMapLocation.toStr());
} else {
mMMKV.encode(AMAPLOCATION_JSON_KEY, "");
}
aMapLocationListener.onLocationChanged(aMapLocation);
}
});
}
public String getLocation() {
AMapLocation aMapLocation = getNowAMapLocation();
if (aMapLocation == null) {
return "0,0";
} else {
String location = aMapLocation.getLongitude() + "," + aMapLocation.getLatitude();
Log.e(TAG, "getLocation: " + location);
return location;
}
}
}

View File

@@ -11,12 +11,14 @@ public class IconUtils {
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");//音乐
@@ -25,6 +27,7 @@ public class IconUtils {
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");//下载
@@ -40,6 +43,7 @@ public class IconUtils {
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");
@@ -47,12 +51,14 @@ public class IconUtils {
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");

View File

@@ -0,0 +1,32 @@
package com.uiui.os.utils;
import android.content.Context;
import android.content.res.Resources;
public class ScreenUtils {
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
public static int dip2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
/**
* 根据手机的分辨率从 px(像素) 的单位 转成为 dp
*/
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
public static int dp2px(Resources resources, float dp) {
final float scale = resources.getDisplayMetrics().density;
return (int) (dp * scale + 0.5f);
}
public static int sp2px(Resources resources, float sp) {
final float scale = resources.getDisplayMetrics().scaledDensity;
return (int) (sp * scale);
}
}