diff --git a/app/build.gradle b/app/build.gradle
index 598b8ea..6eea283 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -15,8 +15,8 @@ android {
applicationId "com.xxpatx.os"
minSdkVersion 24
targetSdkVersion 29
- versionCode 1049
- versionName "1.4.9"
+ versionCode 1052
+ versionName "1.5.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 238d9cb..a582db6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -154,15 +154,23 @@
android:name=".activity.setting.SettingActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait" />
+
+
+ android:screenOrientation="portrait"
+ android:theme="@style/AppTheme" />
+ android:screenOrientation="portrait"
+ android:theme="@style/AppTheme" />
+ android:screenOrientation="portrait"
+ android:theme="@style/AppTheme" />
+ android:screenOrientation="portrait"
+ android:theme="@style/AppTheme" />
getAllBlockedContactNumbers();
+
+ void addWhitelistContactNumber(String phoneNumber);
+
+ void deleteWhitelistContactNumber(String phoneNumber);
+
+ void deleteAllWhitelistContactNumbers();
+
+ List getAllWhitelistContactNumbers();
+
+ void hangUpPhone();
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/xxpatx/os/activity/main/MainActivity.java b/app/src/main/java/com/xxpatx/os/activity/main/MainActivity.java
index 1ed3fa7..3c2434d 100644
--- a/app/src/main/java/com/xxpatx/os/activity/main/MainActivity.java
+++ b/app/src/main/java/com/xxpatx/os/activity/main/MainActivity.java
@@ -22,7 +22,6 @@ import android.os.Bundle;
import android.provider.CallLog;
import android.provider.ContactsContract;
import android.provider.Settings;
-import android.speech.tts.TextToSpeech;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -65,6 +64,7 @@ import com.xxpatx.os.bean.AppInfo;
import com.xxpatx.os.bean.DesktopIcon;
import com.xxpatx.os.bean.DockApp;
import com.xxpatx.os.bean.MapBean;
+import com.xxpatx.os.bean.SystemSettings;
import com.xxpatx.os.bean.TestAppInfo;
import com.xxpatx.os.config.CommonConfig;
import com.xxpatx.os.databinding.ActivityMainBinding;
@@ -74,6 +74,7 @@ import com.xxpatx.os.fragment.home.HomeFragment;
import com.xxpatx.os.fragment.settings.SettingsFragment;
import com.xxpatx.os.manager.AmapManager;
import com.xxpatx.os.manager.DesktopIconManager;
+import com.xxpatx.os.manager.SpeechManager;
import com.xxpatx.os.service.NotificationService;
import com.xxpatx.os.utils.ApkUtils;
import com.xxpatx.os.utils.AppUsedTimeUtils;
@@ -92,7 +93,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import java.util.Locale;
import me.jessyan.autosize.AutoSizeCompat;
import me.jessyan.autosize.AutoSizeConfig;
@@ -100,7 +100,7 @@ import me.jessyan.autosize.AutoSizeConfig;
import static com.arialyy.aria.core.inf.IEntity.STATE_RUNNING;
public class MainActivity extends BaseMvvmActivity implements NetworkUtils.OnNetworkStatusChangedListener,
- NotificationService.NotificationListener, TextToSpeech.OnInitListener {
+ NotificationService.NotificationListener {
private static final String TAG = "MainActivity";
@@ -690,6 +690,16 @@ public class MainActivity extends BaseMvvmActivity() {
+ @Override
+ public void onChanged(SystemSettings systemSettings) {
+ if (systemSettings.getPhone_white_list() == 1) {
+ mViewModel.getContact();
+ }
+ }
+ });
+ mViewModel.getSetting();
+
registReceiver();
initAmap();
}
@@ -1266,11 +1276,10 @@ public class MainActivity extends BaseMvvmActivity mSystemSettingsData = new MutableLiveData<>();
+
+ public void getSetting() {
+ NetInterfaceManager.getInstance().getSettingControl()
+ .compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
+ .subscribe(new Observer>() {
+ @Override
+ public void onSubscribe(@NonNull Disposable d) {
+ Log.e("getSetting", "onSubscribe: ");
+ }
+
+ @Override
+ public void onNext(@NonNull BaseResponse baseResponse) {
+ Log.e("getSetting", "onNext: " + baseResponse);
+ if (baseResponse.code == 200) {
+ SystemSettings systemSettings = baseResponse.data;
+ mSystemSettingsData.setValue(systemSettings);
+ mMMKV.encode(CommonConfig.HOURLY_TIME_SIGNAL_KEY, systemSettings.getHour_notify());
+ mMMKV.encode(CommonConfig.VOICE_SPEAKER_KEY, systemSettings.getVoice_speaker());
+ mMMKV.encode(CommonConfig.PHONE_WHITE_LIST, systemSettings.getPhone_white_list());
+ }
+ }
+
+ @Override
+ public void onError(@NonNull Throwable e) {
+ Log.e("getSetting", "onError: " + e.getMessage());
+ }
+
+ @Override
+ public void onComplete() {
+ Log.e("getSetting", "onComplete: ");
+ }
+ });
+ }
+
+ public void getContact() {
+ NetInterfaceManager.getInstance().getContactListObservable()
+ .compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
+ .subscribe(new Observer>>() {
+ @Override
+ public void onSubscribe(@NonNull Disposable d) {
+ Log.e("getContact", "onSubscribe: ");
+ }
+
+ @Override
+ public void onNext(@NonNull BaseResponse> listBaseResponse) {
+ Log.e("getContact", "onNext: " + listBaseResponse);
+ if (listBaseResponse.code == 200) {
+ int phone_white_list = mMMKV.decodeInt(CommonConfig.PHONE_WHITE_LIST, 0);
+ if (phone_white_list == 1) {
+ ContactManager.getInstance().deleteAllWhitelist();
+ List contactList = listBaseResponse.data;
+ for (Contact contact : contactList) {
+ if (TextUtils.isEmpty(contact.getMobile())) continue;
+ ContactManager.getInstance().addWhiteList(contact.getMobile());
+ }
+ }
+ } else {
+
+ }
+ }
+
+ @Override
+ public void onError(@NonNull Throwable e) {
+ Log.e("getContact", "onError: ");
+ }
+
+ @Override
+ public void onComplete() {
+ Log.e("getContact", "onComplete: ");
+ }
+ });
+ }
}
diff --git a/app/src/main/java/com/xxpatx/os/activity/phone/WhiteListActivity.java b/app/src/main/java/com/xxpatx/os/activity/phone/WhiteListActivity.java
new file mode 100644
index 0000000..e35d696
--- /dev/null
+++ b/app/src/main/java/com/xxpatx/os/activity/phone/WhiteListActivity.java
@@ -0,0 +1,80 @@
+package com.xxpatx.os.activity.phone;
+
+import android.content.Context;
+import android.telecom.TelecomManager;
+import android.view.View;
+
+import androidx.recyclerview.widget.LinearLayoutManager;
+
+import com.tencent.mmkv.MMKV;
+import com.xxpatx.os.R;
+import com.xxpatx.os.adapter.WhiteListAdapter;
+import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
+import com.xxpatx.os.config.CommonConfig;
+import com.xxpatx.os.databinding.ActivityWhiteListBinding;
+import com.xxpatx.os.manager.ContactManager;
+
+public class WhiteListActivity extends BaseMvvmActivity {
+ private static final String TAG = "WhiteListActivity";
+
+ private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
+
+ private WhiteListAdapter mWhiteListAdapter;
+ private TelecomManager mTelecomManager;
+
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.activity_white_list;
+ }
+
+ @Override
+ protected void initDataBinding() {
+ mViewModel.setCtx(this);
+ mViewModel.setVDBinding(mViewDataBinding);
+ mViewModel.setLifecycle(getLifecycleSubject());
+ mViewDataBinding.setClick(new BtnClick());
+ }
+
+ @Override
+ protected void initView() {
+ mWhiteListAdapter = new WhiteListAdapter();
+ mWhiteListAdapter.setListChangeListener(new WhiteListAdapter.ListChangeListener() {
+ @Override
+ public void onChanged() {
+ mWhiteListAdapter.setPhoneList(ContactManager.getInstance().getWhiteListData());
+ }
+ });
+ LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
+ linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
+ mViewDataBinding.recyclerView.setLayoutManager(linearLayoutManager);
+ mViewDataBinding.recyclerView.setAdapter(mWhiteListAdapter);
+ int phone_white_list = mMMKV.decodeInt(CommonConfig.PHONE_WHITE_LIST, 0);
+ mViewDataBinding.setWhiteList(phone_white_list == 1);
+
+
+ }
+
+ @Override
+ protected void initData() {
+ mTelecomManager = (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
+ mWhiteListAdapter.setPhoneList(ContactManager.getInstance().getWhiteListData());
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ }
+
+
+ public class BtnClick {
+ public void exit(View view) {
+ finish();
+ }
+
+ public void openWhiteList(View view) {
+// int phone_white_list = mMMKV.decodeInt(CommonConfig.PHONE_WHITE_LIST, 0);
+
+ }
+ }
+}
diff --git a/app/src/main/java/com/xxpatx/os/activity/phone/WhiteListViewModel.java b/app/src/main/java/com/xxpatx/os/activity/phone/WhiteListViewModel.java
new file mode 100644
index 0000000..5ea0420
--- /dev/null
+++ b/app/src/main/java/com/xxpatx/os/activity/phone/WhiteListViewModel.java
@@ -0,0 +1,18 @@
+package com.xxpatx.os.activity.phone;
+
+import com.trello.rxlifecycle4.android.ActivityEvent;
+import com.xxpatx.os.base.mvvm.BaseViewModel;
+import com.xxpatx.os.databinding.ActivityWhiteListBinding;
+
+public class WhiteListViewModel extends BaseViewModel {
+
+ @Override
+ public ActivityWhiteListBinding getVDBinding() {
+ return binding;
+ }
+
+ @Override
+ public void onDestroy() {
+
+ }
+}
diff --git a/app/src/main/java/com/xxpatx/os/activity/setting/SettingActivity.java b/app/src/main/java/com/xxpatx/os/activity/setting/SettingActivity.java
index 7d6b8aa..90bc69e 100644
--- a/app/src/main/java/com/xxpatx/os/activity/setting/SettingActivity.java
+++ b/app/src/main/java/com/xxpatx/os/activity/setting/SettingActivity.java
@@ -22,6 +22,7 @@ import com.tencent.mmkv.MMKV;
import com.xxpatx.os.BuildConfig;
import com.xxpatx.os.R;
import com.xxpatx.os.activity.dock.DockActivity;
+import com.xxpatx.os.activity.phone.WhiteListActivity;
import com.xxpatx.os.activity.sim.SimCardActivity;
import com.xxpatx.os.activity.tts.TtsActivity;
import com.xxpatx.os.activity.update.UpdateActivity;
@@ -30,7 +31,6 @@ import com.xxpatx.os.bean.AppInfo;
import com.xxpatx.os.bean.SystemSettings;
import com.xxpatx.os.config.CommonConfig;
import com.xxpatx.os.databinding.ActivitySettingBinding;
-import com.xxpatx.os.dialog.CustomDialog;
import com.xxpatx.os.service.WeAccessibilityService;
import com.xxpatx.os.service.main.MainService;
import com.xxpatx.os.utils.AccessibilityUtils;
@@ -127,14 +127,18 @@ public class SettingActivity extends BaseMvvmActivity {
+ private static final String TAG = "TimeActivity";
+ private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
+
+ private List mTimeList;
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.activity_time;
+ }
+
+ @Override
+ protected void initDataBinding() {
+ mViewModel.setCtx(this);
+ mViewModel.setVDBinding(mViewDataBinding);
+ mViewModel.setLifecycle(getLifecycleSubject());
+ mViewDataBinding.setClick(new BtnClick());
+ }
+
+ @Override
+ protected void initView() {
+ String timeString = mMMKV.decodeString(CommonConfig.TIME_HOUR_LIST_KEY);
+ if (TextUtils.isEmpty(timeString)) {
+ mTimeList = new ArrayList<>();
+ } else {
+ Gson gson = new Gson();
+ Type type = new TypeToken>() {
+ }.getType();
+ try {
+ mTimeList = gson.fromJson(timeString, type);
+ } catch (Exception e) {
+ Log.e(TAG, "getLocalContact: " + e.getMessage());
+ mMMKV.remove(CommonConfig.TIME_HOUR_LIST_KEY);
+ mTimeList = new ArrayList<>();
+ }
+ }
+
+ mTimeList.forEach(new Consumer() {
+ @Override
+ public void accept(Integer integer) {
+ Log.e(TAG, "accept: " + integer);
+ int layoutID = getResources().getIdentifier("sw_time_" + integer, "id", getPackageName());
+ Switch aSwitch = getWindow().findViewById(layoutID);
+ if (aSwitch != null) {
+ aSwitch.setChecked(true);
+ }
+ }
+ });
+ boolean hourly_time = mMMKV.decodeInt(CommonConfig.HOURLY_TIME_SIGNAL_KEY, 0) == 1;
+ mViewDataBinding.swTimeHour.setChecked(hourly_time);
+ mViewDataBinding.swTimeHour.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+ mMMKV.encode(CommonConfig.HOURLY_TIME_SIGNAL_KEY, b ? 1 : 0);
+ }
+ });
+ mViewDataBinding.swTime0.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 0));
+ mViewDataBinding.swTime1.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 1));
+ mViewDataBinding.swTime2.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 2));
+ mViewDataBinding.swTime3.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 3));
+ mViewDataBinding.swTime4.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 4));
+ mViewDataBinding.swTime5.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 5));
+ mViewDataBinding.swTime6.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 6));
+ mViewDataBinding.swTime7.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 7));
+ mViewDataBinding.swTime8.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 8));
+ mViewDataBinding.swTime9.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 9));
+ mViewDataBinding.swTime10.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 10));
+ mViewDataBinding.swTime11.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 11));
+ mViewDataBinding.swTime12.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 12));
+ mViewDataBinding.swTime13.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 13));
+ mViewDataBinding.swTime14.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 14));
+ mViewDataBinding.swTime15.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 15));
+ mViewDataBinding.swTime16.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 16));
+ mViewDataBinding.swTime17.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 17));
+ mViewDataBinding.swTime18.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 18));
+ mViewDataBinding.swTime19.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 19));
+ mViewDataBinding.swTime20.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 20));
+ mViewDataBinding.swTime21.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 21));
+ mViewDataBinding.swTime22.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 22));
+ mViewDataBinding.swTime23.setOnCheckedChangeListener((compoundButton, b) -> setTime(b, 23));
+
+ }
+
+ @Override
+ protected void initData() {
+
+
+ }
+
+ private void setTime(boolean open, Integer integer) {
+ if (mTimeList == null) {
+ mTimeList = new ArrayList<>();
+ }
+ if (open) {
+ mTimeList.add(integer);
+ } else {
+ mTimeList.remove(integer);
+ }
+ Log.e(TAG, "setTime: " + GsonUtils.toJSONString(mTimeList));
+ mMMKV.encode(CommonConfig.TIME_HOUR_LIST_KEY, GsonUtils.toJSONString(mTimeList));
+ }
+
+ public class BtnClick {
+ public void exit(View view) {
+ finish();
+ }
+
+
+ }
+}
diff --git a/app/src/main/java/com/xxpatx/os/activity/setting/TimeViewModel.java b/app/src/main/java/com/xxpatx/os/activity/setting/TimeViewModel.java
new file mode 100644
index 0000000..b4fa64d
--- /dev/null
+++ b/app/src/main/java/com/xxpatx/os/activity/setting/TimeViewModel.java
@@ -0,0 +1,18 @@
+package com.xxpatx.os.activity.setting;
+
+import com.trello.rxlifecycle4.android.ActivityEvent;
+import com.xxpatx.os.base.mvvm.BaseViewModel;
+import com.xxpatx.os.databinding.ActivityTimeBinding;
+
+public class TimeViewModel extends BaseViewModel {
+
+ @Override
+ public ActivityTimeBinding getVDBinding() {
+ return binding;
+ }
+
+ @Override
+ public void onDestroy() {
+
+ }
+}
diff --git a/app/src/main/java/com/xxpatx/os/activity/tts/TtsActivity.java b/app/src/main/java/com/xxpatx/os/activity/tts/TtsActivity.java
index 21ca0b3..b936798 100644
--- a/app/src/main/java/com/xxpatx/os/activity/tts/TtsActivity.java
+++ b/app/src/main/java/com/xxpatx/os/activity/tts/TtsActivity.java
@@ -3,17 +3,14 @@ package com.xxpatx.os.activity.tts;
import android.content.Intent;
import android.speech.tts.TextToSpeech;
import android.text.TextUtils;
-import android.util.Log;
import android.view.View;
-import com.hjq.toast.Toaster;
import com.xxpatx.os.R;
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
import com.xxpatx.os.databinding.ActivityTtsBinding;
+import com.xxpatx.os.manager.SpeechManager;
-import java.util.Locale;
-
-public class TtsActivity extends BaseMvvmActivity implements TextToSpeech.OnInitListener {
+public class TtsActivity extends BaseMvvmActivity {
private static final String TAG = "TtsActivity";
@@ -47,40 +44,13 @@ public class TtsActivity extends BaseMvvmActivity {
+ private static final String TAG = "WhiteListAdapter";
+
+ private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
+
+
+ private Context mContext;
+ private List mPhoneList;
+
+ public void setPhoneList(List phoneList) {
+ mPhoneList = phoneList;
+ Log.e(TAG, "setPhoneList: " + mPhoneList);
+ notifyDataSetChanged();
+ }
+
+ public void setListChangeListener(ListChangeListener listChangeListener) {
+ mListChangeListener = listChangeListener;
+ }
+
+ private ListChangeListener mListChangeListener;
+
+ public interface ListChangeListener {
+ public void onChanged();
+ }
+
+ @NonNull
+ @Override
+ public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ mContext = parent.getContext();
+ return new Holder(LayoutInflater.from(mContext).inflate(R.layout.item_black_list, parent, false));
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull Holder holder, int position) {
+ String phone = mPhoneList.get(position);
+ holder.tv_number.setText(phone);
+ holder.tv_delete.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ //移除黑名单
+ ContactManager.getInstance().deleteWhitelist(phone);
+ mListChangeListener.onChanged();
+ }
+ });
+ }
+
+ @Override
+ public int getItemCount() {
+ return mPhoneList == null ? 0 : mPhoneList.size();
+ }
+
+ public class Holder extends RecyclerView.ViewHolder {
+ TextView tv_number, tv_delete;
+
+ public Holder(@NonNull View itemView) {
+ super(itemView);
+ tv_number = itemView.findViewById(R.id.tv_number);
+ tv_delete = itemView.findViewById(R.id.tv_delete);
+ }
+ }
+}
diff --git a/app/src/main/java/com/xxpatx/os/base/BaseApplication.java b/app/src/main/java/com/xxpatx/os/base/BaseApplication.java
index 2731d24..8920dac 100644
--- a/app/src/main/java/com/xxpatx/os/base/BaseApplication.java
+++ b/app/src/main/java/com/xxpatx/os/base/BaseApplication.java
@@ -24,7 +24,9 @@ import com.xxpatx.os.manager.AmapManager;
import com.xxpatx.os.manager.AppManager;
import com.xxpatx.os.manager.AppStatusManager;
import com.xxpatx.os.manager.ConnectManager;
+import com.xxpatx.os.manager.ContactManager;
import com.xxpatx.os.manager.DesktopIconManager;
+import com.xxpatx.os.manager.SpeechManager;
import com.xxpatx.os.network.NetInterfaceManager;
import com.xxpatx.os.push.PushManager;
import com.xxpatx.os.service.main.MainService;
@@ -47,6 +49,7 @@ public class BaseApplication extends Application {
// 初始化 Toast 框架
Toaster.init(this);
+ SpeechManager.init(this);
CrashReport.initCrashReport(getApplicationContext(), "09fec11058", false);
CrashReport.setDeviceModel(getApplicationContext(), Build.MODEL);
@@ -82,6 +85,7 @@ public class BaseApplication extends Application {
WechatContactManager.init(this);
ContactCacheUtils.init(this);
DesktopIconManager.init(this);
+ ContactManager.init(this);
}
private void aliyunPushInit() {
diff --git a/app/src/main/java/com/xxpatx/os/bean/ClockSetting.java b/app/src/main/java/com/xxpatx/os/bean/ClockSetting.java
new file mode 100644
index 0000000..58ee414
--- /dev/null
+++ b/app/src/main/java/com/xxpatx/os/bean/ClockSetting.java
@@ -0,0 +1,17 @@
+package com.xxpatx.os.bean;
+
+import java.io.Serializable;
+
+public class ClockSetting implements Serializable {
+ private static final long serialVersionUID = 6468022565585720520L;
+
+ String clock;
+
+ public String getClock() {
+ return clock;
+ }
+
+ public void setClock(String clock) {
+ this.clock = clock;
+ }
+}
diff --git a/app/src/main/java/com/xxpatx/os/bean/DockApp.java b/app/src/main/java/com/xxpatx/os/bean/DockApp.java
index 1b16c0a..a7a27ac 100644
--- a/app/src/main/java/com/xxpatx/os/bean/DockApp.java
+++ b/app/src/main/java/com/xxpatx/os/bean/DockApp.java
@@ -22,9 +22,9 @@ public class DockApp implements Serializable {
this.className = className;
}
- public DockApp(String packageName, String className) {
+ public DockApp(String packageName, String appName) {
this.packageName = packageName;
- this.className = className;
+ this.appName = appName;
}
public DockApp(String packageName) {
@@ -67,7 +67,7 @@ public class DockApp implements Serializable {
DockApp d = (DockApp) obj;
return
// Objects.equals(appName, d.appName);&&
- Objects.equals(packageName, d.packageName);
+ Objects.equals(packageName, d.packageName);
// && Objects.equals(className, d.className);
} else {
return false;
diff --git a/app/src/main/java/com/xxpatx/os/bean/SystemSettings.java b/app/src/main/java/com/xxpatx/os/bean/SystemSettings.java
index 1d8a2ec..2a5442b 100644
--- a/app/src/main/java/com/xxpatx/os/bean/SystemSettings.java
+++ b/app/src/main/java/com/xxpatx/os/bean/SystemSettings.java
@@ -70,7 +70,12 @@ public class SystemSettings implements Serializable {
int exit_ctrl;
int connect_page_ctrl;
int connect_edit_ctrl;
+ int contact_desktop;
int desktop_location;
+ int hour_notify;
+ int wechat_auto_accept;
+ int voice_speaker;
+ int phone_white_list;
public int getQch_restore() {
return qch_restore;
@@ -545,6 +550,46 @@ public class SystemSettings implements Serializable {
this.desktop_location = desktop_location;
}
+ public int getContact_desktop() {
+ return contact_desktop;
+ }
+
+ public void setContact_desktop(int contact_desktop) {
+ this.contact_desktop = contact_desktop;
+ }
+
+ public int getHour_notify() {
+ return hour_notify;
+ }
+
+ public void setHour_notify(int hour_notify) {
+ this.hour_notify = hour_notify;
+ }
+
+ public int getWechat_auto_accept() {
+ return wechat_auto_accept;
+ }
+
+ public void setWechat_auto_accept(int wechat_auto_accept) {
+ this.wechat_auto_accept = wechat_auto_accept;
+ }
+
+ public int getVoice_speaker() {
+ return voice_speaker;
+ }
+
+ public void setVoice_speaker(int voice_speaker) {
+ this.voice_speaker = voice_speaker;
+ }
+
+ public int getPhone_white_list() {
+ return phone_white_list;
+ }
+
+ public void setPhone_white_list(int phone_white_list) {
+ this.phone_white_list = phone_white_list;
+ }
+
@Override
public String toString() {
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
diff --git a/app/src/main/java/com/xxpatx/os/config/CommonConfig.java b/app/src/main/java/com/xxpatx/os/config/CommonConfig.java
index 7181f78..df03cb1 100644
--- a/app/src/main/java/com/xxpatx/os/config/CommonConfig.java
+++ b/app/src/main/java/com/xxpatx/os/config/CommonConfig.java
@@ -3,6 +3,10 @@ package com.xxpatx.os.config;
public class CommonConfig {
public static final String MMKV_ID = "InterProcessKV";
+ public static final String ACTION_ADD_BLOCKED_CONTACT_NUMBER = "action.com.zkwl.addBlockedContactNumber";
+ public static final String ACTION_DELETE_BLOCKED_CONTACT_NUMBER = "action.com.zkwl.deleteBlockedContactNumber";
+ public static final String TEMP_PHONE_BLACK_LIST_KEY = "temp_phone_black_list";
+
/*保存的应用版本号*/
public final static String APP_VERSION_CODE = "APP_VERSION_CODE";
@@ -101,6 +105,10 @@ public class CommonConfig {
public static final String VOICE_BROADCAST = "voice_broadcast_key";
/*微信语音自动接听*/
public static final String WECHAT_CALL_AUTO_ACCEPT = "wechat_call_auto_accept";
+ /*app启动播报*/
+ public static final String VOICE_SPEAKER_KEY = "voice_speaker";
+ /*电话白名单*/
+ public static final String PHONE_WHITE_LIST = "phone_white_list";
/*本地设置的*/
/*悬浮窗*/
@@ -142,5 +150,5 @@ public class CommonConfig {
public static final String AMAP_LOCATION_MAP_BEAN = "AMapLocation_MapBean_key";
public static final String AMAP_LOCATION_DISTRICT = "AMapLocationMapBean_key";
-
+ public static final String TIME_HOUR_LIST_KEY = "time_hour_list";
}
diff --git a/app/src/main/java/com/xxpatx/os/db/ContactCacheHelper.java b/app/src/main/java/com/xxpatx/os/db/ContactCacheHelper.java
index e1c7f18..48bc161 100644
--- a/app/src/main/java/com/xxpatx/os/db/ContactCacheHelper.java
+++ b/app/src/main/java/com/xxpatx/os/db/ContactCacheHelper.java
@@ -9,7 +9,7 @@ public class ContactCacheHelper extends SQLiteOpenHelper {
public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "ContactDatabase.db";
- public static final String TABLE_ALARM = "ContactTable";
+ public static final String TABLE_Contact = "ContactTable";
public static final String KEY_ID = "id";
public static final String KEY_NAME = "name";
@@ -19,7 +19,7 @@ public class ContactCacheHelper extends SQLiteOpenHelper {
public static final String KEY_TAG = "tag";
- private static final String CREATE_CONTACT_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_ALARM +
+ private static final String CREATE_CONTACT_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_Contact +
"("
+ KEY_ID + " INTEGER,"
+ KEY_NAME + " TEXT,"
diff --git a/app/src/main/java/com/xxpatx/os/db/ContactCacheUtils.java b/app/src/main/java/com/xxpatx/os/db/ContactCacheUtils.java
index 3293bfb..51692ea 100644
--- a/app/src/main/java/com/xxpatx/os/db/ContactCacheUtils.java
+++ b/app/src/main/java/com/xxpatx/os/db/ContactCacheUtils.java
@@ -76,7 +76,7 @@ public class ContactCacheUtils {
long id = 0;
mDatabase.beginTransaction();
try {
- id = mDatabase.insertWithOnConflict(ContactCacheHelper.TABLE_ALARM, null, values, SQLiteDatabase.CONFLICT_REPLACE);
+ id = mDatabase.insertWithOnConflict(ContactCacheHelper.TABLE_Contact, null, values, SQLiteDatabase.CONFLICT_REPLACE);
mDatabase.setTransactionSuccessful();
} catch (Exception e) {
Log.e(TAG, "addContact: " + e.getMessage());
@@ -100,7 +100,7 @@ public class ContactCacheUtils {
mDatabase.beginTransaction();
try {
for (ContentValues v : contentValuesList) {
- mDatabase.insertWithOnConflict(ContactCacheHelper.TABLE_ALARM, null, v, SQLiteDatabase.CONFLICT_REPLACE);
+ mDatabase.insertWithOnConflict(ContactCacheHelper.TABLE_Contact, null, v, SQLiteDatabase.CONFLICT_REPLACE);
}
mDatabase.setTransactionSuccessful();
} catch (Exception e) {
@@ -127,7 +127,7 @@ public class ContactCacheUtils {
long id = 0;
mDatabase.beginTransaction();
try {
- id = mDatabase.delete(ContactCacheHelper.TABLE_ALARM, " id =" + rowId, null);
+ id = mDatabase.delete(ContactCacheHelper.TABLE_Contact, " id =" + rowId, null);
mDatabase.setTransactionSuccessful();
} catch (Exception e) {
Log.e(TAG, "deleteContact: " + e.getMessage());
@@ -145,7 +145,7 @@ public class ContactCacheUtils {
*/
public List getDatabaseContact() {
List list = new ArrayList<>();
- String selectQuery = "SELECT * FROM " + ContactCacheHelper.TABLE_ALARM;
+ String selectQuery = "SELECT * FROM " + ContactCacheHelper.TABLE_Contact;
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
diff --git a/app/src/main/java/com/xxpatx/os/fragment/app/AppListFragment.java b/app/src/main/java/com/xxpatx/os/fragment/app/AppListFragment.java
index 34ddb9a..062f0e0 100644
--- a/app/src/main/java/com/xxpatx/os/fragment/app/AppListFragment.java
+++ b/app/src/main/java/com/xxpatx/os/fragment/app/AppListFragment.java
@@ -39,6 +39,7 @@ import com.xxpatx.os.dialog.DailyAppDialog;
import com.xxpatx.os.dialog.ShortcutDialog;
import com.xxpatx.os.manager.AppManager;
import com.xxpatx.os.manager.AppStatusManager;
+import com.xxpatx.os.manager.SpeechManager;
import com.xxpatx.os.network.NetInterfaceManager;
import com.xxpatx.os.service.NotificationService;
import com.xxpatx.os.shortcut.ShortcutPkgInfo;
@@ -239,6 +240,7 @@ public class AppListFragment extends BaseFragment {
DesktopIcon desktopIcon = mDesktopIcons.get(index);
if (desktopIcon != null) {
Log.e(TAG, "onItemClick: " + desktopIcon.getPackage());
+ speak(desktopIcon.getTitle());
if (desktopIcon instanceof ShortcutPkgInfo) {
try {
ActivityOptions activityOptions = ActivityOptions.makeClipRevealAnimation(v, v.getScrollX(), v.getScrollY(), v.getMeasuredWidth(), v.getMeasuredHeight());
@@ -482,4 +484,8 @@ public class AppListFragment extends BaseFragment {
// outState.putParcelableArrayList("applicationInfos", mDesktopIcons);
// super.onSaveInstanceState(outState);
}
+
+ private void speak(String text) {
+ SpeechManager.getInstance().speakApp("正在打开 " + text);
+ }
}
diff --git a/app/src/main/java/com/xxpatx/os/fragment/home/HomeFragment.java b/app/src/main/java/com/xxpatx/os/fragment/home/HomeFragment.java
index a27ed22..3e6c29d 100644
--- a/app/src/main/java/com/xxpatx/os/fragment/home/HomeFragment.java
+++ b/app/src/main/java/com/xxpatx/os/fragment/home/HomeFragment.java
@@ -38,6 +38,7 @@ import com.xxpatx.os.bean.MapBean;
import com.xxpatx.os.config.CommonConfig;
import com.xxpatx.os.databinding.FragmentHomeBinding;
import com.xxpatx.os.dialog.SingleDialog;
+import com.xxpatx.os.manager.SpeechManager;
import com.xxpatx.os.push.PushManager;
import com.xxpatx.os.utils.ApkUtils;
import com.xxpatx.os.utils.DayUtils;
@@ -63,8 +64,8 @@ public class HomeFragment extends BaseMvvmFragment getWhiteListData() {
+ if (mZkwlContactManager == null) {
+ Toaster.show("服务未连接");
+ bindService();
+ } else {
+ try {
+ return mZkwlContactManager.getAllWhitelistContactNumbers();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ return new ArrayList<>();
+ }
+
+ public void addWhiteList(String phone) {
+ if (mZkwlContactManager == null) {
+ Toaster.show("服务未连接");
+ bindService();
+ } else {
+ try {
+ mZkwlContactManager.addWhitelistContactNumber(phone);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void deleteWhitelist(String phone) {
+ if (mZkwlContactManager == null) {
+ Toaster.show("服务未连接");
+ bindService();
+ } else {
+ try {
+ mZkwlContactManager.deleteWhitelistContactNumber(phone);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void deleteAllWhitelist() {
+ if (mZkwlContactManager == null) {
+ Toaster.show("服务未连接");
+ bindService();
+ } else {
+ try {
+ mZkwlContactManager.deleteAllWhitelistContactNumbers();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/xxpatx/os/manager/DesktopIconManager.java b/app/src/main/java/com/xxpatx/os/manager/DesktopIconManager.java
index cc8d8b1..82f7783 100644
--- a/app/src/main/java/com/xxpatx/os/manager/DesktopIconManager.java
+++ b/app/src/main/java/com/xxpatx/os/manager/DesktopIconManager.java
@@ -48,10 +48,10 @@ public class DesktopIconManager {
public List getDefaultDockApp() {
List dockApps = new ArrayList<>();
- dockApps.add(new DockApp("xxpatx.os.dialer"));
- dockApps.add(new DockApp("com.tencent.mm"));
- dockApps.add(new DockApp("com.ss.android.ugc.aweme"));
- dockApps.add(new DockApp(getDefaultCameraPackageName()));
+ dockApps.add(new DockApp("xxpatx.os.dialer", "电话"));
+ dockApps.add(new DockApp("com.tencent.mm", "微信"));
+ dockApps.add(new DockApp("com.ss.android.ugc.aweme", "抖音"));
+ dockApps.add(new DockApp(getDefaultCameraPackageName(), "相机"));
return dockApps;
}
diff --git a/app/src/main/java/com/xxpatx/os/manager/SpeechManager.java b/app/src/main/java/com/xxpatx/os/manager/SpeechManager.java
new file mode 100644
index 0000000..b243193
--- /dev/null
+++ b/app/src/main/java/com/xxpatx/os/manager/SpeechManager.java
@@ -0,0 +1,102 @@
+package com.xxpatx.os.manager;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.speech.tts.TextToSpeech;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.hjq.toast.Toaster;
+import com.tencent.mmkv.MMKV;
+import com.xxpatx.os.config.CommonConfig;
+
+import java.util.Locale;
+
+public class SpeechManager implements TextToSpeech.OnInitListener {
+ private static final String TAG = "SpeechManager";
+
+ private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
+
+ @SuppressLint("StaticFieldLeak")
+ private static SpeechManager sInstance;
+ private Context mContext;
+
+ private TextToSpeech mTextToSpeech;
+ private boolean mInitSuccess = false;
+
+ private SpeechManager(Context context) {
+ if (context == null) {
+ throw new RuntimeException("Context is NULL");
+ }
+ this.mContext = context.getApplicationContext();
+ this.mTextToSpeech = new TextToSpeech(mContext, this);
+
+ }
+
+ public static void init(Context context) {
+ if (sInstance == null) {
+ Log.e(TAG, "init: ");
+ sInstance = new SpeechManager(context);
+ }
+ }
+
+ public static SpeechManager getInstance() {
+ if (sInstance == null) {
+ throw new IllegalStateException("You must be init SpeechManager first");
+ }
+ return sInstance;
+ }
+
+
+ @Override
+ public void onInit(int status) {
+ //初始化成功
+ if (status == TextToSpeech.SUCCESS) {
+ mInitSuccess = true;
+ Log.e(TAG, "init success");
+ //设置语言
+ int result = mTextToSpeech.setLanguage(Locale.CHINA);
+ if (result != TextToSpeech.LANG_COUNTRY_AVAILABLE
+ && result != TextToSpeech.LANG_AVAILABLE) {
+ } else {
+ //设置音调
+ mTextToSpeech.setPitch(1.0f);
+ //设置语速,1.0为正常语速
+ mTextToSpeech.setSpeechRate(1.0f);
+ }
+ } else {
+ mInitSuccess = false;
+ Log.e(TAG, "init fail");
+ Toaster.showLong("TTS初始化失败");
+ }
+ }
+
+ public void speak(String text) {
+ if (mTextToSpeech == null) {
+ this.mTextToSpeech = new TextToSpeech(mContext, this);
+ Log.e(TAG, "speak: TextToSpeech is null");
+ Toaster.show("文字转语音引擎初始化失败");
+ return;
+ }
+ if (!mInitSuccess) {
+ this.mTextToSpeech = new TextToSpeech(mContext, this);
+ Log.e(TAG, "speak: TextToSpeech init failed");
+ Toaster.show("文字转语音引擎初始化失败");
+ return;
+ }
+ if (TextUtils.isEmpty(text)) {
+ Log.e(TAG, "speak: text is empty");
+ return;
+ }
+ mTextToSpeech.speak(text, TextToSpeech.QUEUE_ADD, null);
+ }
+
+ public void speakApp(String text) {
+ boolean voice_speaker = mMMKV.decodeBool(CommonConfig.VOICE_SPEAKER_KEY, false);
+ Log.e(TAG, "speakApp: " + voice_speaker);
+ if (voice_speaker) {
+ speak(text);
+ }
+ }
+
+}
diff --git a/app/src/main/java/com/xxpatx/os/network/NetInterfaceManager.java b/app/src/main/java/com/xxpatx/os/network/NetInterfaceManager.java
index 40a484a..676eca7 100644
--- a/app/src/main/java/com/xxpatx/os/network/NetInterfaceManager.java
+++ b/app/src/main/java/com/xxpatx/os/network/NetInterfaceManager.java
@@ -3,6 +3,7 @@ package com.xxpatx.os.network;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Environment;
+import android.text.TextUtils;
import android.util.Log;
import com.google.gson.Gson;
@@ -21,6 +22,7 @@ import com.xxpatx.os.bean.AlarmClockId;
import com.xxpatx.os.bean.AppInfo;
import com.xxpatx.os.bean.ArticleList;
import com.xxpatx.os.bean.BaseResponse;
+import com.xxpatx.os.bean.ClockSetting;
import com.xxpatx.os.bean.Contact;
import com.xxpatx.os.bean.DemandBean;
import com.xxpatx.os.bean.ExpressData;
@@ -45,6 +47,7 @@ import com.xxpatx.os.disklrucache.CacheHelper;
import com.xxpatx.os.gson.GsonUtils;
import com.xxpatx.os.manager.ConnectManager;
import com.xxpatx.os.manager.ConnectMode;
+import com.xxpatx.os.manager.ContactManager;
import com.xxpatx.os.network.api.qweather.LookupApi;
import com.xxpatx.os.network.api.uiui.ActivityListApi;
import com.xxpatx.os.network.api.uiui.AddressIndexApi;
@@ -85,6 +88,7 @@ import com.xxpatx.os.network.api.uiui.order.OrderIndexApi;
import com.xxpatx.os.network.api.uiui.pay.GoodsBuyApi;
import com.xxpatx.os.network.api.uiui.pay.OrderPayApi;
import com.xxpatx.os.network.api.uiui.pay.OrderPayCheckApi;
+import com.xxpatx.os.network.api.uiui.sn.ClockSettingApi;
import com.xxpatx.os.network.api.uiui.sn.FamilyAddressApi;
import com.xxpatx.os.network.api.uiui.sn.SendScreenshotApi;
import com.xxpatx.os.network.api.uiui.sn.SettingApi;
@@ -427,6 +431,14 @@ public class NetInterfaceManager {
.observeOn(AndroidSchedulers.mainThread());
}
+ public Observable> getClockSettingObservable() {
+ return mRetrofit.create(ClockSettingApi.class)
+ .getClockSetting(Utils.getSerial())
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread());
+ }
+
+
/*
*闹钟相关
*/
@@ -1168,6 +1180,8 @@ public class NetInterfaceManager {
mMMKV.encode("is_shopping", systemSettings.getIs_shopping());
mMMKV.encode("is_info", systemSettings.getIs_info());
String s = systemSettings.getSetting_sos();
+ mMMKV.encode(CommonConfig.PHONE_WHITE_LIST, systemSettings.getPhone_white_list());
+
} else {
mCacheHelper.put(UrlAddress.GET_SETTINGS, "");
if (callback != null) callback.setContact(null);
@@ -1242,6 +1256,16 @@ public class NetInterfaceManager {
ContactsUtils.saveContactPhone(mContext, contactList);
List emergencyConcacts = contactList.stream().filter(contact -> contact.getIs_urgent() == 1).collect(Collectors.toList());
mMMKV.putString(CommonConfig.EMERGENCY_CONTACT_LIST_KEY, GsonUtils.toJSONString(emergencyConcacts));
+
+ int phone_white_list = mMMKV.decodeInt(CommonConfig.PHONE_WHITE_LIST, 0);
+ if (phone_white_list == 1) {
+ ContactManager.getInstance().deleteAllWhitelist();
+ for (Contact contact : contactList) {
+ if (TextUtils.isEmpty(contact.getMobile())) continue;
+ ContactManager.getInstance().addWhiteList(contact.getMobile());
+ }
+ }
+
if (callback != null) {
callback.setContact(contactList);
}
@@ -1264,7 +1288,6 @@ public class NetInterfaceManager {
Log.e("getContactList", "onComplete: ");
if (callback != null) callback.onComplete();
}
-
};
}
diff --git a/app/src/main/java/com/xxpatx/os/network/UrlAddress.java b/app/src/main/java/com/xxpatx/os/network/UrlAddress.java
index 5d7cb4a..fa66af3 100644
--- a/app/src/main/java/com/xxpatx/os/network/UrlAddress.java
+++ b/app/src/main/java/com/xxpatx/os/network/UrlAddress.java
@@ -70,6 +70,9 @@ public class UrlAddress {
/*编号查询联系人*/
public static final String MAIL_LIST_BY_ID = "MailList/mailListById";
+ /*整点报时设置*/
+ public static final String CLOCK_SETTING = "sn/clock-setting";
+
/**
* 应用统计
*/
diff --git a/app/src/main/java/com/xxpatx/os/network/api/uiui/sn/ClockSettingApi.java b/app/src/main/java/com/xxpatx/os/network/api/uiui/sn/ClockSettingApi.java
new file mode 100644
index 0000000..c703c38
--- /dev/null
+++ b/app/src/main/java/com/xxpatx/os/network/api/uiui/sn/ClockSettingApi.java
@@ -0,0 +1,16 @@
+package com.xxpatx.os.network.api.uiui.sn;
+
+import com.xxpatx.os.bean.BaseResponse;
+import com.xxpatx.os.bean.ClockSetting;
+import com.xxpatx.os.network.UrlAddress;
+
+import io.reactivex.rxjava3.core.Observable;
+import retrofit2.http.GET;
+import retrofit2.http.Query;
+
+public interface ClockSettingApi {
+ @GET(UrlAddress.CLOCK_SETTING)
+ Observable> getClockSetting(
+ @Query("sn") String sn
+ );
+}
diff --git a/app/src/main/java/com/xxpatx/os/service/WeAccessibilityService.java b/app/src/main/java/com/xxpatx/os/service/WeAccessibilityService.java
index b423bc5..c41d3f5 100644
--- a/app/src/main/java/com/xxpatx/os/service/WeAccessibilityService.java
+++ b/app/src/main/java/com/xxpatx/os/service/WeAccessibilityService.java
@@ -49,6 +49,9 @@ public class WeAccessibilityService extends AccessibilityService {
private static final String CALL_TEXT = "语音通话";
private static final String RECEIVE_DESCRIPTION = "接听";
+ private static final String HANDS_FREE_TEXT = "扬声器已关";
+ private static final String DIALER_HANDS_FREE_TEXT = "免提";
+ private static final String DIALER_HANDS_FREE_CLOSE_TEXT = "免提,已关闭";
public static final int TYPE_VOICE = 0;
public static final int TYPE_VIDEO = 1;
@@ -138,6 +141,10 @@ public class WeAccessibilityService extends AccessibilityService {
Log.e(TAG, "_onAccessibilityEvent: " + mCurrentStep);
switch (mCurrentStep) {
case WAITING:
+ if (!TextUtils.isEmpty(event.getPackageName()) && "com.android.dialer".equals(event.getPackageName())) {
+ Log.e(TAG, "_onAccessibilityEvent: to dialer hands free");
+ mCurrentStep = Step.DIALER_HANDS_FREE;
+ }
break;
default:
if (!TextUtils.isEmpty(event.getClassName())) {
@@ -158,12 +165,22 @@ public class WeAccessibilityService extends AccessibilityService {
return;
}
if (stepAnswer(Property.DESCRIPTION, RECEIVE_DESCRIPTION)) {
- mCurrentStep = Step.WAITING;
+ mCurrentStep = Step.WECHAT_HANDS_FREE;
Toast.makeText(this, "已自动接听视频/语音", Toast.LENGTH_LONG).show();
} else {
// clickAnswer();
}
break;
+ case WECHAT_HANDS_FREE:
+ handsFree(Property.DESCRIPTION, HANDS_FREE_TEXT);
+ break;
+ case DIALER_HANDS_FREE:
+ if (findHandsFree(Property.DESCRIPTION, DIALER_HANDS_FREE_CLOSE_TEXT)) {
+ dialerHandsFree(Property.TEXT, DIALER_HANDS_FREE_TEXT);
+ } else {
+ mCurrentStep = Step.WAITING;
+ }
+ break;
case CLICK_HOME://主页能找到直接点击进去更多
stepHome(Property.TEXT, mName);
break;
@@ -524,6 +541,51 @@ public class WeAccessibilityService extends AccessibilityService {
}
}
+ private boolean dialerHandsFree(Property type, String text) {
+ AccessibilityNodeInfo node = findNode(getWindows(), type, text);
+ if (node != null) {
+ Rect rect = new Rect();
+ node.getBoundsInScreen(rect);
+ Log.e(TAG, "dialerHandsFree: rect = " + rect);
+ clickNode(node);
+ Log.e(TAG, "dialerHandsFree: mCurrentStep: " + mCurrentStep + " done");
+ mCurrentStep = Step.WAITING;
+ Log.e(TAG, "dialerHandsFree: next: " + mCurrentStep);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private boolean findHandsFree(Property type, String text) {
+ AccessibilityNodeInfo node = findNode(getWindows(), type, text);
+ if (node != null) {
+ Log.e(TAG, "findHandsFree: true");
+ return true;
+ } else {
+ Log.e(TAG, "findHandsFree: false");
+ return false;
+ }
+ }
+
+ private boolean handsFree(Property type, String text) {
+ AccessibilityNodeInfo node = findNode(getWindows(), type, text);
+ if (node != null) {
+ Point point = getPointtByNode(node);
+ Log.e(TAG, "handsFree: " + point);
+ clickByPoint(point.x, point.y - 50);
+ clickByPoint(point.x, point.y);
+// clickNode(node);
+ Log.e(TAG, "handsFree: mCurrentStep " + mCurrentStep + " done");
+ mCurrentStep = Step.WAITING;
+ Log.e(TAG, "handsFree: next " + mCurrentStep);
+ return true;
+ } else {
+ Log.e(TAG, "handsFree: not found");
+ return false;
+ }
+ }
+
//根据节点信息可获得对应的x,y坐标
static Point getPointtByNode(AccessibilityNodeInfo node) {
if (node == null) {
@@ -609,6 +671,8 @@ public class WeAccessibilityService extends AccessibilityService {
private enum Step {
WAITING,
+ WECHAT_HANDS_FREE,
+ DIALER_HANDS_FREE,
CLICK_HOME,
CLICK_QUICK_WECHAT_CALL,
CLICK_TARGET,
diff --git a/app/src/main/java/com/xxpatx/os/service/main/MainSContact.java b/app/src/main/java/com/xxpatx/os/service/main/MainSContact.java
index 67f5e76..32069b8 100644
--- a/app/src/main/java/com/xxpatx/os/service/main/MainSContact.java
+++ b/app/src/main/java/com/xxpatx/os/service/main/MainSContact.java
@@ -13,6 +13,10 @@ public class MainSContact {
void editAlarmClock();
void updateAlarmClock();
void deleteAlarmClock();
+
+ void getClockSetting();
+
+ void getContact();
}
public interface MainSView extends BaseView {
@@ -21,5 +25,9 @@ public class MainSContact {
void editAlarmClockFinish();
void updateAlarmClockFinish();
void deleteAlarmClockFinish();
+
+ void getClockSettingFinish();
+
+ void getContactFinish();
}
}
diff --git a/app/src/main/java/com/xxpatx/os/service/main/MainSPresenter.java b/app/src/main/java/com/xxpatx/os/service/main/MainSPresenter.java
index 8a00ee6..7a6dfca 100644
--- a/app/src/main/java/com/xxpatx/os/service/main/MainSPresenter.java
+++ b/app/src/main/java/com/xxpatx/os/service/main/MainSPresenter.java
@@ -12,12 +12,17 @@ import com.xxpatx.os.alarm.AlarmClockData;
import com.xxpatx.os.alarm.AlarmUtils;
import com.xxpatx.os.bean.AlarmClockId;
import com.xxpatx.os.bean.BaseResponse;
+import com.xxpatx.os.bean.ClockSetting;
+import com.xxpatx.os.bean.Contact;
import com.xxpatx.os.config.CommonConfig;
+import com.xxpatx.os.gson.GsonUtils;
+import com.xxpatx.os.manager.ContactManager;
import com.xxpatx.os.network.NetInterfaceManager;
import com.xxpatx.os.utils.Utils;
import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -292,6 +297,86 @@ public class MainSPresenter implements MainSContact.Presenter {
}
}
+ @Override
+ public void getClockSetting() {
+ NetInterfaceManager.getInstance().getClockSettingObservable()
+ .compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
+ .subscribe(new Observer>() {
+ @Override
+ public void onSubscribe(@NonNull Disposable d) {
+ Log.e("getClockSetting", "onSubscribe: ");
+ }
+
+ @Override
+ public void onNext(@NonNull BaseResponse baseResponse) {
+ Log.e("getClockSetting", "onNext: " + baseResponse);
+ if (baseResponse.code == 200) {
+ ClockSetting clockSetting = baseResponse.data;
+ String time = clockSetting.getClock();
+ List integers = new ArrayList<>();
+ List timeLsit = new ArrayList<>(Arrays.asList(time.split(",")));
+ for (String s : timeLsit) {
+ integers.add(Integer.parseInt(s));
+ }
+ mMMKV.encode(CommonConfig.TIME_HOUR_LIST_KEY, GsonUtils.toJSONString(integers));
+ }
+ }
+
+ @Override
+ public void onError(@NonNull Throwable e) {
+ Log.e("getClockSetting", "onError: " + e.getMessage());
+ }
+
+ @Override
+ public void onComplete() {
+ Log.e("getClockSetting", "onComplete: ");
+ }
+ });
+ }
+
+ @Override
+ public void getContact() {
+ NetInterfaceManager.getInstance().getContactListObservable()
+ .compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
+ .subscribe(new Observer>>() {
+ @Override
+ public void onSubscribe(@NonNull Disposable d) {
+ Log.e("getContact", "onSubscribe: ");
+ }
+
+ @Override
+ public void onNext(@NonNull BaseResponse> listBaseResponse) {
+ Log.e("getContact", "onNext: " + listBaseResponse);
+ if (listBaseResponse.code == 200) {
+ int phone_white_list = mMMKV.decodeInt(CommonConfig.PHONE_WHITE_LIST, 0);
+ if (phone_white_list == 1) {
+ ContactManager.getInstance().deleteAllWhitelist();
+ List contactList = listBaseResponse.data;
+ for (Contact contact : contactList) {
+ if (TextUtils.isEmpty(contact.getMobile())) continue;
+ ContactManager.getInstance().addWhiteList(contact.getMobile());
+ }
+ } else {
+ ContactManager.getInstance().deleteAllWhitelist();
+ }
+ } else {
+
+ }
+ }
+
+ @Override
+ public void onError(@NonNull Throwable e) {
+ Log.e("getContact", "onError: ");
+ }
+
+ @Override
+ public void onComplete() {
+ Log.e("getContact", "onComplete: ");
+ }
+ });
+ }
+
+
/**
* 创建被观察者集合
*
diff --git a/app/src/main/java/com/xxpatx/os/service/main/MainService.java b/app/src/main/java/com/xxpatx/os/service/main/MainService.java
index b6e2e98..c5d13e5 100644
--- a/app/src/main/java/com/xxpatx/os/service/main/MainService.java
+++ b/app/src/main/java/com/xxpatx/os/service/main/MainService.java
@@ -42,6 +42,7 @@ import com.xxpatx.os.base.rx.BaseRxService;
import com.xxpatx.os.bean.AppInfo;
import com.xxpatx.os.bean.BaseResponse;
import com.xxpatx.os.config.CommonConfig;
+import com.xxpatx.os.manager.ContactManager;
import com.xxpatx.os.network.NetInterfaceManager;
import com.xxpatx.os.receiver.SmsReceiver;
import com.xxpatx.os.utils.ApkUtils;
@@ -55,6 +56,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
+import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
@@ -98,6 +100,8 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
private static final String XXOS_ACTION_TIME_TICK = "xxos_time_tick";
public static final String XXOS_ACTION_TIME_CHANGED = "xxos_time_changed";
+ private List mTimeList;
+
public MainService() {
}
@@ -111,6 +115,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
public void onConnected(NetworkUtils.NetworkType networkType) {
if (isScreenOn()) {
mPresenter.addAlarmClock();
+ mPresenter.getClockSetting();
}
}
@@ -254,7 +259,22 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
@Override
public void onNext(@NonNull Integer hour) {
Log.e("mTimeSignalCallback", "onNext: " + hour);
- if (hour > 6 && hour < 22) {
+ String timeString = mMMKV.decodeString(CommonConfig.TIME_HOUR_LIST_KEY);
+ if (TextUtils.isEmpty(timeString)) {
+ mTimeList = new ArrayList<>();
+ } else {
+ Gson gson = new Gson();
+ Type type = new TypeToken>() {
+ }.getType();
+ try {
+ mTimeList = gson.fromJson(timeString, type);
+ } catch (Exception e) {
+ Log.e(TAG, "getLocalContact: " + e.getMessage());
+ mMMKV.remove(CommonConfig.TIME_HOUR_LIST_KEY);
+ mTimeList = new ArrayList<>();
+ }
+ }
+ if (mTimeList.indexOf(hour) != -1) {
mSoundPool.play(soundMap.get(hour), 1, 1, 0, 0, 1);
} else {
/*10点到86点不报时*/
@@ -272,6 +292,14 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
Log.e("mTimeSignalCallback", "onComplete: ");
}
});
+ mPresenter.getClockSetting();
+
+ int phone_white_list = mMMKV.decodeInt(CommonConfig.PHONE_WHITE_LIST, 0);
+ if (phone_white_list == 1) {
+ mPresenter.getContact();
+ } else {
+ ContactManager.getInstance().deleteAllWhitelist();
+ }
}
private void setAlarmTime() {
@@ -333,6 +361,16 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
mPresenter.getAlarmClock();
}
+ @Override
+ public void getClockSettingFinish() {
+
+ }
+
+ @Override
+ public void getContactFinish() {
+
+ }
+
@Override
public void onDestroy() {
super.onDestroy();
@@ -486,7 +524,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
private TimeSignalCallback mTimeSignalCallback;
private void hourlyTimeSignal() {
- boolean hourly_time = mMMKV.decodeBool(CommonConfig.HOURLY_TIME_SIGNAL_KEY, false);
+ boolean hourly_time = mMMKV.decodeInt(CommonConfig.HOURLY_TIME_SIGNAL_KEY, 0) == 1;
if (hourly_time) {
Calendar cal = Calendar.getInstance();
int hour = cal.get(Calendar.HOUR_OF_DAY);
@@ -502,7 +540,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
}
private void alarmWakeup() {
- boolean hourly_time = mMMKV.decodeBool(CommonConfig.HOURLY_TIME_SIGNAL_KEY, false);
+ boolean hourly_time = mMMKV.decodeInt(CommonConfig.HOURLY_TIME_SIGNAL_KEY, 0) == 1;
if (hourly_time) {
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
@@ -521,6 +559,9 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
IntentFilter filter = new IntentFilter();
filter.addAction(HOURLY_TIME_SIGNAL_KEY);
filter.addAction(WECHAT_AUTO_ACCEPT);
+ filter.addAction(VOICE_SPEAKER_KEY);
+ filter.addAction(PHONE_WHITE_LIST);
+ filter.addAction(HOURLY_TIME_SLOT_KEY);
registerReceiver(mTimeSignalReceiver, filter);
}
@@ -528,6 +569,9 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
private static final String HOURLY_TIME_SIGNAL_KEY = "hourly_time_signal";
private static final String WECHAT_AUTO_ACCEPT = "wechat_auto_accept";
+ private static final String VOICE_SPEAKER_KEY = "voice_speaker";
+ private static final String PHONE_WHITE_LIST = "phone_white_list";
+ private static final String HOURLY_TIME_SLOT_KEY = "HOURLY_TIME_SLOT";
private class TimeSignalReceiver extends BroadcastReceiver {
@@ -543,13 +587,31 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
case HOURLY_TIME_SIGNAL_KEY:
int hour_notify = intent.getIntExtra("hour_notify", 0);
Log.e("TimeSignalReceiver", "onReceive: hour_notify = " + hour_notify);
- mMMKV.encode(CommonConfig.HOURLY_TIME_SIGNAL_KEY, hour_notify == 1);
+ mMMKV.encode(CommonConfig.HOURLY_TIME_SIGNAL_KEY, hour_notify);
break;
case WECHAT_AUTO_ACCEPT:
int wechat_auto_accept = intent.getIntExtra("wechat_auto_accept", 0);
Log.e("TimeSignalReceiver", "onReceive: wechat_auto_accept = " + wechat_auto_accept);
mMMKV.encode(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, wechat_auto_accept == 1);
break;
+ case VOICE_SPEAKER_KEY:
+ int voice_speaker = intent.getIntExtra("voice_speaker", 0);
+ Log.e("TimeSignalReceiver", "onReceive: voice_speaker = " + voice_speaker);
+ mMMKV.encode(CommonConfig.VOICE_SPEAKER_KEY, voice_speaker == 1);
+ break;
+ case PHONE_WHITE_LIST:
+ int phone_white_list = intent.getIntExtra("phone_white_list", 0);
+ Log.e("TimeSignalReceiver", "onReceive: phone_white_list = " + phone_white_list);
+ mMMKV.encode(CommonConfig.PHONE_WHITE_LIST, phone_white_list);
+ if (phone_white_list == 1) {
+ mPresenter.getContact();
+ } else {
+ ContactManager.getInstance().deleteAllWhitelist();
+ }
+ break;
+ case HOURLY_TIME_SLOT_KEY:
+ mPresenter.getClockSetting();
+ break;
default:
}
diff --git a/app/src/main/java/com/xxpatx/os/utils/Utils.java b/app/src/main/java/com/xxpatx/os/utils/Utils.java
index c9d41c3..9610a9c 100644
--- a/app/src/main/java/com/xxpatx/os/utils/Utils.java
+++ b/app/src/main/java/com/xxpatx/os/utils/Utils.java
@@ -66,7 +66,7 @@ public class Utils {
Log.e("e", "读取设备序列号异常:" + e.toString());
}
if (BuildConfig.DEBUG) {
-// return "TYZ185P5250101467";
+// return "TYZ185P5250100275";
}
return serial;
}
diff --git a/app/src/main/res/layout-sw700dp/activity_setting.xml b/app/src/main/res/layout-sw700dp/activity_setting.xml
index d30f440..645bdd1 100644
--- a/app/src/main/res/layout-sw700dp/activity_setting.xml
+++ b/app/src/main/res/layout-sw700dp/activity_setting.xml
@@ -288,6 +288,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_white_list.xml b/app/src/main/res/layout/activity_white_list.xml
new file mode 100644
index 0000000..9efb938
--- /dev/null
+++ b/app/src/main/res/layout/activity_white_list.xml
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_black_list.xml b/app/src/main/res/layout/item_black_list.xml
new file mode 100644
index 0000000..fcd4c93
--- /dev/null
+++ b/app/src/main/res/layout/item_black_list.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/accessibility_service_config.xml b/app/src/main/res/xml/accessibility_service_config.xml
index 143597b..dc0384e 100644
--- a/app/src/main/res/xml/accessibility_service_config.xml
+++ b/app/src/main/res/xml/accessibility_service_config.xml
@@ -6,4 +6,4 @@
android:canRetrieveWindowContent="true"
android:description="@string/accessibility_service_description"
android:notificationTimeout="100"
- android:packageNames="com.tencent.mm" />
+ android:packageNames="com.tencent.mm,com.android.dialer" />