version:1.0.3

fix:
update:基本跳转对接
This commit is contained in:
2025-12-12 18:09:27 +08:00
parent e6a2e71979
commit 3124840575
46 changed files with 2009 additions and 529 deletions

View File

@@ -1,17 +1,47 @@
package com.xwad.os.fragment.mine;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.xwad.os.R;
import com.xwad.os.activity.activation.ActivationActivity;
import com.xwad.os.activity.home.HomeActivity;
import com.xwad.os.base.mvvm.fragment.BaseMvvmFragment;
import com.xwad.os.bean.jxw.AppInfo;
import com.xwad.os.config.CommonConfig;
import com.xwad.os.databinding.FragmentMineBinding;
import com.tencent.mmkv.MMKV;
import com.xwad.os.jxw.StudyRecordMng;
import com.xwad.os.jxw.ToastUtil;
import com.xwad.os.jxw.adapter.ZhMenuAdapter;
import com.xwad.os.jxw.event.UpdateColorEvent;
import com.xwad.os.utils.OpenApkUtils;
import com.xwad.os.view.jxw.view.dialog.QhbzDialog;
import com.xwad.os.view.jxw.view.dialog.RemoveAppDialog;
import com.xwad.os.view.jxw.widget.RecyclerMarginClickHelper;
import org.greenrobot.eventbus.EventBus;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
@@ -23,6 +53,11 @@ public class MineFragment extends BaseMvvmFragment<MineViewModel, FragmentMineBi
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
private Activity mContext;
private ZhMenuAdapter zhMenuAdapter;
private List<AppInfo> mlistAppInfo = new ArrayList<>();
private Handler mHandler = new Handler();
public String file_name = "app_list_6.0";
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
@@ -76,11 +111,78 @@ public class MineFragment extends BaseMvvmFragment<MineViewModel, FragmentMineBi
mParam2 = getArguments().getString(ARG_PARAM2);
}
mViewDataBinding.gridViewId.setLayoutManager(new GridLayoutManager(mContext, 8));
zhMenuAdapter = new ZhMenuAdapter(mContext, mlistAppInfo);
mViewDataBinding.gridViewId.setAdapter(zhMenuAdapter);
// mViewDataBinding.relaRoot.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// zhMenuAdapter.setToDelete(false);
// }
// });
RecyclerMarginClickHelper.setOnMarginClickListener(mViewDataBinding.gridViewId, new View.OnClickListener() {
@Override
public void onClick(View view) {
zhMenuAdapter.setToDelete(false);
}
});
zhMenuAdapter.setOnItemClickListener(new ZhMenuAdapter.RadiaoOnItemClickListener() {
@Override
public void onSelectClick(int i) {
AppInfo appInfo;
if (mlistAppInfo == null || mlistAppInfo.size() <= 0 || (appInfo = mlistAppInfo.get(i)) == null) {
return;
}
if (appInfo.appName.equals("切换壁纸")) {
QhbzDialog qhbzDialog = new QhbzDialog(mContext);
qhbzDialog.show();
qhbzDialog.setOnCallback(new QhbzDialog.Callback() {
@Override
public void onCallback(int i2) {
EventBus.getDefault().postSticky(new UpdateColorEvent());
}
});
} else if (!TextUtils.isEmpty(appInfo.getPkgName())) {
Log.e(TAG, "onSelectClick: onItemClick 11");
startApkByPackName(mContext, appInfo.getPkgName());
} else if (TextUtils.isEmpty(appInfo.mStargss)) {
} else {
Log.e(TAG, "onItemClick66 " + appInfo.mStargss);
// MyApp.getInstance().mBottomBtnOnClickListener.setContext(mContext);
// MyApp.getInstance().mBottomBtnOnClickListener.onClick(appInfo.mStargss);
OpenApkUtils.getInstance().openJxwApp(appInfo.mStargss);
}
}
@Override
public void onDeleteClick(final String str, final int i, String str2) {
RemoveAppDialog removeAppDialog = new RemoveAppDialog(mContext, str2);
removeAppDialog.show();
removeAppDialog.setOnCallback(new RemoveAppDialog.Callback() {
@Override
public void onCallback() {
readContent(str, i);
if (mlistAppInfo != null) {
mlistAppInfo.clear();
}
initAppData();
}
});
}
});
zhMenuAdapter.setOnItemChildLongClickListener(new BaseQuickAdapter.OnItemChildLongClickListener() {
@Override
public boolean onItemChildLongClick(BaseQuickAdapter baseQuickAdapter, View view, int i) {
zhMenuAdapter.setToDelete(true);
return false;
}
});
}
@Override
protected void initData(Bundle savedInstanceState) {
initAppData();
}
@Override
@@ -91,7 +193,7 @@ public class MineFragment extends BaseMvvmFragment<MineViewModel, FragmentMineBi
@Override
public void fetchData() {
initAppData();
}
@Override
@@ -106,11 +208,110 @@ public class MineFragment extends BaseMvvmFragment<MineViewModel, FragmentMineBi
}
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 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);
// mlistAppInfo.add(build3);
mlistAppInfo.add(build4);
mlistAppInfo.add(build5);
mlistAppInfo.add(build6);
mlistAppInfo.add(build7);
mlistAppInfo.add(build8);
mlistAppInfo.add(build9);
getAppData();
mHandler.post(new Runnable() {
@Override
public void run() {
zhMenuAdapter.setData(mlistAppInfo);
zhMenuAdapter.notifyDataSetChanged();
}
});
}
private void getAppData() {
File fileStreamPath = mContext.getFileStreamPath(file_name);
if (!fileStreamPath.exists()) {
return;
}
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileStreamPath));
PackageManager packageManager = mContext.getPackageManager();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine != null) {
try {
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(readLine, PackageManager.GET_META_DATA);
mlistAppInfo.add(new AppInfo.Builder().appLabel((String) packageManager.getApplicationLabel(applicationInfo)).pkgName(readLine).appIcon(packageManager.getApplicationIcon(applicationInfo)).build());
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
} else {
bufferedReader.close();
return;
}
}
} catch (FileNotFoundException e2) {
e2.printStackTrace();
} catch (IOException e3) {
e3.printStackTrace();
}
}
void startApkByPackName(Context context, String str) {
try {
context.startActivity(context.getPackageManager().getLaunchIntentForPackage(str));
StudyRecordMng.startCount(context, str, "", "", true);
} catch (Exception e) {
Log.d("zzj", "startApkByPackName error : " + e.toString());
ToastUtil.showTextToastDia("此应用已经被家长管控");
}
}
public String readContent(String str, int i) {
File fileStreamPath = mContext.getFileStreamPath(file_name);
if (!fileStreamPath.exists()) {
return null;
}
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileStreamPath));
String str2 = "";
Log.e(TAG, "pkg = " + str + "poi=" + i);
while (true) {
String readLine = bufferedReader.readLine();
if (readLine != null) {
Log.e(TAG, "line " + readLine);
if (!readLine.equals(str)) {
str2 = str2 + readLine + "\n";
}
} else {
bufferedReader.close();
FileOutputStream fileOutputStream = new FileOutputStream(fileStreamPath, false);
Log.e(TAG, "sb = " + str2);
fileOutputStream.write(str2.getBytes());
fileOutputStream.flush();
fileOutputStream.close();
return null;
}
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public class BtnClick {
public void openPrecisionHome(View view) {
public void toLigin(View view) {
startActivity(new Intent(mContext, ActivationActivity.class));
}
}
}

View File

@@ -22,12 +22,13 @@ import com.xwad.os.bean.jxw.AppInfo;
import com.xwad.os.config.CommonConfig;
import com.xwad.os.databinding.FragmentSafeBinding;
import com.xwad.os.jxw.AssertUtils;
import com.xwad.os.jxw.event.GkEvent;
import com.xwad.os.view.jxw.view.dialog.QhbzDialog;
import com.xwad.os.jxw.StudyRecordMng;
import com.xwad.os.jxw.ToastUtil;
import com.xwad.os.jxw.adapter.ZhMenuAdapter;
import com.xwad.os.jxw.event.GkEvent;
import com.xwad.os.jxw.event.UpdateColorEvent;
import com.xwad.os.utils.OpenApkUtils;
import com.xwad.os.view.jxw.view.dialog.QhbzDialog;
import com.xwad.os.view.jxw.view.dialog.RemoveAppDialog;
import com.xwad.os.view.jxw.widget.RecyclerMarginClickHelper;
@@ -58,7 +59,7 @@ public class SafeFragment extends BaseMvvmFragment<SafeViewModel, FragmentSafeBi
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
private AppInfo addAppinfo;
private AssertUtils.ZhMenuAdapter zhMenuAdapter;
private ZhMenuAdapter zhMenuAdapter;
private List<AppInfo> mlistAppInfo = new ArrayList<>();
private Handler mHandler = new Handler();
public String file_name = "app_list_6.0";
@@ -118,7 +119,7 @@ public class SafeFragment extends BaseMvvmFragment<SafeViewModel, FragmentSafeBi
}
mViewDataBinding.gridViewId.setLayoutManager(new GridLayoutManager(mContext, 8));
zhMenuAdapter = new AssertUtils.ZhMenuAdapter(mContext, mlistAppInfo);
zhMenuAdapter = new ZhMenuAdapter(mContext, mlistAppInfo);
mViewDataBinding.gridViewId.setAdapter(zhMenuAdapter);
mViewDataBinding.relaRoot.setOnClickListener(new View.OnClickListener() {
@Override
@@ -132,7 +133,7 @@ public class SafeFragment extends BaseMvvmFragment<SafeViewModel, FragmentSafeBi
zhMenuAdapter.setToDelete(false);
}
});
zhMenuAdapter.setOnItemClickListener(new AssertUtils.ZhMenuAdapter.RadiaoOnItemClickListener() {
zhMenuAdapter.setOnItemClickListener(new ZhMenuAdapter.RadiaoOnItemClickListener() {
@Override
public void onSelectClick(int i) {
AppInfo appInfo;
@@ -354,7 +355,6 @@ public class SafeFragment extends BaseMvvmFragment<SafeViewModel, FragmentSafeBi
}
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileStreamPath));
int i2 = len;
String str2 = "";
Log.e(TAG, "pkg = " + str + "poi=" + i);
while (true) {