version:1.5
fix: update:基本功能对接完成
This commit is contained in:
@@ -63,6 +63,7 @@ public class ApkUtils {
|
||||
this.add("com.joytv.live");
|
||||
this.add("com.iflytek.speechcloud");
|
||||
this.add("com.safe.uiui");
|
||||
this.add("com.uiui.aios");
|
||||
}};
|
||||
|
||||
private static HashSet<String> excludeClassName = new HashSet<String>() {{
|
||||
|
||||
72
app/src/main/java/com/uiui/zyos/utils/BitmapUtils.java
Normal file
72
app/src/main/java/com/uiui/zyos/utils/BitmapUtils.java
Normal file
@@ -0,0 +1,72 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
128
app/src/main/java/com/uiui/zyos/utils/IconUtils.java
Normal file
128
app/src/main/java/com/uiui/zyos/utils/IconUtils.java
Normal file
@@ -0,0 +1,128 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -23,18 +24,18 @@ public class OpenApkUtils {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static OpenApkUtils sInstance;
|
||||
private Context mContext;
|
||||
private ContentResolver resolver;
|
||||
private ContentResolver mResolver;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private LessonJson mLessonJson;
|
||||
TimeUtils.ContralTime mContralTime;
|
||||
private TimeUtils.ContralTime mContralTime;
|
||||
|
||||
private OpenApkUtils(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
this.mContext = context;
|
||||
this.resolver = context.getContentResolver();
|
||||
this.mResolver = context.getContentResolver();
|
||||
refresh();
|
||||
}
|
||||
|
||||
@@ -51,6 +52,15 @@ public class OpenApkUtils {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private boolean checkActivation() {
|
||||
int is_activation = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0);
|
||||
if (is_activation != 1) {
|
||||
ApkUtils.openPackage(mContext, "com.uiui.zysn");
|
||||
ToastUtil.show("请激活设备后使用");
|
||||
}
|
||||
return is_activation == 1;
|
||||
}
|
||||
|
||||
public boolean openPackageWithArgs(String packageName, String className, String name, String args) {
|
||||
if (!ApkUtils.isAvailable(mContext, packageName)) {
|
||||
ToastUtil.show("应用未安装");
|
||||
@@ -88,7 +98,13 @@ public class OpenApkUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pkg
|
||||
* @return true为能打开
|
||||
*/
|
||||
public boolean isCloudLessonMod(String pkg) {
|
||||
if (mLessonJson==null)
|
||||
return true;
|
||||
if (mLessonJson.getIs_lesson() == 1) {
|
||||
if (mContralTime == null) {
|
||||
return false;
|
||||
@@ -140,6 +156,9 @@ public class OpenApkUtils {
|
||||
|
||||
|
||||
public void openSyncVideo(String args) {
|
||||
if (!checkActivation()) {
|
||||
return;
|
||||
}
|
||||
String packageName = JxwPackageConfig.JXW_VIDEO_PACKAGE_NAME;
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
if (openPackageWithArgs(packageName, JxwPackageConfig.JXW_VIDEO_CLASS_NAME, "StartArgs", args)) {
|
||||
@@ -151,6 +170,9 @@ public class OpenApkUtils {
|
||||
}
|
||||
|
||||
public void openSynchronousTutoring(String args) {
|
||||
if (!checkActivation()) {
|
||||
return;
|
||||
}
|
||||
String packageName = JxwPackageConfig.JXW_TUTORING_PACKAGE_NAME;
|
||||
String className = JxwPackageConfig.JXW_TUTORING_CLASS_NAME;
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
@@ -163,6 +185,9 @@ public class OpenApkUtils {
|
||||
}
|
||||
|
||||
public void openSolidifiedData(String args) {
|
||||
if (!checkActivation()) {
|
||||
return;
|
||||
}
|
||||
String packageName = JxwPackageConfig.JXW_TUTORING_PACKAGE_NAME;
|
||||
String className = JxwPackageConfig.JXW_RHETORIC_CLASS_NAME;
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
@@ -175,6 +200,9 @@ public class OpenApkUtils {
|
||||
}
|
||||
|
||||
public void openComposition() {
|
||||
if (!checkActivation()) {
|
||||
return;
|
||||
}
|
||||
String packageName = JxwPackageConfig.JXW_VIDEO_PACKAGE_NAME;
|
||||
String className = JxwPackageConfig.JXW_COMPOSITION_CLASS_NAME;
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
@@ -187,6 +215,9 @@ public class OpenApkUtils {
|
||||
}
|
||||
|
||||
public void openQuality() {
|
||||
if (!checkActivation()) {
|
||||
return;
|
||||
}
|
||||
String packageName = JxwPackageConfig.JXW_VIDEO_PACKAGE_NAME;
|
||||
String className = JxwPackageConfig.JXW_Quality_CLASS_NAME;
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
@@ -199,6 +230,9 @@ public class OpenApkUtils {
|
||||
}
|
||||
|
||||
public void openPrecision(String args) {
|
||||
if (!checkActivation()) {
|
||||
return;
|
||||
}
|
||||
String packageName = JxwPackageConfig.JXW_PRECISION_PACKAGE_NAME;
|
||||
String className = JxwPackageConfig.JXW_PRECISION_CLASS_NAME;
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
@@ -211,6 +245,9 @@ public class OpenApkUtils {
|
||||
}
|
||||
|
||||
public void openAppWithoutArgs(String packageName, String className) {
|
||||
if (!checkActivation()) {
|
||||
return;
|
||||
}
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
openApp(packageName, className);
|
||||
} else {
|
||||
@@ -219,8 +256,11 @@ public class OpenApkUtils {
|
||||
}
|
||||
|
||||
public void openLaboratory(String args) {
|
||||
String packageName = JxwPackageConfig.JXW_laboratory_PACKAGE_NAME;
|
||||
String className = JxwPackageConfig.JXW_laboratory_CLASS_NAME;
|
||||
if (!checkActivation()) {
|
||||
return;
|
||||
}
|
||||
String packageName = JxwPackageConfig.JXW_LABORATORY_PACKAGE_NAME;
|
||||
String className = JxwPackageConfig.JXW_LABORATORY_CLASS_NAME;
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
if (openPackageWithArgs(packageName, className, "StartArgs", args)) {
|
||||
sendRuningApp(packageName);
|
||||
@@ -229,4 +269,57 @@ public class OpenApkUtils {
|
||||
ToastUtil.show("网课模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
public void openLetter() {
|
||||
if (!checkActivation()) {
|
||||
return;
|
||||
}
|
||||
String packageName = JxwPackageConfig.JXW_LETTER_PACKAGE_NAME;
|
||||
String className = JxwPackageConfig.JXW_LETTER_CLASS_NAME;
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
if (openLetterApp(packageName, className)) {
|
||||
sendRuningApp(packageName);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show("网课模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean openLetterApp(String packageName, String className) {
|
||||
if (!ApkUtils.isAvailable(mContext, packageName)) {
|
||||
ToastUtil.show("应用未安装");
|
||||
return false;
|
||||
}
|
||||
ComponentName cn = new ComponentName(packageName, className);
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(cn);
|
||||
intent.putExtra("isTopic", true);
|
||||
intent.putExtra("isYYGJ", true);
|
||||
intent.putExtra("url", "http://api4.jiumentongbu.com/api/jwfd/baseapp/url?filePath=专区数据/英语广角/幼儿启蒙/ABC字母/menu.json");
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
try {
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "openPackageWithArgs: " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void openChineseWriting() {
|
||||
if (!checkActivation()) {
|
||||
return;
|
||||
}
|
||||
String packageName = JxwPackageConfig.JXW_LABORATORY_PACKAGE_NAME;
|
||||
String className = JxwPackageConfig.JXW_writing_CLASS_NAME;
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
if (openPackageWithArgs(packageName, className, "StartArgs", "小学")) {
|
||||
sendRuningApp(packageName);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show("网课模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user