version:1.2.7
fix: update:优化sim卡联系人
This commit is contained in:
@@ -15,8 +15,8 @@ android {
|
||||
applicationId "com.xxpatx.os"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 29
|
||||
versionCode 1025
|
||||
versionName "1.2.4"
|
||||
versionCode 1028
|
||||
versionName "1.2.7"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -75,9 +75,9 @@ android {
|
||||
versionNameSuffix "-debug"
|
||||
//Zipalign优化
|
||||
zipAlignEnabled true
|
||||
shrinkResources true
|
||||
// shrinkResources true
|
||||
//混淆
|
||||
minifyEnabled true
|
||||
minifyEnabled false
|
||||
//前一部分代表系统默认的android程序的混淆文件,该文件已经包含了基本的混淆声明,后一个文件是自己的定义混淆文件
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
//签名
|
||||
|
||||
@@ -192,10 +192,14 @@ public class AddWechatContactActivity extends BaseMvvmActivity<AddWechatContactV
|
||||
Toaster.show("请输入手机号码");
|
||||
return;
|
||||
}
|
||||
Log.e("checkContact", "avatarFilePath: " + mViewModel.avatarFilePath);
|
||||
mLoadingDialog.setLoadingText("正在上传");
|
||||
mLoadingDialog.show();
|
||||
mViewModel.checkContact();
|
||||
if (mViewDataBinding.tbSim.isToggleOn() == 1) {
|
||||
createContact(name, phone);
|
||||
} else {
|
||||
Log.e("checkContact", "avatarFilePath: " + mViewModel.avatarFilePath);
|
||||
mLoadingDialog.setLoadingText("正在上传");
|
||||
mLoadingDialog.show();
|
||||
mViewModel.checkContact();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.xxpatx.os.adapter.DailyAppAdapter;
|
||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xxpatx.os.bean.DailyAppBean;
|
||||
import com.xxpatx.os.databinding.ActivityDailyappBinding;
|
||||
import com.xxpatx.os.manager.AppStatusManager;
|
||||
import com.xxpatx.os.service.NotificationService;
|
||||
import com.xxpatx.os.view.GridSpaceItemDecoration;
|
||||
|
||||
@@ -61,7 +60,7 @@ public class DailyAppActivity extends BaseMvvmActivity<DailyAppViewModel, Activi
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
mViewModel.getDailyAppData().observe(this, new Observer<List<DailyAppBean>>() {
|
||||
mViewModel.mDailyAppData.observe(this, new Observer<List<DailyAppBean>>() {
|
||||
@Override
|
||||
public void onChanged(List<DailyAppBean> dailyAppBeans) {
|
||||
mDailyAppAdapter.setDailyAppBeans(dailyAppBeans);
|
||||
|
||||
@@ -22,11 +22,7 @@ public class DailyAppViewModel extends BaseViewModel<ActivityDailyappBinding, Ac
|
||||
|
||||
}
|
||||
|
||||
private MutableLiveData<List<DailyAppBean>> mDailyAppData = new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<List<DailyAppBean>> getDailyAppData() {
|
||||
return mDailyAppData;
|
||||
}
|
||||
public MutableLiveData<List<DailyAppBean>> mDailyAppData = new MutableLiveData<>();
|
||||
|
||||
public void getPackageList() {
|
||||
List<DailyAppBean> appBeanList = AppStatusManager.getInstance().getPackageList();
|
||||
|
||||
@@ -406,7 +406,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
mViewModel.getDesktopIconData().observe(this, new Observer<ArrayList<DesktopIcon>>() {
|
||||
mViewModel.mDesktopIconData.observe(this, new Observer<ArrayList<DesktopIcon>>() {
|
||||
@Override
|
||||
public void onChanged(ArrayList<DesktopIcon> desktopIcons) {
|
||||
int x = 0;
|
||||
@@ -441,7 +441,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
//
|
||||
// mViewModel.getSnIsActivation();
|
||||
|
||||
mViewModel.getAppInfoData().observe(this, new Observer<AppInfo>() {
|
||||
mViewModel.mAppInfoMutableLiveData.observe(this, new Observer<AppInfo>() {
|
||||
@Override
|
||||
public void onChanged(AppInfo appInfo) {
|
||||
if (appInfo == null) {
|
||||
@@ -563,7 +563,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
default:
|
||||
case Intent.ACTION_MAIN:
|
||||
mViewDataBinding.viewPager.setCurrentItem(defaultCurrent);
|
||||
mViewModel.checkUpdate();
|
||||
// mViewModel.checkUpdate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -585,7 +585,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
super.onResume();
|
||||
Log.e(TAG, "onResume: ");
|
||||
int activation = Settings.Global.getInt(getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0);
|
||||
mViewModel.getActivationData().setValue(activation);
|
||||
mViewModel.mActivationData.setValue(activation);
|
||||
addData();
|
||||
// 判断是否开启监听通知权限
|
||||
if (NotificationManagerCompat.getEnabledListenerPackages(this).contains(getPackageName())) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xxpatx.os.activity.main;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
@@ -7,8 +8,9 @@ import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.jeremyliao.liveeventbus.LiveEventBus;
|
||||
import com.qweather.sdk.bean.base.Code;
|
||||
@@ -21,7 +23,6 @@ import com.qweather.sdk.view.QWeather;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.xxpatx.os.BuildConfig;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.base.mvvm.BaseViewModel;
|
||||
import com.xxpatx.os.bean.ActivationBean;
|
||||
@@ -29,7 +30,6 @@ import com.xxpatx.os.bean.AppInfo;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.Contact;
|
||||
import com.xxpatx.os.bean.DesktopIcon;
|
||||
import com.xxpatx.os.bean.NetDesktopIcon;
|
||||
import com.xxpatx.os.bean.SnInfo;
|
||||
import com.xxpatx.os.config.CommonConfig;
|
||||
import com.xxpatx.os.databinding.ActivityMainBinding;
|
||||
@@ -37,9 +37,9 @@ import com.xxpatx.os.db.ContactCacheUtils;
|
||||
import com.xxpatx.os.gson.GsonUtils;
|
||||
import com.xxpatx.os.manager.AppManager;
|
||||
import com.xxpatx.os.network.NetInterfaceManager;
|
||||
import com.xxpatx.os.service.main.MainService;
|
||||
import com.xxpatx.os.utils.ActivationUtil;
|
||||
import com.xxpatx.os.utils.ApkUtils;
|
||||
import com.xxpatx.os.utils.AppUsedTimeUtils;
|
||||
import com.xxpatx.os.utils.FileUtil;
|
||||
import com.xxpatx.os.utils.Utils;
|
||||
import com.xxpatx.os.utils.WiFiUtils;
|
||||
@@ -62,6 +62,8 @@ import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
import static com.arialyy.aria.core.inf.IEntity.STATE_RUNNING;
|
||||
|
||||
public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEvent> {
|
||||
private static final String TAG = "MainViewModel";
|
||||
|
||||
@@ -94,9 +96,6 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
||||
|
||||
private MutableLiveData<WeatherNowBean.NowBaseBean> mNowBaseBeanData = new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<WeatherNowBean.NowBaseBean> getNowBaseBeanData() {
|
||||
return mNowBaseBeanData;
|
||||
}
|
||||
|
||||
public void getWeatherNow(String location) {
|
||||
Log.e(TAG, "getWeatherNow: " + location);
|
||||
@@ -136,9 +135,6 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
||||
|
||||
private MutableLiveData<WeatherHourlyBean.HourlyBean> mHourlyBeanData = new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<WeatherHourlyBean.HourlyBean> getHourlyBeanData() {
|
||||
return mHourlyBeanData;
|
||||
}
|
||||
|
||||
public void getWeather24Hourly(String location) {
|
||||
QWeather.getWeather24Hourly(getCtx(), location, new QWeather.OnResultWeatherHourlyListener() {
|
||||
@@ -170,9 +166,6 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
||||
|
||||
private MutableLiveData<WeatherDailyBean.DailyBean> DailyBeanData = new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<WeatherDailyBean.DailyBean> getDailyBeanData() {
|
||||
return DailyBeanData;
|
||||
}
|
||||
|
||||
public void getWeather7D(String location) {
|
||||
QWeather.getWeather7D(getCtx(), location, new QWeather.OnResultWeatherDailyListener() {
|
||||
@@ -202,9 +195,6 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
||||
|
||||
private MutableLiveData<SnInfo> mSnInfoData = new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<SnInfo> getSnInfoData() {
|
||||
return mSnInfoData;
|
||||
}
|
||||
|
||||
public void getSnInfo() {
|
||||
NetInterfaceManager.getInstance().getSnInfoControl()
|
||||
@@ -239,11 +229,8 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
||||
}
|
||||
|
||||
|
||||
private MutableLiveData<ArrayList<DesktopIcon>> mDesktopIconData = new MutableLiveData<>();
|
||||
public MutableLiveData<ArrayList<DesktopIcon>> mDesktopIconData = new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<ArrayList<DesktopIcon>> getDesktopIconData() {
|
||||
return mDesktopIconData;
|
||||
}
|
||||
|
||||
public void getAppList() {
|
||||
Observable.create(new ObservableOnSubscribe<ArrayList<DesktopIcon>>() {
|
||||
@@ -279,11 +266,7 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
||||
});
|
||||
}
|
||||
|
||||
private MutableLiveData<Integer> mActivationData = new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<Integer> getActivationData() {
|
||||
return mActivationData;
|
||||
}
|
||||
public MutableLiveData<Integer> mActivationData = new MutableLiveData<>();
|
||||
|
||||
public void getSnIsActivation() {
|
||||
NetInterfaceManager.getInstance().getSnIsActivationObservable()
|
||||
@@ -329,11 +312,7 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
||||
});
|
||||
}
|
||||
|
||||
private MutableLiveData<AppInfo> mAppInfoData = new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<AppInfo> getAppInfoData() {
|
||||
return mAppInfoData;
|
||||
}
|
||||
public MutableLiveData<AppInfo> mAppInfoMutableLiveData = new MutableLiveData<>();
|
||||
|
||||
public void checkUpdate() {
|
||||
NetInterfaceManager.getInstance().getUpdateObservable()
|
||||
@@ -349,7 +328,25 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
||||
Log.e("checkUpdate", "onNext: " + appInfoBaseResponse);
|
||||
if (appInfoBaseResponse.code == 200) {
|
||||
AppInfo appInfo = appInfoBaseResponse.data;
|
||||
mAppInfoData.setValue(appInfo);
|
||||
// mAppInfoData.setValue(appInfo);
|
||||
getCtx().startService(new Intent(getCtx(), MainService.class));
|
||||
if (ApkUtils.checkAppUpdate(getCtx(), appInfo)) {
|
||||
DownloadEntity entity = Aria.download(this).getFirstDownloadEntity(appInfo.getApp_url());
|
||||
if (null != entity) {
|
||||
if (entity.isComplete()) {
|
||||
ApkUtils.installApp(getCtx(), entity.getFilePath());
|
||||
} else {
|
||||
if (entity.getState() != STATE_RUNNING) {
|
||||
Aria.download(this).resumeAllTask();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ApkUtils.ariaDownload(getCtx(), appInfo.getApp_url(), appInfo);
|
||||
}
|
||||
} else {
|
||||
Log.e("checkUpdate", "onNext: 已是最新");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,33 +362,6 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void getDesktopLayout() {
|
||||
NetInterfaceManager.getInstance().getDesktopLayoutObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<NetDesktopIcon>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getDesktopLayout", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<NetDesktopIcon>> listBaseResponse) {
|
||||
Log.e("getDesktopLayout", "onNext: " + listBaseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getDesktopLayout", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getDesktopLayout", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void uploadContacts() {
|
||||
List<Contact> contactList = ContactCacheUtils.getInstance().getDatabaseContact();
|
||||
@@ -450,95 +420,4 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void sendAPPUsage() {
|
||||
AppUsedTimeUtils.getInstance().setEndTime(System.currentTimeMillis());
|
||||
String packagename = AppUsedTimeUtils.getInstance().getAppPackageName();
|
||||
Log.e(TAG, "onRestart packagename == " + packagename);
|
||||
if (!TextUtils.isEmpty(packagename)) {
|
||||
Log.e(TAG, "onRestart: " + ApkUtils.getAppNameByPackage(getCtx(), packagename));
|
||||
Log.e(TAG, "onRestart: " + packagename);
|
||||
NetInterfaceManager.getInstance().getAppUsageRecordControl()
|
||||
.sendappUsageRecord(Utils.getSerial(),
|
||||
ApkUtils.getAppNameByPackage(getCtx(), packagename),
|
||||
packagename,
|
||||
AppUsedTimeUtils.getInstance().getStartTime() / 1000,
|
||||
AppUsedTimeUtils.getInstance().getEndTime() / 1000)
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("sendAPPUsage", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("sendAPPUsage", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("sendAPPUsage", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("sendAPPUsage", "onComplete: ");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Log.e("onRestart", "app = null" + packagename);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void sendRunningInfo() {
|
||||
AppUsedTimeUtils.getInstance().setAppPackageName(BuildConfig.APPLICATION_ID);
|
||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
long time = AppUsedTimeUtils.getInstance().getStartTime();
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("app_package", BuildConfig.APPLICATION_ID);
|
||||
jsonObject.addProperty("version_name", ApkUtils.getAPPVersionName(getCtx(), BuildConfig.APPLICATION_ID));
|
||||
jsonObject.addProperty("start_time", time / 1000);
|
||||
String jsonString = jsonObject.toString();
|
||||
Log.e(TAG, "sendRunningInfo: " + jsonString);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getRunningAppObservable(jsonString)
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("sendRunningInfo", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("sendRunningInfo", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("sendRunningInfo", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("sendRunningInfo", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void getAdminSnSetting() {
|
||||
NetInterfaceManager.getInstance().getAdminSnSetting(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.io.Serializable;
|
||||
public class Contact implements Serializable {
|
||||
private static final long serialVersionUID = 8814155739557674021L;
|
||||
|
||||
int id;
|
||||
long id;
|
||||
String name;//名称
|
||||
int is_urgent;//是否紧急联系人 0否1是
|
||||
String mobile;//手机号
|
||||
@@ -32,11 +32,11 @@ public class Contact implements Serializable {
|
||||
this.simContact = sim;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ public class CommonConfig {
|
||||
/*桌面图标个数*/
|
||||
public final static int DESKTOP_LIST_SIZE = 3 * 3;
|
||||
|
||||
public static final String HIDE_CALENDAR_KEY = "hide_desktop_calendar";
|
||||
|
||||
public static final String MAP_LOCATION_JSON_KEY = "MAPLOCATION_JSON_STRING";
|
||||
public static final String MAP_LONGITUDE_KEY = "map_longitude_key";
|
||||
|
||||
@@ -123,7 +123,7 @@ public class ContactCacheUtils {
|
||||
return deleteContact(contact.getId());
|
||||
}
|
||||
|
||||
public boolean deleteContact(int rowId) {
|
||||
public boolean deleteContact(long rowId) {
|
||||
long id = 0;
|
||||
mDatabase.beginTransaction();
|
||||
try {
|
||||
|
||||
@@ -94,8 +94,10 @@ public class EditContactDialog extends AlertDialog {
|
||||
|
||||
}
|
||||
if (hideDelete) {
|
||||
clEdit.setVisibility(View.GONE);
|
||||
clDelete.setVisibility(View.GONE);
|
||||
} else {
|
||||
clEdit.setVisibility(View.VISIBLE);
|
||||
clDelete.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,12 +228,12 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
||||
@Override
|
||||
public void fetchData() {
|
||||
Log.e(TAG, "fetchData: ");
|
||||
mViewModel.getCacheContact();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mViewModel.getCacheContact();
|
||||
String district = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_DISTRICT, CommonConfig.DEFAULT_LOCATION_DISTRICT);
|
||||
mViewDataBinding.tvLocation.setText(district);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ContactViewModel extends BaseViewModel<FragmentContactHomeBinding,
|
||||
return mDeleteData;
|
||||
}
|
||||
|
||||
public void deleteContact(int id) {
|
||||
public void deleteContact(long id) {
|
||||
NetInterfaceManager.getInstance().getMailListDeleteObservable(id)
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class HomeViewModel extends BaseViewModel<FragmentHomeBinding, FragmentEv
|
||||
|
||||
public void init() {
|
||||
getInstalledApp();
|
||||
getAlarmClock();
|
||||
// getAlarmClock();
|
||||
}
|
||||
|
||||
private MutableLiveData<ArrayList<DesktopIcon>> DesktopIconData = new MutableLiveData<>();
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.xxpatx.os.fragment.phone.contact;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
@@ -41,7 +43,7 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private Context mContext;
|
||||
private Activity mContext;
|
||||
private ContactAdapter mContactAdapter;
|
||||
|
||||
public ContactFragment() {
|
||||
@@ -74,10 +76,14 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
||||
@Override
|
||||
public void setOnLongClickListener(Contact contact) {
|
||||
boolean disableModify = mMMKV.decodeBool(CommonConfig.DISABLE_CONTACT_MODIFY, false);
|
||||
if (disableModify){
|
||||
if (disableModify) {
|
||||
Toaster.showLong("已禁用联系人修改");
|
||||
}else {
|
||||
showDialog(contact);
|
||||
} else {
|
||||
if (contact.isSimContact()) {
|
||||
Toaster.showLong("本地联系人不支持修改");
|
||||
} else {
|
||||
showDialog(contact);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -114,7 +120,7 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
||||
} else {
|
||||
Toaster.show("删除失败:" + baseResponse.msg);
|
||||
}
|
||||
mViewModel. getContact();
|
||||
mViewModel.getContact();
|
||||
}
|
||||
});
|
||||
mViewModel.getCacheContact();
|
||||
@@ -136,20 +142,23 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
||||
public static final String NUMBER = "number";
|
||||
|
||||
private List<Contact> getSIMContacts() {
|
||||
getAll();
|
||||
List<Contact> contactList = new ArrayList<>();
|
||||
ContentResolver resolver = mContext.getContentResolver();
|
||||
// 获取Sims卡联系人
|
||||
Uri uri = Uri.parse("content://icc/adn");
|
||||
Cursor phoneCursor = resolver.query(uri, null, null, null, null);
|
||||
if (phoneCursor != null) {
|
||||
final int colName = phoneCursor.getColumnIndex(NAME);
|
||||
final int colNumber = phoneCursor.getColumnIndex(NUMBER);
|
||||
int colName = phoneCursor.getColumnIndex(NAME);
|
||||
int colNumber = phoneCursor.getColumnIndex(NUMBER);
|
||||
while (phoneCursor.moveToNext()) {
|
||||
String number = phoneCursor.getString(colNumber);
|
||||
// 当手机号码为空的或者为空字段 跳过当前循环
|
||||
String username = phoneCursor.getString(colName);
|
||||
Log.e(TAG, "getSIMContacts: number = " + number + " username = " + username);
|
||||
long id = phoneCursor.getLong(phoneCursor.getColumnIndex("_id"));
|
||||
Log.e(TAG, "getSIMContacts: number = " + number + " username = " + username + " _id = " + id);
|
||||
Contact contact = new Contact(username, number, true);
|
||||
contact.setId(id);
|
||||
contactList.add(contact);
|
||||
}
|
||||
phoneCursor.close();
|
||||
@@ -157,15 +166,31 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
||||
return contactList;
|
||||
}
|
||||
|
||||
private void getAll() {
|
||||
ContentResolver resolver = mContext.getContentResolver();
|
||||
Cursor adnCursor = resolver.query(Uri.parse("content://icc/adn/subId/0"), null, null, null, null);
|
||||
for (String columnName : adnCursor.getColumnNames()) {
|
||||
Log.d("CursorFields: adnCursor ", columnName);
|
||||
}
|
||||
Cursor rawContactsCursor = resolver.query(Uri.parse("content://com.android.contacts/raw_contacts"), null, null, null, null);
|
||||
for (String columnName : rawContactsCursor.getColumnNames()) {
|
||||
Log.d("CursorFields: rawContactsCursor ", columnName);
|
||||
}
|
||||
Cursor dataCursor = resolver.query(Uri.parse("content://com.android.contacts/data"), null, null, null, null);
|
||||
for (String columnName : dataCursor.getColumnNames()) {
|
||||
Log.d("CursorFields: dataCursor ", columnName);
|
||||
}
|
||||
}
|
||||
|
||||
private EditContactDialog mEditContactDialog;
|
||||
|
||||
private void showDialog(Contact contact) {
|
||||
if (mEditContactDialog == null) {
|
||||
mEditContactDialog = new EditContactDialog(getContext());
|
||||
}
|
||||
if (contact.isSimContact()){
|
||||
if (contact.isSimContact()) {
|
||||
mEditContactDialog.setHideDelete(true);
|
||||
}else {
|
||||
} else {
|
||||
mEditContactDialog.setHideDelete(false);
|
||||
}
|
||||
mEditContactDialog
|
||||
@@ -173,15 +198,19 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
||||
.setOnClickBottomListener(new EditContactDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onEditClick() {
|
||||
Intent intent =new Intent(getContext(), EditContactActivity.class);
|
||||
intent.putExtra("Contact",contact);
|
||||
Intent intent = new Intent(mContext, EditContactActivity.class);
|
||||
intent.putExtra("Contact", contact);
|
||||
startActivity(intent);
|
||||
mEditContactDialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteClick() {
|
||||
mViewModel.deleteContact(contact.getId());
|
||||
if (contact.isSimContact()) {
|
||||
// deleteSimContact(contact.getId());
|
||||
} else {
|
||||
mViewModel.deleteContact(contact);
|
||||
}
|
||||
mEditContactDialog.dismiss();
|
||||
}
|
||||
|
||||
@@ -195,13 +224,57 @@ public class ContactFragment extends BaseMvvmFragment<ContactViewModel, Fragment
|
||||
mEditContactDialog.show();
|
||||
}
|
||||
|
||||
private static final String[] ENTITY_PROJECTION = new String[]{
|
||||
ContactsContract.Contacts.Entity.RAW_CONTACT_ID, //0
|
||||
ContactsContract.Contacts.Entity.ACCOUNT_TYPE, //1
|
||||
ContactsContract.Contacts.Entity.DATA_SET, // 2
|
||||
ContactsContract.Contacts.Entity.CONTACT_ID, // 3
|
||||
ContactsContract.Contacts.Entity.LOOKUP_KEY, // 4
|
||||
ContactsContract.Contacts.Entity.DISPLAY_NAME, // 5
|
||||
ContactsContract.Contacts.Entity.DISPLAY_NAME_ALTERNATIVE, // 6
|
||||
};
|
||||
|
||||
private static final int COLUMN_INDEX_RAW_CONTACT_ID = 0;
|
||||
private static final int COLUMN_INDEX_ACCOUNT_TYPE = 1;
|
||||
private static final int COLUMN_INDEX_DATA_SET = 2;
|
||||
private static final int COLUMN_INDEX_CONTACT_ID = 3;
|
||||
private static final int COLUMN_INDEX_LOOKUP_KEY = 4;
|
||||
private static final int COLUMN_INDEX_DISPLAY_NAME = 5;
|
||||
private static final int COLUMN_INDEX_DISPLAY_NAME_ALT = 6;
|
||||
|
||||
public void deleteSimContact(long id) {
|
||||
Intent intent = mContext.getIntent();
|
||||
ContentResolver resolver = mContext.getContentResolver();
|
||||
// Uri lookupUri = intent.getData();
|
||||
// final long rawContactId = ContentUris.parseId(lookupUri);
|
||||
Uri lookupUri = ContactsContract.RawContacts.getContactLookupUri(resolver,
|
||||
ContentUris.withAppendedId(ContactsContract.RawContacts.CONTENT_URI, id));
|
||||
Cursor cursor = resolver.query(ContactsContract.RawContacts.CONTENT_URI, null, null, null, null);
|
||||
for (String columnName : cursor.getColumnNames()) {
|
||||
Log.e("deleteSimContact: ", columnName);
|
||||
}
|
||||
while (cursor.moveToNext()) {
|
||||
for (String columnName : cursor.getColumnNames()) {
|
||||
Log.e("deleteSimContact: ", columnName);
|
||||
Log.e("deleteSimContact: ", cursor.getColumnIndex(columnName) + "");
|
||||
if (cursor.getColumnIndex(columnName) != -1) {
|
||||
Log.e("deleteSimContact: getString = ", " - " + cursor.getString(cursor.getColumnIndex(columnName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
// long contactId = 0;
|
||||
// String lookupKey = "";
|
||||
// Uri contactUri = ContactsContract.Contacts.getLookupUri(contactId, lookupKey);
|
||||
// resolver.delete(contactUri, null, null);
|
||||
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
public void add(View view) {
|
||||
boolean disableModify = mMMKV.decodeBool(CommonConfig.DISABLE_CONTACT_MODIFY, false);
|
||||
if (disableModify){
|
||||
if (disableModify) {
|
||||
Toaster.showLong("已禁用联系人修改");
|
||||
}else {
|
||||
} else {
|
||||
Intent intent = new Intent(mContext, AddWechatContactActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
package com.xxpatx.os.fragment.phone.contact;
|
||||
|
||||
import android.content.ContentProviderOperation;
|
||||
import android.content.ContentProviderResult;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.ContactsContract;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -21,13 +30,17 @@ import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class ContactViewModel extends BaseViewModel<FragmentContactBinding, FragmentEvent> {
|
||||
private static final String TAG = "ContactViewModel";
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
@Override
|
||||
@@ -111,8 +124,9 @@ public class ContactViewModel extends BaseViewModel<FragmentContactBinding, Frag
|
||||
return mDeleteData;
|
||||
}
|
||||
|
||||
public void deleteContact(int id) {
|
||||
NetInterfaceManager.getInstance().getMailListDeleteObservable(id)
|
||||
public void deleteContact(Contact contact) {
|
||||
Log.e(TAG, "deleteContact: " + contact.getId());
|
||||
NetInterfaceManager.getInstance().getMailListDeleteObservable(contact.getId())
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
@@ -136,5 +150,131 @@ public class ContactViewModel extends BaseViewModel<FragmentContactBinding, Frag
|
||||
Log.e("deleteContact", "onComplete: ");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void deleteSimContact(long id) {
|
||||
ContentResolver contentResolver = getCtx().getContentResolver();
|
||||
// deleteSimContact(id + "");
|
||||
// Uri deleteUri = ContactsContract.Contacts.CONTENT_URI;
|
||||
// Uri deleteContactUri = ContentUris.withAppendedId(deleteUri, id);
|
||||
// Log.e(TAG, "deleteSimContact: " + contentResolver.delete(deleteContactUri, null, null));
|
||||
|
||||
// Log.e(TAG, "deleteSimContact: " + contentResolver.delete(Uri.parse("content://icc/adn/"), "_id = ?", new String[]{String.valueOf(id)}));
|
||||
// Log.e(TAG, "deleteSimContact: " + contentResolver.delete(Uri.parse("content://com.android.contacts/raw_contacts"), "_id =?", new String[]{String.valueOf(id)}));
|
||||
// Log.e(TAG, "deleteSimContact: " + contentResolver.delete(Uri.parse("content://com.android.contacts/data"), ContactsContract.RawContacts.CONTACT_ID + " =?", new String[]{String.valueOf(id)}));
|
||||
}
|
||||
|
||||
public void deleteSimContact(String simContactId) {
|
||||
|
||||
// SubscriptionManager subscriptionManager = SubscriptionManager.from(getCtx());
|
||||
// List<SubscriptionInfo> subscriptionInfos = subscriptionManager.getActiveSubscriptionInfoList();
|
||||
// if (subscriptionInfos != null) {
|
||||
// for (SubscriptionInfo subscriptionInfo : subscriptionInfos) {
|
||||
// Uri rawContactUri = Uri.parse("content://icc/adn/" + simContactId);
|
||||
// Uri uri = Uri.withAppendedPath(ContactsContract.RawContacts.CONTENT_URI, subscriptionInfo.getSimSlotIndex() + "");
|
||||
// ContentResolver contentResolver = getCtx().getContentResolver();
|
||||
// Cursor cursor = contentResolver.query(uri, new String[]{ContactsContract.RawContacts._ID}, null, null, null);
|
||||
// if (cursor != null && cursor.moveToFirst()) {
|
||||
// do {
|
||||
// long rawContactId = cursor.getLong(cursor.getColumnIndex(ContactsContract.RawContacts._ID));
|
||||
// Log.e(TAG, "deleteSimContact: " + contentResolver.delete(ContentUris.withAppendedId(rawContactUri, rawContactId), null, null));
|
||||
// } while (cursor.moveToNext());
|
||||
// cursor.close();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
SubscriptionManager subscriptionManager = SubscriptionManager.from(getCtx());
|
||||
List<SubscriptionInfo> subscriptionInfos = subscriptionManager.getActiveSubscriptionInfoList();
|
||||
if (subscriptionInfos != null) {
|
||||
for (SubscriptionInfo subscriptionInfo : subscriptionInfos) {
|
||||
int subscriptionId = subscriptionInfo.getSubscriptionId();
|
||||
Uri rawContactUri = Uri.parse("content://icc/adn/subId/" + subscriptionId);
|
||||
Uri dataUri = Uri.parse("content://icc/adn/subId/" + subscriptionId + "/data");
|
||||
|
||||
ContentResolver resolver = getCtx().getContentResolver();
|
||||
Uri uri = ContentUris.withAppendedId(rawContactUri, Integer.parseInt(simContactId));
|
||||
Log.e(TAG, "deleteSimContact: " + resolver.delete(uri, null, null));
|
||||
Log.e(TAG, "deleteSimContact: " + resolver.delete(dataUri, ContactsContract.RawContacts.CONTACT_ID + " = " + simContactId, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeLocalPhoneAccount() {
|
||||
try {
|
||||
final ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI);
|
||||
builder.withValue(ContactsContract.RawContacts.ACCOUNT_NAME, null);
|
||||
builder.withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, null);
|
||||
|
||||
final ArrayList<ContentProviderOperation> operations = new ArrayList<>();
|
||||
operations.add(builder.build());
|
||||
|
||||
final ContentProviderResult[] results = getCtx().getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations);
|
||||
final Optional<ContentProviderResult> rawContactUri = Arrays.stream(results).findFirst();
|
||||
rawContactUri.ifPresent(new Consumer<ContentProviderResult>() {
|
||||
@Override
|
||||
public void accept(ContentProviderResult value) {
|
||||
ContactViewModel.this.getCtx().getContentResolver().delete(value.uri, null, null);
|
||||
}
|
||||
});
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// public boolean deleteContactsinfo(String deleteid) {
|
||||
// try {
|
||||
// ContentResolver mContentResolver = getCtx().getContentResolver();
|
||||
// Cursor cursor = mContentResolver.query(ContactsContract.Contacts.CONTENT_URI, null, "_id =?", new String[]{deleteid}, null);
|
||||
// if (cursor.moveToFirst()) {
|
||||
// int index_in_sim = cursor.getInt(cursor.getColumnIndex(ContactsContract.Contacts.INDEX_IN_SIM));
|
||||
// Log.d(TAG, "deleteContactsinfo: " + " index_in_sim " + index_in_sim);
|
||||
// //通过index_in_sim 来判断是sim卡中的联系人还是设备中的联系人
|
||||
// if (index_in_sim != -1) {
|
||||
// String lookup_key = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
|
||||
// int indicate_phone_or_sim_contact = cursor.getInt(cursor.getColumnIndex(ContactsContract.Contacts.INDICATE_PHONE_SIM));
|
||||
// Uri simUri = Uri.parse("content://icc/pbr/subId/" + indicate_phone_or_sim_contact);
|
||||
// int delete1 = mContentResolver.delete(simUri, "index = " + index_in_sim, null);
|
||||
// int delete5 = mContentResolver.delete(Uri.parse("content://com.android.contacts/contacts/lookup/" + lookup_key + "/" + deleteid), null, null);
|
||||
// Log.d(TAG, " delete1 " + delete1 + " delete5 " + delete5);
|
||||
// } else {
|
||||
// mContentResolver.delete(Uri.parse("content://com.android.contacts/raw_contacts"), "_id =?", new String[]{deleteid});
|
||||
// mContentResolver.delete(Uri.parse("content://com.android.contacts/data"), ContactsContract.RawContacts.CONTACT_ID + " =?", new String[]{deleteid});
|
||||
// }
|
||||
// cursor.close();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 删除单个联系人数据
|
||||
*
|
||||
* @param name
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
public boolean delete(String name) {
|
||||
try {
|
||||
// 根据姓名求id
|
||||
Uri uri = Uri.parse("content://icc/adn/");
|
||||
ContentResolver resolver = getCtx().getContentResolver();
|
||||
Cursor cursor = resolver.query(uri, new String[]{ContactsContract.Data._ID}, "display_name = ?", new String[]{name}, null);
|
||||
if (cursor.moveToFirst()) {
|
||||
int id = cursor.getInt(0);
|
||||
// 根据id删除data中的相应数据
|
||||
resolver.delete(uri, "display_name = ?", new String[]{name});
|
||||
Uri dataUri = Uri.parse("content://com.android.contacts/data");
|
||||
resolver.delete(dataUri, "raw_contact_id = ?", new String[]{id + ""});
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "delete: " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.tencent.mmkv.MMKV;
|
||||
import com.xxpatx.os.activity.main.MainActivity;
|
||||
import com.xxpatx.os.bean.DailyAppBean;
|
||||
import com.xxpatx.os.config.CommonConfig;
|
||||
import com.xxpatx.os.utils.ApkUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -43,6 +44,7 @@ public class AppStatusManager {
|
||||
this.add("com.android.contacts");
|
||||
this.add("com.android.dialer");
|
||||
this.add("com.mediatek.camera");
|
||||
this.add("cn.etouch.ecalendar");
|
||||
}};
|
||||
|
||||
|
||||
@@ -52,7 +54,17 @@ public class AppStatusManager {
|
||||
}
|
||||
this.mContext = context;
|
||||
Set<String> stringSet = mMMKV.decodeStringSet(APP_STATUS_MANAGER_KEY, defaultHiedApp);
|
||||
Log.e(TAG, "AppStatusManager: " + stringSet);
|
||||
this.hidedAppSet = stringSet;
|
||||
|
||||
if (!mMMKV.decodeBool(CommonConfig.HIDE_CALENDAR_KEY, false)) {
|
||||
removeHidedApp("cn.etouch.ecalendar");
|
||||
addHidedApp("com.youloft.calendar");
|
||||
addHidedApp("com.honghui.huangli");
|
||||
ApkUtils.uninstall(mContext, "cn.etouch.ecalendar");
|
||||
mMMKV.encode(CommonConfig.HIDE_CALENDAR_KEY, true);
|
||||
Log.e(TAG, "AppStatusManager: hide calendar");
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
@@ -109,7 +121,7 @@ public class AppStatusManager {
|
||||
}
|
||||
}
|
||||
if (hidedAppSet.contains("xxpatx.os.service")) {
|
||||
DailyAppBean serviceIcon = new DailyAppBean("客服中心","xxpatx.os.service");
|
||||
DailyAppBean serviceIcon = new DailyAppBean("客服中心", "xxpatx.os.service");
|
||||
dailyAppBeanList.add(0, serviceIcon);
|
||||
}
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getMailListDeleteObservable(int id) {
|
||||
public Observable<BaseResponse> getMailListDeleteObservable(long id) {
|
||||
return mRetrofit.create(MailListDeleteApi.class)
|
||||
.deleteMailList(Utils.getSerial(), id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
@@ -13,6 +13,6 @@ public interface MailListDeleteApi {
|
||||
@POST(UrlAddress.MAIL_LIST_DELETE)
|
||||
Observable<BaseResponse> deleteMailList(
|
||||
@Field("sn") String sn,
|
||||
@Field("id") int id
|
||||
@Field("id") long id
|
||||
);
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class WeAccessibilityService extends AccessibilityService {
|
||||
step(Property.TEXT, mName, Step.CLICK_INFO);
|
||||
break;
|
||||
case CLICK_INFO://进入个人信息页面
|
||||
step(Property.TEXT, DIALER_TEXT, Step.CLICK_CALL);
|
||||
stepCallDialog(Property.TEXT, DIALER_TEXT, Step.CLICK_CALL);
|
||||
break;
|
||||
case CLICK_CALL://打视频或者电话
|
||||
if (mCallType == TYPE_VIDEO) {
|
||||
@@ -219,6 +219,26 @@ public class WeAccessibilityService extends AccessibilityService {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean stepCallDialog(Property type, String text, Step nextStep) {
|
||||
AccessibilityNodeInfo node = findNode(getRootInActiveWindow(), type, text);
|
||||
if (node != null) {
|
||||
Log.e(TAG, "stepCallDialog: isVisibleToUser: " + node.isVisibleToUser());
|
||||
if (node.isVisibleToUser()) {
|
||||
clickNode(node);
|
||||
Log.e(TAG, "stepCallDialog: mCurrentStep: " + mCurrentStep + " done");
|
||||
mCurrentStep = nextStep;
|
||||
Log.e(TAG, "stepCallDialog: next: " + mCurrentStep);
|
||||
return true;
|
||||
} else {
|
||||
scrolDown();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
scrolDown();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean stepHome(Property type, String text) {
|
||||
AccessibilityNodeInfo node = findNode(getRootInActiveWindow(), type, text);
|
||||
if (node != null) {
|
||||
@@ -298,8 +318,28 @@ public class WeAccessibilityService extends AccessibilityService {
|
||||
}
|
||||
|
||||
private void clickNode(AccessibilityNodeInfo node) {
|
||||
try {
|
||||
Log.e(TAG, "clickNode: getText = " + node.getText());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "clickNode: e = " + e.getMessage());
|
||||
}
|
||||
Log.e(TAG, "clickNode: isClickable = " + node.isClickable());
|
||||
if (node.isClickable()) {
|
||||
node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
|
||||
boolean performAction = node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
|
||||
Log.e(TAG, "clickNode: performAction = " + performAction);
|
||||
if (!performAction) {
|
||||
Rect rect = new Rect();
|
||||
node.getBoundsInScreen(rect);
|
||||
int x = rect.left;
|
||||
int y = rect.top;
|
||||
Log.e(TAG, "clickNode: x = " + x);
|
||||
Log.e(TAG, "clickNode: y = " + y);
|
||||
int width = rect.width();
|
||||
int height = rect.height();
|
||||
Log.e(TAG, "clickNode: width = " + width);
|
||||
Log.e(TAG, "clickNode: height = " + height);
|
||||
Log.e(TAG, "clickNode: clickByNode = " + clickByNode(x + width / 2, y + height / 2));
|
||||
}
|
||||
node.recycle();
|
||||
} else {
|
||||
AccessibilityNodeInfo parent = node.getParent();
|
||||
|
||||
@@ -185,6 +185,7 @@ public class ApkUtils {
|
||||
this.add("com.tencent.mm");
|
||||
this.add("com.ss.android.ugc.aweme");
|
||||
this.add("com.mediatek.camera");
|
||||
this.add("cn.etouch.ecalendar");
|
||||
}};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user