在号码识别对比中,兼容当前区域号码。
This commit is contained in:
parent
fa43d43110
commit
2c91d32e41
@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Apr 01 19:55:49 HKT 2025
|
||||
#Mon Apr 14 08:23:49 GMT 2025
|
||||
stageCount=5
|
||||
libraryProject=
|
||||
baseVersion=15.2
|
||||
publishVersion=15.2.4
|
||||
buildCount=0
|
||||
buildCount=12
|
||||
baseBetaVersion=15.2.5
|
||||
|
@ -36,7 +36,7 @@ public class SMSRecevier extends BroadcastReceiver {
|
||||
|
||||
String szAction = intent.getAction();
|
||||
if (szAction.equals(ACTION_SMS_RECEIVED)) {
|
||||
//LogUtils.d(TAG, "ACTION_SMS_RECEIVED");
|
||||
LogUtils.d(TAG, "ACTION_SMS_RECEIVED");
|
||||
String szSmsBody = SMSUtil.getSmsBody(intent);
|
||||
String szSmsAddress = SMSUtil.getSmsAddress(intent);
|
||||
AppConfigUtil configUtil = AppConfigUtil.getInstance(context);
|
||||
|
@ -62,13 +62,39 @@ public class PhoneUtil {
|
||||
|
||||
public boolean isPhoneInContacts(String szPhone) {
|
||||
List<PhoneBean> listPhoneDto = getPhoneList();
|
||||
LogUtils.d(TAG, String.format("isPhoneInContacts(...) listPhoneDto.size() %d", listPhoneDto.size()));
|
||||
for (int i = 0; i < listPhoneDto.size(); i++) {
|
||||
if (listPhoneDto.get(i).getTelPhone().equals(szPhone)) {
|
||||
if (isTheSamePhoneNumber(listPhoneDto.get(i).getTelPhone(), szPhone)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isTheSamePhoneNumber(String szNum1, String szNum2) {
|
||||
//LogUtils.d(TAG, String.format("szNum1 %s\nszNum2 %s", szNum1, szNum2));
|
||||
if(szNum1.equals(szNum2)) {
|
||||
LogUtils.d(TAG, "szNum1.equals(szNum2)");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(UnitAreaUtils.getInstance(mContext).isCurrentUnitAreaNumber(szNum1)) {
|
||||
if(szNum1.equals(UnitAreaUtils.getInstance(mContext).genCurrentUnitAreaNumber(szNum2))) {
|
||||
LogUtils.d(TAG, "szNum1.equals(UnitAreaUtils.genCurrentUnitAreaNumber(szNum2))");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(UnitAreaUtils.getInstance(mContext).isCurrentUnitAreaNumber(szNum2)) {
|
||||
if(szNum2.equals(UnitAreaUtils.getInstance(mContext).genCurrentUnitAreaNumber(szNum1))) {
|
||||
LogUtils.d(TAG, "szNum2.equals(UnitAreaUtils.genCurrentUnitAreaNumber(szNum1))");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
LogUtils.d(TAG, "isTheSamePhoneNumber(...) return false;");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// 检验电话号码是否是数字
|
||||
|
@ -0,0 +1,47 @@
|
||||
package cc.winboll.studio.mymessagemanager.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/04/14 15:55:36
|
||||
* @Describe 电话号码区域管理辅助类
|
||||
*/
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.mymessagemanager.beans.AppConfigBean;
|
||||
import android.content.Context;
|
||||
|
||||
public class UnitAreaUtils {
|
||||
|
||||
public static final String TAG = "UnitAreaUtils";
|
||||
|
||||
static UnitAreaUtils _UnitAreaUtils;
|
||||
Context mContext;
|
||||
|
||||
UnitAreaUtils(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public static UnitAreaUtils getInstance(Context context) {
|
||||
if (_UnitAreaUtils == null) {
|
||||
_UnitAreaUtils = new UnitAreaUtils(context);
|
||||
}
|
||||
return _UnitAreaUtils;
|
||||
}
|
||||
|
||||
public boolean isCurrentUnitAreaNumber(String szPhoneNumer) {
|
||||
String szUnitArea = getUnitArea();
|
||||
LogUtils.d(TAG, String.format("szPhoneNumer.substring(1,3) %s", szPhoneNumer.substring(1,3)));
|
||||
return szPhoneNumer.substring(1,3).equals(szUnitArea);
|
||||
}
|
||||
|
||||
public String genCurrentUnitAreaNumber(String szPhoneNumer) {
|
||||
String szUnitArea = getUnitArea();
|
||||
LogUtils.d(TAG, String.format("szUnitArea %s", szUnitArea));
|
||||
return "+" + szUnitArea + szPhoneNumer;
|
||||
}
|
||||
|
||||
String getUnitArea() {
|
||||
String szUnitArea = AppConfigUtil.getInstance(mContext).mAppConfigBean.getCountryCode();
|
||||
LogUtils.d(TAG, String.format("szUnitArea %s", szUnitArea));
|
||||
return szUnitArea;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user