version:1.5
fix: update:基本功能对接完成
This commit is contained in:
@@ -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