Compare commits

...

58 Commits

Author SHA1 Message Date
d689db61ff 分支合并修整 2025-05-20 20:16:03 +08:00
d7efdb6c02 编译调试 2025-05-20 11:28:25 +08:00
20b36dd63b Merge remote-tracking branch 'origin/androidxdemo' into appbase 2025-05-20 05:46:28 +08:00
a40450c085 Merge remote-tracking branch 'origin/androiddemo' into appbase 2025-05-20 05:46:23 +08:00
e7a7a4438c 更新类库 2025-05-20 05:45:52 +08:00
3e6de13fa3 更新类库 2025-05-20 05:44:07 +08:00
af848809e9 <libappbase>Library Release 15.8.1 2025-05-20 05:41:16 +08:00
2c7026a635 <appbase>APK 15.8.1 release Publish. 2025-05-20 05:40:58 +08:00
6278c3f945 修复次级窗口打开时传递的参数缺失问题 2025-05-20 05:39:48 +08:00
bc3a320433 移除WinBoLL应用模块 2025-05-13 12:01:35 +08:00
e03b8d4745 Merge remote-tracking branch 'origin/androidxdemo' into appbase 2025-05-13 11:52:23 +08:00
d5fb348134 Merge remote-tracking branch 'origin/androiddemo' into appbase 2025-05-13 11:52:17 +08:00
5c7437b19c Merge remote-tracking branch 'origin/aes' into appbase 2025-05-13 11:52:11 +08:00
bf09def10b 更新适配系统版本 2025-05-13 11:44:39 +08:00
8431d7dfa9 更新适配系统版本 2025-05-13 11:43:25 +08:00
6aadaf87af 更新类库版本 2025-05-13 11:40:34 +08:00
6a2943420f 更新类库版本 2025-05-13 11:34:56 +08:00
dc704e292a <libaes>Library Release 15.8.0 2025-05-13 11:22:45 +08:00
1087a7837c <aes>APK 15.8.0 release Publish. 2025-05-13 11:22:24 +08:00
59876a2353 设置基础版本号 2025-05-13 11:21:27 +08:00
ae8da772c0 常驻通知栏UI优化。 2025-05-03 20:50:53 +08:00
b2555ebfd3 类库升级,源码编译整理。 2025-05-03 20:48:33 +08:00
82d9aabf33 Merge remote-tracking branch 'origin/appbase' into mymessagemanager 2025-05-03 16:50:15 +08:00
ZhanGSKen
2c91d32e41 在号码识别对比中,兼容当前区域号码。 2025-04-14 16:36:24 +08:00
ZhanGSKen
fa43d43110 <mymessagemanager>APK 15.2.4 release Publish. 2025-04-01 19:55:49 +08:00
ZhanGSKen
8f8e7d98c7 通知调试完成,添加旧通知设置清理按钮。 2025-04-01 19:54:30 +08:00
ZhanGSKen
af39f98a51 通知模块调试ing... 2025-04-01 15:20:02 +08:00
ZhanGSKen
5a1d557683 <mymessagemanager>APK 15.2.3 release Publish. 2025-03-31 20:04:51 +08:00
ZhanGSKen
39116f0912 更新类库,修复调试模式保存问题。 2025-03-31 20:03:40 +08:00
ZhanGSKen
a6b711b38b <mymessagemanager>APK 15.2.2 release Publish. 2025-03-31 02:36:56 +08:00
ZhanGSKen
d1703551f5 更新应用调试模式设置方法 2025-03-31 02:36:15 +08:00
ZhanGSKen
d63f7d3d83 <mymessagemanager>APK 15.2.1 release Publish. 2025-03-31 02:29:38 +08:00
ZhanGSKen
06b399846d Merge remote-tracking branch 'origin/appbase' into mymessagemanager 2025-03-31 02:27:33 +08:00
ZhanGSKen
e06efea08e <mymessagemanager>APK 15.2.0 release Publish. 2025-03-31 02:27:06 +08:00
ZhanGSKen
890ff6eda9 更新类库,添加更新日志查看方式和应用介绍窗口。 2025-03-31 02:24:50 +08:00
ZhanGSKen
e5a5eda9b6 1225 2025-03-29 12:25:04 +08:00
ZhanGSKen
174a052088 更新类库引用次序,预防资源引用次序混乱。 2025-03-29 12:24:14 +08:00
ZhanGSKen
fbd8441264 更新类库解决应用介绍窗口资源引用冲突问题 2025-03-29 12:19:26 +08:00
ZhanGSKen
fb92e9f673 更新类库 2025-03-29 11:53:35 +08:00
ZhanGSKen
d34d1e2796 设置版本号 2025-03-29 10:20:29 +08:00
ZhanGSKen
36fb8b41a4 1017 2025-03-29 10:17:55 +08:00
ZhanGSKen
fe70a18547 Merge branch 'appbase' into mymessagemanager 2025-03-29 09:45:00 +08:00
ZhanGSKen
46e4ee7fb7 <mymessagemanager>APK 15.0.0 release Publish. 2025-03-26 17:54:55 +08:00
ZhanGSKen
b2b959232c 去掉二级窗口分屏模式 2025-03-26 17:52:10 +08:00
ZhanGSKen
b11f814c41 Merge remote-tracking branch 'origin/appbase' into mymessagemanager 2025-03-26 17:49:04 +08:00
ZhanGSKen
1e991aed7e 适配小米15,设置编译参数。 2025-03-25 19:39:21 +08:00
ZhanGSKen
f56125f82a Merge branch 'appbase' into mymessagemanager 2025-03-25 19:29:33 +08:00
ZhanGSKen
33b7b65239 <mymessagemanager>APK 4.1.18 release Publish. 2025-03-01 14:11:49 +08:00
ZhanGSKen
664d14ad84 编译配置修复 2025-03-01 14:09:49 +08:00
ZhanGSKen
47cb393f76 更新短信接收规则设定:
1.启用了只接受通讯录,通讯录里有记录
2.如果不是数字通讯地址,但是在通讯录内
3.通讯地址是数字,并且在短信接收规则内。
以上3种情况就接收,其他一律放到回收站。
2025-03-01 14:01:13 +08:00
ZhanGSKen
6495f1c66e <mymessagemanager>APK 4.1.17 release Publish. 2025-03-01 13:39:17 +08:00
ZhanGSKen
f0c52d1e02 修复格式化通信录地址后的短信浏览BUG。 2025-03-01 13:38:37 +08:00
ZhanGSKen
d948f31331 <mymessagemanager>APK 4.1.16 release Publish. 2025-03-01 13:27:26 +08:00
ZhanGSKen
e1b3087020 格式化通讯地址显示 2025-03-01 13:25:22 +08:00
ZhanGSKen
03e21ab81c <mymessagemanager>APK 4.1.15 release Publish. 2025-02-25 20:51:01 +08:00
ZhanGSKen
ac72132969 添加电话号码前面有+号的检测兼容。 2025-02-25 20:50:03 +08:00
ZhanGSKen
cedb5f521b <mymessagemanager>APK 4.1.14 release Publish. 2025-02-25 20:25:31 +08:00
ZhanGSKen
396df6713c 添加单元测试模块,增加电话号码是否是数字的检测。 2025-02-25 20:19:54 +08:00
103 changed files with 1061 additions and 2949 deletions

View File

@ -29,7 +29,7 @@ android {
// versionName // versionName
// build.gradle stageCount=0 // build.gradle stageCount=0
// Gradle编译环境下合起来的 versionName "${versionName}.0" // Gradle编译环境下合起来的 versionName "${versionName}.0"
versionName "15.6" versionName "15.8"
if(true) { if(true) {
versionName = genVersionName("${versionName}") versionName = genVersionName("${versionName}")
} }

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Mon May 12 18:10:35 HKT 2025 #Tue May 13 11:22:39 HKT 2025
stageCount=4 stageCount=1
libraryProject=libaes libraryProject=libaes
baseVersion=15.6 baseVersion=15.8
publishVersion=15.6.3 publishVersion=15.8.0
buildCount=0 buildCount=0
baseBetaVersion=15.6.4 baseBetaVersion=15.8.1

View File

@ -24,7 +24,7 @@ android {
defaultConfig { defaultConfig {
applicationId "cc.winboll.studio.androiddemo" applicationId "cc.winboll.studio.androiddemo"
minSdkVersion 24 minSdkVersion 24
targetSdkVersion 29 targetSdkVersion 30
versionCode 1 versionCode 1
// versionName // versionName
// .winboll/winbollBuildProps.properties stageCount=0 // .winboll/winbollBuildProps.properties stageCount=0
@ -67,6 +67,6 @@ dependencies {
// https://mvnrepository.com/artifact/com.android.support/recyclerview-v7 // https://mvnrepository.com/artifact/com.android.support/recyclerview-v7
api 'com.android.support:recyclerview-v7:28.0.0' api 'com.android.support:recyclerview-v7:28.0.0'
api 'cc.winboll.studio:libapputils:15.2.2' api 'cc.winboll.studio:libapputils:15.8.1'
api 'cc.winboll.studio:libappbase:15.2.2' api 'cc.winboll.studio:libappbase:15.8.1'
} }

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Thu Apr 03 03:17:18 GMT 2025 #Mon May 19 21:45:28 GMT 2025
stageCount=0 stageCount=0
libraryProject= libraryProject=
baseVersion=15.0 baseVersion=15.0
publishVersion=15.0.0 publishVersion=15.0.0
buildCount=21 buildCount=25
baseBetaVersion=15.0.1 baseBetaVersion=15.0.1

View File

@ -24,7 +24,7 @@ android {
defaultConfig { defaultConfig {
applicationId "cc.winboll.studio.androidxdemo" applicationId "cc.winboll.studio.androidxdemo"
minSdkVersion 24 minSdkVersion 24
targetSdkVersion 29 targetSdkVersion 30
versionCode 1 versionCode 1
// versionName // versionName
// .winboll/winbollBuildProps.properties stageCount=0 // .winboll/winbollBuildProps.properties stageCount=0
@ -67,7 +67,7 @@ dependencies {
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0' //api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
//api 'androidx.fragment:fragment:1.1.0' //api 'androidx.fragment:fragment:1.1.0'
api 'cc.winboll.studio:libaes:15.2.6' api 'cc.winboll.studio:libaes:15.8.0'
api 'cc.winboll.studio:libapputils:15.2.2' api 'cc.winboll.studio:libapputils:15.8.1'
api 'cc.winboll.studio:libappbase:15.2.2' api 'cc.winboll.studio:libappbase:15.8.1'
} }

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Thu Apr 03 03:15:55 GMT 2025 #Mon May 19 21:43:40 GMT 2025
stageCount=0 stageCount=0
libraryProject= libraryProject=
baseVersion=15.0 baseVersion=15.0
publishVersion=15.0.0 publishVersion=15.0.0
buildCount=18 buildCount=22
baseBetaVersion=15.0.1 baseBetaVersion=15.0.1

View File

@ -22,9 +22,9 @@ import android.widget.HorizontalScrollView;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import cc.winboll.studio.androidxdemo.R;
import cc.winboll.studio.libappbase.GlobalApplication; import cc.winboll.studio.libappbase.GlobalApplication;
import com.hjq.toast.ToastUtils; import com.hjq.toast.ToastUtils;
import com.hjq.toast.style.WhiteToastStyle;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.Closeable; import java.io.Closeable;
@ -53,8 +53,8 @@ public class App extends GlobalApplication {
// 初始化 Toast 框架 // 初始化 Toast 框架
ToastUtils.init(this); ToastUtils.init(this);
// 设置 Toast 布局样式 // 设置 Toast 布局样式
ToastUtils.setView(R.layout.view_toast); //ToastUtils.setView(R.layout.view_toast);
//ToastUtils.setStyle(new WhiteToastStyle()); ToastUtils.setStyle(new WhiteToastStyle());
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200); ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
//CrashHandler.getInstance().registerGlobal(this); //CrashHandler.getInstance().registerGlobal(this);

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Tue May 13 11:05:12 HKT 2025 #Tue May 20 03:28:00 GMT 2025
stageCount=1 stageCount=2
libraryProject=libappbase libraryProject=libappbase
baseVersion=15.8 baseVersion=15.8
publishVersion=15.8.0 publishVersion=15.8.1
buildCount=0 buildCount=1
baseBetaVersion=15.8.1 baseBetaVersion=15.8.2

View File

@ -21,9 +21,8 @@ android {
dependencies { dependencies {
api fileTree(dir: 'libs', include: ['*.jar']) api fileTree(dir: 'libs', include: ['*.jar'])
//api 'cc.winboll.studio:libaes:15.6.0' api 'cc.winboll.studio:libapputils:15.8.1'
api 'cc.winboll.studio:libapputils:15.3.4' api 'cc.winboll.studio:libappbase:15.8.0'
api 'cc.winboll.studio:libappbase:15.7.6'
// //
api 'com.github.getActivity:ToastUtils:10.5' api 'com.github.getActivity:ToastUtils:10.5'

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Mon May 12 18:10:35 HKT 2025 #Tue May 13 11:22:23 HKT 2025
stageCount=4 stageCount=1
libraryProject=libaes libraryProject=libaes
baseVersion=15.6 baseVersion=15.8
publishVersion=15.6.3 publishVersion=15.8.0
buildCount=0 buildCount=0
baseBetaVersion=15.6.4 baseBetaVersion=15.8.1

View File

@ -176,8 +176,8 @@ public abstract class DrawerFragmentActivity extends AppCompatActivity implement
for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) { for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
getString(i); getString(i);
} }
} else if (R.id.item_log == item.getItemId()) { // } else if (R.id.item_log == item.getItemId()) {
GlobalApplication.getWinBoLLActivityManager().startLogActivity(this); // GlobalApplication.getWinBoLLActivityManager().startLogActivity(this);
} else if (R.id.item_about == item.getItemId()) { } else if (R.id.item_about == item.getItemId()) {
LogUtils.d(TAG, "onAbout"); LogUtils.d(TAG, "onAbout");
} else if (android.R.id.home == item.getItemId()) { } else if (android.R.id.home == item.getItemId()) {

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Tue May 13 11:05:02 HKT 2025 #Tue May 20 03:28:00 GMT 2025
stageCount=1 stageCount=2
libraryProject=libappbase libraryProject=libappbase
baseVersion=15.8 baseVersion=15.8
publishVersion=15.8.0 publishVersion=15.8.1
buildCount=0 buildCount=1
baseBetaVersion=15.8.1 baseBetaVersion=15.8.2

View File

@ -81,6 +81,7 @@ public class WinBoLLActivityManager {
// 新建一个任务窗口 // 新建一个任务窗口
Intent intent = new Intent(context, clazz); Intent intent = new Intent(context, clazz);
//打开多任务窗口 flags //打开多任务窗口 flags
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.putExtra("tag", tag); intent.putExtra("tag", tag);
@ -102,6 +103,7 @@ public class WinBoLLActivityManager {
// 新建一个任务窗口 // 新建一个任务窗口
//Intent intent = new Intent(context, clazz); //Intent intent = new Intent(context, clazz);
//打开多任务窗口 flags //打开多任务窗口 flags
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.putExtra("tag", tag); intent.putExtra("tag", tag);

View File

@ -18,18 +18,18 @@ def genVersionName(def versionName){
} }
android { android {
compileSdkVersion 30 compileSdkVersion 32
buildToolsVersion "30.0.3" buildToolsVersion "32.0.0"
defaultConfig { defaultConfig {
applicationId "cc.winboll.studio.mymessagemanager" applicationId "cc.winboll.studio.mymessagemanager"
minSdkVersion 26 minSdkVersion 24
targetSdkVersion 29 targetSdkVersion 29
versionCode 8 versionCode 8
// versionName // versionName
// .winboll/winbollBuildProps.properties stageCount=0 // .winboll/winbollBuildProps.properties stageCount=0
// Gradle编译环境下合起来的 versionName "${versionName}.0" // Gradle编译环境下合起来的 versionName "${versionName}.0"
versionName "4.1" versionName "15.2"
if(true) { if(true) {
versionName = genVersionName("${versionName}") versionName = genVersionName("${versionName}")
} }
@ -44,26 +44,27 @@ android {
} }
dependencies { dependencies {
api 'cc.winboll.studio:winboll-shared:1.6.4' api fileTree(dir: 'libs', include: ['*.jar'])
api 'cc.winboll.studio:libaes:15.6.0'
api 'cc.winboll.studio:libapputils:15.3.4'
api 'cc.winboll.studio:libappbase:15.7.6'
api 'io.github.medyo:android-about-page:2.0.0' api 'io.github.medyo:android-about-page:2.0.0'
api 'com.github.getActivity:ToastUtils:10.5' api 'com.github.getActivity:ToastUtils:10.5'
api 'com.jcraft:jsch:0.1.55' api 'com.jcraft:jsch:0.1.55'
api 'org.jsoup:jsoup:1.13.1' api 'org.jsoup:jsoup:1.13.1'
api 'com.squareup.okhttp3:okhttp:4.4.1' api 'com.squareup.okhttp3:okhttp:4.4.1'
api 'androidx.appcompat:appcompat:1.0.0'
api 'androidx.fragment:fragment:1.0.0'
api 'com.google.android.material:material:1.0.0'
// https://github.com/getActivity/XXPermissions // https://github.com/getActivity/XXPermissions
api 'com.github.getActivity:XXPermissions:18.63' api 'com.github.getActivity:XXPermissions:18.63'
api 'com.baoyz.pullrefreshlayout:library:1.2.0' api 'com.baoyz.pullrefreshlayout:library:1.2.0'
api 'androidx.appcompat:appcompat:1.0.0' // AndroidX
api 'androidx.fragment:fragment:1.0.0' api 'androidx.appcompat:appcompat:1.1.0'
api 'com.google.android.material:material:1.4.0'
//api 'androidx.viewpager:viewpager:1.0.0'
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
//api 'androidx.fragment:fragment:1.1.0'
api 'com.google.android.material:material:1.0.0' api 'com.google.android.material:material:1.0.0'
api 'cc.winboll.studio:libaes:7.6.0'
api fileTree(dir: 'libs', include: ['*.jar'])
} }

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Tue Feb 25 10:52:41 GMT 2025 #Sat May 03 12:49:28 GMT 2025
stageCount=14 stageCount=5
libraryProject= libraryProject=
baseVersion=4.1 baseVersion=15.2
publishVersion=4.1.13 publishVersion=15.2.4
buildCount=5 buildCount=14
baseBetaVersion=4.1.14 baseBetaVersion=15.2.5

View File

@ -53,30 +53,28 @@
</queries> </queries>
<application <application
android:name=".GlobalApplication" android:name=".App"
android:allowBackup="true" android:allowBackup="true"
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"
android:roundIcon="@drawable/ic_launcher" android:roundIcon="@drawable/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/WinBoll.SupportThemeNoActionBar" android:theme="@style/MyAppTheme"
android:persistent="true" android:persistent="true"
android:resizeableActivity="true" android:resizeableActivity="true"
android:supportsRtl="true" android:supportsRtl="true"
android:requestLegacyExternalStorage="true"> android:requestLegacyExternalStorage="true"
android:networkSecurityConfig="@xml/network_security_config">
<activity <activity
android:name=".activitys.SMSActivity" android:name=".activitys.SMSActivity"/>
android:process=":sms"/>
<activity <activity
android:name=".activitys.SMSReceiveRuleActivity" android:name=".activitys.SMSReceiveRuleActivity">
android:process=":smsars">
</activity> </activity>
<activity <activity
android:name=".activitys.SharedJSONReceiveActivity" android:name=".activitys.SharedJSONReceiveActivity"
android:process=":smssjr"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
@ -98,17 +96,14 @@
</activity> </activity>
<activity <activity
android:name=".activitys.TTSPlayRuleActivity" android:name=".activitys.TTSPlayRuleActivity"/>
android:process=":ttsrule"/>
<activity <activity
android:name=".activitys.AboutActivity" android:name=".activitys.AboutActivity"/>
android:process=":about"/>
<activity <activity
android:name=".activitys.MainActivity" android:name=".activitys.MainActivity"
android:exported="true" android:exported="true">
android:process=":main">
<intent-filter> <intent-filter>
@ -122,8 +117,7 @@
<activity <activity
android:name=".activitys.ComposeSMSActivity" android:name=".activitys.ComposeSMSActivity"
android:exported="true" android:exported="true">
android:process=":csms">
<intent-filter> <intent-filter>
@ -226,6 +220,8 @@
<activity android:name="cc.winboll.studio.mymessagemanager.activitys.SMSRecycleActivity"/> <activity android:name="cc.winboll.studio.mymessagemanager.activitys.SMSRecycleActivity"/>
<activity android:name="cc.winboll.studio.mymessagemanager.unittest.UnitTestActivity"/>
</application> </application>
</manifest> </manifest>

View File

@ -0,0 +1,46 @@
package cc.winboll.studio.mymessagemanager;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2023/07/24 01:46:59
* @Describe 全局应用类
*/
import android.view.Gravity;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.mymessagemanager.R;
import com.hjq.toast.ToastUtils;
import java.io.File;
public class App extends GlobalApplication {
public static final String TAG = "GlobalApplication";
static String _mszAppExternalFilesDir;
static String _mszConfigUtilFileName = "ConfigUtil.json";
static String _mszConfigUtilPath;
static String _mszSMSReceiveRuleUtilFileName = "SMSReceiveRuleUtil.json";
static String _mszSMSReceiveRuleUtilPath;
public static final int USER_ID = -1;
Long mszVersionName = 1L;
Long mszDataVersionName = 1L;
@Override
public void onCreate() {
super.onCreate();
// 初始化 Toast 框架
ToastUtils.init(this);
// 设置 Toast 布局样式
ToastUtils.setView(R.layout.toast_custom_view);
//ToastUtils.setStyle(new WhiteToastStyle());
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
//LogUtils.d(TAG, "BuildConfig.DEBUG " + Boolean.toString(BuildConfig.DEBUG));
_mszAppExternalFilesDir = getExternalFilesDir(TAG).toString();
_mszConfigUtilPath = _mszAppExternalFilesDir + File.separator + _mszConfigUtilFileName;
_mszSMSReceiveRuleUtilPath = _mszAppExternalFilesDir + File.separator + _mszSMSReceiveRuleUtilFileName;
}
}

View File

@ -3,72 +3,89 @@ package cc.winboll.studio.mymessagemanager.activitys;
/** /**
* @Author ZhanGSKen<zhangsken@188.com> * @Author ZhanGSKen<zhangsken@188.com>
* @Date 2024/07/14 13:20:33 * @Date 2024/07/14 13:20:33
* @Describe 应用关于对话窗口 * @Describe 应用介绍窗口
*/ */
import android.os.Bundle; import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import androidx.appcompat.widget.Toolbar;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.shared.app.WinBollActivity;
import cc.winboll.studio.shared.app.WinBollActivityManager;
import com.hjq.toast.ToastUtils;
import cc.winboll.studio.libaes.utils.AESThemeUtil;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.appcompat.widget.Toolbar;
import cc.winboll.studio.libaes.winboll.APPInfo;
import cc.winboll.studio.libaes.winboll.AboutView;
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
import cc.winboll.studio.mymessagemanager.App;
import cc.winboll.studio.mymessagemanager.R;
final public class AboutActivity extends WinBollActivity { public class AboutActivity extends WinBollActivity implements IWinBoLLActivity {
public static final String TAG = "AboutActivity"; public static final String TAG = "AboutActivity";
Context mContext; Context mContext;
Toolbar mToolbar;
@Override
public Activity getActivity() {
return this;
}
@Override @Override
public String getTag() { public String getTag() {
return TAG; return TAG;
} }
@Override
protected boolean isEnableDisplayHomeAsUp() {
return false;
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
setTheme(AESThemeUtil.getThemeTypeID(getApplicationContext()));
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mContext = this;
setContentView(R.layout.activity_about); setContentView(R.layout.activity_about);
mContext = getApplicationContext();
mToolbar = findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
mToolbar.setSubtitle(TAG);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
AboutView aboutView = CreateAboutView();
// Activity onCreate 或其他生命周期方法中调用
// LinearLayout layout = new LinearLayout(this);
// layout.setOrientation(LinearLayout.VERTICAL);
// // 创建布局参数宽度和高度
// ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
// ViewGroup.LayoutParams.MATCH_PARENT,
// ViewGroup.LayoutParams.MATCH_PARENT
// );
// addContentView(aboutView, params);
LinearLayout layout = findViewById(R.id.aboutviewroot_ll);
// 创建布局参数宽度和高度
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
);
layout.addView(aboutView, params);
App.getWinBoLLActivityManager().add(this);
} }
@Override @Override
protected void onPostCreate(Bundle savedInstanceState) { protected void onDestroy() {
super.onPostCreate(savedInstanceState); super.onDestroy();
setTitle(mContext.getString(R.string.text_about) + mContext.getString(R.string.app_name)); App.getWinBoLLActivityManager().registeRemove(this);
} }
@Override public AboutView CreateAboutView() {
protected boolean isAddWinBollToolBar() { String szBranchName = "mymessagemanager";
return false; APPInfo appInfo = new APPInfo();
} appInfo.setAppName(getString(R.string.app_name));
appInfo.setAppIcon(cc.winboll.studio.libaes.R.drawable.ic_winboll);
@Override appInfo.setAppDescription(getString(R.string.app_description));
protected Toolbar initToolBar() { appInfo.setAppGitName("APP");
return findViewById(R.id.activityaboutASupportToolbar1); appInfo.setAppGitOwner("Studio");
} appInfo.setAppGitAPPBranch(szBranchName);
appInfo.setAppGitAPPSubProjectFolder(szBranchName);
@Override appInfo.setAppHomePage("https://www.winboll.cc/studio/details.php?app=MyMessageManager");
public boolean onCreateOptionsMenu(Menu menu) { appInfo.setAppAPKName("MyMessageManager");
getMenuInflater().inflate(R.menu.toolbar_about, menu); appInfo.setAppAPKFolderName("MyMessageManager");
return super.onCreateOptionsMenu(menu); return new AboutView(mContext, appInfo);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
/*if (item.getItemId() == R.id.item_help) {
ToastUtils.show("R.id.item_help");
} else */if (item.getItemId() == android.R.id.home) {
WinBollActivityManager.getInstance(getApplicationContext()).finish(this);
}
return super.onOptionsItemSelected(item);
} }
} }

View File

@ -17,6 +17,8 @@ import cc.winboll.studio.libaes.views.AToolbar;
import cc.winboll.studio.mymessagemanager.R; import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil; import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil;
import cc.winboll.studio.mymessagemanager.utils.PermissionUtil; import cc.winboll.studio.mymessagemanager.utils.PermissionUtil;
import cc.winboll.studio.mymessagemanager.utils.NotificationHelper;
import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog;
public class AppSettingsActivity extends BaseActivity { public class AppSettingsActivity extends BaseActivity {
@ -96,4 +98,18 @@ public class AppSettingsActivity extends BaseActivity {
Toast.makeText(getApplication(), "应用已获得所需权限。", Toast.LENGTH_SHORT).show(); Toast.makeText(getApplication(), "应用已获得所需权限。", Toast.LENGTH_SHORT).show();
} }
} }
public void onCleanOldChannels(View view) {
YesNoAlertDialog.show(this, "通知设置清理", "是否清理旧的通知设置?", new YesNoAlertDialog.OnDialogResultListener(){
@Override
public void onNo() {
}
@Override
public void onYes() {
NotificationHelper notificationHelper = new NotificationHelper(AppSettingsActivity.this);
notificationHelper.cleanOldChannels();
}
});
}
} }

View File

@ -1,6 +1,5 @@
package cc.winboll.studio.mymessagemanager.activitys; package cc.winboll.studio.mymessagemanager.activitys;
import cc.winboll.studio.mymessagemanager.R;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
@ -8,9 +7,8 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import cc.winboll.studio.libaes.utils.AESThemeUtil; import cc.winboll.studio.libaes.utils.AESThemeUtil;
import cc.winboll.studio.shared.log.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
import com.hjq.toast.ToastUtils; import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.libaes.beans.AESThemeBean;
abstract public class BaseActivity extends AppCompatActivity { abstract public class BaseActivity extends AppCompatActivity {
@ -103,7 +101,7 @@ abstract public class BaseActivity extends AppCompatActivity {
AESThemeUtil.saveThemeStyleID(this, R.style.MyTaoAESTheme); AESThemeUtil.saveThemeStyleID(this, R.style.MyTaoAESTheme);
recreate(); recreate();
} else if (R.id.item_defaulttheme == item.getItemId()) { } else if (R.id.item_defaulttheme == item.getItemId()) {
AESThemeUtil.saveThemeStyleID(this, R.style.MyDefaultAESTheme); AESThemeUtil.saveThemeStyleID(this, R.style.MyAppTheme);
recreate(); recreate();
} }
//ToastUtils.show("nThemeStyleID " + Integer.toString(nThemeStyleID)); //ToastUtils.show("nThemeStyleID " + Integer.toString(nThemeStyleID));

View File

@ -10,7 +10,6 @@ import android.widget.ListView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.SimpleAdapter; import android.widget.SimpleAdapter;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import android.widget.Toolbar; import android.widget.Toolbar;
import cc.winboll.studio.libaes.views.AOHPCTCSeekBar; import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
import cc.winboll.studio.mymessagemanager.R; import cc.winboll.studio.mymessagemanager.R;

View File

@ -10,28 +10,25 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.ScrollView; import android.widget.ScrollView;
import cc.winboll.studio.libaes.views.AToolbar; import androidx.appcompat.widget.Toolbar;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.LogView;
import cc.winboll.studio.mymessagemanager.App;
import cc.winboll.studio.mymessagemanager.BuildConfig; import cc.winboll.studio.mymessagemanager.BuildConfig;
import cc.winboll.studio.mymessagemanager.R; import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.MainActivity; import cc.winboll.studio.mymessagemanager.activitys.MainActivity;
import cc.winboll.studio.mymessagemanager.adapters.PhoneArrayAdapter; import cc.winboll.studio.mymessagemanager.adapters.PhoneArrayAdapter;
import cc.winboll.studio.mymessagemanager.services.MainService; import cc.winboll.studio.mymessagemanager.services.MainService;
import cc.winboll.studio.mymessagemanager.unittest.UnitTestActivity;
import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil; import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil;
import cc.winboll.studio.mymessagemanager.utils.AppGoToSettingsUtil; import cc.winboll.studio.mymessagemanager.utils.AppGoToSettingsUtil;
import cc.winboll.studio.mymessagemanager.utils.NotificationUtil;
import cc.winboll.studio.mymessagemanager.utils.PermissionUtil; import cc.winboll.studio.mymessagemanager.utils.PermissionUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil; import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
import cc.winboll.studio.mymessagemanager.utils.ThemeUtil;
import cc.winboll.studio.mymessagemanager.utils.ViewUtil; import cc.winboll.studio.mymessagemanager.utils.ViewUtil;
import cc.winboll.studio.mymessagemanager.views.ConfirmSwitchView; import cc.winboll.studio.mymessagemanager.views.ConfirmSwitchView;
import cc.winboll.studio.mymessagemanager.views.PhoneListViewForScrollView; import cc.winboll.studio.mymessagemanager.views.PhoneListViewForScrollView;
import cc.winboll.studio.shared.log.LogUtils;
import cc.winboll.studio.shared.log.LogView;
import com.baoyz.widget.PullRefreshLayout; import com.baoyz.widget.PullRefreshLayout;
import java.util.ArrayList; import java.util.ArrayList;
import cc.winboll.studio.libaes.utils.AESThemeUtil;
import cc.winboll.studio.libaes.views.ASupportToolbar;
import androidx.appcompat.widget.Toolbar;
public class MainActivity extends BaseActivity { public class MainActivity extends BaseActivity {
@ -45,7 +42,7 @@ public class MainActivity extends BaseActivity {
public static final int MY_PERMISSIONS_REQUEST = 0; public static final int MY_PERMISSIONS_REQUEST = 0;
static MainActivity _mMainActivity; static MainActivity _mMainActivity;
LogView mLogView; //LogView mLogView;
AppConfigUtil mAppConfigUtil; AppConfigUtil mAppConfigUtil;
ConfirmSwitchView msvEnableService; ConfirmSwitchView msvEnableService;
ConfirmSwitchView msvOnlyReceiveContacts; ConfirmSwitchView msvOnlyReceiveContacts;
@ -121,8 +118,8 @@ public class MainActivity extends BaseActivity {
// //
void initView() { void initView() {
// 设置调试日志 // 设置调试日志
mLogView = findViewById(R.id.logview); // mLogView = findViewById(R.id.logview);
mLogView.start(); // mLogView.start();
// 设置消息处理函数 // 设置消息处理函数
setOnActivityMessageReceived(mIOnActivityMessageReceived); setOnActivityMessageReceived(mIOnActivityMessageReceived);
@ -132,11 +129,6 @@ public class MainActivity extends BaseActivity {
mToolbar.setSubtitle(getString(R.string.activity_name_main)); mToolbar.setSubtitle(getString(R.string.activity_name_main));
setSupportActionBar(mToolbar); setSupportActionBar(mToolbar);
// 创建通知频道
NotificationUtil nu = new NotificationUtil();
nu.createServiceNotificationChannel(MainActivity.this);
nu.createSMSNotificationChannel(MainActivity.this);
boolean isEnableService = mAppConfigUtil.mAppConfigBean.isEnableService(); boolean isEnableService = mAppConfigUtil.mAppConfigBean.isEnableService();
msvEnableService = findViewById(R.id.activitymainSwitchView1); msvEnableService = findViewById(R.id.activitymainSwitchView1);
msvEnableService.setChecked(isEnableService); msvEnableService.setChecked(isEnableService);
@ -270,7 +262,7 @@ public class MainActivity extends BaseActivity {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
reloadSMS(); reloadSMS();
mLogView.start(); //mLogView.start();
} }
@Override @Override
@ -303,15 +295,21 @@ public class MainActivity extends BaseActivity {
int nItemId = item.getItemId(); int nItemId = item.getItemId();
if (nItemId == R.id.app_ttsrule) { if (nItemId == R.id.app_ttsrule) {
Intent i = new Intent(MainActivity.this, TTSPlayRuleActivity.class); Intent i = new Intent(MainActivity.this, TTSPlayRuleActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i); startActivity(i);
} else if (nItemId == R.id.app_smsrule) { } else if (nItemId == R.id.app_smsrule) {
Intent i = new Intent(MainActivity.this, SMSReceiveRuleActivity.class); Intent i = new Intent(MainActivity.this, SMSReceiveRuleActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i); startActivity(i);
} else if (nItemId == R.id.app_appsettings) { } else if (nItemId == R.id.app_appsettings) {
Intent i = new Intent(MainActivity.this, AppSettingsActivity.class); Intent i = new Intent(MainActivity.this, AppSettingsActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
} else if (nItemId == R.id.app_log) {
App.getWinBoLLActivityManager().startLogActivity(this);
} else if (nItemId == R.id.app_unittest) {
Intent i = new Intent(MainActivity.this, UnitTestActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i); startActivity(i);
} else if (nItemId == R.id.app_crashtest) { } else if (nItemId == R.id.app_crashtest) {
for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) { for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
@ -319,11 +317,11 @@ public class MainActivity extends BaseActivity {
} }
} else if (nItemId == R.id.app_about) { } else if (nItemId == R.id.app_about) {
Intent i = new Intent(MainActivity.this, AboutActivity.class); Intent i = new Intent(MainActivity.this, AboutActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i); startActivity(i);
} else if (nItemId == R.id.app_smsrecycle) { } else if (nItemId == R.id.app_smsrecycle) {
Intent i = new Intent(MainActivity.this, SMSRecycleActivity.class); Intent i = new Intent(MainActivity.this, SMSRecycleActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i); startActivity(i);
} }

View File

@ -18,10 +18,10 @@ import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
import cc.winboll.studio.mymessagemanager.R; import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.SMSActivity; import cc.winboll.studio.mymessagemanager.activitys.SMSActivity;
import cc.winboll.studio.mymessagemanager.adapters.SMSArrayAdapter; import cc.winboll.studio.mymessagemanager.adapters.SMSArrayAdapter;
import cc.winboll.studio.mymessagemanager.utils.AddressUtils;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil; import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
import cc.winboll.studio.mymessagemanager.utils.ViewUtil; import cc.winboll.studio.mymessagemanager.utils.ViewUtil;
import cc.winboll.studio.mymessagemanager.views.SMSListViewForScrollView; import cc.winboll.studio.mymessagemanager.views.SMSListViewForScrollView;
import cc.winboll.studio.mymessagemanager.views.SMSView;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
public class SMSActivity extends BaseActivity { public class SMSActivity extends BaseActivity {
@ -102,7 +102,7 @@ public class SMSActivity extends BaseActivity {
// 初始化标题栏 // 初始化标题栏
mToolbar = findViewById(R.id.activitysmsASupportToolbar1); mToolbar = findViewById(R.id.activitysmsASupportToolbar1);
mToolbar.setSubtitle(getString(R.string.activity_name_smsinphone) + " < Phone : " + mszPhoneTo + " >"); mToolbar.setSubtitle(getString(R.string.activity_name_smsinphone) + " < Phone : " + AddressUtils.getFormattedAddress(mszPhoneTo) + " >");
setActionBar(mToolbar); setActionBar(mToolbar);
// 初始化滚动窗口 // 初始化滚动窗口

View File

@ -21,7 +21,7 @@ import android.widget.Toast;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import cc.winboll.studio.mymessagemanager.GlobalApplication; import cc.winboll.studio.mymessagemanager.App;
import cc.winboll.studio.mymessagemanager.R; import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.SMSReceiveRuleActivity; import cc.winboll.studio.mymessagemanager.activitys.SMSReceiveRuleActivity;
import cc.winboll.studio.mymessagemanager.adapters.SMSAcceptRuleArrayAdapter; import cc.winboll.studio.mymessagemanager.adapters.SMSAcceptRuleArrayAdapter;
@ -114,7 +114,7 @@ public class SMSReceiveRuleActivity extends BaseActivity {
} }
void initSMSAcceptRuleBeanAdd() { void initSMSAcceptRuleBeanAdd() {
mSMSAcceptRuleBeanAdd = new SMSAcceptRuleBean(GlobalApplication.USER_ID, "", true, SMSAcceptRuleBean.RuleType.REFUSE, true); mSMSAcceptRuleBeanAdd = new SMSAcceptRuleBean(App.USER_ID, "", true, SMSAcceptRuleBean.RuleType.REFUSE, true);
} }
@Override @Override

View File

@ -8,16 +8,16 @@ package cc.winboll.studio.mymessagemanager.activitys;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog;
import cc.winboll.studio.mymessagemanager.R; import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.SMSRecycleActivity; import cc.winboll.studio.mymessagemanager.activitys.SMSRecycleActivity;
import cc.winboll.studio.mymessagemanager.adapters.SMSRecycleAdapter; import cc.winboll.studio.mymessagemanager.adapters.SMSRecycleAdapter;
import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil; import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil;
import cc.winboll.studio.shared.view.YesNoAlertDialog;
import com.baoyz.widget.PullRefreshLayout; import com.baoyz.widget.PullRefreshLayout;
import java.io.File; import java.io.File;
import androidx.appcompat.widget.Toolbar;
public class SMSRecycleActivity extends BaseActivity { public class SMSRecycleActivity extends BaseActivity {

View File

@ -0,0 +1,60 @@
package cc.winboll.studio.mymessagemanager.activitys;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/31 01:31:17
* @Describe 应用活动窗口基类
*/
import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;
import androidx.appcompat.app.AppCompatActivity;
import cc.winboll.studio.libaes.beans.AESThemeBean;
import cc.winboll.studio.libaes.utils.AESThemeUtil;
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
public class WinBollActivity extends AppCompatActivity implements IWinBoLLActivity {
public static final String TAG = "WinBollActivity";
protected volatile AESThemeBean.ThemeType mThemeType;
@Override
public Activity getActivity() {
return this;
}
@Override
public String getTag() {
return TAG;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
mThemeType = getThemeType();
setThemeStyle();
super.onCreate(savedInstanceState);
}
AESThemeBean.ThemeType getThemeType() {
/*SharedPreferences sharedPreferences = getSharedPreferences(
SHAREDPREFERENCES_NAME, MODE_PRIVATE);
return AESThemeBean.ThemeType.values()[((sharedPreferences.getInt(DRAWER_THEME_TYPE, AESThemeBean.ThemeType.DEFAULT.ordinal())))];
*/
return AESThemeBean.getThemeStyleType(AESThemeUtil.getThemeTypeID(getApplicationContext()));
}
void setThemeStyle() {
//setTheme(AESThemeBean.getThemeStyle(getThemeType()));
setTheme(AESThemeUtil.getThemeTypeID(getApplicationContext()));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}

View File

@ -9,13 +9,14 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.R; import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.SMSActivity; import cc.winboll.studio.mymessagemanager.activitys.SMSActivity;
import cc.winboll.studio.mymessagemanager.beans.PhoneBean; import cc.winboll.studio.mymessagemanager.beans.PhoneBean;
import cc.winboll.studio.mymessagemanager.beans.SMSBean; import cc.winboll.studio.mymessagemanager.beans.SMSBean;
import cc.winboll.studio.mymessagemanager.utils.AddressUtils;
import cc.winboll.studio.mymessagemanager.utils.PhoneUtil; import cc.winboll.studio.mymessagemanager.utils.PhoneUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil; import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
import cc.winboll.studio.shared.log.LogUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -74,9 +75,9 @@ public class PhoneArrayAdapter extends BaseAdapter {
viewHolder = (ViewHolder) convertView.getTag(); viewHolder = (ViewHolder) convertView.getTag();
} }
String szAddress = ((SMSBean)getItem(position)).getAddress(); final String szAddress = ((SMSBean)getItem(position)).getAddress();
viewHolder.tvAddress.setText(szAddress); viewHolder.tvAddress.setText(AddressUtils.getFormattedAddress(szAddress));
viewHolder.tvName.setText(getName(szAddress)); viewHolder.tvName.setText(getName(szAddress));
//Drawable drawableFrame = AppCompatResources.getDrawable(mContext, R.drawable.bg_frame); //Drawable drawableFrame = AppCompatResources.getDrawable(mContext, R.drawable.bg_frame);
@ -87,7 +88,7 @@ public class PhoneArrayAdapter extends BaseAdapter {
//Toast.makeText(mContext, tv.getText(), Toast.LENGTH_SHORT).show(); //Toast.makeText(mContext, tv.getText(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(mContext, SMSActivity.class); Intent intent = new Intent(mContext, SMSActivity.class);
intent.putExtra(SMSActivity.EXTRA_PHONE, viewHolder.tvAddress.getText()); intent.putExtra(SMSActivity.EXTRA_PHONE, szAddress);
mContext.startActivity(intent); mContext.startActivity(intent);
} }

View File

@ -18,7 +18,6 @@ import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity; import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity;
import cc.winboll.studio.mymessagemanager.beans.SMSBean; import cc.winboll.studio.mymessagemanager.beans.SMSBean;
import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog; import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog;
import cc.winboll.studio.mymessagemanager.utils.NotificationUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSReceiveRuleUtil; import cc.winboll.studio.mymessagemanager.utils.SMSReceiveRuleUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil; import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil; import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
@ -28,6 +27,7 @@ import cc.winboll.studio.mymessagemanager.views.SMSView;
import com.hjq.toast.ToastUtils; import com.hjq.toast.ToastUtils;
import java.util.ArrayList; import java.util.ArrayList;
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean; import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
import cc.winboll.studio.mymessagemanager.utils.NotificationHelper;
public class SMSArrayAdapter extends BaseAdapter { public class SMSArrayAdapter extends BaseAdapter {
@ -54,7 +54,8 @@ public class SMSArrayAdapter extends BaseAdapter {
public void cancelMessageNotification() { public void cancelMessageNotification() {
for (SMSBean bean : mData) { for (SMSBean bean : mData) {
NotificationUtil.cancelNotification(mContext, bean.getId()); NotificationHelper notificationHelper = new NotificationHelper(mContext);
notificationHelper.cancelNotification(bean.getId());
} }
} }

View File

@ -34,6 +34,7 @@ import cc.winboll.studio.mymessagemanager.views.DateAgoTextView;
import cc.winboll.studio.mymessagemanager.views.SMSView; import cc.winboll.studio.mymessagemanager.views.SMSView;
import com.hjq.toast.ToastUtils; import com.hjq.toast.ToastUtils;
import java.util.ArrayList; import java.util.ArrayList;
import cc.winboll.studio.mymessagemanager.utils.AddressUtils;
public class SMSRecycleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class SMSRecycleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@ -154,7 +155,7 @@ public class SMSRecycleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
final SMSRecycleBean item = mDataList.get(position); final SMSRecycleBean item = mDataList.get(position);
if (holder.getItemViewType() == 0) { if (holder.getItemViewType() == 0) {
SimpleViewHolder viewHolder = (SimpleViewHolder) holder; SimpleViewHolder viewHolder = (SimpleViewHolder) holder;
viewHolder.mtvAddress.setText(item.getAddress()); viewHolder.mtvAddress.setText(AddressUtils.getFormattedAddress(item.getAddress()));
viewHolder.mbtnViewBody.setOnClickListener(new View.OnClickListener(){ viewHolder.mbtnViewBody.setOnClickListener(new View.OnClickListener(){
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -179,7 +180,7 @@ public class SMSRecycleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
viewHolder.mvRight.setVisibility(View.GONE); viewHolder.mvRight.setVisibility(View.GONE);
viewHolder.mSMSView.setSMSType(SMSView.SMSType.SEND); viewHolder.mSMSView.setSMSType(SMSView.SMSType.SEND);
} }
viewHolder.mtvAddress.setText(item.getAddress()); viewHolder.mtvAddress.setText(AddressUtils.getFormattedAddress(item.getAddress()));
viewHolder.mdatvDeleteDate.setDate(item.getDeleteDate()); viewHolder.mdatvDeleteDate.setDate(item.getDeleteDate());
viewHolder.mdatvDate.setDate(item.getDate()); viewHolder.mdatvDate.setDate(item.getDate());
if(mAppConfigUtil.mAppConfigBean.isSMSRecycleProtectMode()) { if(mAppConfigUtil.mAppConfigBean.isSMSRecycleProtectMode()) {

View File

@ -7,8 +7,7 @@ package cc.winboll.studio.mymessagemanager.beans;
*/ */
import android.util.JsonReader; import android.util.JsonReader;
import android.util.JsonWriter; import android.util.JsonWriter;
import cc.winboll.studio.mymessagemanager.utils.ThemeUtil; import cc.winboll.studio.libappbase.BaseBean;
import cc.winboll.studio.shared.app.BaseBean;
import java.io.IOException; import java.io.IOException;
public class AppConfigBean extends BaseBean { public class AppConfigBean extends BaseBean {

View File

@ -7,7 +7,7 @@ package cc.winboll.studio.mymessagemanager.beans;
*/ */
import android.util.JsonReader; import android.util.JsonReader;
import android.util.JsonWriter; import android.util.JsonWriter;
import cc.winboll.studio.shared.app.BaseBean; import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException; import java.io.IOException;
public class SMSAcceptRuleBean extends BaseBean { public class SMSAcceptRuleBean extends BaseBean {

View File

@ -34,7 +34,7 @@ package cc.winboll.studio.mymessagemanager.beans;
import android.content.ContentValues; import android.content.ContentValues;
import android.util.JsonReader; import android.util.JsonReader;
import android.util.JsonWriter; import android.util.JsonWriter;
import cc.winboll.studio.shared.app.BaseBean; import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException; import java.io.IOException;
import java.text.Collator; import java.text.Collator;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -7,7 +7,7 @@ package cc.winboll.studio.mymessagemanager.beans;
*/ */
import android.util.JsonReader; import android.util.JsonReader;
import android.util.JsonWriter; import android.util.JsonWriter;
import cc.winboll.studio.shared.app.BaseBean; import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException; import java.io.IOException;
import java.text.Collator; import java.text.Collator;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -7,7 +7,7 @@ package cc.winboll.studio.mymessagemanager.beans;
*/ */
import android.util.JsonReader; import android.util.JsonReader;
import android.util.JsonWriter; import android.util.JsonWriter;
import cc.winboll.studio.shared.app.BaseBean; import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException; import java.io.IOException;
public class TTSPlayRuleBean extends BaseBean { public class TTSPlayRuleBean extends BaseBean {

View File

@ -8,8 +8,8 @@ package cc.winboll.studio.mymessagemanager.beans;
import android.content.Context; import android.content.Context;
import android.util.JsonReader; import android.util.JsonReader;
import android.util.JsonWriter; import android.util.JsonWriter;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.utils.FileUtil; import cc.winboll.studio.mymessagemanager.utils.FileUtil;
import cc.winboll.studio.shared.log.LogUtils;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.io.StringWriter; import java.io.StringWriter;

View File

@ -10,9 +10,9 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.services.MainService; import cc.winboll.studio.mymessagemanager.services.MainService;
import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil; import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil;
import cc.winboll.studio.shared.log.LogUtils;
public class MainReceiver extends BroadcastReceiver { public class MainReceiver extends BroadcastReceiver {

View File

@ -4,17 +4,17 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import cc.winboll.studio.mymessagemanager.GlobalApplication; import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.App;
import cc.winboll.studio.mymessagemanager.activitys.SMSActivity; import cc.winboll.studio.mymessagemanager.activitys.SMSActivity;
import cc.winboll.studio.mymessagemanager.beans.SMSBean; import cc.winboll.studio.mymessagemanager.beans.SMSBean;
import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil; import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil;
import cc.winboll.studio.mymessagemanager.utils.NotificationUtil;
import cc.winboll.studio.mymessagemanager.utils.PhoneUtil; import cc.winboll.studio.mymessagemanager.utils.PhoneUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSReceiveRuleUtil; import cc.winboll.studio.mymessagemanager.utils.SMSReceiveRuleUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil; import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil; import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
import cc.winboll.studio.mymessagemanager.utils.TTSPlayRuleUtil; import cc.winboll.studio.mymessagemanager.utils.TTSPlayRuleUtil;
import cc.winboll.studio.mymessagemanager.utils.RegexPPiUtils; import cc.winboll.studio.mymessagemanager.utils.NotificationHelper;
public class SMSRecevier extends BroadcastReceiver { public class SMSRecevier extends BroadcastReceiver {
@ -36,34 +36,20 @@ public class SMSRecevier extends BroadcastReceiver {
String szAction = intent.getAction(); String szAction = intent.getAction();
if (szAction.equals(ACTION_SMS_RECEIVED)) { if (szAction.equals(ACTION_SMS_RECEIVED)) {
//LogUtils.d(TAG, "ACTION_SMS_RECEIVED"); LogUtils.d(TAG, "ACTION_SMS_RECEIVED");
String szSmsBody = SMSUtil.getSmsBody(intent); String szSmsBody = SMSUtil.getSmsBody(intent);
String szSmsAddress = SMSUtil.getSmsAddress(intent); String szSmsAddress = SMSUtil.getSmsAddress(intent);
PhoneUtil phoneUtil = new PhoneUtil(context);
boolean isPhoneInContacts = phoneUtil.isPhoneInContacts(szSmsAddress);
AppConfigUtil configUtil = AppConfigUtil.getInstance(context); AppConfigUtil configUtil = AppConfigUtil.getInstance(context);
boolean isOnlyReceiveContacts = configUtil.mAppConfigBean.isEnableOnlyReceiveContacts();
boolean isEnableTTS = configUtil.mAppConfigBean.isEnableTTS(); boolean isEnableTTS = configUtil.mAppConfigBean.isEnableTTS();
boolean isEnableTTSAnalyzeMode = configUtil.mAppConfigBean.isEnableTTSRuleMode(); boolean isEnableTTSAnalyzeMode = configUtil.mAppConfigBean.isEnableTTSRuleMode();
boolean isInSMSAcceptRule = SMSReceiveRuleUtil.getInstance(context, false).checkIsSMSAcceptInRule(context, szSmsBody);
//LogUtils.d(TAG, "isInSMSAcceptRule is : " + Boolean.toString(isInSMSAcceptRule));
if (!isPhoneInContacts) { if (checkIsSMSOK(context, szSmsBody, szSmsAddress)) {
GlobalApplication.showApplicationMessage(" The phone number " + szSmsAddress + " is not in contacts.");
if (isOnlyReceiveContacts) {
GlobalApplication.showApplicationMessage("Close the \"Only Receive Contacts\" switch will be receive The " + szSmsAddress + "'s message in future.");
}
}
if ((!isOnlyReceiveContacts)
|| isPhoneInContacts
|| isInSMSAcceptRule) {
int nResultId = SMSUtil.saveReceiveSms(context, szSmsAddress, szSmsBody, "0", System.currentTimeMillis(), "inbox"); int nResultId = SMSUtil.saveReceiveSms(context, szSmsAddress, szSmsBody, "0", System.currentTimeMillis(), "inbox");
if (nResultId >= 0) { if (nResultId >= 0) {
NotificationUtil nu = new NotificationUtil(); NotificationHelper notificationHelper = new NotificationHelper(context);
nu.sendSMSReceivedMessage(context, nResultId, szSmsAddress, szSmsBody); notificationHelper.sendSMSReceivedMessage(nResultId, szSmsAddress, szSmsBody);
LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(SMSActivity.ACTION_NOTIFY_SMS_CHANGED)); LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(SMSActivity.ACTION_NOTIFY_SMS_CHANGED));
GlobalApplication.showApplicationMessage("<" + szSmsAddress + "> : ( " + szSmsBody + " ) [SAVED]"); LogUtils.d(TAG, "<" + szSmsAddress + "> : ( " + szSmsBody + " ) [SAVED]");
if (isEnableTTS) { if (isEnableTTS) {
if (isEnableTTSAnalyzeMode) { if (isEnableTTSAnalyzeMode) {
TTSPlayRuleUtil ttsPlayRuleUtil = TTSPlayRuleUtil.getInstance(context); TTSPlayRuleUtil ttsPlayRuleUtil = TTSPlayRuleUtil.getInstance(context);
@ -81,12 +67,41 @@ public class SMSRecevier extends BroadcastReceiver {
SMSRecycleUtil.addSMSRecycleItem(context, bean); SMSRecycleUtil.addSMSRecycleItem(context, bean);
} }
} }
} }
//
// 检查短信是否在接收设定规则内
//
public static boolean checkIsSMSOK(Context context, String szSmsBody, String szSmsAddress) {
PhoneUtil phoneUtil = new PhoneUtil(context);
boolean isPhoneInContacts = phoneUtil.isPhoneInContacts(szSmsAddress);
LogUtils.d(TAG, String.format("isPhoneInContacts %s", isPhoneInContacts));
boolean isPhoneByDigit = phoneUtil.isPhoneByDigit(szSmsAddress);
LogUtils.d(TAG, String.format("isPhoneByDigit %s", isPhoneByDigit));
AppConfigUtil configUtil = AppConfigUtil.getInstance(context);
boolean isOnlyReceiveContacts = configUtil.mAppConfigBean.isEnableOnlyReceiveContacts();
LogUtils.d(TAG, String.format("isOnlyReceiveContacts %s", isOnlyReceiveContacts));
boolean isInSMSAcceptRule = SMSReceiveRuleUtil.getInstance(context, false).checkIsSMSAcceptInRule(context, szSmsBody);
LogUtils.d(TAG, String.format("isInSMSAcceptRule %s", isInSMSAcceptRule));
// 启用了只接受通讯录通讯录里有记录
if (isOnlyReceiveContacts && isPhoneInContacts) {
return true;
}
// 如果不是数字通讯地址但是在通讯录内
if (!isPhoneByDigit && isPhoneInContacts) {
return true;
}
// 通讯地址是数字并且在短信接收规则内
if (isPhoneByDigit && isInSMSAcceptRule) {
return true;
}
return false;
}
} }

View File

@ -5,6 +5,7 @@ package cc.winboll.studio.mymessagemanager.services;
* @Date 2024/07/19 14:30:57 * @Date 2024/07/19 14:30:57
* @Describe 应用主要服务组件类 * @Describe 应用主要服务组件类
*/ */
import android.app.Notification;
import android.app.Service; import android.app.Service;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
@ -12,20 +13,24 @@ import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.os.IBinder; import android.os.IBinder;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.R; import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.MainActivity;
import cc.winboll.studio.mymessagemanager.beans.MessageNotificationBean; import cc.winboll.studio.mymessagemanager.beans.MessageNotificationBean;
import cc.winboll.studio.mymessagemanager.receivers.SMSRecevier; import cc.winboll.studio.mymessagemanager.receivers.SMSRecevier;
import cc.winboll.studio.mymessagemanager.services.MainService; import cc.winboll.studio.mymessagemanager.services.MainService;
import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil; import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil;
import cc.winboll.studio.mymessagemanager.utils.NotificationUtil; import cc.winboll.studio.mymessagemanager.utils.NotificationHelper;
import cc.winboll.studio.mymessagemanager.utils.ServiceUtil; import cc.winboll.studio.mymessagemanager.utils.ServiceUtil;
import cc.winboll.studio.shared.log.LogUtils;
import com.hjq.toast.ToastUtils; import com.hjq.toast.ToastUtils;
public class MainService extends Service { public class MainService extends Service {
public static String TAG = "ManagerService"; public static String TAG = "ManagerService";
// 前台服务通知工具
NotificationHelper mNotificationHelper;
Notification notification;
AppConfigUtil mConfigUtil; AppConfigUtil mConfigUtil;
//MyBinder mMyBinder; //MyBinder mMyBinder;
MyServiceConnection mMyServiceConnection; MyServiceConnection mMyServiceConnection;
@ -73,16 +78,11 @@ public class MainService extends Service {
mSMSRecevier = new SMSRecevier(); mSMSRecevier = new SMSRecevier();
registerReceiver(mSMSRecevier, localIntentFilter); registerReceiver(mSMSRecevier, localIntentFilter);
// 显示前台通知栏 // 显示前台通知栏
MessageNotificationBean notificationMessage = createNotificationMessage(); NotificationHelper helper = new NotificationHelper(this);
NotificationUtil nu = new NotificationUtil(); Intent intent = new Intent(this, MainActivity.class);
nu.sendForegroundNotification(MainService.this, notificationMessage); notification = helper.showForegroundNotification(intent, getString(R.string.app_name), getString(R.string.text_aboutservernotification));
startForeground(NotificationHelper.FOREGROUND_NOTIFICATION_ID, notification);
/*if (mConfigUtil.isEnableTTS()) {
TTSPlayRuleUtil.speakText(ManagerService.this, getString(R.string.text_iamhere), 0);
GlobalApplication.showApplicationMessage(getString(R.string.text_iamhere));
}*/
ToastUtils.show("Service is start."); ToastUtils.show("Service is start.");
LogUtils.i(TAG, "Service is start."); LogUtils.i(TAG, "Service is start.");
@ -101,13 +101,6 @@ public class MainService extends Service {
} }
private MessageNotificationBean createNotificationMessage() {
String szTitle = getApplicationContext().getString(R.string.app_name);
String szContent = getString(R.string.text_aboutservernotification);
return new MessageNotificationBean(NotificationUtil.ID_MSG_SERVICE, "", szTitle, szContent);
}
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
//return super.onStartCommand(intent, flags, startId); //return super.onStartCommand(intent, flags, startId);

View File

@ -0,0 +1,28 @@
package cc.winboll.studio.mymessagemanager.unittest;
import android.content.Context;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.utils.AddressUtils;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/01 13:07:32
* @Describe AddressUtils Test
*/
public class AddressUtils_Test {
public static final String TAG = "AddressUtils_Test";
public static void main(Context context) {
String szSmsBody = "无影无迹";
String szSmsAddress = "无名小辈";
LogUtils.d(TAG, String.format("szSmsAddress %s\n getFormattedAddress : %s", szSmsAddress, AddressUtils.getFormattedAddress(szSmsAddress)));
szSmsAddress = "13172887736";
LogUtils.d(TAG, String.format("szSmsAddress %s\n getFormattedAddress : %s", szSmsAddress, AddressUtils.getFormattedAddress(szSmsAddress)));
szSmsAddress = "+8613172887736";
LogUtils.d(TAG, String.format("szSmsAddress %s\n getFormattedAddress : %s", szSmsAddress, AddressUtils.getFormattedAddress(szSmsAddress)));
szSmsAddress = "8613172887736";
LogUtils.d(TAG, String.format("szSmsAddress %s\n getFormattedAddress : %s", szSmsAddress, AddressUtils.getFormattedAddress(szSmsAddress)));
}
}

View File

@ -0,0 +1,56 @@
package cc.winboll.studio.mymessagemanager.unittest;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/25 19:02:15
* @Describe SMSRecevier 测试类
*/
import android.content.Context;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.receivers.SMSRecevier;
public class SMSRecevier_Test {
public static final String TAG = "SMSRecevier_Test";
public static void main(Context context) {
String szSmsBody = "无影无迹";
String szSmsAddress = "无名小辈";
test1(context, szSmsBody, szSmsAddress);
szSmsBody = "无影无迹";
szSmsAddress = "淘宝物流";
test1(context, szSmsBody, szSmsAddress);
szSmsBody = "无影无迹";
szSmsAddress = "1?0";
test1(context, szSmsBody, szSmsAddress);
szSmsBody = "无影无迹";
szSmsAddress = "10000";
test1(context, szSmsBody, szSmsAddress);
szSmsBody = "【UC】无影无迹";
szSmsAddress = "无名小辈";
test1(context, szSmsBody, szSmsAddress);
szSmsBody = "【UC】无影无迹";
szSmsAddress = "10000";
test1(context, szSmsBody, szSmsAddress);
szSmsBody = "【UC】无影无迹";
szSmsAddress = "13172887736";
test1(context, szSmsBody, szSmsAddress);
szSmsBody = "【UC】无影无迹";
szSmsAddress = "+8613172887736";
test1(context, szSmsBody, szSmsAddress);
}
public static void test1(Context context, String szSmsBody, String szSmsAddress) {
boolean isSMSOK = SMSRecevier.checkIsSMSOK(context, szSmsBody, szSmsAddress);
LogUtils.d(TAG, String.format("szSmsBody : %s\nszSmsAddress : %s\nisSMSOK : %s", szSmsBody, szSmsAddress, isSMSOK));
}
}

View File

@ -0,0 +1,36 @@
package cc.winboll.studio.mymessagemanager.unittest;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/25 19:00:10
* @Describe 应用单元测试窗口
*/
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.LogView;
import cc.winboll.studio.mymessagemanager.R;
public class UnitTestActivity extends Activity {
public static final String TAG = "UnitTestActivity";
LogView mLogView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_unittest);
mLogView = findViewById(R.id.logview);
mLogView.start();
}
public void onMain(View view) {
LogUtils.d(TAG, "SMSRecevier_Test");
SMSRecevier_Test.main(this);
LogUtils.d(TAG, "AddressUtils_Test");
AddressUtils_Test.main(this);
}
}

View File

@ -0,0 +1,20 @@
package cc.winboll.studio.mymessagemanager.utils;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/01 13:03:16
* @Describe 通信录地址工具
*/
public class AddressUtils {
public static final String TAG = "AddressUtils";
public static String getFormattedAddress(String address) {
if (address != null && address.matches("[+]?\\d+")) {
return address;
} else {
return "" + address + "";
}
}
}

View File

@ -10,7 +10,7 @@ import android.content.Intent;
import android.content.res.AssetManager; import android.content.res.AssetManager;
import android.net.Uri; import android.net.Uri;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import cc.winboll.studio.shared.log.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;

View File

@ -0,0 +1,202 @@
package cc.winboll.studio.mymessagemanager.utils;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/04/01 14:10:35
* @Describe 应用通知工具类
*/
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.widget.RemoteViews;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.SMSActivity;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class NotificationHelper {
public static final String TAG = "NotificationHelper";
// 渠道ID和名称
private static final String CHANNEL_ID_FOREGROUND = "foreground_channel";
private static final String CHANNEL_NAME_FOREGROUND = "Foreground Service";
private static final String CHANNEL_ID_TEMPORARY = "temporary_channel";
private static final String CHANNEL_NAME_TEMPORARY = "Temporary Notifications";
// 通知ID
public static final int FOREGROUND_NOTIFICATION_ID = 1001;
public static final int TEMPORARY_NOTIFICATION_ID = 2001;
private final Context mContext;
private final NotificationManager mNotificationManager;
// 示例维护当前使用的渠道ID列表
// 渠道ID渠道重要性级别
Map<String, Integer> activeChannelConfigs = new HashMap<>();
public NotificationHelper(Context context) {
mContext = context;
mNotificationManager = context.getSystemService(NotificationManager.class);
// 初始化配置
activeChannelConfigs.put(
CHANNEL_ID_FOREGROUND,
NotificationManager.IMPORTANCE_HIGH
);
activeChannelConfigs.put(
CHANNEL_ID_TEMPORARY,
NotificationManager.IMPORTANCE_DEFAULT
);
createNotificationChannels();
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void createNotificationChannels() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createForegroundChannel();
createTemporaryChannel();
}
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void createForegroundChannel() {
NotificationChannel channel = new NotificationChannel(
CHANNEL_ID_FOREGROUND,
CHANNEL_NAME_FOREGROUND,
NotificationManager.IMPORTANCE_LOW
);
channel.setDescription("Persistent service notifications");
channel.setSound(null, null);
channel.enableVibration(false);
mNotificationManager.createNotificationChannel(channel);
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void createTemporaryChannel() {
NotificationChannel channel = new NotificationChannel(
CHANNEL_ID_TEMPORARY,
CHANNEL_NAME_TEMPORARY,
NotificationManager.IMPORTANCE_HIGH
);
channel.setDescription("Temporary alert notifications");
channel.setSound(null, null);
channel.enableVibration(true);
channel.setVibrationPattern(new long[]{100, 200, 300, 400});
channel.setBypassDnd(true);
mNotificationManager.createNotificationChannel(channel);
}
// 显示常驻通知通常用于前台服务
public Notification showForegroundNotification(Intent intent, String title, String content) {
PendingIntent pendingIntent = createPendingIntent(intent);
Notification notification = new NotificationCompat.Builder(mContext, CHANNEL_ID_FOREGROUND)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_launcher))
//.setContentTitle(title)
.setContentTitle(content)
//.setContentText(content)
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_LOW)
.setOngoing(true)
.build();
mNotificationManager.notify(FOREGROUND_NOTIFICATION_ID, notification);
return notification;
}
// 显示临时通知自动消失
public void showTemporaryNotification(Intent intent, String title, String content) {
showTemporaryNotification(intent, TEMPORARY_NOTIFICATION_ID, title, content);
}
// 显示临时通知自动消失
public void showTemporaryNotification(Intent intent, int notificationID, String title, String content) {
PendingIntent pendingIntent = createPendingIntent(intent);
Notification notification = new NotificationCompat.Builder(mContext, CHANNEL_ID_TEMPORARY)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_launcher))
.setContentTitle(title)
.setContentText(content)
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setAutoCancel(true)
.setVibrate(new long[]{100, 200, 300, 400})
.build();
mNotificationManager.notify(notificationID, notification);
}
// 创建自定义布局通知可扩展
public void showCustomNotification(Intent intent, RemoteViews contentView, RemoteViews bigContentView) {
PendingIntent pendingIntent = createPendingIntent(intent);
Notification notification = new NotificationCompat.Builder(mContext, CHANNEL_ID_TEMPORARY)
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pendingIntent)
.setContent(contentView)
.setCustomBigContentView(bigContentView)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setAutoCancel(true)
.build();
mNotificationManager.notify(TEMPORARY_NOTIFICATION_ID + 1, notification);
}
// 取消所有通知
public void cancelAllNotifications() {
mNotificationManager.cancelAll();
}
// 取消指定通知
public void cancelNotification(int notificationID) {
mNotificationManager.cancel(notificationID);
}
// 创建PendingIntent兼容不同API版本
private PendingIntent createPendingIntent(Intent intent) {
int flags = PendingIntent.FLAG_UPDATE_CURRENT;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// flags |= PendingIntent.FLAG_IMMUTABLE;
// }
return PendingIntent.getActivity(
mContext,
0,
intent,
flags
);
}
public void sendSMSReceivedMessage(int notificationID, String szPhone, String szBody) {
Intent intent = new Intent(mContext, SMSActivity.class);
intent.putExtra(SMSActivity.EXTRA_PHONE, szPhone);
String szTitle = mContext.getString(R.string.text_smsfrom) + "<" + szPhone + ">";
String szContent = "[ " + szBody + " ]";
showTemporaryNotification(intent, notificationID, szTitle, szContent);
}
public void cleanOldChannels() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
List<NotificationChannel> allChannels = mNotificationManager.getNotificationChannels();
for (NotificationChannel channel : allChannels) {
LogUtils.d(TAG, "Clean channel : " + channel.getId());
if (!activeChannelConfigs.containsKey(channel.getId())) {
// 安全删除渠道
mNotificationManager.deleteNotificationChannel(channel.getId());
LogUtils.d(TAG, String.format("Deleted Channel %s", channel.getId()));
}
}
}
}
}

View File

@ -0,0 +1,168 @@
package cc.winboll.studio.mymessagemanager.utils;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/07/19 14:30:57
* @Describe 应用通知栏工具类
*/
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.media.RingtoneManager;
import android.widget.RemoteViews;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.MainActivity;
import cc.winboll.studio.mymessagemanager.activitys.SMSActivity;
import cc.winboll.studio.mymessagemanager.beans.MessageNotificationBean;
import cc.winboll.studio.mymessagemanager.services.MainService;
public class NotificationUtil_Bck {
public static final String TAG = "NotificationUtil";
public static final int ID_MSG_SERVICE = 10000;
static final String szSMSChannelID = "1";
static final String szServiceChannelID = "0";
//static int mNumSendForegroundNotification = 10000;
//static int mNumSendSMSNotification = 20000;
public NotificationManager createServiceNotificationChannel(Context context) {
//创建通知渠道ID
String channelId = szServiceChannelID;
//创建通知渠道名称
String channelName = "Service Message";
//创建通知渠道重要性
int importance = NotificationManager.IMPORTANCE_MIN;
NotificationChannel channel = new NotificationChannel(channelId, channelName, importance);
channel.setSound(null, null);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(
Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
return notificationManager;
}
public NotificationManager createSMSNotificationChannel(Context context) {
//创建通知渠道ID
String channelId = szSMSChannelID;
//创建通知渠道名称
String channelName = "SMS Message";
//创建通知渠道重要性
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel channel = new NotificationChannel(channelId, channelName, importance);
channel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE), Notification.AUDIO_ATTRIBUTES_DEFAULT);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(
Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
return notificationManager;
}
// 创建通知
//
public void sendForegroundNotification(MainService service, MessageNotificationBean nessageNotificationBean) {
//创建Notification传入Context和channelId
Intent intent = new Intent();//这个intent会传给目标,可以使用getIntent来获取
intent.setClass(service, MainActivity.class);
//这里放一个count用来区分每一个通知
//intent.putExtra("intent", "intent--->" + count);//这里设置一个数据,带过去
//参数1:context 上下文对象
//参数2:发送者私有的请求码(Private request code for the sender)
//参数3:intent 意图对象
//参数4:必须为FLAG_ONE_SHOT,FLAG_NO_CREATE,FLAG_CANCEL_CURRENT,FLAG_UPDATE_CURRENT,中的一个
PendingIntent mForegroundPendingIntent = PendingIntent.getActivity(service, nessageNotificationBean.getMessageId(), intent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT);
Notification mForegroundNotification = new Notification.Builder(service, szServiceChannelID)
.setAutoCancel(true)
.setContentTitle(nessageNotificationBean.getTitle())
.setContentText(nessageNotificationBean.getContent())
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher)
//设置红色
.setColor(Color.parseColor("#F00606"))
.setLargeIcon(BitmapFactory.decodeResource(service.getResources(), R.drawable.ic_launcher))
.setContentIntent(mForegroundPendingIntent)
.build();
RemoteViews mrvForegroundNotificationView = new RemoteViews(service.getPackageName(), R.layout.remoteview);
mrvForegroundNotificationView.setTextViewText(R.id.remoteviewTextView1, nessageNotificationBean.getTitle());
mrvForegroundNotificationView.setTextViewText(R.id.remoteviewTextView2, nessageNotificationBean.getContent());
mrvForegroundNotificationView.setImageViewResource(R.id.remoteviewImageView1, R.drawable.ic_launcher);
mForegroundNotification.contentView = mrvForegroundNotificationView;
mForegroundNotification.bigContentView = mrvForegroundNotificationView;
service.startForeground(nessageNotificationBean.getMessageId(), mForegroundNotification);
}
public void sendSMSNotification(Context context, MessageNotificationBean messageNotificationBean) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(
Context.NOTIFICATION_SERVICE);
/*NotificationManager notificationManager = createSMSNotificationChannel(context);
if (notificationManager == null) {
LogUtils.d(TAG, "createSMSNotificationChannel failed.");
return;
}*/
//创建Notification传入Context和channelId
Intent intent = new Intent(context, SMSActivity.class);
intent.putExtra(SMSActivity.EXTRA_PHONE, messageNotificationBean.getPhone());
LogUtils.d(TAG, "sendSMSNotification(...) message.getPhone() is : " + messageNotificationBean.getPhone());
//Intent intent = new Intent();//这个intent会传给目标,可以使用getIntent来获取
//intent.setClass(context, MainActivity.class);
//这里放一个count用来区分每一个通知
//intent.putExtra("intent", "intent--->" + count);//这里设置一个数据,带过去
//参数1:context 上下文对象
//参数2:发送者私有的请求码(Private request code for the sender)
//参数3:intent 意图对象
//参数4:必须为FLAG_ONE_SHOT,FLAG_NO_CREATE,FLAG_CANCEL_CURRENT,FLAG_UPDATE_CURRENT,中的一个
PendingIntent mRemindPendingIntent = PendingIntent.getActivity(context, messageNotificationBean.getMessageId(), intent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT);
Notification mSMSNotification = new Notification.Builder(context, szSMSChannelID)
.setAutoCancel(true)
.setContentTitle(messageNotificationBean.getTitle())
.setContentText(messageNotificationBean.getContent())
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher)
//设置红色
.setColor(Color.parseColor("#F00606"))
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher))
.setContentIntent(mRemindPendingIntent)
.build();
RemoteViews mrvSMSNotificationView = new RemoteViews(context.getPackageName(), R.layout.remoteview);
mrvSMSNotificationView.setTextViewText(R.id.remoteviewTextView1, messageNotificationBean.getTitle());
mrvSMSNotificationView.setTextViewText(R.id.remoteviewTextView2, messageNotificationBean.getContent());
mrvSMSNotificationView.setImageViewResource(R.id.remoteviewImageView1, R.drawable.ic_launcher);
mSMSNotification.contentView = mrvSMSNotificationView;
mSMSNotification.bigContentView = mrvSMSNotificationView;
notificationManager.notify(messageNotificationBean.getMessageId(), mSMSNotification);
LogUtils.d(TAG, "getMessageId is : " + Integer.toString(messageNotificationBean.getMessageId()));
}
public void sendSMSReceivedMessage(Context context, int nMessageId, String szPhone, String szBody) {
String szTitle = context.getString(R.string.text_smsfrom) + "<" + szPhone + ">";
String szContent = "[ " + szBody + " ]";
sendSMSNotification(context, new MessageNotificationBean(nMessageId, szPhone, szTitle, szContent));
}
public static void cancelNotification(Context context, int notificationId) {
// 获取 NotificationManager 实例
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// 撤回指定 ID 的通知栏消息
notificationManager.cancel(notificationId);
}
}

View File

@ -10,9 +10,9 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.R; import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.BaseActivity; import cc.winboll.studio.mymessagemanager.activitys.BaseActivity;
import cc.winboll.studio.shared.log.LogUtils;
import com.hjq.permissions.OnPermissionCallback; import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission; import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions; import com.hjq.permissions.XXPermissions;

View File

@ -10,11 +10,14 @@ import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.beans.PhoneBean; import cc.winboll.studio.mymessagemanager.beans.PhoneBean;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PhoneUtil { public class PhoneUtil {
@ -59,12 +62,57 @@ public class PhoneUtil {
public boolean isPhoneInContacts(String szPhone) { public boolean isPhoneInContacts(String szPhone) {
List<PhoneBean> listPhoneDto = getPhoneList(); List<PhoneBean> listPhoneDto = getPhoneList();
LogUtils.d(TAG, String.format("isPhoneInContacts(...) listPhoneDto.size() %d", listPhoneDto.size()));
for (int i = 0; i < listPhoneDto.size(); i++) { 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 true;
} }
} }
return false; 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;
}
//
// 检验电话号码是否是数字
//
public static boolean isPhoneByDigit(String szPhone) {
if(!RegexPPiUtils.isPPiOK(szPhone)) {
return false;
}
//String text = "这里是一些任意的文本内容";
String regex = "[+]?\\d+";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(szPhone);
LogUtils.d(TAG, String.format("matcher.matches() : %s", matcher.matches()));
/*if (matcher.matches()) {
System.out.println("文本满足该正则表达式模式");
} else {
System.out.println("文本不满足该正则表达式模式");
}*/
return matcher.matches();
}
} }

View File

@ -7,9 +7,9 @@ package cc.winboll.studio.mymessagemanager.utils;
*/ */
import android.content.Context; import android.content.Context;
import android.util.JsonReader; import android.util.JsonReader;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean; import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean_V1; import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean_V1;
import cc.winboll.studio.shared.log.LogUtils;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -18,7 +18,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.nio.channels.AcceptPendingException;
public class SMSReceiveRuleUtil { public class SMSReceiveRuleUtil {
@ -194,9 +193,9 @@ public class SMSReceiveRuleUtil {
public ArrayList<SMSAcceptRuleBean> loadConfigData() { public ArrayList<SMSAcceptRuleBean> loadConfigData() {
ArrayList<SMSAcceptRuleBean> list = new ArrayList<SMSAcceptRuleBean>(); ArrayList<SMSAcceptRuleBean> list = new ArrayList<SMSAcceptRuleBean>();
SMSAcceptRuleBean.loadBeanList(mContext, list, SMSAcceptRuleBean.class); SMSAcceptRuleBean.loadBeanList(mContext, list, SMSAcceptRuleBean.class);
for (int i = 0; i < list.size(); i++) { // for (int i = 0; i < list.size(); i++) {
LogUtils.d(TAG, "loadConfigData isEnable : " + Boolean.toString(list.get(i).isEnable())); // LogUtils.d(TAG, "loadConfigData isEnable : " + Boolean.toString(list.get(i).isEnable()));
} // }
mDataList.clear(); mDataList.clear();
mDataList.addAll(list); mDataList.addAll(list);
return mDataList; return mDataList;

View File

@ -6,7 +6,7 @@ package cc.winboll.studio.mymessagemanager.utils;
* @Describe 短信回收站工具类 * @Describe 短信回收站工具类
*/ */
import android.content.Context; import android.content.Context;
import cc.winboll.studio.mymessagemanager.GlobalApplication; import cc.winboll.studio.mymessagemanager.App;
import cc.winboll.studio.mymessagemanager.beans.SMSBean; import cc.winboll.studio.mymessagemanager.beans.SMSBean;
import cc.winboll.studio.mymessagemanager.beans.SMSRecycleBean; import cc.winboll.studio.mymessagemanager.beans.SMSRecycleBean;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -17,8 +17,8 @@ import android.os.Bundle;
import android.provider.Telephony; import android.provider.Telephony;
import android.telephony.gsm.SmsManager; import android.telephony.gsm.SmsManager;
import android.telephony.gsm.SmsMessage; import android.telephony.gsm.SmsMessage;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.beans.SMSBean; import cc.winboll.studio.mymessagemanager.beans.SMSBean;
import cc.winboll.studio.shared.log.LogUtils;
import com.hjq.toast.ToastUtils; import com.hjq.toast.ToastUtils;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -10,6 +10,7 @@ import android.content.Intent;
import android.os.Message; import android.os.Message;
import android.util.JsonReader; import android.util.JsonReader;
import android.widget.Toast; import android.widget.Toast;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.R; import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity; import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity;
import cc.winboll.studio.mymessagemanager.beans.TTSPlayRuleBean; import cc.winboll.studio.mymessagemanager.beans.TTSPlayRuleBean;
@ -17,7 +18,6 @@ import cc.winboll.studio.mymessagemanager.beans.TTSPlayRuleBean_V1;
import cc.winboll.studio.mymessagemanager.beans.TTSSpeakTextBean; import cc.winboll.studio.mymessagemanager.beans.TTSSpeakTextBean;
import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog; import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog;
import cc.winboll.studio.mymessagemanager.services.TTSPlayService; import cc.winboll.studio.mymessagemanager.services.TTSPlayService;
import cc.winboll.studio.shared.log.LogUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

View File

@ -14,9 +14,9 @@ import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.R; import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.beans.TTSSpeakTextBean; import cc.winboll.studio.mymessagemanager.beans.TTSSpeakTextBean;
import cc.winboll.studio.shared.log.LogUtils;
import java.util.ArrayList; import java.util.ArrayList;
public class TextToSpeechUtil { public class TextToSpeechUtil {

View File

@ -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;
}
}

View File

@ -8,8 +8,8 @@ import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.widget.Switch; import android.widget.Switch;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog; import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog;
import cc.winboll.studio.shared.log.LogUtils;
public class ConfirmSwitchView extends Switch { public class ConfirmSwitchView extends Switch {

View File

@ -6,24 +6,16 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<!--<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/activityaboutToolbar1"/>-->
<cc.winboll.studio.libaes.views.ASupportToolbar <cc.winboll.studio.libaes.views.ASupportToolbar
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height" android:layout_height="wrap_content"
android:id="@+id/activityaboutASupportToolbar1"/> android:id="@+id/toolbar"/>
<cc.winboll.studio.shared.view.AboutView <LinearLayout
app:appname="MyMessageManager" android:orientation="vertical"
app:appprojectname="MyMessageManager"
app:appdescription="用正则表达式方法自定义短信过滤和语音播报的短信应用。"
app:appicon="@drawable/ic_winboll"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="0dp"
android:id="@+id/activityaboutAboutView1"/> android:layout_weight="1.0"
android:id="@+id/aboutviewroot_ll"/>
</LinearLayout> </LinearLayout>

View File

@ -213,6 +213,12 @@
android:text="检查应用权限" android:text="检查应用权限"
android:onClick="onCheckAndGetAppPermission"/> android:onClick="onCheckAndGetAppPermission"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="清理通知设置"
android:onClick="onCleanOldChannels"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -72,11 +72,5 @@
</com.baoyz.widget.PullRefreshLayout> </com.baoyz.widget.PullRefreshLayout>
<cc.winboll.studio.shared.log.LogView
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="120dp"
android:id="@+id/logview"/>
</LinearLayout> </LinearLayout>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="500dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test Main"
android:onClick="onMain"
android:textAllCaps="false"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<cc.winboll.studio.shared.log.LogView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:id="@+id/logview"/>
</LinearLayout>

View File

@ -19,6 +19,12 @@
android:title="@string/text_smsrule"/> android:title="@string/text_smsrule"/>
<item android:title="@string/app_developoptions"> <item android:title="@string/app_developoptions">
<menu> <menu>
<item
android:id="@+id/app_log"
android:title="@string/app_log"/>
<item
android:id="@+id/app_unittest"
android:title="@string/app_unittest"/>
<item <item
android:id="@+id/app_crashtest" android:id="@+id/app_crashtest"
android:title="@string/app_crashtest"/> android:title="@string/app_crashtest"/>

View File

@ -9,6 +9,7 @@
<string name="app_goldentheme">辉煌历程主题</string> <string name="app_goldentheme">辉煌历程主题</string>
<string name="app_developoptions">开发选项</string> <string name="app_developoptions">开发选项</string>
<string name="app_default_app_settings">默认应用设置</string> <string name="app_default_app_settings">默认应用设置</string>
<string name="app_unittest">单元测试</string>
<string name="app_crashtest">应用异常崩溃处理测试</string> <string name="app_crashtest">应用异常崩溃处理测试</string>
<string name="app_about">关于应用</string> <string name="app_about">关于应用</string>
<string name="app_smsrecycle">短信回收站</string> <string name="app_smsrecycle">短信回收站</string>

View File

@ -9,6 +9,7 @@
<string name="app_goldentheme">Golden Theme</string> <string name="app_goldentheme">Golden Theme</string>
<string name="app_developoptions">Develop Options</string> <string name="app_developoptions">Develop Options</string>
<string name="app_default_app_settings">Default App Settings</string> <string name="app_default_app_settings">Default App Settings</string>
<string name="app_unittest">Unit Test</string>
<string name="app_crashtest">Crash Test</string> <string name="app_crashtest">Crash Test</string>
<string name="app_about">About APP</string> <string name="app_about">About APP</string>
<string name="app_smsrecycle">SMS Recycle</string> <string name="app_smsrecycle">SMS Recycle</string>

View File

@ -1,6 +1,6 @@
<resources> <resources>
<style name="MyDefaultAESTheme" parent="DefaultAESTheme"> <style name="MyAppTheme" parent="AESTheme">
<item name="android:textSize">20sp</item> <item name="android:textSize">20sp</item>
<item name="attrSMSViewSendColor">@color/colorSMSSendColor</item> <item name="attrSMSViewSendColor">@color/colorSMSSendColor</item>
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColor</item> <item name="attrSMSViewInboxColor">@color/colorSMSInboxColor</item>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">winboll.cc</domain>
</domain-config>
</network-security-config>

1
winboll/.gitignore vendored
View File

@ -1 +0,0 @@
/build

View File

@ -1 +0,0 @@

View File

@ -1,50 +0,0 @@
apply plugin: 'com.android.application'
apply from: '../.winboll/winboll_app_build.gradle'
apply from: '../.winboll/winboll_lint_build.gradle'
def genVersionName(def versionName){
//
assert (winbollBuildProps['stageCount'] != null)
assert (winbollBuildProps['baseVersion'] != null)
//
winbollBuildProps.setProperty("baseVersion", "${versionName}");
//
FileOutputStream fos = new FileOutputStream(winbollBuildPropsFile)
winbollBuildProps.store(fos, "${winbollBuildPropsDesc}");
fos.close();
//
return "${versionName}." + winbollBuildProps['stageCount']
}
android {
compileSdkVersion 32
buildToolsVersion "32.0.0"
defaultConfig {
applicationId "cc.winboll.studio.appbase"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
// versionName
// .winboll/winbollBuildProps.properties stageCount=0
// Gradle编译环境下合起来的 versionName "${versionName}.0"
versionName "15.2"
if(true) {
versionName = genVersionName("${versionName}")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api project(':libappbase')
api fileTree(dir: 'libs', include: ['*.jar'])
}

View File

@ -1,8 +0,0 @@
#Created by .winboll/winboll_app_build.gradle
#Sat Apr 12 15:06:52 HKT 2025
stageCount=6
libraryProject=libappbase
baseVersion=15.2
publishVersion=15.2.5
buildCount=0
baseBetaVersion=15.2.6

View File

@ -1,17 +0,0 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\tools\adt-bundle-windows-x86_64-20131030\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >
<application>
<!-- Put flavor specific code here -->
</application>
</manifest>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">AppBase+</string>
</resources>

View File

@ -1,128 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="cc.winboll.studio.appbase">
<application
android:name=".App"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyAPPBaseTheme"
android:resizeableActivity="true"
android:process=":App">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:exported="true"
android:resizeableActivity="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".activities.NewActivity"
android:label="NewActivity"
android:exported="true"
android:resizeableActivity="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"/>
<activity android:name=".activities.New2Activity"
android:label="New2Activity"
android:exported="true"
android:resizeableActivity="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"/>
<service
android:name=".MyTileService"
android:exported="true"
android:label="@string/tileservice_name"
android:icon="@drawable/ic_launcher"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE"/>
</intent-filter>
</service>
<service
android:name=".services.MainService"
android:exported="true"/>
<service
android:name="cc.winboll.studio.appbase.services.TestDemoBindService"
android:exported="true"/>
<service
android:name="cc.winboll.studio.appbase.services.TestDemoService"
android:exported="true"/>
<service android:name=".services.AssistantService"/>
<receiver android:name="cc.winboll.studio.appbase.receivers.MainReceiver"
android:exported="true">
<intent-filter>
<action android:name="cc.winboll.studio.appbase.receivers.MainReceiver"/>
</intent-filter>
</receiver>
<receiver
android:name=".widgets.APPNewsWidget"
android:exported="true">
<intent-filter>
<action android:name="cc.winboll.studio.appbase.widgets.APPNewsWidget.ACTION_WAKEUP_SERVICE"/>
<action android:name="cc.winboll.studio.appbase.widgets.APPNewsWidget.ACTION_RELOAD_REPORT"/>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_provider_info_sos"/>
</receiver>
<receiver android:name=".receivers.APPNewsWidgetClickListener"
android:exported="true">
<intent-filter>
<action android:name="cc.winboll.studio.appbase.receivers.APPNewsWidgetClickListener.ACTION_PRE"/>
<action android:name="cc.winboll.studio.appbase.receivers.APPNewsWidgetClickListener.ACTION_NEXT"/>
</intent-filter>
</receiver>
<meta-data
android:name="android.max_aspect"
android:value="4.0"/>
</application>
</manifest>

View File

@ -1,27 +0,0 @@
package cc.winboll.studio.appbase;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/01/05 09:54:42
* @Describe APPbase 应用类
*/
import cc.winboll.studio.libappbase.GlobalApplication;
import android.content.IntentFilter;
import cc.winboll.studio.libappbase.sos.SOSCenterServiceReceiver;
import cc.winboll.studio.libappbase.sos.SOS;
public class App extends GlobalApplication {
public static final String TAG = "App";
SOSCenterServiceReceiver mSOSCenterServiceReceiver;
@Override
public void onCreate() {
super.onCreate();
mSOSCenterServiceReceiver = new SOSCenterServiceReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(SOS.ACTION_SOS);
registerReceiver(mSOSCenterServiceReceiver, intentFilter);
}
}

View File

@ -1,184 +0,0 @@
package cc.winboll.studio.appbase;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import cc.winboll.studio.appbase.R;
import cc.winboll.studio.appbase.activities.NewActivity;
import cc.winboll.studio.appbase.services.MainService;
import cc.winboll.studio.appbase.services.TestDemoBindService;
import cc.winboll.studio.appbase.services.TestDemoService;
import cc.winboll.studio.libappbase.CrashHandler;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.GlobalCrashActivity;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.sos.SOS;
import cc.winboll.studio.libappbase.utils.ToastUtils;
import cc.winboll.studio.libappbase.widgets.StatusWidget;
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog;
public class MainActivity extends WinBollActivityBase implements IWinBollActivity {
public static final String TAG = "MainActivity";
@Override
public Activity getActivity() {
return this;
}
@Override
public String getTag() {
return TAG;
}
Toolbar mToolbar;
//LogView mLogView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ToastUtils.show("onCreate");
setContentView(R.layout.activity_main);
mToolbar = findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
CheckBox cbIsDebugMode = findViewById(R.id.activitymainCheckBox1);
cbIsDebugMode.setChecked(GlobalApplication.isDebuging());
//mLogView = findViewById(R.id.activitymainLogView1);
// if (GlobalApplication.isDebuging()) {
// mLogView.start();
// ToastUtils.show("LogView start.");
// }
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.toolbar_main, menu);
getMenuInflater().inflate(R.menu.toolbar_appbase, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// 在switch语句中处理每个ID并在处理完后返回true未处理的情况返回false
return super.onOptionsItemSelected(item);
}
@Override
protected void onDestroy() {
super.onDestroy();
Intent intentAPPWidget = new Intent(this, StatusWidget.class);
intentAPPWidget.setAction(StatusWidget.ACTION_STATUS_UPDATE);
sendBroadcast(intentAPPWidget);
}
public void onSwitchDebugMode(View view) {
boolean isDebuging = ((CheckBox)view).isChecked();
GlobalApplication.setIsDebuging(isDebuging);
GlobalApplication.saveDebugStatus();
}
public void onPreviewGlobalCrashActivity(View view) {
Intent intent = new Intent(this, GlobalCrashActivity.class);
intent.putExtra(CrashHandler.EXTRA_CRASH_INFO, "Demo log...");
startActivity(intent);
}
public void onStartCenter(View view) {
MainService.startMainService(this);
}
public void onStopCenter(View view) {
MainService.stopMainService(this);
}
public void onTestStopMainServiceWithoutSettingEnable(View view) {
LogUtils.d(TAG, "onTestStopMainServiceWithoutSettingEnable");
stopService(new Intent(this, MainService.class));
}
public void onTestUseComponentStartService(View view) {
LogUtils.d(TAG, "onTestUseComponentStartService");
// 目标服务的包名和类名
String packageName = this.getPackageName();
String serviceClassName = TestDemoService.class.getName();
// 构建Intent
Intent intentService = new Intent();
intentService.setComponent(new ComponentName(packageName, serviceClassName));
startService(intentService);
}
public void onTestDemoServiceSOS(View view) {
Intent intent = new Intent(this, TestDemoService.class);
stopService(intent);
if (App.isDebuging()) {
SOS.sosToAppBaseBeta(this, TestDemoService.class.getName());
} else {
SOS.sosToAppBase(this, TestDemoService.class.getName());
}
}
public void onSartTestDemoService(View view) {
Intent intent = new Intent(this, TestDemoService.class);
intent.setAction(TestDemoService.ACTION_ENABLE);
startService(intent);
}
public void onStopTestDemoService(View view) {
Intent intent = new Intent(this, TestDemoService.class);
intent.setAction(TestDemoService.ACTION_DISABLE);
startService(intent);
Intent intentStop = new Intent(this, TestDemoService.class);
stopService(intentStop);
}
public void onStopTestDemoServiceNoSettings(View view) {
Intent intent = new Intent(this, TestDemoService.class);
stopService(intent);
}
public void onSartTestDemoBindService(View view) {
Intent intent = new Intent(this, TestDemoBindService.class);
intent.setAction(TestDemoBindService.ACTION_ENABLE);
startService(intent);
}
public void onStopTestDemoBindService(View view) {
Intent intent = new Intent(this, TestDemoBindService.class);
intent.setAction(TestDemoBindService.ACTION_DISABLE);
startService(intent);
Intent intentStop = new Intent(this, TestDemoBindService.class);
stopService(intentStop);
}
public void onStopTestDemoBindServiceNoSettings(View view) {
Intent intent = new Intent(this, TestDemoBindService.class);
stopService(intent);
}
public void onTestOpenNewActivity(View view) {
GlobalApplication.getWinBollActivityManager().startWinBollActivity(this, NewActivity.class);
}
}

View File

@ -1,79 +0,0 @@
package cc.winboll.studio.appbase;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/02/13 19:30:10
*/
import android.content.Context;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import cc.winboll.studio.appbase.models.MainServiceBean;
import cc.winboll.studio.appbase.services.MainService;
public class MyTileService extends TileService {
public static final String TAG = "MyTileService";
volatile static MyTileService _MyTileService;
@Override
public void onStartListening() {
super.onStartListening();
_MyTileService = this;
Tile tile = getQsTile();
MainServiceBean bean = MainServiceBean.loadBean(this, MainServiceBean.class);
if (bean != null && bean.isEnable()) {
//MainService.startMainService(context);
tile.setState(Tile.STATE_ACTIVE);
tile.setIcon(android.graphics.drawable.Icon.createWithResource(this, R.drawable.ic_cloud));
} else {
//MainService.stopMainService(context);
tile.setState(Tile.STATE_INACTIVE);
tile.setIcon(android.graphics.drawable.Icon.createWithResource(this, R.drawable.ic_cloud_outline));
}
tile.updateTile();
// Tile tile = getQsTile();
// tile.setState(Tile.STATE_INACTIVE);
// tile.setLabel(getString(R.string.tileservice_name));
// tile.setIcon(android.graphics.drawable.Icon.createWithResource(this, R.drawable.ic_cloud_outline));
// tile.updateTile();
}
@Override
public void onClick() {
super.onClick();
Tile tile = getQsTile();
MainServiceBean bean = MainServiceBean.loadBean(this, MainServiceBean.class);
if (bean == null) {
bean = new MainServiceBean();
}
if (tile.getState() == Tile.STATE_ACTIVE) {
bean.setIsEnable(false);
MainServiceBean.saveBean(this, bean);
MainService.stopMainService(this);
} else if (tile.getState() == Tile.STATE_INACTIVE) {
bean.setIsEnable(true);
MainServiceBean.saveBean(this, bean);
MainService.startMainService(this);
}
updateServiceIconStatus(this);
}
public static void updateServiceIconStatus(Context context) {
if (_MyTileService == null) {
return;
}
Tile tile = _MyTileService.getQsTile();
MainServiceBean bean = MainServiceBean.loadBean(context, MainServiceBean.class);
if (bean != null && bean.isEnable()) {
tile.setState(Tile.STATE_ACTIVE);
tile.setIcon(android.graphics.drawable.Icon.createWithResource(context, R.drawable.ic_cloud));
} else {
tile.setState(Tile.STATE_INACTIVE);
tile.setIcon(android.graphics.drawable.Icon.createWithResource(context, R.drawable.ic_cloud_outline));
}
tile.updateTile();
}
}

View File

@ -1,82 +0,0 @@
package cc.winboll.studio.appbase;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/03/28 15:34:16
* @Describe 应用活动窗口基类
*/
import android.app.Activity;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import cc.winboll.studio.appbase.App;
import cc.winboll.studio.appbase.R;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog;
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
import cc.winboll.studio.libappbase.winboll.WinBollActivityManager;
public class WinBollActivityBase extends AppCompatActivity implements IWinBollActivity {
public static final String TAG = "WinBollActivityBase";
@Override
public Activity getActivity() {
return this;
}
@Override
public String getTag() {
return TAG;
}
WinBollActivityManager getWinBollActivityManager() {
return WinBollActivityManager.getInstance(GlobalApplication.getInstance());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWinBollActivityManager().add(this);
}
@Override
public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onPostCreate(savedInstanceState, persistentState);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == cc.winboll.studio.appbase.R.id.item_log) {
GlobalApplication.getWinBollActivityManager().startLogActivity(this);
return true;
} else if(item.getItemId() == cc.winboll.studio.appbase.R.id.item_minimal) {
//moveTaskToBack(true);
exit();
}
// 在switch语句中处理每个ID并在处理完后返回true未处理的情况返回false
return super.onOptionsItemSelected(item);
}
void exit() {
YesNoAlertDialog.show(this, "Exit " + getString(R.string.app_name), "Close all activity and exit?", new YesNoAlertDialog.OnDialogResultListener(){
@Override
public void onYes() {
App.getWinBollActivityManager().finishAll();
}
@Override
public void onNo() {
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
getWinBollActivityManager().registeRemove(this);
}
}

View File

@ -1,83 +0,0 @@
package cc.winboll.studio.appbase.activities;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/03/25 11:46:40
* @Describe 测试窗口2
*/
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import cc.winboll.studio.appbase.R;
import cc.winboll.studio.appbase.WinBollActivityBase;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
public class New2Activity extends WinBollActivityBase implements IWinBollActivity {
public static final String TAG = "New2Activity";
Toolbar mToolbar;
//LogView mLogView;
@Override
public Activity getActivity() {
return this;
}
@Override
public String getTag() {
return TAG;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new2);
// mLogView = findViewById(R.id.logview);
// mLogView.start();
mToolbar = findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
}
@Override
protected void onResume() {
super.onResume();
//mLogView.start();
}
public void onCloseThisActivity(View view) {
GlobalApplication.getWinBollActivityManager().finish(this);
}
public void onCloseAllActivity(View view) {
GlobalApplication.getWinBollActivityManager().finishAll();
}
public void onNewActivity(View view) {
GlobalApplication.getWinBollActivityManager().startWinBollActivity(this, NewActivity.class);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.toolbar_main, menu);
getMenuInflater().inflate(R.menu.toolbar_appbase, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == cc.winboll.studio.appbase.R.id.item_log) {
GlobalApplication.getWinBollActivityManager().startLogActivity(this);
return true;
}
// 在switch语句中处理每个ID并在处理完后返回true未处理的情况返回false
return super.onOptionsItemSelected(item);
}
}

View File

@ -1,81 +0,0 @@
package cc.winboll.studio.appbase.activities;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/03/25 05:04:22
*/
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import cc.winboll.studio.appbase.R;
import cc.winboll.studio.appbase.WinBollActivityBase;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
public class NewActivity extends WinBollActivityBase implements IWinBollActivity {
public static final String TAG = "NewActivity";
Toolbar mToolbar;
//LogView mLogView;
@Override
public Activity getActivity() {
return this;
}
@Override
public String getTag() {
return TAG;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new);
// mLogView = findViewById(R.id.logview);
// mLogView.start();
mToolbar = findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
}
@Override
protected void onResume() {
super.onResume();
//mLogView.start();
}
public void onCloseThisActivity(View view) {
GlobalApplication.getWinBollActivityManager().finish(this);
}
public void onCloseAllActivity(View view) {
GlobalApplication.getWinBollActivityManager().finishAll();
}
public void onNew2Activity(View view) {
GlobalApplication.getWinBollActivityManager().startWinBollActivity(this, New2Activity.class);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.toolbar_main, menu);
getMenuInflater().inflate(R.menu.toolbar_appbase, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == cc.winboll.studio.appbase.R.id.item_log) {
GlobalApplication.getWinBollActivityManager().startLogActivity(this);
return true;
}
// 在switch语句中处理每个ID并在处理完后返回true未处理的情况返回false
return super.onOptionsItemSelected(item);
}
}

View File

@ -1,38 +0,0 @@
package cc.winboll.studio.appbase.handlers;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/02/14 03:51:40
*/
import android.os.Handler;
import android.os.Message;
import cc.winboll.studio.appbase.services.MainService;
import java.lang.ref.WeakReference;
public class MainServiceHandler extends Handler {
public static final String TAG = "MainServiceHandler";
public static final int MSG_REMINDTHREAD = 0;
WeakReference<MainService> serviceWeakReference;
public MainServiceHandler(MainService service) {
serviceWeakReference = new WeakReference<MainService>(service);
}
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_REMINDTHREAD: // 处理下载完成消息更新UI
{
// 显示提醒消息
//
//LogUtils.d(TAG, "显示提醒消息");
MainService mainService = serviceWeakReference.get();
if (mainService != null) {
mainService.appenMessage((String)msg.obj);
}
break;
}
}
}
}

View File

@ -1,67 +0,0 @@
package cc.winboll.studio.appbase.models;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/02/13 07:06:13
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class MainServiceBean extends BaseBean {
public static final String TAG = "MainServiceBean";
boolean isEnable;
public MainServiceBean() {
this.isEnable = false;
}
public void setIsEnable(boolean isEnable) {
this.isEnable = isEnable;
}
public boolean isEnable() {
return isEnable;
}
@Override
public String getName() {
return MainServiceBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
jsonWriter.name("isEnable").value(isEnable());
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
if (name.equals("isEnable")) {
setIsEnable(jsonReader.nextBoolean());
} else {
return false;
}
}
return true;
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (!initObjectsFromJsonReader(jsonReader, name)) {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return this;
}
}

View File

@ -1,67 +0,0 @@
package cc.winboll.studio.appbase.models;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/03/07 12:47:22
* @Describe TestServiceBean
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class TestDemoBindServiceBean extends BaseBean {
public static final String TAG = "TestServiceBean";
boolean isEnable;
public TestDemoBindServiceBean() {
this.isEnable = false;
}
public void setIsEnable(boolean isEnable) {
this.isEnable = isEnable;
}
public boolean isEnable() {
return isEnable;
}
@Override
public String getName() {
return TestDemoBindServiceBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
jsonWriter.name("isEnable").value(isEnable());
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
if (name.equals("isEnable")) {
setIsEnable(jsonReader.nextBoolean());
} else {
return false;
}
}
return true;
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (!initObjectsFromJsonReader(jsonReader, name)) {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return this;
}
}

View File

@ -1,68 +0,0 @@
package cc.winboll.studio.appbase.models;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/03/07 12:49:21
* @Describe TestDemoServiceBean
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class TestDemoServiceBean extends BaseBean {
public static final String TAG = "TestDemoServiceBean";
boolean isEnable;
public TestDemoServiceBean() {
this.isEnable = false;
}
public void setIsEnable(boolean isEnable) {
this.isEnable = isEnable;
}
public boolean isEnable() {
return isEnable;
}
@Override
public String getName() {
return TestDemoServiceBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
jsonWriter.name("isEnable").value(isEnable());
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
if (name.equals("isEnable")) {
setIsEnable(jsonReader.nextBoolean());
} else {
return false;
}
}
return true;
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (!initObjectsFromJsonReader(jsonReader, name)) {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return this;
}
}

View File

@ -1,72 +0,0 @@
package cc.winboll.studio.appbase.models;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/02/17 10:05:09
* @Describe APPSOSReportBean
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class WinBollNewsBean extends BaseBean {
public static final String TAG = "WinBollNewsBean";
protected String message;
public WinBollNewsBean() {
this.message = "";
}
public WinBollNewsBean(String message) {
this.message = message;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
@Override
public String getName() {
return WinBollNewsBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
jsonWriter.name("message").value(getMessage());
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
if (name.equals("message")) {
setMessage(jsonReader.nextString());
} else {
return false;
}
}
return true;
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (!initObjectsFromJsonReader(jsonReader, name)) {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return this;
}
}

View File

@ -1,36 +0,0 @@
package cc.winboll.studio.appbase.receivers;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/03/24 07:11:44
*/
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import cc.winboll.studio.appbase.widgets.APPNewsWidget;
import cc.winboll.studio.libappbase.LogUtils;
public class APPNewsWidgetClickListener extends BroadcastReceiver {
public static final String TAG = "APPNewsWidgetClickListener";
public static final String ACTION_PRE = APPNewsWidgetClickListener.class.getName() + ".ACTION_PRE";
public static final String ACTION_NEXT = APPNewsWidgetClickListener.class.getName() + ".ACTION_NEXT";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action == null) {
LogUtils.d(TAG, String.format("action %s", action));
return;
}
if (action.equals(ACTION_PRE)) {
LogUtils.d(TAG, "ACTION_PRE");
APPNewsWidget.prePage(context);
} else if (action.equals(ACTION_NEXT)) {
LogUtils.d(TAG, "ACTION_NEXT");
APPNewsWidget.nextPage(context);
} else {
LogUtils.d(TAG, String.format("action %s", action));
}
}
}

View File

@ -1,117 +0,0 @@
package cc.winboll.studio.appbase.receivers;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/02/13 06:58:04
* @Describe 主要广播接收器
*/
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import cc.winboll.studio.appbase.models.WinBollNewsBean;
import cc.winboll.studio.appbase.services.MainService;
import cc.winboll.studio.appbase.widgets.APPNewsWidget;
import cc.winboll.studio.libappbase.AppUtils;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.sos.APPModel;
import cc.winboll.studio.libappbase.sos.SOS;
import cc.winboll.studio.libappbase.sos.SOSObject;
import cc.winboll.studio.libappbase.sos.WinBoll;
import cc.winboll.studio.libappbase.utils.ToastUtils;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.Date;
public class MainReceiver extends BroadcastReceiver {
public static final String TAG = "MainReceiver";
public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
WeakReference<MainService> mwrService;
public MainReceiver(MainService service) {
mwrService = new WeakReference<MainService>(service);
}
@Override
public void onReceive(Context context, Intent intent) {
String szAction = intent.getAction();
if (szAction.equals(ACTION_BOOT_COMPLETED)) {
ToastUtils.show("ACTION_BOOT_COMPLETED");
} else if (szAction.equals(WinBoll.ACTION_BIND)) {
LogUtils.d(TAG, "ACTION_BIND");
LogUtils.d(TAG, String.format("context.getPackageName() %s", context.getPackageName()));
LogUtils.d(TAG, String.format("intent.getAction() %s", intent.getAction()));
String szAPPModel = intent.getStringExtra(WinBoll.EXTRA_APPMODEL);
LogUtils.d(TAG, String.format("szAPPModel %s", szAPPModel));
if (szAPPModel != null && !szAPPModel.equals("")) {
try {
APPModel bean = APPModel.parseStringToBean(szAPPModel, APPModel.class);
if (bean != null) {
String szAppPackageName = bean.getAppPackageName();
LogUtils.d(TAG, String.format("szAppPackageName %s", szAppPackageName));
String szAppMainServiveName = bean.getAppMainServiveName();
LogUtils.d(TAG, String.format("szAppMainServiveName %s", szAppMainServiveName));
mwrService.get().bindAPPModelConnection(bean);
}
} catch (IOException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
} else if (intent.getAction().equals(SOS.ACTION_SOS)) {
LogUtils.d(TAG, "ACTION_SOS");
String sos = intent.getStringExtra(SOS.EXTRA_OBJECT);
LogUtils.d(TAG, String.format("SOS %s", sos));
if (sos != null && !sos.equals("")) {
SOSObject bean = SOS.parseSOSObject(sos);
if (bean != null) {
String szObjectPackageName = bean.getObjectPackageName();
LogUtils.d(TAG, String.format("szObjectPackageName %s", szObjectPackageName));
String szObjectServiveName = bean.getObjectServiveName();
LogUtils.d(TAG, String.format("szObjectServiveName %s", szObjectServiveName));
Intent intentService = new Intent();
intentService.setComponent(new ComponentName(szObjectPackageName, szObjectServiveName));
context.startService(intentService);
String appName = AppUtils.getAppNameByPackageName(context, szObjectPackageName);
LogUtils.d(TAG, String.format("appName %s", appName));
WinBollNewsBean appWinBollNewsBean = new WinBollNewsBean(appName);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
String currentTime = sdf.format(new Date());
StringBuilder sbLine = new StringBuilder();
sbLine.append("[");
sbLine.append(currentTime);
sbLine.append("] Power to ");
sbLine.append(appName);
appWinBollNewsBean.setMessage(sbLine.toString());
APPNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean);
Intent intentWidget = new Intent(context, APPNewsWidget.class);
intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
context.sendBroadcast(intentWidget);
}
}
} else {
ToastUtils.show(szAction);
}
}
// 注册 Receiver
//
public void registerAction(MainService service) {
IntentFilter filter=new IntentFilter();
filter.addAction(ACTION_BOOT_COMPLETED);
filter.addAction(SOS.ACTION_SOS);
filter.addAction(WinBoll.ACTION_BIND);
//filter.addAction(Intent.ACTION_BATTERY_CHANGED);
service.registerReceiver(this, filter);
}
}

View File

@ -1,138 +0,0 @@
package cc.winboll.studio.appbase.services;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/02/14 03:38:31
* @Describe 守护进程服务
*/
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import cc.winboll.studio.appbase.models.MainServiceBean;
import cc.winboll.studio.appbase.services.AssistantService;
import cc.winboll.studio.appbase.services.MainService;
import cc.winboll.studio.libappbase.LogUtils;
import android.os.Binder;
public class AssistantService extends Service {
public static final String TAG = "AssistantService";
MainServiceBean mMainServiceBean;
MyServiceConnection mMyServiceConnection;
MainService mMainService;
boolean isBound = false;
volatile boolean isThreadAlive = false;
public synchronized void setIsThreadAlive(boolean isThreadAlive) {
LogUtils.d(TAG, "setIsThreadAlive(...)");
LogUtils.d(TAG, String.format("isThreadAlive %s", isThreadAlive));
this.isThreadAlive = isThreadAlive;
}
public boolean isThreadAlive() {
return isThreadAlive;
}
@Override
public IBinder onBind(Intent intent) {
return new MyBinder();
}
@Override
public void onCreate() {
LogUtils.d(TAG, "onCreate");
super.onCreate();
//mMyBinder = new MyBinder();
if (mMyServiceConnection == null) {
mMyServiceConnection = new MyServiceConnection();
}
// 设置运行参数
setIsThreadAlive(false);
assistantService();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
LogUtils.d(TAG, "call onStartCommand(...)");
assistantService();
return START_STICKY;
}
@Override
public void onDestroy() {
//LogUtils.d(TAG, "onDestroy");
setIsThreadAlive(false);
// 解除绑定
if (isBound) {
unbindService(mMyServiceConnection);
isBound = false;
}
super.onDestroy();
}
// 运行服务内容
//
void assistantService() {
LogUtils.d(TAG, "assistantService()");
mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
LogUtils.d(TAG, String.format("mMainServiceBean.isEnable() %s", mMainServiceBean.isEnable()));
if (mMainServiceBean.isEnable()) {
LogUtils.d(TAG, String.format("mIsThreadAlive %s", isThreadAlive()));
if (isThreadAlive() == false) {
// 设置运行状态
setIsThreadAlive(true);
// 唤醒和绑定主进程
wakeupAndBindMain();
}
}
}
// 唤醒和绑定主进程
//
void wakeupAndBindMain() {
LogUtils.d(TAG, "wakeupAndBindMain()");
// 绑定服务的Intent
Intent intent = new Intent(this, MainService.class);
startService(new Intent(this, MainService.class));
bindService(intent, mMyServiceConnection, Context.BIND_IMPORTANT);
// startService(new Intent(this, MainService.class));
// bindService(new Intent(AssistantService.this, MainService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
}
// 主进程与守护进程连接时需要用到此类
//
class MyServiceConnection implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
LogUtils.d(TAG, "onServiceConnected(...)");
MainService.MyBinder binder = (MainService.MyBinder) service;
mMainService = binder.getService();
isBound = true;
}
@Override
public void onServiceDisconnected(ComponentName name) {
LogUtils.d(TAG, "onServiceDisconnected(...)");
mMainServiceBean = MainServiceBean.loadBean(AssistantService.this, MainServiceBean.class);
if (mMainServiceBean.isEnable()) {
wakeupAndBindMain();
}
isBound = false;
mMainService = null;
}
}
// 用于返回服务实例的Binder
public class MyBinder extends Binder {
AssistantService getService() {
LogUtils.d(TAG, "AssistantService MyBinder getService()");
return AssistantService.this;
}
}
}

View File

@ -1,316 +0,0 @@
package cc.winboll.studio.appbase.services;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/02/13 06:56:41
* @Describe 拨号主服务
* 参考:
* 进程保活-双进程守护的正确姿势
* https://blog.csdn.net/sinat_35159441/article/details/75267380
* Android Service之onStartCommand方法研究
* https://blog.csdn.net/cyp331203/article/details/38920491
*/
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Binder;
import android.os.IBinder;
import cc.winboll.studio.appbase.MyTileService;
import cc.winboll.studio.appbase.models.MainServiceBean;
import cc.winboll.studio.appbase.handlers.MainServiceHandler;
import cc.winboll.studio.appbase.receivers.MainReceiver;
import cc.winboll.studio.appbase.services.AssistantService;
import cc.winboll.studio.appbase.threads.MainServiceThread;
import cc.winboll.studio.appbase.widgets.APPNewsWidget;
import cc.winboll.studio.libappbase.LogUtils;
import java.util.ArrayList;
import cc.winboll.studio.libappbase.sos.APPModel;
public class MainService extends Service {
public static final String TAG = "MainService";
public static final int MSG_UPDATE_STATUS = 0;
static MainService _mControlCenterService;
volatile boolean isServiceRunning;
MainServiceBean mMainServiceBean;
MainServiceThread mMainServiceThread;
MainServiceHandler mMainServiceHandler;
MyServiceConnection mMyServiceConnection;
AssistantService mAssistantService;
boolean isBound = false;
MainReceiver mMainReceiver;
ArrayList<APPConnection> mAPPModelConnectionList;
@Override
public IBinder onBind(Intent intent) {
return new MyBinder();
}
public MainServiceThread getRemindThread() {
return mMainServiceThread;
}
@Override
public void onCreate() {
super.onCreate();
LogUtils.d(TAG, "onCreate()");
mAPPModelConnectionList = new ArrayList<APPConnection>();
_mControlCenterService = MainService.this;
isServiceRunning = false;
mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
if (mMyServiceConnection == null) {
mMyServiceConnection = new MyServiceConnection();
}
mMainServiceHandler = new MainServiceHandler(this);
// 运行服务内容
mainService();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
LogUtils.d(TAG, "onStartCommand(...)");
// 运行服务内容
mainService();
return (mMainServiceBean.isEnable()) ? START_STICKY : super.onStartCommand(intent, flags, startId);
}
// 运行服务内容
//
void mainService() {
LogUtils.d(TAG, "mainService()");
mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
if (mMainServiceBean.isEnable() && isServiceRunning == false) {
LogUtils.d(TAG, "mainService() start running");
isServiceRunning = true;
// 唤醒守护进程
wakeupAndBindAssistant();
if (mMainReceiver == null) {
// 注册广播接收器
mMainReceiver = new MainReceiver(this);
mMainReceiver.registerAction(this);
}
// 启动小部件
Intent intentTimeWidget = new Intent(this, APPNewsWidget.class);
intentTimeWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
this.sendBroadcast(intentTimeWidget);
startMainServiceThread();
MyTileService.updateServiceIconStatus(this);
LogUtils.i(TAG, "Main Service Is Start.");
}
}
// 唤醒和绑定守护进程
//
void wakeupAndBindAssistant() {
LogUtils.d(TAG, "wakeupAndBindAssistant()");
Intent intent = new Intent(this, AssistantService.class);
startService(intent);
// 绑定服务的Intent
bindService(intent, mMyServiceConnection, Context.BIND_IMPORTANT);
}
// 开启提醒铃声线程
//
public void startMainServiceThread() {
LogUtils.d(TAG, "startMainServiceThread");
if (mMainServiceThread == null) {
mMainServiceThread = new MainServiceThread(this, mMainServiceHandler);
LogUtils.d(TAG, "new MainServiceThread");
} else {
if (mMainServiceThread.isExist() == true) {
mMainServiceThread = new MainServiceThread(this, mMainServiceHandler);
LogUtils.d(TAG, "renew MainServiceThread");
} else {
// 提醒进程正在进行中就更新状态后退出
LogUtils.d(TAG, "A mMainServiceThread running.");
return;
}
}
mMainServiceThread.start();
}
public void stopRemindThread() {
if (mMainServiceThread != null) {
mMainServiceThread.setIsExist(true);
mMainServiceThread = null;
}
}
@Override
public void onDestroy() {
//LogUtils.d(TAG, "onDestroy");
mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
if (mMainServiceBean.isEnable() == false) {
// 设置运行状态
isServiceRunning = false;// 解除绑定
if (isBound) {
unbindService(mMyServiceConnection);
isBound = false;
}
// 停止守护进程
Intent intent = new Intent(this, AssistantService.class);
stopService(intent);
// 停止Receiver
if (mMainReceiver != null) {
unregisterReceiver(mMainReceiver);
mMainReceiver = null;
}
// 停止前台通知栏
stopForeground(true);
// 停止消息提醒进程
stopRemindThread();
MyTileService.updateServiceIconStatus(this);
super.onDestroy();
//LogUtils.d(TAG, "onDestroy done");
}
}
public void bindAPPModelConnection(APPModel bean) {
LogUtils.d(TAG, "bindAPPModelConnection(...)");
// 清理旧的绑定链接
for (int i = mAPPModelConnectionList.size() - 1; i > -1; i--) {
APPConnection item = mAPPModelConnectionList.get(i);
if (item.isBindToAPP(bean)) {
LogUtils.d(TAG, "Bind Servive exist.");
unbindService(item);
mAPPModelConnectionList.remove(i);
}
}
// 绑定服务
APPConnection appConnection = new APPConnection();
Intent intentService = new Intent();
intentService.setComponent(new ComponentName(bean.getAppPackageName(), bean.getAppMainServiveName()));
bindService(intentService, appConnection, Context.BIND_IMPORTANT);
mAPPModelConnectionList.add(appConnection);
Intent intentWidget = new Intent(this, APPNewsWidget.class);
intentWidget.setAction(APPNewsWidget.ACTION_WAKEUP_SERVICE);
APPModel appSOSBean = new APPModel(bean.getAppPackageName(), bean.getAppMainServiveName());
intentWidget.putExtra("APPSOSBean", appSOSBean.toString());
sendBroadcast(intentWidget);
}
public class APPConnection implements ServiceConnection {
ComponentName mComponentName;
boolean isBindToAPP(APPModel bean) {
return mComponentName != null
&& mComponentName.getClassName().equals(bean.getAppMainServiveName())
&& mComponentName.getPackageName().equals(bean.getAppPackageName());
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
LogUtils.d(TAG, "onServiceConnected(...)");
mComponentName = name;
LogUtils.d(TAG, String.format("onServiceConnected : \ngetClassName %s\ngetPackageName %s", name.getClassName(), name.getPackageName()));
}
@Override
public void onServiceDisconnected(ComponentName name) {
LogUtils.d(TAG, "onServiceDisconnected(...)");
LogUtils.d(TAG, String.format("onServiceDisconnected : \ngetClassName %s\ngetPackageName %s", name.getClassName(), name.getPackageName()));
// 尝试无参数启动一下服务
String appPackage = mComponentName.getPackageName();
LogUtils.d(TAG, String.format("appPackage %s", appPackage));
String appMainServiceClassName = mComponentName.getClassName();
LogUtils.d(TAG, String.format("appMainServiceClassName %s", appMainServiceClassName));
Intent intentService = new Intent();
intentService.setComponent(new ComponentName(appPackage, appMainServiceClassName));
startService(intentService);
}
}
// 主进程与守护进程连接时需要用到此类
//
private class MyServiceConnection implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
LogUtils.d(TAG, "onServiceConnected(...)");
AssistantService.MyBinder binder = (AssistantService.MyBinder) service;
mAssistantService = binder.getService();
isBound = true;
}
@Override
public void onServiceDisconnected(ComponentName name) {
LogUtils.d(TAG, "onServiceDisconnected(...)");
if (mMainServiceBean.isEnable()) {
// 唤醒守护进程
wakeupAndBindAssistant();
}
isBound = false;
mAssistantService = null;
}
}
// 用于返回服务实例的Binder
public class MyBinder extends Binder {
MainService getService() {
LogUtils.d(TAG, "MainService MyBinder getService()");
return MainService.this;
}
}
// //
// // 启动服务
// //
// public static void startControlCenterService(Context context) {
// Intent intent = new Intent(context, MainService.class);
// context.startForegroundService(intent);
// }
//
// //
// // 停止服务
// //
// public static void stopControlCenterService(Context context) {
// Intent intent = new Intent(context, MainService.class);
// context.stopService(intent);
// }
public void appenMessage(String message) {
LogUtils.d(TAG, String.format("Message : %s", message));
}
public static void stopMainService(Context context) {
LogUtils.d(TAG, "stopMainService");
MainServiceBean bean = new MainServiceBean();
bean.setIsEnable(false);
MainServiceBean.saveBean(context, bean);
context.stopService(new Intent(context, MainService.class));
}
public static void startMainService(Context context) {
LogUtils.d(TAG, "startMainService");
MainServiceBean bean = new MainServiceBean();
bean.setIsEnable(true);
MainServiceBean.saveBean(context, bean);
context.startService(new Intent(context, MainService.class));
}
}

View File

@ -1,178 +0,0 @@
package cc.winboll.studio.appbase.services;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/03/07 12:45:49
* @Describe 启动时申请绑定到APPBase主服务的服务示例
*/
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import cc.winboll.studio.appbase.models.TestDemoBindServiceBean;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.sos.WinBoll;
import cc.winboll.studio.appbase.App;
import cc.winboll.studio.libappbase.sos.SOS;
public class TestDemoBindService extends Service {
public static final String TAG = "TestDemoBindService";
public static final String ACTION_ENABLE = TestDemoBindService.class.getName() + ".ACTION_ENABLE";
public static final String ACTION_DISABLE = TestDemoBindService.class.getName() + ".ACTION_DISABLE";
volatile static TestThread _TestThread;
volatile static boolean _IsRunning;
public synchronized static void setIsRunning(boolean isRunning) {
_IsRunning = isRunning;
}
public static boolean isRunning() {
return _IsRunning;
}
@Override
public IBinder onBind(Intent intent) {
return new MyBinder();
}
public class MyBinder extends Binder {
public TestDemoBindService getService() {
return TestDemoBindService.this;
}
}
@Override
public void onCreate() {
super.onCreate();
LogUtils.d(TAG, "onCreate()");
run();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
LogUtils.d(TAG, "onStartCommand(...)");
TestDemoBindServiceBean bean = TestDemoBindServiceBean.loadBean(this, TestDemoBindServiceBean.class);
if (bean == null) {
bean = new TestDemoBindServiceBean();
}
if (intent.getAction() != null) {
if (intent.getAction().equals(ACTION_ENABLE)) {
bean.setIsEnable(true);
LogUtils.d(TAG, "setIsEnable(true);");
TestDemoBindServiceBean.saveBean(this, bean);
} else if (intent.getAction().equals(ACTION_DISABLE)) {
bean.setIsEnable(false);
LogUtils.d(TAG, "setIsEnable(false);");
TestDemoBindServiceBean.saveBean(this, bean);
}
}
run();
return (bean.isEnable()) ? START_STICKY : super.onStartCommand(intent, flags, startId);
//return super.onStartCommand(intent, flags, startId);
}
void run() {
LogUtils.d(TAG, "run()");
TestDemoBindServiceBean bean = TestDemoBindServiceBean.loadBean(this, TestDemoBindServiceBean.class);
if (bean == null) {
bean = new TestDemoBindServiceBean();
TestDemoBindServiceBean.saveBean(this, bean);
}
if (bean.isEnable()) {
LogUtils.d(TAG, "run() bean.isEnable()");
TestThread.getInstance(this).start();
LogUtils.d(TAG, "_TestThread.start()");
}
}
@Override
public void onDestroy() {
super.onDestroy();
LogUtils.d(TAG, "onDestroy()");
TestDemoBindServiceBean bean = TestDemoBindServiceBean.loadBean(this, TestDemoBindServiceBean.class);
if (bean == null) {
bean = new TestDemoBindServiceBean();
}
TestThread.getInstance(this).setIsExit(true);
// 预防 APPBase 应用重启绑定失效
// 所以退出时检查本服务是否配置启用如果启用就发送一个 SOS 信号
// 这样 APPBase 就会用组件方式启动本服务
if (bean.isEnable()) {
if (App.isDebuging()) {
SOS.sosToAppBaseBeta(this, TestDemoBindService.class.getName());
} else {
SOS.sosToAppBase(this, TestDemoBindService.class.getName());
}
}
_IsRunning = false;
}
static class TestThread extends Thread {
volatile static TestThread _TestThread;
Context mContext;
volatile boolean isStarted = false;
volatile boolean isExit = false;
TestThread(Context context) {
super();
mContext = context;
}
public static synchronized TestThread getInstance(Context context) {
if (_TestThread != null) {
_TestThread.setIsExit(true);
}
_TestThread = new TestThread(context);
return _TestThread;
}
public synchronized void setIsExit(boolean isExit) {
this.isExit = isExit;
}
public boolean isExit() {
return isExit;
}
@Override
public void run() {
if (isStarted == false) {
isStarted = true;
super.run();
LogUtils.d(TAG, "run() start");
if (App.isDebuging()) {
WinBoll.bindToAPPBaseBeta(mContext, TestDemoBindService.class.getName());
} else {
WinBoll.bindToAPPBase(mContext, TestDemoBindService.class.getName());
}
while (!isExit()) {
LogUtils.d(TAG, "run()");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
LogUtils.d(TAG, "run() exit");
}
}
}
}

View File

@ -1,156 +0,0 @@
package cc.winboll.studio.appbase.services;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/03/07 12:39:24
* @Describe 普通服务示例
*/
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import cc.winboll.studio.appbase.models.TestDemoServiceBean;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.sos.WinBoll;
public class TestDemoService extends Service {
public static final String TAG = "TestDemoService";
public static final String ACTION_ENABLE = TestDemoService.class.getName() + ".ACTION_ENABLE";
public static final String ACTION_DISABLE = TestDemoService.class.getName() + ".ACTION_DISABLE";
volatile static TestThread _TestThread;
volatile static boolean _IsRunning;
public synchronized static void setIsRunning(boolean isRunning) {
_IsRunning = isRunning;
}
public static boolean isRunning() {
return _IsRunning;
}
@Override
public IBinder onBind(Intent intent) {
return new MyBinder();
}
public class MyBinder extends Binder {
public TestDemoService getService() {
return TestDemoService.this;
}
}
@Override
public void onCreate() {
super.onCreate();
LogUtils.d(TAG, "onCreate()");
run();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
LogUtils.d(TAG, "onStartCommand(...)");
TestDemoServiceBean bean = TestDemoServiceBean.loadBean(this, TestDemoServiceBean.class);
if (bean == null) {
bean = new TestDemoServiceBean();
}
if (intent.getAction() != null) {
if (intent.getAction().equals(ACTION_ENABLE)) {
bean.setIsEnable(true);
LogUtils.d(TAG, "setIsEnable(true);");
TestDemoServiceBean.saveBean(this, bean);
} else if (intent.getAction().equals(ACTION_DISABLE)) {
bean.setIsEnable(false);
LogUtils.d(TAG, "setIsEnable(false);");
TestDemoServiceBean.saveBean(this, bean);
}
}
run();
return (bean.isEnable()) ? START_STICKY : super.onStartCommand(intent, flags, startId);
//return super.onStartCommand(intent, flags, startId);
}
void run() {
LogUtils.d(TAG, "run()");
TestDemoServiceBean bean = TestDemoServiceBean.loadBean(this, TestDemoServiceBean.class);
if (bean == null) {
bean = new TestDemoServiceBean();
TestDemoServiceBean.saveBean(this, bean);
}
if (bean.isEnable()) {
LogUtils.d(TAG, "run() bean.isEnable()");
TestThread.getInstance(this).start();
LogUtils.d(TAG, "_TestThread.start()");
}
}
@Override
public void onDestroy() {
super.onDestroy();
LogUtils.d(TAG, "onDestroy()");
TestThread.getInstance(this).setIsExit(true);
_IsRunning = false;
}
static class TestThread extends Thread {
volatile static TestThread _TestThread;
Context mContext;
volatile boolean isStarted = false;
volatile boolean isExit = false;
TestThread(Context context) {
super();
mContext = context;
}
public static synchronized TestThread getInstance(Context context) {
if (_TestThread != null) {
_TestThread.setIsExit(true);
}
_TestThread = new TestThread(context);
return _TestThread;
}
public synchronized void setIsExit(boolean isExit) {
this.isExit = isExit;
}
public boolean isExit() {
return isExit;
}
@Override
public void run() {
if (isStarted == false) {
isStarted = true;
super.run();
LogUtils.d(TAG, "run() start");
while (!isExit()) {
LogUtils.d(TAG, "run()");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
LogUtils.d(TAG, "run() exit");
}
}
}
}

View File

@ -1,54 +0,0 @@
package cc.winboll.studio.appbase.threads;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/02/14 03:46:44
*/
import android.content.Context;
import cc.winboll.studio.appbase.handlers.MainServiceHandler;
import cc.winboll.studio.libappbase.LogUtils;
import java.lang.ref.WeakReference;
public class MainServiceThread extends Thread {
public static final String TAG = "MainServiceThread";
Context mContext;
// 控制线程是否退出的标志
volatile boolean isExist = false;
// 服务Handler, 用于线程发送消息使用
WeakReference<MainServiceHandler> mwrMainServiceHandler;
public void setIsExist(boolean isExist) {
this.isExist = isExist;
}
public boolean isExist() {
return isExist;
}
public MainServiceThread(Context context, MainServiceHandler handler) {
mContext = context;
mwrMainServiceHandler = new WeakReference<MainServiceHandler>(handler);
}
@Override
public void run() {
LogUtils.d(TAG, "run()");
while (!isExist()) {
//ToastUtils.show("run()");
//LogUtils.d(TAG, "run()");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
LogUtils.d(TAG, "run() exit.");
}
}

View File

@ -1,186 +0,0 @@
package cc.winboll.studio.appbase.widgets;
/**
* @Author ZhanGSKen<zhangsken@188.com>
* @Date 2025/02/15 14:41:25
* @Describe TimeWidget
*/
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;
import cc.winboll.studio.appbase.R;
import cc.winboll.studio.appbase.models.WinBollNewsBean;
import cc.winboll.studio.appbase.receivers.APPNewsWidgetClickListener;
import cc.winboll.studio.libappbase.AppUtils;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.sos.APPModel;
import cc.winboll.studio.libappbase.sos.WinBoll;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
public class APPNewsWidget extends AppWidgetProvider {
public static final String TAG = "APPNewsWidget";
public static final String ACTION_WAKEUP_SERVICE = APPNewsWidget.class.getName() + ".ACTION_WAKEUP_SERVICE";
public static final String ACTION_RELOAD_REPORT = APPNewsWidget.class.getName() + ".ACTION_RELOAD_REPORT";
volatile static ArrayList<WinBollNewsBean> _WinBollNewsBeanList;
final static int _MAX_PAGES = 10;
final static int _OnePageLinesCount = 5;
volatile static int _CurrentPageIndex = 0;
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
initWinBollNewsBeanList(context);
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
}
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
initWinBollNewsBeanList(context);
if (intent.getAction().equals(ACTION_RELOAD_REPORT)) {
LogUtils.d(TAG, "ACTION_RELOAD_REPORT");
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, APPNewsWidget.class));
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
}else if (intent.getAction().equals(ACTION_WAKEUP_SERVICE)) {
LogUtils.d(TAG, "ACTION_WAKEUP_SERVICE");
String szAPPModel = intent.getStringExtra(WinBoll.EXTRA_APPMODEL);
LogUtils.d(TAG, String.format("szAPPModel %s", szAPPModel));
if (szAPPModel != null && !szAPPModel.equals("")) {
try {
APPModel bean = APPModel.parseStringToBean(szAPPModel, APPModel.class);
if (bean != null) {
String szAppPackageName = bean.getAppPackageName();
LogUtils.d(TAG, String.format("szAppPackageName %s", szAppPackageName));
String szAppMainServiveName = bean.getAppMainServiveName();
LogUtils.d(TAG, String.format("szAppMainServiveName %s", szAppMainServiveName));
String appName = AppUtils.getAppNameByPackageName(context, szAppPackageName);
LogUtils.d(TAG, String.format("appName %s", appName));
WinBollNewsBean winBollNewsBean = new WinBollNewsBean(appName);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
String currentTime = sdf.format(new Date());
StringBuilder sbLine = new StringBuilder();
sbLine.append("[");
sbLine.append(currentTime);
sbLine.append("] Wake up ");
sbLine.append(appName);
winBollNewsBean.setMessage(sbLine.toString());
addWinBollNewsBean(context, winBollNewsBean);
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, APPNewsWidget.class));
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
}
} catch (IOException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
}
}
//
// 加入新报告信息
//
public synchronized static void addWinBollNewsBean(Context context, WinBollNewsBean bean) {
initWinBollNewsBeanList(context);
_WinBollNewsBeanList.add(0, bean);
// 控制记录总数
while (_WinBollNewsBeanList.size() > _MAX_PAGES * _OnePageLinesCount) {
_WinBollNewsBeanList.remove(_WinBollNewsBeanList.size() - 1);
}
WinBollNewsBean.saveBeanList(context, _WinBollNewsBeanList, WinBollNewsBean.class);
}
synchronized static void initWinBollNewsBeanList(Context context) {
if (_WinBollNewsBeanList == null) {
_WinBollNewsBeanList = new ArrayList<WinBollNewsBean>();
WinBollNewsBean.loadBeanList(context, _WinBollNewsBeanList, WinBollNewsBean.class);
}
if (_WinBollNewsBeanList == null) {
_WinBollNewsBeanList = new ArrayList<WinBollNewsBean>();
WinBollNewsBean.saveBeanList(context, _WinBollNewsBeanList, WinBollNewsBean.class);
}
}
private void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
LogUtils.d(TAG, "updateAppWidget(...)");
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_news);
//设置按钮点击事件
Intent intentPre = new Intent(context, APPNewsWidgetClickListener.class);
intentPre.setAction(APPNewsWidgetClickListener.ACTION_PRE);
PendingIntent pendingIntentPre = PendingIntent.getBroadcast(context, 0, intentPre, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.widget_button_pre, pendingIntentPre);
Intent intentNext = new Intent(context, APPNewsWidgetClickListener.class);
intentNext.setAction(APPNewsWidgetClickListener.ACTION_NEXT);
PendingIntent pendingIntentNext = PendingIntent.getBroadcast(context, 0, intentNext, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.widget_button_next, pendingIntentNext);
views.setTextViewText(R.id.tv_msg, getPageInfo());
views.setTextViewText(R.id.tv_news, getMessage());
appWidgetManager.updateAppWidget(appWidgetId, views);
}
public static String getMessage() {
ArrayList<String> msgTemp = new ArrayList<String>();
if (_WinBollNewsBeanList != null) {
int start = _OnePageLinesCount * _CurrentPageIndex;
start = _WinBollNewsBeanList.size() > start ? start : _WinBollNewsBeanList.size() - 1;
for (int i = start, j = 0; i < _WinBollNewsBeanList.size() && j < _OnePageLinesCount && start > -1; i++, j++) {
msgTemp.add(_WinBollNewsBeanList.get(i).getMessage());
}
String message = String.join("\n", msgTemp);
return message;
}
return "";
}
public static void prePage(Context context) {
if (_WinBollNewsBeanList != null) {
if (_CurrentPageIndex > 0) {
_CurrentPageIndex = _CurrentPageIndex - 1;
}
Intent intentWidget = new Intent(context, APPNewsWidget.class);
intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
context.sendBroadcast(intentWidget);
}
}
public static void nextPage(Context context) {
if (_WinBollNewsBeanList != null) {
if ((_CurrentPageIndex + 1) * _OnePageLinesCount < _WinBollNewsBeanList.size()) {
_CurrentPageIndex = _CurrentPageIndex + 1;
}
Intent intentWidget = new Intent(context, APPNewsWidget.class);
intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
context.sendBroadcast(intentWidget);
}
}
String getPageInfo() {
if (_WinBollNewsBeanList == null) {
return "0/0";
}
int leftCount = _WinBollNewsBeanList.size() % _OnePageLinesCount;
int currentPageCount = _WinBollNewsBeanList.size() / _OnePageLinesCount + (leftCount == 0 ?0: 1);
return String.format("%d/%d", _CurrentPageIndex + 1, currentPageCount);
}
}

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#ff000000"
android:pathData="M6.5,20Q4.22,20 2.61,18.43 1,16.85 1,14.58 1,12.63 2.17,11.1 3.35,9.57 5.25,9.15 5.88,6.85 7.75,5.43 9.63,4 12,4 14.93,4 16.96,6.04 19,8.07 19,11 20.73,11.2 21.86,12.5 23,13.78 23,15.5 23,17.38 21.69,18.69 20.38,20 18.5,20Z"/>
</vector>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#ff000000"
android:pathData="M6.5,20Q4.22,20 2.61,18.43 1,16.85 1,14.58 1,12.63 2.17,11.1 3.35,9.57 5.25,9.15 5.88,6.85 7.75,5.43 9.63,4 12,4 14.93,4 16.96,6.04 19,8.07 19,11 20.73,11.2 21.86,12.5 23,13.78 23,15.5 23,17.38 21.69,18.69 20.38,20 18.5,20M6.5,18H18.5Q19.55,18 20.27,17.27 21,16.55 21,15.5 21,14.45 20.27,13.73 19.55,13 18.5,13H17V11Q17,8.93 15.54,7.46 14.08,6 12,6 9.93,6 8.46,7.46 7,8.93 7,11H6.5Q5.05,11 4.03,12.03 3,13.05 3,14.5 3,15.95 4.03,17 5.05,18 6.5,18M12,12Z"/>
</vector>

View File

@ -1,216 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0">
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, WinBoll!"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android版本10的代号是“Q”API级别是29。 Android 10开始谷歌不再公开使用甜品作为版本代号但内部仍保留了大量与“Q”相关的元素。Android 10本身并没有严格对应某个特定的Java版本但在开发Android 10应用时通常可以使用Java 8或更高版本。 Java 8为Android开发带来了诸如Lambda表达式、方法引用等新特性能提高开发效率和代码可读性与Android 10开发适配良好。Java 9及更高版本也可用于Android 10开发能使用一些新的语言特性和API但可能需要注意兼容性和配置问题。"/>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:gravity="right|center_vertical"
android:layout_width="wrap_content">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Debug Mode"
android:layout_weight="1.0"
android:onClick="onSwitchDebugMode"
android:id="@+id/activitymainCheckBox1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test Application CrashReport"
android:textAllCaps="false"
android:onClick="onTestApplicationCrashReport"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PreviewGlobalCrashActivity"
android:textAllCaps="false"
android:onClick="onPreviewGlobalCrashActivity"/>
</LinearLayout>
</HorizontalScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="400dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StartCenter"
android:textAllCaps="false"
android:onClick="onStartCenter"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StopCenter"
android:textAllCaps="false"
android:onClick="onStopCenter"/>
</LinearLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SartTestDemoService"
android:textAllCaps="false"
android:onClick="onSartTestDemoService"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StopTestDemoService"
android:textAllCaps="false"
android:onClick="onStopTestDemoService"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StopTestDemoServiceNoSettings"
android:textAllCaps="false"
android:onClick="onStopTestDemoServiceNoSettings"/>
</LinearLayout>
</HorizontalScrollView>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SartTestDemoBindService"
android:textAllCaps="false"
android:onClick="onSartTestDemoBindService"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StopTestDemoBindService"
android:textAllCaps="false"
android:onClick="onStopTestDemoBindService"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StopTestDemoBindServiceNoSettings"
android:textAllCaps="false"
android:onClick="onStopTestDemoBindServiceNoSettings"/>
</LinearLayout>
</HorizontalScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TestStopMainServiceWithoutSettingEnable"
android:textAllCaps="false"
android:onClick="onTestStopMainServiceWithoutSettingEnable"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TestUseComponentStartService"
android:textAllCaps="false"
android:onClick="onTestUseComponentStartService"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TestDemoServiceSOS"
android:textAllCaps="false"
android:onClick="onTestDemoServiceSOS"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TestOpenNewActivity"
android:textAllCaps="false"
android:onClick="onTestOpenNewActivity"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NewActivity"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CloseThisActivity"
android:textAllCaps="false"
android:onClick="onCloseThisActivity"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CloseAllActivity"
android:textAllCaps="false"
android:onClick="onCloseAllActivity"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New2Activity"
android:textAllCaps="false"
android:onClick="onNew2Activity"/>
</LinearLayout>

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New2Activity"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CloseThisActivity"
android:textAllCaps="false"
android:onClick="onCloseThisActivity"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CloseAllActivity"
android:textAllCaps="false"
android:onClick="onCloseAllActivity"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NewActivity"
android:textAllCaps="false"
android:onClick="onNewActivity"/>
</LinearLayout>

View File

@ -1,51 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FFFFFFFF">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right|center_vertical">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/tv_title"
android:layout_weight="1.0"
android:text="WinBollNews"
android:textStyle="bold"
android:textSize="16sp"/>
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:text="⇦"
android:id="@+id/widget_button_pre"/>
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:text="⇨"
android:id="@+id/widget_button_next"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tv_msg"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/tv_news"
android:layout_weight="1.0"/>
</LinearLayout>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
</menu>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#FF00B322</color>
<color name="colorPrimaryDark">#FF005C12</color>
<color name="colorAccent">#FF8DFFA2</color>
<color name="colorText">#FFFFFB8D</color>
</resources>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">AppBase</string>
<string name="tileservice_name">WinBoll</string>
</resources>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyAPPBaseTheme" parent="APPBaseTheme">
<item name="attrColorPrimary">@color/colorPrimary</item>
<item name="themeGlobalCrashActivity">@style/MyGlobalCrashActivityTheme</item>
</style>
<style name="MyGlobalCrashActivityTheme" parent="GlobalCrashActivityTheme">
<item name="colorTittle">#FFFFFFFF</item>
<item name="colorTittleBackgound">#FF00A4B3</item>
<item name="colorText">#FFFFFFFF</item>
<item name="colorTextBackgound">#FF000000</item>
</style>
</resources>

Some files were not shown because too many files have changed in this diff Show More