version:1.7.9
fix:修复竖屏报错 update:增加客服,适配不同版本ai精准学
This commit is contained in:
90
app/src/main/java/com/uiui/zyos/utils/ActivationUtil.java
Normal file
90
app/src/main/java/com/uiui/zyos/utils/ActivationUtil.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.uiui.zyos.config.CommonConfig;
|
||||
|
||||
public class ActivationUtil {
|
||||
|
||||
/*写入1为激活*/
|
||||
private static final int ACTIVATED_KEY = 1;
|
||||
private static final int INACTIVATED_KEY = 0;
|
||||
/*默认激活码类型*/
|
||||
private static final int DEFAULT_CODE_TYPE = -1;
|
||||
/*默认过期时间*/
|
||||
private static final int DEFAULT_EXPIRE_TIME = -1;
|
||||
|
||||
|
||||
/**
|
||||
* 获取激活状态
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static int getActivationStateCode(Context context) {
|
||||
int activation = Settings.Global.getInt(context.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, INACTIVATED_KEY);
|
||||
return activation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否激活
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static boolean isActivation(Context context) {
|
||||
return getActivationStateCode(context) == ACTIVATED_KEY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置激活状态
|
||||
*
|
||||
* @param context
|
||||
* @param code
|
||||
*/
|
||||
public static void setActivation(Context context, int code) {
|
||||
Settings.Global.putInt(context.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置激活码类型
|
||||
*
|
||||
* @param context
|
||||
* @param code
|
||||
*/
|
||||
public static void setActivationCodeType(Context context, int code) {
|
||||
Settings.Global.putInt(context.getContentResolver(), CommonConfig.UIUI_CODE_TYPE_KEY, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取激活码类型
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static int getActivationCodeType(Context context) {
|
||||
return Settings.Global.getInt(context.getContentResolver(), CommonConfig.UIUI_CODE_TYPE_KEY, DEFAULT_CODE_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置过期时间
|
||||
*
|
||||
* @param context
|
||||
* @param expireTime
|
||||
*/
|
||||
public static void setActivationExpireTime(Context context, long expireTime) {
|
||||
Settings.Global.putLong(context.getContentResolver(), CommonConfig.UIUI_EXPIRE_TIME_KEY, expireTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取过期时间
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static long getActivationExpireTime(Context context) {
|
||||
return Settings.Global.getLong(context.getContentResolver(), CommonConfig.UIUI_EXPIRE_TIME_KEY, DEFAULT_EXPIRE_TIME);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,12 +5,16 @@ import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.zyos.bean.LessonJson;
|
||||
import com.uiui.zyos.config.CommonConfig;
|
||||
@@ -61,14 +65,14 @@ public class OpenApkUtils {
|
||||
int is_activation = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0);
|
||||
if (is_activation != 1) {
|
||||
ApkUtils.openPackage(mContext, "com.uiui.zy", "com.uiui.zy.activity.main.MainActivity");
|
||||
ToastUtil.show("请激活设备后使用");
|
||||
Toaster.show("请激活设备后使用");
|
||||
}
|
||||
return is_activation == 1;
|
||||
}
|
||||
|
||||
public boolean openPackageWithArgs(String packageName, String className, String name, String args) {
|
||||
if (!ApkUtils.isAvailable(mContext, packageName)) {
|
||||
ToastUtil.show("应用未安装");
|
||||
Toaster.show("应用未安装");
|
||||
return false;
|
||||
}
|
||||
ComponentName cn = new ComponentName(packageName, className);
|
||||
@@ -181,35 +185,35 @@ public class OpenApkUtils {
|
||||
}};
|
||||
|
||||
private void sendRuningApp(String packageName) {
|
||||
AppUsedTimeUtils.getInstance().setAppPackageName(packageName);
|
||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
AppUsedTimeUtils.getInstance().sendRunningApp(() -> {
|
||||
});
|
||||
// AppUsedTimeUtils.getInstance().setAppPackageName(packageName);
|
||||
// AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
// AppUsedTimeUtils.getInstance().sendRunningApp(() -> {
|
||||
// });
|
||||
}
|
||||
|
||||
public void openApp(String packageName) {
|
||||
if (!ApkUtils.isAvailable(mContext, packageName)) {
|
||||
ToastUtil.show("应用未安装");
|
||||
Toaster.show("应用未安装");
|
||||
return;
|
||||
}
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
ApkUtils.openPackage(mContext, packageName);
|
||||
sendRuningApp(packageName);
|
||||
} else {
|
||||
ToastUtil.show("专注模式只允许使用指定应用");
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
public void openApp(String packageName, String className) {
|
||||
if (!ApkUtils.isAvailable(mContext, packageName)) {
|
||||
ToastUtil.show("应用未安装");
|
||||
Toaster.show("应用未安装");
|
||||
return;
|
||||
}
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
ApkUtils.openPackage(mContext, packageName, className);
|
||||
sendRuningApp(packageName);
|
||||
} else {
|
||||
ToastUtil.show("专注模式只允许使用指定应用");
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +228,7 @@ public class OpenApkUtils {
|
||||
sendRuningApp(packageName);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show("专注模式只允许使用指定应用");
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +243,7 @@ public class OpenApkUtils {
|
||||
sendRuningApp(packageName);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show("专注模式只允许使用指定应用");
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +258,7 @@ public class OpenApkUtils {
|
||||
sendRuningApp(packageName);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show("专注模式只允许使用指定应用");
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +273,7 @@ public class OpenApkUtils {
|
||||
sendRuningApp(packageName);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show("专注模式只允许使用指定应用");
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,9 +286,35 @@ public class OpenApkUtils {
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
if (openPackageWithArgs(packageName, className, "StartArgs", "中华文化")) {
|
||||
sendRuningApp(packageName);
|
||||
} else {
|
||||
Toaster.show("打开失败:应用未安装");
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show("专注模式只允许使用指定应用");
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNewAiApp() {
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
PackageInfo packageInfo = null;
|
||||
try {
|
||||
packageInfo = pm.getPackageInfo(JxwPackageConfig.JXW_PRECISION_PACKAGE_NAME, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (packageInfo == null) {
|
||||
return false;
|
||||
}
|
||||
long appVersionCode;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
appVersionCode = packageInfo.getLongVersionCode();
|
||||
} else {
|
||||
appVersionCode = packageInfo.versionCode;
|
||||
}
|
||||
if (appVersionCode == 85) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,16 +323,79 @@ public class OpenApkUtils {
|
||||
return;
|
||||
}
|
||||
String packageName = JxwPackageConfig.JXW_PRECISION_PACKAGE_NAME;
|
||||
String className = JxwPackageConfig.JXW_PRECISION_CLASS_NAME;
|
||||
String className = JxwPackageConfig.JXW_PRECISION_CLASS_NAME_85;
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
if (openPackageWithArgs(packageName, className, "tiku_func_type", args)) {
|
||||
sendRuningApp(packageName);
|
||||
} else {
|
||||
Toaster.show("打开失败:应用未安装");
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show("专注模式只允许使用指定应用");
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
public void openAiPrecision(int page, String subject) {
|
||||
if (!checkActivation()) {
|
||||
return;
|
||||
}
|
||||
String packageName = JxwPackageConfig.JXW_PRECISION_PACKAGE_NAME;
|
||||
String className = JxwPackageConfig.JXW_PRECISION_CLASS_NAME_1;
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
if (openAiWithArgs(packageName, className, page, subject)) {
|
||||
sendRuningApp(packageName);
|
||||
} else {
|
||||
Toaster.show("打开失败:应用未安装");
|
||||
}
|
||||
} else {
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static final String NAME_PRIMARY_SCHOOL = "小学";
|
||||
public static final String NAME_MIDDLE_SCHOOL = "初中";
|
||||
public static final String NAME_HIGH_SCHOOL = "高中";
|
||||
|
||||
/**
|
||||
* page_navigate 写死传0
|
||||
* appoint_subject_list 不需要传
|
||||
* appoint_period_name 这个是学段,一定要传 ,
|
||||
* <p>
|
||||
* public static final String NAME_PRIMARY_SCHOOL = "小学";
|
||||
* public static final String NAME_MIDDLE_SCHOOL = "初中";
|
||||
* public static final String NAME_HIGH_SCHOOL = "高中";
|
||||
* <p>
|
||||
* appoint_period_name字段的值是上面这三个之一
|
||||
*
|
||||
* @param packageName
|
||||
* @param className
|
||||
* @param page
|
||||
* @param subject
|
||||
* @return
|
||||
*/
|
||||
public boolean openAiWithArgs(String packageName, String className, int page, String subject) {
|
||||
if (!ApkUtils.isAvailable(mContext, packageName)) {
|
||||
Toaster.show("应用未安装");
|
||||
return false;
|
||||
}
|
||||
ComponentName cn = new ComponentName(packageName, className);
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(cn);
|
||||
intent.putExtra("page_navigate", page);
|
||||
intent.putExtra("appoint_subject_name", subject);
|
||||
intent.putExtra("appoint_period_name", NAME_HIGH_SCHOOL);
|
||||
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 openAppWithoutArgs(String packageName, String className) {
|
||||
if (!checkActivation()) {
|
||||
return;
|
||||
@@ -310,7 +403,7 @@ public class OpenApkUtils {
|
||||
if (isCloudLessonMod(packageName)) {
|
||||
openApp(packageName, className);
|
||||
} else {
|
||||
ToastUtil.show("专注模式只允许使用指定应用");
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +418,7 @@ public class OpenApkUtils {
|
||||
sendRuningApp(packageName);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show("专注模式只允许使用指定应用");
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,13 +433,13 @@ public class OpenApkUtils {
|
||||
sendRuningApp(packageName);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show("专注模式只允许使用指定应用");
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean openLetterApp(String packageName, String className) {
|
||||
if (!ApkUtils.isAvailable(mContext, packageName)) {
|
||||
ToastUtil.show("应用未安装");
|
||||
Toaster.show("应用未安装");
|
||||
return false;
|
||||
}
|
||||
ComponentName cn = new ComponentName(packageName, className);
|
||||
@@ -377,7 +470,7 @@ public class OpenApkUtils {
|
||||
sendRuningApp(packageName);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show("专注模式只允许使用指定应用");
|
||||
Toaster.show("专注模式只允许使用指定应用");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.uiui.zyos.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.uiui.zyos.BuildConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Created by haoge on 2017/3/2.
|
||||
*/
|
||||
|
||||
public class ToastUtil {
|
||||
private static final String TAG = ToastUtil.class.getSimpleName();
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Context mContext;
|
||||
private static Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
private static Toast debugToast;
|
||||
private static Toast toast;
|
||||
|
||||
|
||||
@SuppressLint("ShowToast")
|
||||
public static void init(Context context) {
|
||||
mContext = context;
|
||||
toast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
|
||||
debugToast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
|
||||
|
||||
}
|
||||
|
||||
private static long time1 = 0L;
|
||||
private static long time2 = 0L;
|
||||
|
||||
public static void show(final String msg) {
|
||||
ToastUtils.make()
|
||||
// .setBgColor(ColorUtils.getColor(R.color.toast_color))
|
||||
.setTextColor(Color.DKGRAY)
|
||||
// .setGravity(Gravity.CENTER, 0, 0)
|
||||
.setNotUseSystemToast()
|
||||
.show(msg);
|
||||
}
|
||||
|
||||
public static void betaShow(final String msg) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
ToastUtils.make()
|
||||
// .setBgColor(ColorUtils.getColor(R.color.toast_color))
|
||||
.setTextColor(Color.RED)
|
||||
// .setGravity(Gravity.CENTER, 0, 0)
|
||||
.setNotUseSystemToast()
|
||||
.setDurationIsLong(true)
|
||||
.show(msg);
|
||||
} else {
|
||||
Log.e(TAG, "debugShow: " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
private static Toast mToast = null;
|
||||
|
||||
//android 8.0以后限制
|
||||
//https://www.jianshu.com/p/d9813ad03d59
|
||||
//https://www.jianshu.com/p/050ce052b873
|
||||
public static void showToast(Context context, String text, int duration) {
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.P) {
|
||||
Toast.makeText(context, text, duration).show();
|
||||
} else {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, text, duration);
|
||||
} else {
|
||||
mToast.setText(text);
|
||||
mToast.setDuration(duration);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
// public static void showInCenter(String msg) {
|
||||
// mainHandler.post(() -> {
|
||||
// if (toast != null) {
|
||||
// toast.setGravity(Gravity.CENTER, 0, 0);
|
||||
// toast.setText(msg);
|
||||
// toast.show();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user