diff --git a/mymessagemanager/build.gradle b/mymessagemanager/build.gradle index ca1b9a7..d423b2c 100644 --- a/mymessagemanager/build.gradle +++ b/mymessagemanager/build.gradle @@ -46,7 +46,7 @@ android { dependencies { api fileTree(dir: 'libs', include: ['*.jar']) api 'cc.winboll.studio:libaes:15.9.3' - api 'cc.winboll.studio:libapputils:15.8.5' + api 'cc.winboll.studio:libapputils:15.8.6' api 'cc.winboll.studio:libappbase:15.9.5' api 'io.github.medyo:android-about-page:2.0.0' diff --git a/mymessagemanager/build.properties b/mymessagemanager/build.properties index 68eda2b..d959701 100644 --- a/mymessagemanager/build.properties +++ b/mymessagemanager/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Sun Aug 31 06:13:45 CST 2025 -stageCount=7 +#Sat Sep 06 01:57:20 HKT 2025 +stageCount=9 libraryProject= baseVersion=15.3 -publishVersion=15.3.6 +publishVersion=15.3.8 buildCount=0 -baseBetaVersion=15.3.7 +baseBetaVersion=15.3.9 diff --git a/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/activitys/ComposeSMSActivity.java b/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/activitys/ComposeSMSActivity.java index 5229fd5..3aec098 100644 --- a/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/activitys/ComposeSMSActivity.java +++ b/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/activitys/ComposeSMSActivity.java @@ -57,6 +57,7 @@ public class ComposeSMSActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + LogUtils.d(TAG, "onCreate"); setContentView(R.layout.activity_composesms); // 初始化Intent数据(增加空判断,避免NullPointerException) @@ -116,8 +117,9 @@ public class ComposeSMSActivity extends BaseActivity { } }); - // 初始化联系人列表 + // 初始化联系人列表(关键:设置单选模式,确保选中状态生效) mlvContracts = (ListView) findViewById(R.id.activitycomposesmsListView1); + mlvContracts.setChoiceMode(ListView.CHOICE_MODE_SINGLE); // 开启单选,与布局中一致 // 初始化号码输入框(核心:优化文本变化监听逻辑) metTO = (EditText) findViewById(R.id.activitycomposesmsEditText1); @@ -171,7 +173,7 @@ public class ComposeSMSActivity extends BaseActivity { } } - // 核心优化:根据输入号码筛选列表(无结果则显示空列表) + // 核心优化:根据输入号码筛选列表(无结果则显示空列表,优化选中逻辑) private void filterListByPhone(String inputPhone) { PhoneUtil phoneUtil = new PhoneUtil(this); List allContacts = phoneUtil.getPhoneList(); @@ -179,7 +181,7 @@ public class ComposeSMSActivity extends BaseActivity { // 遍历所有联系人,匹配包含输入号码的联系人 for (PhoneBean contact : allContacts) { - if (contact.getTelPhone().contains(inputPhone) + if (contact.getTelPhone().contains(inputPhone) || phoneUtil.isTheSamePhoneNumber(contact.getTelPhone(), inputPhone)) { matchedContacts.add(contact); } @@ -190,10 +192,29 @@ public class ComposeSMSActivity extends BaseActivity { // 用筛选结果更新列表(无结果则传入空列表) initAdapter(matchedContacts.isEmpty() ? new ArrayList() : matchedContacts); - // 定位到第一个匹配项(如果有) + // 定位并选中匹配项(如果有) if (!matchedContacts.isEmpty()) { - mlvContracts.setSelection(0); - mtvTOName.setText(matchedContacts.get(0).getName()); + boolean isFound = false; + for (int i = 0; i < matchedContacts.size(); i++) { + PhoneBean item = matchedContacts.get(i); + // 精确匹配号码(兼容区域码格式) + if (phoneUtil.isTheSamePhoneNumber(item.getTelPhone(), inputPhone)) { + mtvTOName.setText(item.getName()); + // 关键:先滚动到目标位置,再设置选中状态 + mlvContracts.setSelection(i); + // 主动设置选中(确保样式生效,兼容部分系统) + mlvContracts.setItemChecked(i, true); + LogUtils.d(TAG, String.format("%s 匹配 %s,选中位置:%d", inputPhone, item.getTelPhone(), i)); + isFound = true; + break; + } + } + // 若未精确匹配,选中第一个结果 + /*if (!isFound) { + mlvContracts.setSelection(0); + mlvContracts.setItemChecked(0, true); + mtvTOName.setText(matchedContacts.get(0).getName()); + }*/ } else { mtvTOName.setText(""); // 无结果时清空姓名显示 } @@ -206,7 +227,9 @@ public class ComposeSMSActivity extends BaseActivity { List matchedContacts = phoneUtil.getPhonesByName(searchName); initAdapter(matchedContacts); if (!matchedContacts.isEmpty()) { + // 选中第一个结果并设置样式 mlvContracts.setSelection(0); + mlvContracts.setItemChecked(0, true); } } @@ -246,7 +269,7 @@ public class ComposeSMSActivity extends BaseActivity { return 0; } - // 初始化或更新列表适配器 + // 初始化或更新列表适配器 private void initAdapter(List initData) { mAdapterData.clear(); // 清空旧数据 final PhoneUtil phoneUtil = new PhoneUtil(this); @@ -280,19 +303,45 @@ public class ComposeSMSActivity extends BaseActivity { mSimpleAdapter.setDropDownViewResource(R.layout.listview_contracts); mlvContracts.setAdapter(mSimpleAdapter); - // 列表项点击事件 + // 列表项点击事件:点击时主动设置选中状态,确保样式突显 mlvContracts.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { if (position < mAdapterData.size()) { + // 1. 主动设置当前项为选中状态 + mlvContracts.setItemChecked(position, true); + // 2. 更新号码输入框和姓名显示 String phone = mAdapterData.get(position).get(MAP_PHONE).toString(); metTO.setText(phone); mtvTOName.setText(phoneUtil.getNameByPhone(phone)); + // 3. 滚动到点击位置(确保可见) + mlvContracts.setSelection(position); } } }); + + // 列表项选中状态变化监听(可选,增强选中反馈) + mlvContracts.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + // 选中时可添加额外反馈(如改变文本颜色,可选) + if (view != null) { + TextView tvName = (TextView) view.findViewById(R.id.listviewcontractsTextView1); + TextView tvPhone = (TextView) view.findViewById(R.id.listviewcontractsTextView2); + if (tvName != null) tvName.setTextColor(getResources().getColor(R.color.white)); + if (tvPhone != null) tvPhone.setTextColor(getResources().getColor(R.color.white)); + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + // 未选中时无操作 + } + }); } else { - mSimpleAdapter.notifyDataSetChanged(); // 数据更新时通知适配器 + // 数据更新时,先取消所有旧选中状态,再通知适配器刷新 + mlvContracts.clearChoices(); + mSimpleAdapter.notifyDataSetChanged(); } } diff --git a/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/utils/PhoneUtil.java b/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/utils/PhoneUtil.java index d36ce2c..e72fc73 100644 --- a/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/utils/PhoneUtil.java +++ b/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/utils/PhoneUtil.java @@ -11,19 +11,19 @@ import android.database.Cursor; import android.net.Uri; import android.provider.ContactsContract; import cc.winboll.studio.libappbase.LogUtils; +import cc.winboll.studio.libapputils.utils.RegexPPiUtils; import cc.winboll.studio.mymessagemanager.beans.PhoneBean; -import net.sourceforge.pinyin4j.PinyinHelper; -import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; -import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; -import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; -import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; - import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import net.sourceforge.pinyin4j.PinyinHelper; +import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; +import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; +import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; +import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; public class PhoneUtil { diff --git a/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/utils/RegexPPiUtils.java b/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/utils/RegexPPiUtils.java deleted file mode 100644 index 8e27dc3..0000000 --- a/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/utils/RegexPPiUtils.java +++ /dev/null @@ -1,32 +0,0 @@ -package cc.winboll.studio.mymessagemanager.utils; - -/** - * @Author ZhanGSKen - * @Date 2024/12/09 19:00:21 - * @Describe .* 前置预防针 - regex pointer preventive injection - 简称 RegexPPi - */ -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class RegexPPiUtils { - - public static final String TAG = "RegexPPiUtils"; - - // - // 检验文本是否满足适合正则表达式模式计算 - // - public static boolean isPPiOK(String text) { - //String text = "这里是一些任意的文本内容"; - String regex = ".*"; - Pattern pattern = Pattern.compile(regex); - Matcher matcher = pattern.matcher(text); - /*if (matcher.matches()) { - System.out.println("文本满足该正则表达式模式"); - } else { - System.out.println("文本不满足该正则表达式模式"); - }*/ - return matcher.matches(); - } -} diff --git a/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/utils/SMSReceiveRuleUtil.java b/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/utils/SMSReceiveRuleUtil.java index 5e37b3a..70286c5 100644 --- a/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/utils/SMSReceiveRuleUtil.java +++ b/mymessagemanager/src/main/java/cc/winboll/studio/mymessagemanager/utils/SMSReceiveRuleUtil.java @@ -8,6 +8,7 @@ package cc.winboll.studio.mymessagemanager.utils; import android.content.Context; import android.util.JsonReader; import cc.winboll.studio.libappbase.LogUtils; +import cc.winboll.studio.libapputils.utils.RegexPPiUtils; import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean; import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean_V1; import java.io.IOException; diff --git a/mymessagemanager/src/main/res/drawable/listview_item_selector.xml b/mymessagemanager/src/main/res/drawable/listview_item_selector.xml new file mode 100644 index 0000000..8fcab31 --- /dev/null +++ b/mymessagemanager/src/main/res/drawable/listview_item_selector.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/mymessagemanager/src/main/res/layout/activity_composesms.xml b/mymessagemanager/src/main/res/layout/activity_composesms.xml index fd06f8a..d15d89a 100644 --- a/mymessagemanager/src/main/res/layout/activity_composesms.xml +++ b/mymessagemanager/src/main/res/layout/activity_composesms.xml @@ -1,109 +1,112 @@ + xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + - + - + diff --git a/mymessagemanager/src/main/res/values/colors.xml b/mymessagemanager/src/main/res/values/colors.xml index e75d537..505c0b6 100644 --- a/mymessagemanager/src/main/res/values/colors.xml +++ b/mymessagemanager/src/main/res/values/colors.xml @@ -1,5 +1,8 @@ + + #FFFFFFFF + #FFDCDA3D #FF3DDC84 #FFDCDA3D @@ -7,11 +10,11 @@ #FFA28BFF #FF8BAEFF #FFA28BFF - + #FFFFEB8C #FF8CD9FF #FFFFEB8C - + #FF78BDFF #FFFFED78 #FF78BDFF @@ -19,9 +22,13 @@ #FF5AEB53 #FFE653EB #FF5AEB53 - + #FFB4B4B4 #FFD9D9D9 #FFB4B4B4 - + + + #FF696969 + + #FFE0E0E0