From 8c7c3bef54e8f603bf44a0c8b67d359f137349d4 Mon Sep 17 00:00:00 2001 From: tongtongstudio Date: Sat, 30 Aug 2025 14:30:03 +0800 Subject: [PATCH] =?UTF-8?q?version:1.7.1=20fix:=20update:=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=8B=A8=E5=8F=B7=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 6 +- .../selecttospeak/SelectToSpeakService.java | 174 ++++++++++++++---- .../alarm/edit/AlarmEditActivity.java | 8 +- .../callwechat/CallWechatActivity.java | 7 + .../activity/contact/AddContactViewModel.java | 31 ++-- .../activity/contact/EditContactActivity.java | 47 +++-- .../contact/EditContactViewModel.java | 5 +- .../xxpatx/os/activity/main/MainActivity.java | 17 +- .../os/activity/main/MainViewModel.java | 35 ++-- .../os/activity/setting/SettingActivity.java | 6 + .../com/xxpatx/os/base/BaseApplication.java | 14 ++ .../main/java/com/xxpatx/os/bean/AppInfo.java | 10 + .../main/java/com/xxpatx/os/bean/Contact.java | 9 + .../com/xxpatx/os/bean/ContactConfig.java | 65 +++++++ .../os/fragment/contact/ContactViewModel.java | 2 +- .../os/network/NetInterfaceManager.java | 58 ++++-- .../network/api/uiui/contact/ContactApi.java | 48 +++++ .../network/api/uiui/contact/GetMailList.java | 18 -- .../api/uiui/contact/MailListAddApi.java | 22 --- .../api/uiui/contact/MailListDeleteApi.java | 18 -- .../api/uiui/contact/MailListEditApi.java | 22 --- .../os/service/main/MainSPresenter.java | 9 +- .../xxpatx/os/service/main/MainService.java | 3 +- .../java/com/xxpatx/os/utils/ToastUtils.java | 28 +++ .../layout-sw700dp/activity_contact_add.xml | 135 +++++++++++++- .../main/res/layout/activity_contact_add.xml | 104 +++++++++++ .../main/res/layout/activity_contact_edit.xml | 110 ++++++++++- .../main/res/layout/activity_wechat_call.xml | 21 ++- app/src/main/res/values/colors.xml | 2 + 29 files changed, 844 insertions(+), 190 deletions(-) create mode 100644 app/src/main/java/com/xxpatx/os/bean/ContactConfig.java create mode 100644 app/src/main/java/com/xxpatx/os/network/api/uiui/contact/ContactApi.java delete mode 100644 app/src/main/java/com/xxpatx/os/network/api/uiui/contact/GetMailList.java delete mode 100644 app/src/main/java/com/xxpatx/os/network/api/uiui/contact/MailListAddApi.java delete mode 100644 app/src/main/java/com/xxpatx/os/network/api/uiui/contact/MailListDeleteApi.java delete mode 100644 app/src/main/java/com/xxpatx/os/network/api/uiui/contact/MailListEditApi.java create mode 100644 app/src/main/java/com/xxpatx/os/utils/ToastUtils.java diff --git a/app/build.gradle b/app/build.gradle index 4862d24..649f08e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,8 +17,8 @@ android { applicationId "com.xxpatx.os" minSdkVersion 24 targetSdkVersion 29 - versionCode 1069 - versionName "1.6.9" + versionCode 1071 + versionName "1.7.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -199,6 +199,8 @@ dependencies { // implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' // implementation 'com.squareup.okhttp3:okhttp:4.9.1' + //log打印 + implementation 'com.squareup.okhttp3:logging-interceptor:4.7.0' implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' // implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0' diff --git a/app/src/main/java/com/google/android/accessibility/selecttospeak/SelectToSpeakService.java b/app/src/main/java/com/google/android/accessibility/selecttospeak/SelectToSpeakService.java index 731b3d2..a6814b6 100644 --- a/app/src/main/java/com/google/android/accessibility/selecttospeak/SelectToSpeakService.java +++ b/app/src/main/java/com/google/android/accessibility/selecttospeak/SelectToSpeakService.java @@ -19,14 +19,15 @@ import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityWindowInfo; -import android.widget.Toast; import com.hjq.toast.Toaster; import com.tencent.mmkv.MMKV; import com.xxpatx.os.bean.Contact; import com.xxpatx.os.config.CommonConfig; import com.xxpatx.os.utils.ForegroundAppUtil; +import com.xxpatx.os.utils.ToastUtils; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.Random; @@ -70,7 +71,7 @@ public class SelectToSpeakService extends AccessibilityService { public static final int TYPE_VOICE = 0; public static final int TYPE_VIDEO = 1; - private static final int WAIT_TIME = 1300; + private static final int WAIT_TIME = 1600; private int mCallType = TYPE_VOICE; @@ -79,6 +80,7 @@ public class SelectToSpeakService extends AccessibilityService { private String mName = "";//微信昵称 private String mTagName = "";//微信联系人标签名 private boolean mAutoAccept = false; + private boolean mAutoHandsFree = false; public interface AccessibilityEventCallback { void onAccessibilityEventCallback(AccessibilityEvent accessibilityEvent); @@ -92,6 +94,7 @@ public class SelectToSpeakService extends AccessibilityService { Log.e(TAG, "onCreate: "); registerSettingReceiver(); mAutoAccept = mMMKV.decodeBool(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, false); + mAutoHandsFree = mMMKV.decodeBool(CommonConfig.WECHAT_AUTO_HNADS_FREE, false); analysisAccessibilityEvent(); } @@ -198,20 +201,18 @@ public class SelectToSpeakService extends AccessibilityService { case WAITING: mAutoAccept = mMMKV.decodeBool(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, false); Log.e(TAG, "_onAccessibilityEvent: mAutoAccept = " + mAutoAccept); - if (!mAutoAccept) { - return; - } - if (stepAnswer(Property.DESCRIPTION, RECEIVE_DESCRIPTION)) { - mCurrentStep = Step.WECHAT_HANDS_FREE; - Toast.makeText(this, "已自动接听视频/语音", Toast.LENGTH_LONG).show(); - } else { - mCurrentStep = Step.WAITING; -// clickAnswer(); + if (mAutoAccept) { + autoAccept(); } break; case WECHAT_HANDS_FREE: - handsFree(Property.DESCRIPTION, HANDS_FREE_TEXT); - break; + mAutoHandsFree = mMMKV.decodeInt(CommonConfig.WECHAT_AUTO_HNADS_FREE, 0) == 1; + Log.e(TAG, "_onAccessibilityEvent: mAutoHandsFree = " + mAutoHandsFree); + if (mAutoHandsFree) { + handsFree(Property.DESCRIPTION, HANDS_FREE_TEXT); + } else { + Log.e(TAG, "_onAccessibilityEvent: not enable auto handsfree"); + } case DIALER_HANDS_FREE: if (findHandsFree(Property.DESCRIPTION, DIALER_HANDS_FREE_CLOSE_TEXT)) { dialerHandsFree(Property.TEXT, DIALER_HANDS_FREE_TEXT); @@ -245,6 +246,13 @@ public class SelectToSpeakService extends AccessibilityService { stepCall(Property.TEXT, PARENT_VIDEO_TEXT); // clickVideoCall(); break; + case CLICK_CALL://打视频或者电话 + if (mCallType == TYPE_VIDEO) { + step(Property.TEXT, VIDEO_TEXT, Step.WAITING); + } else if (mCallType == TYPE_VOICE) { + step(Property.TEXT, CALL_TEXT, Step.WAITING); + } + break; case CLICK_CONTACT://进入通讯录界面 if (stepHome(Property.TEXT, CONTACT_TEXT, Step.FIND_TAG)) { @@ -271,17 +279,11 @@ public class SelectToSpeakService extends AccessibilityService { case CLICK_INFO://进入个人信息页面 stepCallDialog(Property.TEXT, DIALER_TEXT, Step.CLICK_CALL); break; - case CLICK_CALL://打视频或者电话 - if (mCallType == TYPE_VIDEO) { - step(Property.TEXT, VIDEO_TEXT, Step.WAITING); - } else if (mCallType == TYPE_VOICE) { - step(Property.TEXT, CALL_TEXT, Step.WAITING); - } - break; + // case CLICK_VIDEO_CALL: // if (step(Property.TEXT, VIDEO_TEXT)) { // Log.d(TAG, "finish, now: " + mCurrentStep); -// Toast.makeText(this, "成功发起视频聊天", Toast.LENGTH_LONG).show(); +// ToastUtils.show("成功发起视频聊天"); // } // break; default: @@ -316,6 +318,95 @@ public class SelectToSpeakService extends AccessibilityService { } } + private void autoAccept() { + if (stepAnswer(Property.DESCRIPTION, RECEIVE_DESCRIPTION)) { + mCurrentStep = Step.WECHAT_HANDS_FREE; + ToastUtils.show("已自动接听视频/语音"); + } else if (clickNode("com.tencent.mm:id/kfp", false)) { + mCurrentStep = Step.WECHAT_HANDS_FREE; + ToastUtils.show("已自动接听视频/语音"); + } else { + mCurrentStep = Step.WAITING; +// clickAnswer(); + } + } + + /** + * @param text 对应文本 + * @param simulate 是否通过坐标模拟点击 + * @return + */ + private boolean clickNode(String text, boolean simulate) { + findFloatWindowNode(text); + List nodeInfos = findNodesByViewId(text); + Optional optional = nodeInfos.stream().findAny(); + if (optional.isPresent()) { + AccessibilityNodeInfo node = optional.get(); + if (node.isClickable()) { + boolean performAction = node.performAction(AccessibilityNodeInfo.ACTION_CLICK); + Log.e(TAG, "clickNode: performAction = " + performAction); + node.recycle(); + return performAction; + } else { + if (simulate) { + Point point = getPointtByNode(node); + Log.e(TAG, "clickNode: " + point); + clickByPoint(point.x, point.y); + Log.e(TAG, "clickNode: mCurrentStep " + mCurrentStep + " done"); + } else { + clickNode(findClickableNode(node)); + } + } + return true; + } else { + Log.e(TAG, "clickNode: not found"); + return false; + } + } + + private AccessibilityNodeInfo findClickableNode(AccessibilityNodeInfo node) { + if (node == null) { + Log.e(TAG, "findClickableNode: node is null"); + return null; + } + if (node.isClickable()) { + return node; + } else { + return findClickableNode(node); + } + } + + public void findFloatWindowNode(String id) { + List windows = getWindows(); + for (AccessibilityWindowInfo window : windows) { + // 筛选悬浮窗窗口 + if (isFloatingWindow(window)) { + AccessibilityNodeInfo rootNode = window.getRoot(); + // 处理悬浮窗节点 + traverseNode(rootNode); + rootNode.recycle(); // 释放资源 + } + } + + } + + private boolean isFloatingWindow(AccessibilityWindowInfo window) { + Log.e(TAG, "isFloatingWindow: " + window.getType()); + // 根据窗口类型或标题筛选 + return window.getType() == AccessibilityWindowInfo.TYPE_ACCESSIBILITY_OVERLAY; + } + + private void traverseNode(AccessibilityNodeInfo node) { + if (node == null) return; + // 提取节点信息(如文本、ID等) + String text = node.getText() != null ? node.getText().toString() : ""; + String id = node.getViewIdResourceName(); + // 递归遍历子节点 + for (int i = 0; i < node.getChildCount(); i++) { + traverseNode(node.getChild(i)); + } + } + @Deprecated private void clickAnswer() { String className = ForegroundAppUtil.getForegroundActivityName(SelectToSpeakService.this); @@ -325,7 +416,7 @@ public class SelectToSpeakService extends AccessibilityService { boolean successful = clickByPoint(595, 1376); Log.e(TAG, "clickAnswer: " + successful); if (successful) { - Toast.makeText(this, "已自动接听视频/语音", Toast.LENGTH_LONG).show(); + ToastUtils.show("已自动接听视频/语音"); } } else { Log.e(TAG, "clickAnswer: Not in the answering interface"); @@ -433,13 +524,19 @@ public class SelectToSpeakService extends AccessibilityService { clickNode(nodeInfo); mCurrentStep = nextStep; } else { - Toaster.show("没有找到搜索按钮"); +// Toaster.show("没有找到搜索按钮"); + step(Property.DESCRIPTION, SEARCH_TEXT, Step.CLICK_SEARCH); } } private List findNodesByViewId(String id) { - List accessibilityNodeInfos = getRootInActiveWindow().findAccessibilityNodeInfosByViewId(id); - return accessibilityNodeInfos; + AccessibilityNodeInfo nodeInfo = getRootInActiveWindow(); + if (nodeInfo != null) { + List accessibilityNodeInfos = nodeInfo.findAccessibilityNodeInfosByViewId(id); + return accessibilityNodeInfos; + } else { + return new ArrayList<>(); + } } private AccessibilityNodeInfo findNodeByText(AccessibilityNodeInfo root, String text) { @@ -478,7 +575,7 @@ public class SelectToSpeakService extends AccessibilityService { } else { if (mFindCount == mMaxCount) { Log.e("stepCallDialog", "mCurrentStep: max"); - Toast.makeText(this, "没有找到联系人", Toast.LENGTH_LONG).show(); + ToastUtils.show("没有找到联系人"); mCurrentStep = Step.WAITING; mFindCount = 0; return false; @@ -522,7 +619,7 @@ public class SelectToSpeakService extends AccessibilityService { } else { if (mFindCount == mMaxCount) { Log.e("findContact", "mCurrentStep: max"); - Toast.makeText(this, "没有找到联系人", Toast.LENGTH_LONG).show(); + ToastUtils.show("没有找到联系人"); mCurrentStep = Step.WAITING; mFindCount = 0; return false; @@ -583,6 +680,10 @@ public class SelectToSpeakService extends AccessibilityService { private void clickNode(AccessibilityNodeInfo node) { + if (node == null) { + Log.e(TAG, "clickNode: node is null"); + return; + } try { Log.e(TAG, "clickNode: getText = " + node.getText()); Log.e(TAG, "clickNode: isClickable = " + node.isClickable()); @@ -811,29 +912,30 @@ public class SelectToSpeakService extends AccessibilityService { WECHAT_HANDS_FREE, //电话免提 DIALER_HANDS_FREE, - //微信主页找用户名 + + //1-1微信主页找用户名 CLICK_HOME, - //进入搜索界面 + //2-2进入搜索界面 CLICK_SEARCH, - //是否弹出了联系人列表 + //2-3是否弹出了联系人列表 CLICK_SEARCH_CONTACT, - //聊天界面+号 + //1-2 2-4聊天界面+号 CLICK_QUICK_WECHAT_CALL, - //更多里面视频通话 + //1-3 2-5更多里面视频通话 CLICK_TARGET, + /*1-4 语音通话*/ + CLICK_CALL, + + //主页点击导航栏通讯录 CLICK_CONTACT, - FIND_CONTACT, //通讯录页面点击标签 FIND_TAG, //点击对应的标签名 CLICK_TAG, - CLICK_NAME, CLICK_INFO, - - CLICK_CALL, CLICK_VIDEO_CALL; private Step next() { diff --git a/app/src/main/java/com/xxpatx/os/activity/alarm/edit/AlarmEditActivity.java b/app/src/main/java/com/xxpatx/os/activity/alarm/edit/AlarmEditActivity.java index 4ebc79d..9bcbac6 100644 --- a/app/src/main/java/com/xxpatx/os/activity/alarm/edit/AlarmEditActivity.java +++ b/app/src/main/java/com/xxpatx/os/activity/alarm/edit/AlarmEditActivity.java @@ -205,15 +205,11 @@ public class AlarmEditActivity extends BaseMvvmActivity params = new HashMap<>(); - params.put("sn", Utils.getSerial()); - params.put("name", name); - params.put("mobile", phone); - params.put("tag", tag); - params.put("is_urgent", String.valueOf(binding.toggleButton.isToggleOn())); - params.put("show_desktop", String.valueOf(binding.tbShow.isToggleOn())); + MultipartBody.Part avatarBody = NetInterfaceManager.convertFileToMultipartBody("avatar", avatarFile, "image/png"); + + Map params = new HashMap<>(); + params.put("sn", NetInterfaceManager.convertToRequestBody(Utils.getSerial())); + params.put("name", NetInterfaceManager.convertToRequestBody(name)); + params.put("mobile", NetInterfaceManager.convertToRequestBody(phone)); + params.put("tag", NetInterfaceManager.convertToRequestBody(tag)); + params.put("is_urgent", NetInterfaceManager.convertToRequestBody(binding.toggleButton.isToggleOn())); + params.put("show_desktop", NetInterfaceManager.convertToRequestBody(binding.tbShow.isToggleOn())); + params.put("config", NetInterfaceManager.convertObjectToJsonRequestBody(contactConfig)); Contact contact = new Contact(); ThreadLocalRandom random = ThreadLocalRandom.current(); @@ -90,7 +99,7 @@ public class AddContactViewModel extends BaseViewModel() { @Override diff --git a/app/src/main/java/com/xxpatx/os/activity/contact/EditContactActivity.java b/app/src/main/java/com/xxpatx/os/activity/contact/EditContactActivity.java index 6e89ea5..c296143 100644 --- a/app/src/main/java/com/xxpatx/os/activity/contact/EditContactActivity.java +++ b/app/src/main/java/com/xxpatx/os/activity/contact/EditContactActivity.java @@ -16,6 +16,7 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.SimpleTarget; import com.bumptech.glide.request.transition.Transition; +import com.google.gson.JsonObject; import com.hjq.toast.Toaster; import com.luck.picture.lib.basic.PictureSelector; import com.luck.picture.lib.config.SelectMimeType; @@ -26,8 +27,10 @@ import com.xxpatx.os.R; import com.xxpatx.os.base.mvvm.BaseMvvmActivity; import com.xxpatx.os.bean.BaseResponse; import com.xxpatx.os.bean.Contact; +import com.xxpatx.os.bean.ContactConfig; import com.xxpatx.os.custom.GlideEngine; import com.xxpatx.os.databinding.ActivityContactEditBinding; +import com.xxpatx.os.network.NetInterfaceManager; import com.xxpatx.os.utils.ContactsUtils; import com.xxpatx.os.utils.FileUtil; import com.xxpatx.os.utils.ScreenUtils; @@ -114,6 +117,9 @@ public class EditContactActivity extends BaseMvvmActivity params = new HashMap<>(); - params.put("sn", Utils.getSerial()); - params.put("id", String.valueOf(mContact.getId())); - params.put("name", name); - params.put("mobile", phone); - params.put("tag", groupTag); - params.put("is_urgent", String.valueOf(mViewDataBinding.toggleButton.isToggleOn())); - params.put("show_desktop", String.valueOf(mViewDataBinding.tbShow.isToggleOn())); + + MultipartBody.Part avatarBody = NetInterfaceManager.convertFileToMultipartBody("avatar", avatarFile, "image/png"); + + Map params = new HashMap<>(); + params.put("sn", NetInterfaceManager.convertToRequestBody(Utils.getSerial())); + params.put("id", NetInterfaceManager.convertToRequestBody(mContact.getId())); + params.put("name", NetInterfaceManager.convertToRequestBody(name)); + params.put("mobile", NetInterfaceManager.convertToRequestBody(phone)); + params.put("tag", NetInterfaceManager.convertToRequestBody(groupTag)); + params.put("is_urgent", NetInterfaceManager.convertToRequestBody(mViewDataBinding.toggleButton.isToggleOn())); + params.put("show_desktop", NetInterfaceManager.convertToRequestBody(mViewDataBinding.tbShow.isToggleOn())); + params.put("config", NetInterfaceManager.convertObjectToJsonRequestBody(contactConfig)); + Contact contact = new Contact(); ThreadLocalRandom random = ThreadLocalRandom.current(); int fakeId = random.nextInt(Integer.MAX_VALUE); @@ -206,7 +220,8 @@ public class EditContactActivity extends BaseMvvmActivity { @@ -32,7 +35,7 @@ public class EditContactViewModel extends BaseViewModel mBaseResponseMutableLiveData = new MutableLiveData<>(); - public void editContact(Map params, MultipartBody.Part body) { + public void editContact(Map params, MultipartBody.Part body) { NetInterfaceManager.getInstance() .getMailListEditObservable(params, body) .compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY)) 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 f6e3e45..9a772f2 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 @@ -148,6 +148,10 @@ public class MainActivity extends BaseMvvmActivity() { @Override diff --git a/app/src/main/java/com/xxpatx/os/activity/main/MainViewModel.java b/app/src/main/java/com/xxpatx/os/activity/main/MainViewModel.java index 51f0e39..d2135fc 100644 --- a/app/src/main/java/com/xxpatx/os/activity/main/MainViewModel.java +++ b/app/src/main/java/com/xxpatx/os/activity/main/MainViewModel.java @@ -24,6 +24,8 @@ import com.tencent.mmkv.MMKV; import com.trello.rxlifecycle4.RxLifecycle; import com.trello.rxlifecycle4.android.ActivityEvent; import com.xxpatx.os.R; +import com.xxpatx.os.activity.setting.SettingActivity; +import com.xxpatx.os.activity.update.UpdateActivity; import com.xxpatx.os.base.mvvm.BaseViewModel; import com.xxpatx.os.bean.ActivationBean; import com.xxpatx.os.bean.AppInfo; @@ -374,7 +376,15 @@ public class MainViewModel extends BaseViewModel params = new HashMap<>(); - params.put("sn", Utils.getSerial()); - params.put("name", contact.getName()); - params.put("mobile", contact.getMobile()); - params.put("tag", contact.getTag()); - params.put("is_urgent", String.valueOf(contact.getIs_urgent())); + + MultipartBody.Part avatarBody = NetInterfaceManager.convertFileToMultipartBody("avatar", avatarFile, "image/png"); + + Map params = new HashMap<>(); + params.put("sn", NetInterfaceManager.convertToRequestBody(Utils.getSerial())); + params.put("name", NetInterfaceManager.convertToRequestBody(contact.getName())); + params.put("mobile", NetInterfaceManager.convertToRequestBody(contact.getMobile())); + params.put("tag", NetInterfaceManager.convertToRequestBody(contact.getTag())); + params.put("is_urgent", NetInterfaceManager.convertToRequestBody(contact.getIs_urgent())); + params.put("show_desktop", NetInterfaceManager.convertToRequestBody(contact.getShow_desktop())); + params.put("config", NetInterfaceManager.convertObjectToJsonRequestBody(contact.getConfig().toJsonObject())); + NetInterfaceManager.getInstance() - .getMailListAddObservable(params, body) + .getMailListAddObservable(params, avatarBody) .compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY)) .subscribe(new Observer() { @Override 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 a808d38..53c79f8 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 @@ -120,6 +120,11 @@ public class SettingActivity extends BaseMvvmActivity>> getContactListObservable() { - return mRetrofit.create(GetMailList.class) + return mRetrofit.create(ContactApi.class) .getContact(Utils.getSerial()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); @@ -402,22 +436,22 @@ public class NetInterfaceManager { .observeOn(AndroidSchedulers.mainThread()); } - public Observable getMailListAddObservable(Map params, MultipartBody.Part body) { - return mRetrofit.create(MailListAddApi.class) - .addMailList(params, body) + public Observable getMailListAddObservable(Map partMap, MultipartBody.Part body) { + return mRetrofit.create(ContactApi.class) + .addMailList(partMap, body) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } - public Observable getMailListEditObservable(Map params, MultipartBody.Part body) { - return mRetrofit.create(MailListEditApi.class) - .editContact(params, body) + public Observable getMailListEditObservable(Map partMap, MultipartBody.Part body) { + return mRetrofit.create(ContactApi.class) + .editContact(partMap, body) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable getMailListDeleteObservable(long id) { - return mRetrofit.create(MailListDeleteApi.class) + return mRetrofit.create(ContactApi.class) .deleteMailList(Utils.getSerial(), id) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); diff --git a/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/ContactApi.java b/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/ContactApi.java new file mode 100644 index 0000000..8c8f721 --- /dev/null +++ b/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/ContactApi.java @@ -0,0 +1,48 @@ +package com.xxpatx.os.network.api.uiui.contact; + +import com.xxpatx.os.bean.BaseResponse; +import com.xxpatx.os.bean.Contact; +import com.xxpatx.os.network.UrlAddress; + +import java.util.List; +import java.util.Map; + +import io.reactivex.rxjava3.core.Observable; +import okhttp3.MultipartBody; +import okhttp3.RequestBody; +import retrofit2.http.Field; +import retrofit2.http.FormUrlEncoded; +import retrofit2.http.GET; +import retrofit2.http.Multipart; +import retrofit2.http.POST; +import retrofit2.http.Part; +import retrofit2.http.PartMap; +import retrofit2.http.Query; + +public interface ContactApi { + @GET(UrlAddress.GET_MAIL_LIST) + Observable>> getContact( + @Query("sn") String sn + ); + + @Multipart + @POST(UrlAddress.MAIL_LIST_ADD) + Observable addMailList( + @PartMap Map partMap, + @Part MultipartBody.Part body + ); + + @Multipart + @POST(UrlAddress.MAIL_LIST_EDIT) + Observable editContact( + @PartMap Map partMap, + @Part MultipartBody.Part body + ); + + @FormUrlEncoded + @POST(UrlAddress.MAIL_LIST_DELETE) + Observable deleteMailList( + @Field("sn") String sn, + @Field("id") long id + ); +} diff --git a/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/GetMailList.java b/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/GetMailList.java deleted file mode 100644 index 03faa36..0000000 --- a/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/GetMailList.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.xxpatx.os.network.api.uiui.contact; - -import com.xxpatx.os.bean.BaseResponse; -import com.xxpatx.os.bean.Contact; -import com.xxpatx.os.network.UrlAddress; - -import java.util.List; - -import io.reactivex.rxjava3.core.Observable; -import retrofit2.http.GET; -import retrofit2.http.Query; - -public interface GetMailList { - @GET(UrlAddress.GET_MAIL_LIST) - Observable>> getContact( - @Query("sn") String sn - ); -} diff --git a/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/MailListAddApi.java b/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/MailListAddApi.java deleted file mode 100644 index f42a1d3..0000000 --- a/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/MailListAddApi.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.xxpatx.os.network.api.uiui.contact; - -import com.xxpatx.os.bean.BaseResponse; -import com.xxpatx.os.network.UrlAddress; - -import java.util.Map; - -import io.reactivex.rxjava3.core.Observable; -import okhttp3.MultipartBody; -import retrofit2.http.Multipart; -import retrofit2.http.POST; -import retrofit2.http.Part; -import retrofit2.http.QueryMap; - -public interface MailListAddApi { - @Multipart - @POST(UrlAddress.MAIL_LIST_ADD) - Observable addMailList( - @QueryMap Map params, - @Part MultipartBody.Part body - ); -} diff --git a/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/MailListDeleteApi.java b/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/MailListDeleteApi.java deleted file mode 100644 index 493ef72..0000000 --- a/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/MailListDeleteApi.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.xxpatx.os.network.api.uiui.contact; - -import com.xxpatx.os.bean.BaseResponse; -import com.xxpatx.os.network.UrlAddress; - -import io.reactivex.rxjava3.core.Observable; -import retrofit2.http.Field; -import retrofit2.http.FormUrlEncoded; -import retrofit2.http.POST; - -public interface MailListDeleteApi { - @FormUrlEncoded - @POST(UrlAddress.MAIL_LIST_DELETE) - Observable deleteMailList( - @Field("sn") String sn, - @Field("id") long id - ); -} diff --git a/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/MailListEditApi.java b/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/MailListEditApi.java deleted file mode 100644 index 807b67e..0000000 --- a/app/src/main/java/com/xxpatx/os/network/api/uiui/contact/MailListEditApi.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.xxpatx.os.network.api.uiui.contact; - -import com.xxpatx.os.bean.BaseResponse; -import com.xxpatx.os.network.UrlAddress; - -import java.util.Map; - -import io.reactivex.rxjava3.core.Observable; -import okhttp3.MultipartBody; -import retrofit2.http.Multipart; -import retrofit2.http.POST; -import retrofit2.http.Part; -import retrofit2.http.QueryMap; - -public interface MailListEditApi { - @Multipart - @POST(UrlAddress.MAIL_LIST_EDIT) - Observable editContact( - @QueryMap Map params, - @Part MultipartBody.Part body - ); -} 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 4fe2835..01d8992 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 @@ -146,9 +146,7 @@ public class MainSPresenter implements MainSContact.Presenter { }); } else { File picFile = new File(alarmClockData.getFile()); - MediaType mediaType = MediaType.Companion.parse("image/png"); - RequestBody requestBody = RequestBody.Companion.create(picFile, mediaType); - MultipartBody.Part body = MultipartBody.Part.createFormData("file", picFile.getName(), requestBody); + MultipartBody.Part body = NetInterfaceManager.convertFileToMultipartBody("file", picFile, "image/png"); NetInterfaceManager.getInstance().getAlarmClockAddObservable(params, body) .compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY)) @@ -211,10 +209,7 @@ public class MainSPresenter implements MainSContact.Presenter { params.put("is_onoff", "1"); File picFile = new File(alarmClockData.getFile()); - MediaType mediaType = MediaType.Companion.parse("image/png"); - RequestBody requestBody = RequestBody.Companion.create(picFile, mediaType); - MultipartBody.Part body = MultipartBody.Part.createFormData("file", picFile.getName(), requestBody); - + MultipartBody.Part body = NetInterfaceManager.convertFileToMultipartBody("file", picFile, "image/png"); return NetInterfaceManager.getInstance().getAlarmClockAddObservable(params, body); } 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 c5d13e5..e9df86c 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 @@ -705,8 +705,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView // fos.write(b, 0, x); // } // fos.close(); - RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file); - MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), requestFile); + MultipartBody.Part body = NetInterfaceManager.convertFileToMultipartBody("file", file, "multipart/form-data"); return getSendFile(filePath, body); } }).subscribeOn(Schedulers.io()) diff --git a/app/src/main/java/com/xxpatx/os/utils/ToastUtils.java b/app/src/main/java/com/xxpatx/os/utils/ToastUtils.java new file mode 100644 index 0000000..47b71d8 --- /dev/null +++ b/app/src/main/java/com/xxpatx/os/utils/ToastUtils.java @@ -0,0 +1,28 @@ +package com.xxpatx.os.utils; + +import android.os.Handler; +import android.os.Looper; +import android.widget.Toast; + +import com.xxpatx.os.base.BaseApplication; + +public class ToastUtils { + + public static void show(String msg) { + Handler mainHandler = new Handler(Looper.getMainLooper()); + new Thread(() -> { + mainHandler.post(() -> { + Toast.makeText(BaseApplication.getContext(), msg, Toast.LENGTH_SHORT).show(); + }); + }).start(); + } + + public static void showLong(String msg) { + Handler mainHandler = new Handler(Looper.getMainLooper()); + new Thread(() -> { + mainHandler.post(() -> { + Toast.makeText(BaseApplication.getContext(), msg, Toast.LENGTH_LONG).show(); + }); + }).start(); + } +} diff --git a/app/src/main/res/layout-sw700dp/activity_contact_add.xml b/app/src/main/res/layout-sw700dp/activity_contact_add.xml index a483c0b..b4feb2a 100644 --- a/app/src/main/res/layout-sw700dp/activity_contact_add.xml +++ b/app/src/main/res/layout-sw700dp/activity_contact_add.xml @@ -289,6 +289,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - diff --git a/app/src/main/res/layout/activity_contact_add.xml b/app/src/main/res/layout/activity_contact_add.xml index c82ca03..9fd6570 100644 --- a/app/src/main/res/layout/activity_contact_add.xml +++ b/app/src/main/res/layout/activity_contact_add.xml @@ -318,6 +318,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_wechat_call.xml b/app/src/main/res/layout/activity_wechat_call.xml index 01595fa..22e8806 100644 --- a/app/src/main/res/layout/activity_wechat_call.xml +++ b/app/src/main/res/layout/activity_wechat_call.xml @@ -15,7 +15,23 @@ type="com.xxpatx.os.bean.Contact" /> + + + + + + + + @@ -210,6 +226,7 @@ #98999a #2384BC #9D9D9D + + #626E82