version:1.0.5
fix: update:资源替换,跳转优化
This commit is contained in:
@@ -17,6 +17,7 @@ import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -52,6 +53,7 @@ import com.xwad.os.jxw.JxwPackageConfig;
|
||||
import com.xwad.os.jxw.SPUtils;
|
||||
import com.xwad.os.jxw.StudyRecordAPKInfo;
|
||||
import com.xwad.os.jxw.TabAdapter;
|
||||
import com.xwad.os.jxw.event.UpdateColorEvent;
|
||||
import com.xwad.os.jxw.util.Util;
|
||||
import com.xwad.os.jxw.event.UpdateGradeEvent;
|
||||
import com.xwad.os.jxw.fragment.SztzFragment;
|
||||
@@ -109,6 +111,8 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
setWallpaper();
|
||||
|
||||
startActivity(new Intent(HomeActivity.this, LoginActivity.class));
|
||||
RemoteManager.setListener(this);
|
||||
Utils.getAndroiodScreenProperty(this);
|
||||
@@ -182,6 +186,27 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
initDatas();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGkNoticeEvent(UpdateColorEvent updateColorEvent) {
|
||||
mViewDataBinding.llMain.setBackgroundResource(getResources().getIdentifier("img_home_bg_" + SPUtils.getInt(this, "themenBg", 0), "drawable", getPackageName()));
|
||||
}
|
||||
|
||||
private void setWallpaper() {
|
||||
// List<Integer> arrayList = new ArrayList<Integer>() {{
|
||||
// this.add(R.drawable.icon_bz_0);
|
||||
// this.add(R.drawable.icon_bz_1);
|
||||
// this.add(R.drawable.icon_bz_2);
|
||||
// this.add(R.drawable.icon_bz_3);
|
||||
// this.add(R.drawable.icon_bz_4);
|
||||
// this.add(R.drawable.icon_bz_5);
|
||||
// this.add(R.drawable.icon_bz_6);
|
||||
// this.add(R.drawable.icon_bz_7);
|
||||
// this.add(R.drawable.icon_bz_8);
|
||||
// }};
|
||||
mViewDataBinding.llMain.setBackgroundResource(getResources().getIdentifier("img_home_bg_" + SPUtils.getInt(this, "themenBg", 0), "drawable", getPackageName()));
|
||||
|
||||
}
|
||||
|
||||
private void initDatas() {
|
||||
Log.e(TAG, "initDatas: ");
|
||||
mViewDataBinding.tvTime.setText(DataUtil.formatDateHour());
|
||||
@@ -210,7 +235,7 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
// if ("小学".equals(Util.checkGrade(SPUtils.getGrade()))) {
|
||||
tabBeanLists.add(new TabBean("素养课", R.drawable.icon_tab_syk, R.drawable.icon_tab_syk_pre));
|
||||
// }
|
||||
tabBeanLists.add(new TabBean("绿色安全", R.drawable.icon_tab_lsaq, R.drawable.icon_tab_lsaq_pre));
|
||||
tabBeanLists.add(new TabBean("应用", R.drawable.icon_tab_app, R.drawable.icon_tab_app));
|
||||
|
||||
tabAdapter.setData(tabBeanLists);
|
||||
tabAdapter.setChoosePosition(defaultCurrent);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SelecteGradeActivity extends BaseMvvmActivity<SelecteGradeViewModel
|
||||
public void initView() {
|
||||
grade = mMMKV.decodeString(CommonConfig.UIUI_USER_GRADE_KEY, "七年级");
|
||||
|
||||
for (int i = 1; i < 13; i++) {
|
||||
for (int i = 1; i <= 13; i++) {
|
||||
int viewId = getResources().getIdentifier("radioButton" + i, "id", getPackageName());
|
||||
RadioButton radioButton = findViewById(viewId);
|
||||
if (grade.equals(radioButton.getText().toString())) {
|
||||
@@ -101,6 +101,10 @@ public class SelecteGradeActivity extends BaseMvvmActivity<SelecteGradeViewModel
|
||||
if (b) setPrimary2(compoundButton);
|
||||
});
|
||||
|
||||
mViewDataBinding.radioButton13.setOnCheckedChangeListener((compoundButton, b) -> {
|
||||
if (b) setJuniorHighSchool(compoundButton);
|
||||
});
|
||||
|
||||
mViewDataBinding.radioButton7.setOnCheckedChangeListener((compoundButton, b) -> {
|
||||
if (b) setJuniorHighSchool(compoundButton);
|
||||
});
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.xwad.os.fragment.mine;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -15,6 +19,7 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.xwad.os.BuildConfig;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.activity.activation.ActivationActivity;
|
||||
import com.xwad.os.activity.home.HomeActivity;
|
||||
@@ -44,6 +49,9 @@ import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
@@ -326,6 +334,30 @@ public class MineFragment extends BaseMvvmFragment<MineViewModel, FragmentMineBi
|
||||
}
|
||||
}
|
||||
|
||||
private List<ComponentName> getAllLauncherApps(Context context) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
|
||||
// 构建用于查询桌面应用的Intent
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
|
||||
// 查询所有可以处理该Intent的Activity
|
||||
List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(intent, PackageManager.MATCH_ALL);
|
||||
|
||||
List<ComponentName> launcherPackageList = resolveInfoList.stream().filter(new Predicate<ResolveInfo>() {
|
||||
@Override
|
||||
public boolean test(ResolveInfo resolveInfo) {
|
||||
return !BuildConfig.APPLICATION_ID.equals(resolveInfo.activityInfo.packageName);
|
||||
}
|
||||
}).map(new Function<ResolveInfo, ComponentName>() {
|
||||
@Override
|
||||
public ComponentName apply(ResolveInfo resolveInfo) {
|
||||
return resolveInfo.getComponentInfo().getComponentName();
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return launcherPackageList;
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
public void toLigin(View view) {
|
||||
@@ -342,5 +374,24 @@ public class MineFragment extends BaseMvvmFragment<MineViewModel, FragmentMineBi
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void exit(View view) {
|
||||
Log.e(TAG, "exit: " + getAllLauncherApps(mContext));
|
||||
ComponentName componentName = new ComponentName("com.hihonor.android.launcher", "com.hihonor.android.launcher.unihome.UniHomeLauncher");
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(componentName);
|
||||
mContext.startActivity(intent);
|
||||
startActivity(new Intent(Settings.ACTION_HOME_SETTINGS));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mContext.finishAndRemoveTask();
|
||||
} else {
|
||||
mContext.finishAffinity();
|
||||
}
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(0);
|
||||
|
||||
// OpenApkUtils.getInstance().openJxwApp(mContext, "com.hihonor.android.launcher,com.hihonor.android.launcher.unihome.UniHomeLauncher,,,退出桌面");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class ReadFragment extends BaseMvvmFragment<ReadViewModel, FragmentReadBi
|
||||
@Override
|
||||
public void onPageSelected(int i) {
|
||||
if (i == 0) {
|
||||
mViewDataBinding.tvTitle.setText("最近阅读");
|
||||
mViewDataBinding.tvTitle.setText("阅读报告");
|
||||
} else {
|
||||
mViewDataBinding.tvTitle.setText("我的书架");
|
||||
}
|
||||
|
||||
@@ -278,24 +278,24 @@ public class SafeFragment extends BaseMvvmFragment<SafeViewModel, FragmentSafeBi
|
||||
}
|
||||
|
||||
public void initAppData() {
|
||||
AppInfo build = new AppInfo.Builder().appLabel("课程表").appStargs(getResources().getString(R.string.tag_args_new_kcb)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_kcb)).build();
|
||||
AppInfo build2 = new AppInfo.Builder().appLabel("语音翻译").appStargs(getResources().getString(R.string.tag_args_new_zyhy)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_yyfy)).build();
|
||||
// AppInfo build = new AppInfo.Builder().appLabel("课程表").appStargs(getResources().getString(R.string.tag_args_new_kcb)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_kcb)).build();
|
||||
// AppInfo build2 = new AppInfo.Builder().appLabel("语音翻译").appStargs(getResources().getString(R.string.tag_args_new_zyhy)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_yyfy)).build();
|
||||
AppInfo build3 = new AppInfo.Builder().appLabel("使用助手").appStargs(getResources().getString(R.string.tag_args_new_sysmx)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_syzs)).build();
|
||||
AppInfo build4 = new AppInfo.Builder().appLabel("应用更新").appStargs(getResources().getString(R.string.tag_args_updae)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_yygx)).build();
|
||||
AppInfo build5 = new AppInfo.Builder().appLabel("一键加速").appStargs(getResources().getString(R.string.tag_args_new_yjjs)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_yjjs)).build();
|
||||
AppInfo build6 = new AppInfo.Builder().appLabel("下载中心").appStargs(getResources().getString(R.string.tag_args_new_download)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_xzzx)).build();
|
||||
AppInfo build7 = new AppInfo.Builder().appLabel("切换壁纸").appStargs(getResources().getString(R.string.tag_args_launcher)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_qhbz)).build();
|
||||
AppInfo build8 = new AppInfo.Builder().appLabel("安卓平台").appStargs(getResources().getString(R.string.tag_args_launcher)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_azpt)).build();
|
||||
AppInfo build9 = new AppInfo.Builder().appLabel("设置").appStargs(getResources().getString(R.string.tag_args_new_jxwSettings)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_sz)).build();
|
||||
mlistAppInfo.add(build);
|
||||
mlistAppInfo.add(build2);
|
||||
// AppInfo build4 = new AppInfo.Builder().appLabel("应用更新").appStargs(getResources().getString(R.string.tag_args_updae)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_yygx)).build();
|
||||
// AppInfo build5 = new AppInfo.Builder().appLabel("一键加速").appStargs(getResources().getString(R.string.tag_args_new_yjjs)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_yjjs)).build();
|
||||
// AppInfo build6 = new AppInfo.Builder().appLabel("下载中心").appStargs(getResources().getString(R.string.tag_args_new_download)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_xzzx)).build();
|
||||
// AppInfo build7 = new AppInfo.Builder().appLabel("切换壁纸").appStargs(getResources().getString(R.string.tag_args_launcher)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_qhbz)).build();
|
||||
// AppInfo build8 = new AppInfo.Builder().appLabel("安卓平台").appStargs(getResources().getString(R.string.tag_args_launcher)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_azpt)).build();
|
||||
// AppInfo build9 = new AppInfo.Builder().appLabel("设置").appStargs(getResources().getString(R.string.tag_args_new_jxwSettings)).appIcon(mContext.getResources().getDrawable(R.drawable.icon_bbx_sz)).build();
|
||||
// mlistAppInfo.add(build);
|
||||
// mlistAppInfo.add(build2);
|
||||
mlistAppInfo.add(build3);
|
||||
mlistAppInfo.add(build4);
|
||||
mlistAppInfo.add(build5);
|
||||
mlistAppInfo.add(build6);
|
||||
mlistAppInfo.add(build7);
|
||||
mlistAppInfo.add(build8);
|
||||
mlistAppInfo.add(build9);
|
||||
// mlistAppInfo.add(build4);
|
||||
// mlistAppInfo.add(build5);
|
||||
// mlistAppInfo.add(build6);
|
||||
// mlistAppInfo.add(build7);
|
||||
// mlistAppInfo.add(build8);
|
||||
// mlistAppInfo.add(build9);
|
||||
getAppData();
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -72,7 +72,7 @@ public class WlFragment extends BaseNewFragment {
|
||||
});
|
||||
}
|
||||
};
|
||||
List<ItemsBean> appList = new ArrayList();
|
||||
List<ItemsBean> appList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void initListener() {
|
||||
|
||||
@@ -653,7 +653,7 @@ public class OpenApkUtils {
|
||||
*
|
||||
* @param paramStr 参数字符串(格式:包名,类名,extra参数,第四项,第五项)
|
||||
*/
|
||||
public void openJxwApp(Activity context, String paramStr) {
|
||||
public void openJxwApp(Activity activity, String paramStr) {
|
||||
if (TextUtils.isEmpty(paramStr)) {
|
||||
Log.e(TAG, "context为空或参数字符串为空");
|
||||
return;
|
||||
@@ -677,7 +677,7 @@ public class OpenApkUtils {
|
||||
+ "\n第四项:" + fourthParam + "\n应用名:" + appName);
|
||||
|
||||
if (!ApkUtils.isAvailable(mContext, packageName)) {
|
||||
showDownloadDialog(context, packageName, appName);
|
||||
showDownloadDialog(activity, packageName, appName);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -711,10 +711,11 @@ public class OpenApkUtils {
|
||||
|
||||
// 4. 启动Activity(处理异常)
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
activity.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof android.content.ActivityNotFoundException) {
|
||||
Log.e(TAG, "未找到目标Activity:" + packageName + "/" + className);
|
||||
Toaster.show("打开失败,请升级应用到最新版本");
|
||||
} else if (e instanceof SecurityException) {
|
||||
Log.e(TAG, "启动Activity权限不足");
|
||||
} else {
|
||||
@@ -773,7 +774,7 @@ public class OpenApkUtils {
|
||||
public void showDownloadDialog(Activity context, String pkg, String appName) {
|
||||
Dialog dialog = new Dialog(context, R.style.ActionSheet);
|
||||
Window window = dialog.getWindow();
|
||||
View inflate = ((LayoutInflater) context.getSystemService("layout_inflater")).inflate(R.layout.download_dialog, (ViewGroup) null);
|
||||
View inflate = ((LayoutInflater) context.getSystemService("layout_inflater")).inflate(R.layout.download_dialog, null);
|
||||
TextView textView = inflate.findViewById(R.id.download_cancel);
|
||||
TextView textView2 = inflate.findViewById(R.id.tag_title);
|
||||
if (!TextUtils.isEmpty(appName)) {
|
||||
|
||||
Reference in New Issue
Block a user