version:1.0.3
fix: update:基本跳转对接
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
package com.xwad.os.activity.activation;
|
||||
|
||||
import android.text.InputFilter;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.DigitsKeyListener;
|
||||
import android.view.View;
|
||||
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xwad.os.databinding.ActivityActivationBinding;
|
||||
|
||||
public class ActivationActivity extends BaseMvvmActivity<ActivationViewModel, ActivityActivationBinding> {
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_activation;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mViewModel.setCtx(this);
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
mViewDataBinding.setClick(new BtnClick());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
// 优化后的InputFilter:兼容手动输入、粘贴、输入法联想
|
||||
InputFilter englishNumberFilter = new InputFilter() {
|
||||
@Override
|
||||
public CharSequence filter(CharSequence source, int start, int end,
|
||||
Spanned dest, int dstart, int dend) {
|
||||
// 空字符直接返回(避免过滤正常的删除/回退操作)
|
||||
if (source.toString().isEmpty()) {
|
||||
return source;
|
||||
}
|
||||
|
||||
StringBuilder legalStr = new StringBuilder();
|
||||
for (int i = start; i < end; i++) {
|
||||
char c = source.charAt(i);
|
||||
// 严格匹配:大小写英文 或 数字
|
||||
boolean isLetter = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
boolean isNumber = (c >= '0' && c <= '9');
|
||||
if (isLetter || isNumber) {
|
||||
legalStr.append(c);
|
||||
}
|
||||
}
|
||||
return legalStr;
|
||||
}
|
||||
};
|
||||
|
||||
// 设置仅允许输入指定字符
|
||||
mViewDataBinding.etCoupons.setFilters(new InputFilter[]{
|
||||
englishNumberFilter,
|
||||
new InputFilter.LengthFilter(20)
|
||||
});
|
||||
mViewDataBinding.etKey.setFilters(new InputFilter[]{
|
||||
englishNumberFilter,
|
||||
new InputFilter.LengthFilter(20)
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
public void exit(View view) {
|
||||
finish();
|
||||
}
|
||||
|
||||
public void useQrCode(View view) {
|
||||
mViewDataBinding.clQrcode.setVisibility(View.VISIBLE);
|
||||
mViewDataBinding.clCoupons.setVisibility(View.GONE);
|
||||
mViewDataBinding.clKey.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void useCoupons(View view) {
|
||||
mViewDataBinding.clQrcode.setVisibility(View.GONE);
|
||||
mViewDataBinding.clCoupons.setVisibility(View.VISIBLE);
|
||||
mViewDataBinding.clKey.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void useKey(View view) {
|
||||
mViewDataBinding.clQrcode.setVisibility(View.GONE);
|
||||
mViewDataBinding.clCoupons.setVisibility(View.GONE);
|
||||
mViewDataBinding.clKey.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xwad.os.activity.activation;
|
||||
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.xwad.os.base.mvvm.BaseViewModel;
|
||||
import com.xwad.os.databinding.ActivityActivationBinding;
|
||||
|
||||
public class ActivationViewModel extends BaseViewModel<ActivityActivationBinding, ActivityEvent> {
|
||||
|
||||
@Override
|
||||
public ActivityActivationBinding getVDBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import android.view.animation.TranslateAnimation;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
@@ -33,6 +32,8 @@ import com.hjq.toast.Toaster;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xwad.os.BuildConfig;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.activity.activation.ActivationActivity;
|
||||
import com.xwad.os.activity.login.LoginActivity;
|
||||
import com.xwad.os.activity.permission.PermissionActivity;
|
||||
import com.xwad.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xwad.os.bean.jxw.TabBean;
|
||||
@@ -57,7 +58,6 @@ import com.xwad.os.manager.RemoteManager;
|
||||
import com.xwad.os.utils.DataUtil;
|
||||
import com.xwad.os.utils.OpenApkUtils;
|
||||
import com.xwad.os.utils.Utils;
|
||||
import com.xwad.os.view.viewpager.BaseFragmentPagerAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -67,23 +67,9 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private List<TabBean> tabBeanLists = new ArrayList();
|
||||
private List<Fragment> fragments = new ArrayList();
|
||||
private List<TabBean> tabBeanLists = new ArrayList<>();
|
||||
private List<Fragment> fragments = new ArrayList<>();
|
||||
|
||||
private String[] mAllTitle = new String[]{"我的", "AI+学习", "语文", "数学", "英语", "其他学科", "读书", "绿色安全",};
|
||||
|
||||
private MineFragment mMineFragment;
|
||||
private AiFragment mAiFragment;
|
||||
private ChineseFragment mChineseFragment;
|
||||
private MathFragment mMathFragment;
|
||||
private EnglishFragment mEnglishFragment;
|
||||
private ComplexFragment mComplexFragment;
|
||||
private ReadFragment mReadFragment;
|
||||
private SafeFragment mSafeFragment;
|
||||
|
||||
private FragmentManager mFragmentManager;
|
||||
private BaseFragmentPagerAdapter mBaseFragmentPagerAdapter;
|
||||
private ViewPager.OnPageChangeListener mListener;
|
||||
private int defaultCurrent = 0;
|
||||
|
||||
@Override
|
||||
@@ -110,6 +96,7 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
public void initView() {
|
||||
Log.e(TAG, "initView: getSerial = " + RemoteManager.getInstance().getSerial());
|
||||
|
||||
startActivity(new Intent(HomeActivity.this, LoginActivity.class));
|
||||
RemoteManager.setListener(this);
|
||||
Utils.getAndroiodScreenProperty(this);
|
||||
|
||||
@@ -171,9 +158,9 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
// }
|
||||
tabBeanLists.add(new TabBean("绿色安全", R.drawable.icon_tab_lsaq, R.drawable.icon_tab_lsaq_pre));
|
||||
tabAdapter.setData(this.tabBeanLists);
|
||||
mViewDataBinding.subjectViewPager.setOffscreenPageLimit(5);
|
||||
tabAdapter.setChoosePosition(0);
|
||||
mViewDataBinding.subjectViewPager.setCurrentItem(0);
|
||||
mViewDataBinding.subjectViewPager.setOffscreenPageLimit(10);
|
||||
tabAdapter.setChoosePosition(defaultCurrent);
|
||||
mViewDataBinding.subjectViewPager.setCurrentItem(defaultCurrent);
|
||||
mViewDataBinding.subjectViewPager.setScrollAnim(true);
|
||||
mViewDataBinding.subjectViewPager.setAdapter(new TabFragmentAdapter(getSupportFragmentManager()));
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xwad.os.activity.login;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.activity.login.result.LoginSuccessfulActivity;
|
||||
import com.xwad.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xwad.os.databinding.ActivityLoginBinding;
|
||||
|
||||
public class LoginActivity extends BaseMvvmActivity<LoginViewModel, ActivityLoginBinding> {
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_login;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mViewModel.setCtx(this);
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
mViewDataBinding.setClick(new BtnClick());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
public void loginPhone(View view) {
|
||||
startActivity(new Intent(LoginActivity.this, LoginSuccessfulActivity.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.xwad.os.activity.login;
|
||||
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.xwad.os.base.mvvm.BaseViewModel;
|
||||
import com.xwad.os.databinding.ActivityLoginBinding;
|
||||
|
||||
public class LoginViewModel extends BaseViewModel<ActivityLoginBinding, ActivityEvent> {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.xwad.os.activity.login.result;
|
||||
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xwad.os.databinding.ActivityLoginBinding;
|
||||
import com.xwad.os.databinding.ActivityLoginSuccessfulBinding;
|
||||
|
||||
public class LoginSuccessfulActivity extends BaseMvvmActivity<LoginSuccessfulViewModel, ActivityLoginSuccessfulBinding> {
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_login_successful;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mViewModel.setCtx(this);
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
mViewDataBinding.setClick(new BtnClick());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.xwad.os.activity.login.result;
|
||||
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.xwad.os.base.mvvm.BaseViewModel;
|
||||
import com.xwad.os.databinding.ActivityLoginBinding;
|
||||
import com.xwad.os.databinding.ActivityLoginSuccessfulBinding;
|
||||
|
||||
public class LoginSuccessfulViewModel extends BaseViewModel<ActivityLoginSuccessfulBinding, ActivityEvent> {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,9 @@ import android.util.Log;
|
||||
|
||||
import androidx.multidex.MultiDex;
|
||||
|
||||
import com.alibaba.sdk.android.push.CloudPushService;
|
||||
import com.alibaba.sdk.android.push.CommonCallback;
|
||||
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.tencent.bugly.crashreport.CrashReport;
|
||||
@@ -101,27 +104,27 @@ public class BaseApplication extends Application {
|
||||
// Aria.get(this).getDownloadConfig().setMaxTaskNum(1);
|
||||
// Aria.get(this).getDownloadConfig().setConvertSpeed(true);
|
||||
|
||||
// aliyunPushInit();
|
||||
aliyunPushInit();
|
||||
}
|
||||
}
|
||||
|
||||
// public void aliyunPushInit() {
|
||||
// PushServiceFactory.init(this);
|
||||
// final CloudPushService pushService = PushServiceFactory.getCloudPushService();
|
||||
// pushService.setLogLevel(CloudPushService.LOG_DEBUG);
|
||||
//// pushService.register(this, new CommonCallback() {
|
||||
//// @Override
|
||||
//// public void onSuccess(String response) {
|
||||
//// Log.e("AliyunPush", "init cloudchannel success");
|
||||
//// Log.e("AliyunPush", "init cloudchannel success " + pushService.getDeviceId());
|
||||
//// }
|
||||
////
|
||||
//// @Override
|
||||
//// public void onFailed(String errorCode, String errorMessage) {
|
||||
//// Log.e("AliyunPush", "init cloudchannel failed -- errorcode:" + errorCode + " -- errorMessage:" + errorMessage);
|
||||
//// }
|
||||
//// });
|
||||
// }
|
||||
public void aliyunPushInit() {
|
||||
PushServiceFactory.init(this);
|
||||
final CloudPushService pushService = PushServiceFactory.getCloudPushService();
|
||||
pushService.setLogLevel(CloudPushService.LOG_DEBUG);
|
||||
pushService.register(this, new CommonCallback() {
|
||||
@Override
|
||||
public void onSuccess(String response) {
|
||||
Log.e("AliyunPush", "init cloudchannel success");
|
||||
Log.e("AliyunPush", "init cloudchannel success " + pushService.getDeviceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(String errorCode, String errorMessage) {
|
||||
Log.e("AliyunPush", "init cloudchannel failed -- errorcode:" + errorCode + " -- errorMessage:" + errorMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private APKinstallReceiver apKinstallReceiver;
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -67,123 +67,4 @@ public class AssertUtils {
|
||||
return context.getResources().getDimensionPixelSize(context.getResources().getIdentifier(str, "dimen", context.getPackageName()));
|
||||
}
|
||||
|
||||
public static class ZhMenuAdapter extends BaseQuickAdapter<AppInfo, BaseViewHolder> {
|
||||
private Context context;
|
||||
private List<AppInfo> data;
|
||||
private List<String> gkAppData;
|
||||
private RadiaoOnItemClickListener listener;
|
||||
private Handler mHandler;
|
||||
public int remove_position;
|
||||
private boolean xiezai;
|
||||
|
||||
public interface RadiaoOnItemClickListener {
|
||||
void onDeleteClick(String str, int i, String str2);
|
||||
|
||||
void onSelectClick(int i);
|
||||
}
|
||||
|
||||
public boolean getToDelete() {
|
||||
return this.xiezai;
|
||||
}
|
||||
|
||||
public void setToDelete(boolean z) {
|
||||
this.xiezai = z;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setData(List<AppInfo> list) {
|
||||
this.data = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public ZhMenuAdapter(Context context, List<AppInfo> list) {
|
||||
super(R.layout.item_app_gk, list);
|
||||
this.xiezai = false;
|
||||
this.remove_position = -1;
|
||||
this.mHandler = new Handler();
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(final BaseViewHolder baseViewHolder, final AppInfo appInfo) {
|
||||
try {
|
||||
TextView textView = baseViewHolder.getView(R.id.app_name);
|
||||
ImageView imageView = baseViewHolder.getView(R.id.app_icon);
|
||||
ImageView imageView2 = baseViewHolder.getView(R.id.delet_iv);
|
||||
RelativeLayout relativeLayout = baseViewHolder.getView(R.id.rl_jinyong);
|
||||
RelativeLayout relativeLayout2 = baseViewHolder.getView(R.id.rl_xzsy);
|
||||
textView.setText(appInfo.appName);
|
||||
if (SPUtils.getInt(this.mContext, "themenBg", 0) == 1) {
|
||||
textView.setTextColor(-10066330);
|
||||
} else {
|
||||
textView.setTextColor(-1);
|
||||
}
|
||||
Glide.with(imageView).load(appInfo.getAppIcon()).apply(RequestOptions.bitmapTransform(new RoundedCorners((int) this.mContext.getResources().getDimension(R.dimen.x20)))).into(imageView);
|
||||
relativeLayout.setVisibility(8);
|
||||
relativeLayout2.setVisibility(8);
|
||||
if (GkAppUseInfo.getGkAppUseInfo().datas != null) {
|
||||
for (AppUseInfo appUseInfo : GkAppUseInfo.getGkAppUseInfo().datas) {
|
||||
Log.e("jxw", appInfo.packageName + "--" + appUseInfo.getPackageName());
|
||||
if ((appInfo.packageName != null && appInfo.packageName.equals(appUseInfo.getPackageName()) && appUseInfo.getEnabled().intValue() == 0) || (appInfo.mStargss != null && appInfo.mStargss.contains(appUseInfo.getPackageName()) && appUseInfo.getEnabled().intValue() == 0)) {
|
||||
Log.e("jxw-", "禁止使用的app==" + appInfo.packageName + "--" + appInfo.mStargss + "--" + appUseInfo.getPackageName());
|
||||
relativeLayout.setVisibility(0);
|
||||
break;
|
||||
} else if ((appInfo.packageName != null && appInfo.packageName.equals(appUseInfo.getPackageName()) && appUseInfo.getEnabled().intValue() == 2) || (appInfo.mStargss != null && appInfo.mStargss.contains(appUseInfo.getPackageName()) && appUseInfo.getEnabled().intValue() == 2)) {
|
||||
Log.e("jxw-", "限制使用的app==" + appInfo.packageName + "--" + appInfo.mStargss + "--" + appUseInfo.getPackageName());
|
||||
relativeLayout2.setVisibility(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!this.xiezai) {
|
||||
imageView2.setVisibility(8);
|
||||
} else {
|
||||
imageView2.setVisibility(0);
|
||||
}
|
||||
imageView2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (ZhMenuAdapter.this.listener != null) {
|
||||
ZhMenuAdapter.this.listener.onDeleteClick(appInfo.packageName, baseViewHolder.getAdapterPosition(), appInfo.appName);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!this.xiezai) {
|
||||
imageView2.setVisibility(8);
|
||||
} else if (!TextUtils.isEmpty(appInfo.packageName) && appInfo.getIntent() == null) {
|
||||
imageView2.setVisibility(0);
|
||||
} else {
|
||||
imageView2.setVisibility(8);
|
||||
}
|
||||
baseViewHolder.addOnLongClickListener(R.id.app_icon);
|
||||
imageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (GkAppUseInfo.getGkAppUseInfo().datas != null) {
|
||||
for (AppUseInfo appUseInfo2 : GkAppUseInfo.getGkAppUseInfo().datas) {
|
||||
Log.e("jxw", appInfo.packageName + "--" + appUseInfo2.getPackageName());
|
||||
if ((appInfo.packageName != null && appInfo.packageName.equals(appUseInfo2.getPackageName()) && appUseInfo2.getEnabled().intValue() == 0) || (appInfo.mStargss != null && appInfo.mStargss.contains(appUseInfo2.getPackageName()) && appUseInfo2.getEnabled().intValue() == 0)) {
|
||||
new LockDialog(ZhMenuAdapter.this.mContext, appInfo.appName).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ZhMenuAdapter.this.listener != null) {
|
||||
ZhMenuAdapter.this.listener.onSelectClick(baseViewHolder.getAdapterPosition());
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
}
|
||||
|
||||
public void setGkApp(List<String> list) {
|
||||
this.gkAppData = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(RadiaoOnItemClickListener radiaoOnItemClickListener) {
|
||||
this.listener = radiaoOnItemClickListener;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
144
app/src/main/java/com/xwad/os/jxw/adapter/ZhMenuAdapter.java
Normal file
144
app/src/main/java/com/xwad/os/jxw/adapter/ZhMenuAdapter.java
Normal file
@@ -0,0 +1,144 @@
|
||||
package com.xwad.os.jxw.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.bean.jxw.AppInfo;
|
||||
import com.xwad.os.bean.jxw.AppUseInfo;
|
||||
import com.xwad.os.bean.jxw.GkAppUseInfo;
|
||||
import com.xwad.os.jxw.SPUtils;
|
||||
import com.xwad.os.view.jxw.view.dialog.LockDialog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ZhMenuAdapter extends BaseQuickAdapter<AppInfo, BaseViewHolder> {
|
||||
private Context context;
|
||||
private List<AppInfo> data;
|
||||
private List<String> gkAppData;
|
||||
private RadiaoOnItemClickListener listener;
|
||||
private Handler mHandler;
|
||||
public int remove_position;
|
||||
private boolean xiezai;
|
||||
|
||||
public interface RadiaoOnItemClickListener {
|
||||
void onDeleteClick(String str, int i, String str2);
|
||||
|
||||
void onSelectClick(int i);
|
||||
}
|
||||
|
||||
public boolean getToDelete() {
|
||||
return xiezai;
|
||||
}
|
||||
|
||||
public void setToDelete(boolean z) {
|
||||
xiezai = z;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setData(List<AppInfo> list) {
|
||||
data = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public ZhMenuAdapter(Context context, List<AppInfo> list) {
|
||||
super(R.layout.item_app_gk, list);
|
||||
xiezai = false;
|
||||
remove_position = -1;
|
||||
mHandler = new Handler();
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(final BaseViewHolder baseViewHolder, final AppInfo appInfo) {
|
||||
try {
|
||||
TextView textView = baseViewHolder.getView(R.id.app_name);
|
||||
ImageView imageView = baseViewHolder.getView(R.id.app_icon);
|
||||
ImageView imageView2 = baseViewHolder.getView(R.id.delet_iv);
|
||||
RelativeLayout relativeLayout = baseViewHolder.getView(R.id.rl_jinyong);
|
||||
RelativeLayout relativeLayout2 = baseViewHolder.getView(R.id.rl_xzsy);
|
||||
textView.setText(appInfo.appName);
|
||||
if (SPUtils.getInt(mContext, "themenBg", 0) == 1) {
|
||||
textView.setTextColor(-10066330);
|
||||
} else {
|
||||
textView.setTextColor(-1);
|
||||
}
|
||||
Glide.with(imageView).load(appInfo.getAppIcon()).apply(RequestOptions.bitmapTransform(new RoundedCorners((int) mContext.getResources().getDimension(R.dimen.x20)))).into(imageView);
|
||||
relativeLayout.setVisibility(View.GONE);
|
||||
relativeLayout2.setVisibility(View.GONE);
|
||||
if (GkAppUseInfo.getGkAppUseInfo().datas != null) {
|
||||
for (AppUseInfo appUseInfo : GkAppUseInfo.getGkAppUseInfo().datas) {
|
||||
Log.e("jxw", appInfo.packageName + "--" + appUseInfo.getPackageName());
|
||||
if ((appInfo.packageName != null && appInfo.packageName.equals(appUseInfo.getPackageName()) && appUseInfo.getEnabled() == 0) || (appInfo.mStargss != null && appInfo.mStargss.contains(appUseInfo.getPackageName()) && appUseInfo.getEnabled() == 0)) {
|
||||
Log.e("jxw-", "禁止使用的app==" + appInfo.packageName + "--" + appInfo.mStargss + "--" + appUseInfo.getPackageName());
|
||||
relativeLayout.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
} else if ((appInfo.packageName != null && appInfo.packageName.equals(appUseInfo.getPackageName()) && appUseInfo.getEnabled() == 2) || (appInfo.mStargss != null && appInfo.mStargss.contains(appUseInfo.getPackageName()) && appUseInfo.getEnabled() == 2)) {
|
||||
Log.e("jxw-", "限制使用的app==" + appInfo.packageName + "--" + appInfo.mStargss + "--" + appUseInfo.getPackageName());
|
||||
relativeLayout2.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!xiezai) {
|
||||
imageView2.setVisibility(View.GONE);
|
||||
} else {
|
||||
imageView2.setVisibility(View.VISIBLE);
|
||||
}
|
||||
imageView2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.onDeleteClick(appInfo.packageName, baseViewHolder.getAdapterPosition(), appInfo.appName);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!xiezai) {
|
||||
imageView2.setVisibility(View.GONE);
|
||||
} else if (!TextUtils.isEmpty(appInfo.packageName) && appInfo.getIntent() == null) {
|
||||
imageView2.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
imageView2.setVisibility(View.GONE);
|
||||
}
|
||||
baseViewHolder.addOnLongClickListener(R.id.app_icon);
|
||||
imageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (GkAppUseInfo.getGkAppUseInfo().datas != null) {
|
||||
for (AppUseInfo appUseInfo2 : GkAppUseInfo.getGkAppUseInfo().datas) {
|
||||
Log.e("jxw", appInfo.packageName + "--" + appUseInfo2.getPackageName());
|
||||
if ((appInfo.packageName != null && appInfo.packageName.equals(appUseInfo2.getPackageName()) && appUseInfo2.getEnabled() == 0) || (appInfo.mStargss != null && appInfo.mStargss.contains(appUseInfo2.getPackageName()) && appUseInfo2.getEnabled() == 0)) {
|
||||
new LockDialog(mContext, appInfo.appName).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onSelectClick(baseViewHolder.getAdapterPosition());
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
}
|
||||
|
||||
public void setGkApp(List<String> list) {
|
||||
gkAppData = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(RadiaoOnItemClickListener radiaoOnItemClickListener) {
|
||||
listener = radiaoOnItemClickListener;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user