Compare commits

..

30 Commits

Author SHA1 Message Date
a3855b4375 docs: 重构 gpsrelaysentinel/README.md 中英文双语文档
- 中文文档新增核心功能清单(双模式运行、前台服务、订阅者管理、模拟面板、日志输出、崩溃处理、关于页面)
- 技术栈改用表格展示,模块说明更新为实际编译模块(:gpsrelaysentinel 与 :libgpsrelaysentinel)
- 核心依赖库分类更清晰(网络、终端模拟、功能组件、UI 组件)
- 项目结构树精确到具体 Java 源文件及其功能说明
- 权限说明改为具体 Android 权限声明
- 新增完整英文版本文档(Project Introduction、Core Features、Tech Stack、Module Structure、Core Dependencies、Build Instructions、Permissions、Project Structure、Contributing、License)
- 删除失效的参考文档链接
2026-05-07 16:25:40 +08:00
d5100a8aa4 feat: MainActivity工具栏添加About按钮跳转AboutActivity窗口
- 新增菜单资源文件 res/menu/menu_main.xml
- MainActivity 添加 onCreateOptionsMenu() 加载菜单
- MainActivity 添加 onOptionsItemSelected() 处理 About 按钮点击事件
- 点击 About 按钮后通过 Intent 启动 AboutActivity
2026-05-07 16:17:37 +08:00
e17929c09b 添加应用介绍窗口编译资源。 2026-05-07 15:57:54 +08:00
332c7ee21c 双剑合璧。
Merge remote-tracking branch 'origin/gpsrelaysentinel' into gpsrelaysentinel
2026-05-07 15:20:33 +08:00
20cb50ff29 feat(gpsrelaysentinel): 模拟GPS发送面板与订阅系统重构
[主应用]
- MainActivity: 新增模拟移动GPS发送面板(方向/距离/目标坐标预览/静态坐标同步)
- MainService: 代码模块化重构,方法拆分,实时同步最新GPS到MainActivity
- 新增3个子服务 GpsReceiverChildService1/2/3
- activity_main.xml: 深色主题改版,新增模拟面板、订阅面板容器、日志容器
- 新增资源: border_gray.xml、spinner_item_gray.xml、arrays.xml(8方向)

[类库]
- SubscribeLocationManager: 新增精准推送计数统计,公开配置查询方法
- GpsSubscribeReceiverService: 改为抽象父类,统一 onReceiveGpsData 入口
- GpsSubscribeControlView: 移除广播/倒计时,改用Manager直调+Handler自动刷新
- view_gps_subscribe_control.xml: 深色主题,新增SID标识与订阅数据记录表
2026-05-07 15:18:38 +08:00
498372c914 fix(libgpsrelaysentinel): 对齐 minSdk 与 Java 编译配置
- minSdkVersion 21 -> 26,与 gpsrelaysentinel 主模块及 API 26~30 要求一致
- 新增 compileOptions 设置 Java 7 编译,与项目 Java 语法规范统一
2026-05-07 15:10:09 +08:00
e147d46921 添加示例服务类注册 2026-05-07 14:41:12 +08:00
42d135068c 改进应用主窗口与调试接口UI 2026-05-07 14:39:49 +08:00
ceeacb5022 改进应用主要服务启动类 2026-05-07 14:38:56 +08:00
e24c9bdce3 改进GPS订阅服务发送框架 2026-05-07 14:37:07 +08:00
9c16685c1f 添加应用GPS订阅示例服务类 2026-05-07 14:35:58 +08:00
6ffcbbc4f4 添加模拟方位下拉列表项的视图资源 2026-05-07 14:34:33 +08:00
3c39225087 添加灰色边框资源,用于辅助深色视图渲染。 2026-05-07 14:32:58 +08:00
39b4761e49 添加定向方位数组 2026-05-07 14:30:50 +08:00
534ec28637 更新Maven库基础类库 2026-05-07 14:08:54 +08:00
89f96a7b99 预备调试框架 2026-05-07 11:11:24 +08:00
429db23050 fix(libgpsrelaysentinel): 修复LocationPoint无法通过Intent传递的编译错误
LocationPoint类实现Serializable接口,解决
GpsSubscribeReceiverService中使用putExtra()传递对象时的类型不匹配问题。
2026-05-07 11:00:48 +08:00
3e4a64f31e 添加libgpsrelaysentinel类库初始源码 2026-05-07 10:54:13 +08:00
2927303a88 GPSRelaySentinel项目添加类库模块libgpsrelaysentinel。 2026-05-07 10:33:56 +08:00
2c4fc218b0 fix(gpsrelaysentinel): 修复MainActivity访问MainService常量的权限问题
- 将PREF_NAME和KEY_SERVICE_ENABLED字段从private改为包内可见
- 允许MainActivity访问SP相关常量以设置服务状态标记
- 修复编译错误:KEY_SERVICE_ENABLED has private access
2026-05-07 03:05:47 +08:00
b065a20c4d feat(gpsrelaysentinel): 前台服务通知添加GPS数据计数值
- 添加mGpsCount计数器统计GPS数据接收次数
- 每次onLocationChanged时计数器自增
- 通知栏实时显示GPS数据计数值(Count: x)
- 计数包含在通知内容中:经纬度 | Count: x
2026-05-07 02:56:15 +08:00
b3df8c7770 feat(gpsrelaysentinel): 使用SP标记管理服务状态并支持自启动
- onStartCommand返回START_STICKY实现服务自启动
- onStartCommand直接设置SP标记为启用,不检查现有标记
- onCreate时检查SP标记,已启用则自动启动GPS
- onDestroy不再改变SP标记
- MainActivity stopService前先设置SP标记为不启用
2026-05-07 02:45:56 +08:00
dae269ff77 feat(gpsrelaysentinel): 升级为始终允许GPS监听权限申请
- 添加ACCESS_BACKGROUND_LOCATION权限声明
- 在Android Q及以上版本申请后台位置权限
- 权限检查包含后台位置权限验证
- 权限申请时根据系统版本动态添加后台位置权限
2026-05-07 02:26:55 +08:00
cb8c3448f5 feat(gpsrelaysentinel): 添加Switch打开时的GPS权限检查与申请
- Switch打开时检查是否有定位权限
- 无权限时自动申请ACCESS_FINE_LOCATION和ACCESS_COARSE_LOCATION
- 权限申请成功后自动启动MainService
- 权限申请失败时提示用户并关闭switch
- 根据当前权限状态初始化switch显示状态
2026-05-07 02:23:14 +08:00
0e90f40f0f feat(gpsrelaysentinel): 实现前台服务通知并通过Switch控制服务启停
- 添加FOREGROUND_SERVICE权限支持前台服务
- 使用startForegroundService替代startService启动服务
- 实现前台服务通知,实时显示GPS经纬度数据
- 在MainActivity添加Switch开关控制服务启停
- GPS位置更新时通过updateNotification实时更新通知内容
- 创建通知渠道适配Android O及以上版本
2026-05-07 02:15:19 +08:00
11aee7e373 refactor(gpsrelaysentinel): 重构MainService添加run函数管理GPS监听
- 将GPS定位申请逻辑从onCreate()转移到新增的run()函数
- onStartCommand()调用run()启动GPS监听
- 添加mIsRunning标志防止重复启动
- onCreate()不再直接初始化定位功能
- onDestroy()中重置mIsRunning标志
2026-05-07 02:02:50 +08:00
58a93a6746 feat(gpsrelaysentinel): 新增MainService服务用于接收GPS定位消息
- 添加MainService服务类,监听GPS定位更新(1秒间隔,1米距离)
- 在AndroidManifest.xml注册MainService服务
- 添加定位权限ACCESS_FINE_LOCATION和ACCESS_COARSE_LOCATION
- 使用LogUtils替代android.util.Log进行日志记录
- TAG属性改为public static final
2026-05-07 01:50:25 +08:00
38eacb9a57 docs(gpsrelaysentinel): 重新整理README.md项目说明书
- 基于项目实际情况重新组织文档结构
- 使用Markdown语法完善项目说明
- 补充技术栈、模块说明、依赖库等详细信息
- 添加项目结构、使用说明和参与贡献指南
- 更新项目名称为GPSRelaySentinel
2026-05-06 21:03:51 +08:00
377d084aad chore(gpsrelaysentinel): 配置Java 7编译选项适配项目技术栈
- 为gpsrelaysentinel模块添加compileOptions配置
- 设置sourceCompatibility和targetCompatibility为Java 7
- 满足项目要求:Java文件使用Java 7语法
- 保持Gradle编译使用Java 11(根目录subprojects配置)
- 保持安卓API适配范围26-30,compileSdkVersion 30
- 保持Gradle插件7.2.1版本
2026-05-06 21:01:38 +08:00
a16d98cad0 添加GPSRelaySentinel项目 2026-05-06 20:51:01 +08:00
211 changed files with 3033 additions and 13217 deletions

239
gpsrelaysentinel/README.md Normal file
View File

@@ -0,0 +1,239 @@
# GPSRelaySentinel
---
## 中文文档
### 项目介绍
GPSRelaySentinel 是一款专业的 **GPS 定位中继守护工具**,支持真实系统 GPS 定位监听与模拟 GPS 坐标仿真双模式运行。应用后台常驻前台服务,实时接收系统 GPS 位置数据,内置订阅者步长阈值判断机制,可对多个 GPS 订阅视图进行定点推送管理。
#### 核心功能
- **双模式运行**:支持真实 GPS 工作模式与虚拟仿真模式一键切换
- **前台常驻服务**`MainService` 作为前台 Service 持续监听 GPS 定位变化
- **订阅者管理**:内置 `GpsSubscribeManager``SubscribeLocationManager`,支持多订阅者步长阈值推送
- **模拟控制面板**:支持八大方位选择、自定义移动距离,自动计算偏移目标经纬度
- **实时日志输出**:集成 `LogView` 面板,方便调试定位轨迹与订阅推送状态
- **崩溃处理**`App` 类提供全局 CrashHandler 与 CrashActivity 展示崩溃日志
- **关于页面**:工具栏提供 About 按钮,可查看应用版本与项目信息
#### 技术栈
| 项目 | 版本/说明 |
|------|-----------|
| 编程语言 | Java 7源码 |
| 编译环境 | Java 11Gradle 编译) |
| Gradle 插件 | 7.2.1 |
| 最低 API | API 26 (Android 8.0) |
| 目标 API | API 30 (Android 11) |
| 编译 API | API 30 |
#### 模块结构
本项目采用多模块 Gradle 结构:
| 模块 | 类型 | 说明 |
|------|------|------|
| `:gpsrelaysentinel` | application | 主应用模块MainActivity、MainService、AboutActivity 等) |
| `:libgpsrelaysentinel` | library | GPS 中继核心类库GpsSubscribeManager、SubscribeLocationManager 等) |
#### 核心依赖库
**网络相关**
- OkHttp 4.4.1 / 3.14.9 — HTTP 客户端
- Gson 2.10.1 — JSON 解析
**终端模拟**
- Termux: terminal-emulator 0.118.0
- Termux: terminal-view 0.118.0
- Termux: termux-shared 0.118.0
**功能组件**
- ZXing 3.4.1 — 二维码生成与扫描
- JSch 0.1.55 — SSH/SFTP 客户端
- Jsoup 1.13.1 — HTML 解析
- FastJSON 1.2.76 — JSON 处理
**UI 组件**
- Material Design 1.4.0
- AndroidX 组件库
- PullRefreshLayout 1.2.0 — 下拉刷新
#### 编译说明
**调试版编译**
```bash
./gradlew assembleBetaDebug
```
**阶段版编译(发布)**
```bash
bash .winboll/bashPublishAPKAddTag.sh gpsrelaysentinel
```
**版本管理**
版本信息由 `gpsrelaysentinel/build.properties` 管理:
- `baseVersion` — 基础版本号
- `stageCount` — 阶段构建次数
- `publishVersion` — 发布版本号
- `buildCount` — 构建次数
#### 权限说明
应用需要以下权限:
- `ACCESS_FINE_LOCATION` — 精确定位
- `ACCESS_COARSE_LOCATION` — 大致定位
- `ACCESS_BACKGROUND_LOCATION` — 后台定位
- `FOREGROUND_SERVICE` — 前台服务
#### 项目结构
```
gpsrelaysentinel/
├── src/main/
│ ├── java/cc/winboll/studio/gpsrelaysentinel/
│ │ ├── App.java # Application 类,初始化与崩溃处理
│ │ ├── MainActivity.java # 主控制页面GPS服务开关、模拟面板、订阅视图
│ │ ├── MainService.java # GPS 定位核心前台服务
│ │ ├── AboutActivity.java # 关于页面
│ │ └── GpsReceiverChildService[1-3].java # GPS 接收子服务
│ ├── res/
│ │ ├── layout/ # 布局文件
│ │ ├── menu/ # 菜单文件
│ │ └── values/ # 资源值文件
│ ├── libs/ # 本地库文件
│ └── AndroidManifest.xml # 应用清单
├── build.gradle # 模块构建配置
└── build.properties # 版本配置文件
```
#### 参与贡献
1. Fork 本仓库
2. 新建功能分支 (`git checkout -b feat_xxx`)
3. 提交代码(作者: ZhanGSKen <ZhanGSKen@QQ.COM>
4. 新建 Pull Request
#### 许可证
[待添加许可证信息]
---
## English Documentation
### Project Introduction
GPSRelaySentinel is a professional **GPS relay and guardian tool**, supporting dual modes of real system GPS location monitoring and simulated GPS coordinate simulation. It runs as a foreground persistent background service, receives real-time system GPS location data, and builds-in subscriber step threshold judgment mechanism to manage fixed-point push for multiple GPS subscription views.
#### Core Features
- **Dual Mode Operation**: One-click switch between real GPS working mode and virtual simulation mode
- **Foreground Persistent Service**: `MainService` as a foreground Service continuously monitors GPS location changes
- **Subscriber Management**: Built-in `GpsSubscribeManager` and `SubscribeLocationManager`, supporting multi-subscriber step threshold push
- **Simulation Control Panel**: Supports eight direction selections, custom moving distance, and automatic offset target coordinate calculation
- **Real-time Log Output**: Integrated `LogView` panel for debugging location tracks and subscription push status
- **Crash Handling**: `App` class provides global CrashHandler and CrashActivity for crash log display
- **About Page**: Toolbar provides an About button to view app version and project information
#### Tech Stack
| Item | Version/Description |
|------|---------------------|
| Programming Language | Java 7 (source code) |
| Build Environment | Java 11 (Gradle compilation) |
| Gradle Plugin | 7.2.1 |
| Minimum API | API 26 (Android 8.0) |
| Target API | API 30 (Android 11) |
| Compile API | API 30 |
#### Module Structure
This project uses a multi-module Gradle structure:
| Module | Type | Description |
|--------|------|-------------|
| `:gpsrelaysentinel` | application | Main application module (MainActivity, MainService, AboutActivity, etc.) |
| `:libgpsrelaysentinel` | library | GPS relay core library (GpsSubscribeManager, SubscribeLocationManager, etc.) |
#### Core Dependencies
**Networking**
- OkHttp 4.4.1 / 3.14.9 — HTTP client
- Gson 2.10.1 — JSON parsing
**Terminal Emulation**
- Termux: terminal-emulator 0.118.0
- Termux: terminal-view 0.118.0
- Termux: termux-shared 0.118.0
**Functional Components**
- ZXing 3.4.1 — QR code generation and scanning
- JSch 0.1.55 — SSH/SFTP client
- Jsoup 1.13.1 — HTML parsing
- FastJSON 1.2.76 — JSON processing
**UI Components**
- Material Design 1.4.0
- AndroidX libraries
- PullRefreshLayout 1.2.0 — Pull-to-refresh
#### Build Instructions
**Debug Build**
```bash
./gradlew assembleBetaDebug
```
**Stage Build (Release)**
```bash
bash .winboll/bashPublishAPKAddTag.sh gpsrelaysentinel
```
**Version Management**
Version info is managed by `gpsrelaysentinel/build.properties`:
- `baseVersion` — Base version number
- `stageCount` — Stage build count
- `publishVersion` — Release version number
- `buildCount` — Build count
#### Permissions
The app requires the following permissions:
- `ACCESS_FINE_LOCATION` — Precise location
- `ACCESS_COARSE_LOCATION` — Approximate location
- `ACCESS_BACKGROUND_LOCATION` — Background location
- `FOREGROUND_SERVICE` — Foreground service
#### Project Structure
```
gpsrelaysentinel/
├── src/main/
│ ├── java/cc/winboll/studio/gpsrelaysentinel/
│ │ ├── App.java # Application class, initialization and crash handling
│ │ ├── MainActivity.java # Main control page (GPS service switch, simulation panel, subscription views)
│ │ ├── MainService.java # GPS location core foreground service
│ │ ├── AboutActivity.java # About page
│ │ └── GpsReceiverChildService[1-3].java # GPS receiver child services
│ ├── res/
│ │ ├── layout/ # Layout files
│ │ ├── menu/ # Menu files
│ │ └── values/ # Resource value files
│ ├── libs/ # Local library files
│ └── AndroidManifest.xml # App manifest
├── build.gradle # Module build configuration
└── build.properties # Version configuration file
```
#### Contributing
1. Fork this repository
2. Create a feature branch (`git checkout -b feat_xxx`)
3. Commit your changes (Author: ZhanGSKen <ZhanGSKen@QQ.COM>)
4. Create a Pull Request
#### License
[License information to be added]

View File

@@ -18,74 +18,109 @@ def genVersionName(def versionName){
}
android {
compileSdkVersion 30
// MIUI12
compileSdkVersion 30
buildToolsVersion "30.0.3"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
defaultConfig {
applicationId "cc.winboll.studio.mymessagemanager"
applicationId "cc.winboll.studio.gpsrelaysentinel"
minSdkVersion 26
// MIUI12
targetSdkVersion 30
versionCode 8
versionCode 1
// versionName
// .winboll/winbollBuildProps.properties stageCount=0
// Gradle编译环境下合起来的 versionName "${versionName}.0"
versionName "15.12"
versionName "15.11"
if(true) {
versionName = genVersionName("${versionName}")
}
}
// SDK
packagingOptions {
doNotStrip "*/*/libmimo_1011.so"
}
sourceSets {
main {
jniLibs.srcDirs = ['libs'] // SO库放在libs目录下
}
}
// Java 7
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
api project(':libgpsrelaysentinel')
api 'com.google.code.gson:gson:2.10.1'
//
api 'com.baoyz.pullrefreshlayout:library:1.2.0'
// SSH
api 'com.jcraft:jsch:0.1.55'
// Html
api 'org.jsoup:jsoup:1.13.1'
//
api 'com.google.zxing:core:3.4.1'
api 'com.journeyapps:zxing-android-embedded:3.6.0'
//
api 'io.github.medyo:android-about-page:2.0.0'
//
api 'com.squareup.okhttp3:okhttp:4.4.1'
// OkHttp网络请求
implementation 'com.squareup.okhttp3:okhttp:3.14.9'
// FastJSON解析
implementation 'com.alibaba:fastjson:1.2.76'
// AndroidX
/*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.miui.zeus:mimo-ad-sdk:5.3.+'//使sdk
//5
//api 'androidx.appcompat:appcompat:1.4.1'
//implementation 'androidx.appcompat:appcompat:1.4.1'
api 'androidx.recyclerview:recyclerview:1.0.0'
api 'com.google.code.gson:gson:2.8.5'
api 'com.github.bumptech.glide:glide:4.9.0'
//annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
api 'io.github.medyo:android-about-page:2.0.0'
api 'com.jcraft:jsch:0.1.55'
api 'org.jsoup:jsoup:1.13.1'
api 'com.squareup.okhttp3:okhttp:4.4.1'
api 'com.belerweb:pinyin4j:2.5.1'
// https://github.com/getActivity/XXPermissions
api 'com.github.getActivity:XXPermissions:18.63'
api 'com.baoyz.pullrefreshlayout:library:1.2.0'
// AndroidX
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'
implementation "androidx.annotation:annotation:1.3.0"
implementation "androidx.core:core:1.6.0"
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
implementation "androidx.preference:preference:1.1.1"
implementation "androidx.viewpager:viewpager:1.0.0"
implementation "com.google.android.material:material:1.4.0"
implementation "com.google.guava:guava:24.1-jre"
/*
implementation "io.noties.markwon:core:$markwonVersion"
implementation "io.noties.markwon:ext-strikethrough:$markwonVersion"
implementation "io.noties.markwon:linkify:$markwonVersion"
implementation "io.noties.markwon:recycler:$markwonVersion"
*/
implementation 'com.termux:terminal-emulator:0.118.0'
implementation 'com.termux:terminal-view:0.118.0'
implementation 'com.termux:termux-shared:0.118.0'
// WinBoLL库 nexus.winboll.cc
api 'cc.winboll.studio:libaes:15.12.12'
api 'cc.winboll.studio:libappbase:15.14.2'
api 'cc.winboll.studio:libaes:15.15.9'
api 'cc.winboll.studio:libappbase:15.15.21'
// WinBoLL备用库 jitpack.io
//api 'com.github.ZhanGSKen:AES:aes-v15.12.9'
//api 'com.github.ZhanGSKen:APPBase:appbase-v15.14.1'
//api 'com.github.ZhanGSKen:AES:aes-v15.15.7'
//api 'com.github.ZhanGSKen:APPBase:appbase-v15.15.4'
api fileTree(dir: 'libs', include: ['*.jar'])
}

View File

@@ -0,0 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Thu May 07 15:04:39 CST 2026
stageCount=27
libraryProject=
baseVersion=15.11
publishVersion=15.11.26
buildCount=33
baseBetaVersion=15.11.27

View File

@@ -67,12 +67,6 @@
-keep class okio.** { *; }
-dontwarn okhttp3.internal.platform.**
-dontwarn okio.**
# ============================== 必要补充规则 ==============================
# OkHttp 4.4.1 补充规则Java 7 兼容)
-keep class okhttp3.internal.concurrent.** { *; }
-keep class okhttp3.internal.connection.** { *; }
-dontwarn okhttp3.internal.concurrent.TaskRunner
-dontwarn okhttp3.internal.connection.RealCall
# Glide 4.9.0(米盟广告图片加载依赖)
-keep public class * implements com.bumptech.glide.module.GlideModule

View File

@@ -0,0 +1,12 @@
<?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

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">GPSRelaySentinel★</string>
<string name="app_description">一款支持真实/模拟定位的GPS中继工具可后台常驻实现位置数据转发、调试与仿真适配开发测试使用。</string>
</resources>

View File

@@ -0,0 +1,62 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="cc.winboll.studio.gpsrelaysentinel">
<!-- 只能在前台获取精确的位置信息 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- 只有在前台运行时才能获取大致位置信息 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<!-- 在后台使用位置信息 -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<!-- 运行前台服务 -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:theme="@style/MyAppTheme"
android:resizeableActivity="true"
android:name=".App">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="android.max_aspect"
android:value="4.0"/>
<activity android:name=".GlobalApplication$CrashActivity"/>
<service
android:name=".MainService"
android:enabled="true"
android:exported="false"/>
<service android:name=".GpsReceiverChildService1"/>
<service android:name=".GpsReceiverChildService2"/>
<service android:name=".GpsReceiverChildService3"/>
<activity android:name=".AboutActivity"/>
</application>
</manifest>

View File

@@ -0,0 +1,58 @@
package cc.winboll.studio.gpsrelaysentinel;
import android.app.Activity;
import android.os.Bundle;
/**
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
* @Date 2026/05/07 15:39
*/
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.models.APPInfo;
import cc.winboll.studio.libappbase.views.AboutView;
public class AboutActivity extends AppCompatActivity {
public static final String TAG = "AboutActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
AboutView aboutView = findViewById(R.id.aboutview);
aboutView.setAPPInfo(genDefaultAppInfo());
}
private APPInfo genDefaultAppInfo() {
LogUtils.d(TAG, "genDefaultAppInfo() 调用");
String branchName = "gpsrelaysentinel";
APPInfo appInfo = new APPInfo();
appInfo.setAppName("GPSRelaySentinel");
appInfo.setAppIcon(R.drawable.ic_winboll);
appInfo.setAppDescription(getString(R.string.app_description));
appInfo.setAppGitName("WinBoLL");
appInfo.setAppGitOwner("Studio");
appInfo.setAppGitAPPBranch(branchName);
appInfo.setAppGitAPPSubProjectFolder(branchName);
appInfo.setAppHomePage("https://www.winboll.cc/apks/index.php?project=GPSRelaySentinel");
appInfo.setAppAPKName("GPSRelaySentinel");
appInfo.setAppAPKFolderName("GPSRelaySentinel");
LogUtils.d(TAG, "genDefaultAppInfo: 应用信息已生成");
return appInfo;
}
}

View File

@@ -0,0 +1,340 @@
package cc.winboll.studio.gpsrelaysentinel;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.ToastUtils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.Thread.UncaughtExceptionHandler;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
public class App extends GlobalApplication {
private static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
@Override
public void onCreate() {
super.onCreate();
// 初始化 Toast 框架
ToastUtils.init(this);
//CrashHandler.getInstance().registerGlobal(this);
//CrashHandler.getInstance().registerPart(this);
}
public static void write(InputStream input, OutputStream output) throws IOException {
byte[] buf = new byte[1024 * 8];
int len;
while ((len = input.read(buf)) != -1) {
output.write(buf, 0, len);
}
}
public static void write(File file, byte[] data) throws IOException {
File parent = file.getParentFile();
if (parent != null && !parent.exists()) parent.mkdirs();
ByteArrayInputStream input = new ByteArrayInputStream(data);
FileOutputStream output = new FileOutputStream(file);
try {
write(input, output);
} finally {
closeIO(input, output);
}
}
public static String toString(InputStream input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
write(input, output);
try {
return output.toString("UTF-8");
} finally {
closeIO(input, output);
}
}
public static void closeIO(Closeable... closeables) {
for (Closeable closeable : closeables) {
try {
if (closeable != null) closeable.close();
} catch (IOException ignored) {}
}
}
public static class CrashHandler {
public static final UncaughtExceptionHandler DEFAULT_UNCAUGHT_EXCEPTION_HANDLER = Thread.getDefaultUncaughtExceptionHandler();
private static CrashHandler sInstance;
private PartCrashHandler mPartCrashHandler;
public static CrashHandler getInstance() {
if (sInstance == null) {
sInstance = new CrashHandler();
}
return sInstance;
}
public void registerGlobal(Context context) {
registerGlobal(context, null);
}
public void registerGlobal(Context context, String crashDir) {
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandlerImpl(context.getApplicationContext(), crashDir));
}
public void unregister() {
Thread.setDefaultUncaughtExceptionHandler(DEFAULT_UNCAUGHT_EXCEPTION_HANDLER);
}
public void registerPart(Context context) {
unregisterPart(context);
mPartCrashHandler = new PartCrashHandler(context.getApplicationContext());
MAIN_HANDLER.postAtFrontOfQueue(mPartCrashHandler);
}
public void unregisterPart(Context context) {
if (mPartCrashHandler != null) {
mPartCrashHandler.isRunning.set(false);
mPartCrashHandler = null;
}
}
private static class PartCrashHandler implements Runnable {
private final Context mContext;
public AtomicBoolean isRunning = new AtomicBoolean(true);
public PartCrashHandler(Context context) {
this.mContext = context;
}
@Override
public void run() {
while (isRunning.get()) {
try {
Looper.loop();
} catch (final Throwable e) {
e.printStackTrace();
if (isRunning.get()) {
MAIN_HANDLER.post(new Runnable(){
@Override
public void run() {
Toast.makeText(mContext, e.toString(), Toast.LENGTH_LONG).show();
}
});
} else {
if (e instanceof RuntimeException) {
throw (RuntimeException)e;
} else {
throw new RuntimeException(e);
}
}
}
}
}
}
private static class UncaughtExceptionHandlerImpl implements UncaughtExceptionHandler {
private static DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss");
private final Context mContext;
private final File mCrashDir;
public UncaughtExceptionHandlerImpl(Context context, String crashDir) {
this.mContext = context;
this.mCrashDir = TextUtils.isEmpty(crashDir) ? new File(mContext.getExternalCacheDir(), "crash") : new File(crashDir);
}
@Override
public void uncaughtException(Thread thread, Throwable throwable) {
try {
String log = buildLog(throwable);
writeLog(log);
try {
Intent intent = new Intent(mContext, CrashActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_TEXT, log);
mContext.startActivity(intent);
} catch (Throwable e) {
e.printStackTrace();
writeLog(e.toString());
}
throwable.printStackTrace();
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
} catch (Throwable e) {
if (DEFAULT_UNCAUGHT_EXCEPTION_HANDLER != null) DEFAULT_UNCAUGHT_EXCEPTION_HANDLER.uncaughtException(thread, throwable);
}
}
private String buildLog(Throwable throwable) {
String time = DATE_FORMAT.format(new Date());
String versionName = "unknown";
long versionCode = 0;
try {
PackageInfo packageInfo = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
versionName = packageInfo.versionName;
versionCode = Build.VERSION.SDK_INT >= 28 ? packageInfo.getLongVersionCode() : packageInfo.versionCode;
} catch (Throwable ignored) {}
LinkedHashMap<String, String> head = new LinkedHashMap<String, String>();
head.put("Time Of Crash", time);
head.put("Device", String.format("%s, %s", Build.MANUFACTURER, Build.MODEL));
head.put("Android Version", String.format("%s (%d)", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
head.put("App Version", String.format("%s (%d)", versionName, versionCode));
head.put("Kernel", getKernel());
head.put("Support Abis", Build.VERSION.SDK_INT >= 21 && Build.SUPPORTED_ABIS != null ? Arrays.toString(Build.SUPPORTED_ABIS): "unknown");
head.put("Fingerprint", Build.FINGERPRINT);
StringBuilder builder = new StringBuilder();
for (String key : head.keySet()) {
if (builder.length() != 0) builder.append("\n");
builder.append(key);
builder.append(" : ");
builder.append(head.get(key));
}
builder.append("\n\n");
builder.append(Log.getStackTraceString(throwable));
return builder.toString();
}
private void writeLog(String log) {
String time = DATE_FORMAT.format(new Date());
File file = new File(mCrashDir, "crash_" + time + ".txt");
try {
write(file, log.getBytes("UTF-8"));
} catch (Throwable e) {
e.printStackTrace();
}
}
private static String getKernel() {
try {
return App.toString(new FileInputStream("/proc/version")).trim();
} catch (Throwable e) {
return e.getMessage();
}
}
}
}
public static final class CrashActivity extends Activity {
private String mLog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_DeviceDefault);
setTitle("App Crash");
mLog = getIntent().getStringExtra(Intent.EXTRA_TEXT);
ScrollView contentView = new ScrollView(this);
contentView.setFillViewport(true);
HorizontalScrollView horizontalScrollView = new HorizontalScrollView(this);
TextView textView = new TextView(this);
int padding = dp2px(16);
textView.setPadding(padding, padding, padding, padding);
textView.setText(mLog);
textView.setTextIsSelectable(true);
textView.setTypeface(Typeface.DEFAULT);
textView.setLinksClickable(true);
horizontalScrollView.addView(textView);
contentView.addView(horizontalScrollView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
setContentView(contentView);
}
private void restart() {
Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName());
if (intent != null) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
finish();
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
}
private static int dp2px(float dpValue) {
final float scale = Resources.getSystem().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, android.R.id.copy, 0, android.R.string.copy)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.copy:
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
cm.setPrimaryClip(ClipData.newPlainText(getPackageName(), mLog));
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
restart();
}
}
}

View File

@@ -0,0 +1,27 @@
package cc.winboll.studio.gpsrelaysentinel;
import android.content.Intent;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeMsg;
import cc.winboll.studio.libgpsrelaysentinel.model.LocationPoint;
import cc.winboll.studio.libgpsrelaysentinel.service.GpsSubscribeReceiverService;
public final class GpsReceiverChildService1 extends GpsSubscribeReceiverService {
public static final String TAG = "GpsReceiverChildService1";
@Override
public void onReceiveGpsData(LocationPoint point, GpsSubscribeMsg config) {
super.onReceiveGpsData(point, config);
//当前独立接收日志
LogUtils.d(TAG,"独立接收服务1 成功收到GPS消息");
LogUtils.d(TAG,"纬度:"+point.getLatitude()+" 经度:"+point.getLongitude());
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_NOT_STICKY;
}
}

View File

@@ -0,0 +1,26 @@
package cc.winboll.studio.gpsrelaysentinel;
import android.content.Intent;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeMsg;
import cc.winboll.studio.libgpsrelaysentinel.model.LocationPoint;
import cc.winboll.studio.libgpsrelaysentinel.service.GpsSubscribeReceiverService;
public final class GpsReceiverChildService2 extends GpsSubscribeReceiverService {
public static final String TAG = "GpsReceiverChildService2";
@Override
public void onReceiveGpsData(LocationPoint point, GpsSubscribeMsg config) {
super.onReceiveGpsData(point, config);
LogUtils.d(TAG,"独立接收服务2 成功收到GPS消息");
LogUtils.d(TAG,"纬度:"+point.getLatitude()+" 经度:"+point.getLongitude());
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_NOT_STICKY;
}
}

View File

@@ -0,0 +1,26 @@
package cc.winboll.studio.gpsrelaysentinel;
import android.content.Intent;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeMsg;
import cc.winboll.studio.libgpsrelaysentinel.model.LocationPoint;
import cc.winboll.studio.libgpsrelaysentinel.service.GpsSubscribeReceiverService;
public final class GpsReceiverChildService3 extends GpsSubscribeReceiverService {
public static final String TAG = "GpsReceiverChildService3";
@Override
public void onReceiveGpsData(LocationPoint point, GpsSubscribeMsg config) {
super.onReceiveGpsData(point, config);
LogUtils.d(TAG,"独立接收服务3 成功收到GPS消息");
LogUtils.d(TAG,"纬度:"+point.getLatitude()+" 经度:"+point.getLongitude());
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_NOT_STICKY;
}
}

View File

@@ -0,0 +1,375 @@
package cc.winboll.studio.gpsrelaysentinel;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;
import android.view.Menu;
import android.view.MenuItem;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import cc.winboll.studio.gpsrelaysentinel.R;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.LogView;
import cc.winboll.studio.libappbase.ToastUtils;
/**
* WinBoLL Studio
* GPSRelaySentinel 主控制页面
* Java7 | API26~30
* 新增:模拟模式勾选控制 + 按钮互斥可用状态
*/
public final class MainActivity extends AppCompatActivity {
//原有控件
private Toolbar mToolbar;
private LogView mLogView;
private Switch mSwitchService;
//新增
private CheckBox mCheckBoxSimMode;
private Button btnSendLastGps;
private Spinner spinDirection;
private EditText etSimDistance;
private TextView tvTargetPreview;
private Button btnSimSend;
//全局模式标识 供给MainService判断
public static boolean IS_GPS_SIM_MODE = false;
//最后真实GPS坐标
public static double lastLat = 30.5928;
public static double lastLng = 114.3055;
//全局模拟坐标 供给MainService使用
public static double simLat = 30.5928;
public static double simLng = 114.3055;
//方位对应角度(正北0° 顺时针)
private double currentAngle = 0.0D;
//权限请求常量
private static final int REQUEST_LOCATION_PERMISSION = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
initToolbar();
initSwitchEvent();
initSimPanelEvent();
initSimModeCheck();
ToastUtils.show("onCreate");
}
/**
* 全部控件绑定
*/
private void initView() {
//原有
mToolbar = findViewById(R.id.toolbar);
mLogView = findViewById(R.id.logview);
mSwitchService = findViewById(R.id.switch_service);
//新增
mCheckBoxSimMode = findViewById(R.id.checkbox_sim_mode);
btnSendLastGps = findViewById(R.id.btn_send_last_gps);
spinDirection = findViewById(R.id.spin_direction);
etSimDistance = findViewById(R.id.et_sim_distance);
tvTargetPreview = findViewById(R.id.tv_target_point_preview);
btnSimSend = findViewById(R.id.btn_sim_send_gps);
//方位下拉 全局灰色文字
ArrayAdapter<CharSequence> dirAdapter = ArrayAdapter.createFromResource(
this,
R.array.direction_list,
R.layout.spinner_item_gray
);
dirAdapter.setDropDownViewResource(R.layout.spinner_item_gray);
spinDirection.setAdapter(dirAdapter);
//初始化开关状态
mSwitchService.setChecked(hasLocationPermission());
refreshButtonEnableStatus();
refreshTargetPreview();
}
//模拟勾选框监听
private void initSimModeCheck() {
mCheckBoxSimMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
IS_GPS_SIM_MODE = isChecked;
refreshButtonEnableStatus();
if (isChecked) {
ToastUtils.show("已进入GPS模拟模式");
} else {
ToastUtils.show("退出模拟模式使用真实GPS");
}
}
});
}
//刷新按钮互斥可用状态
private void refreshButtonEnableStatus() {
if (IS_GPS_SIM_MODE) {
//模拟模式:真实按钮禁用、模拟按钮可用
btnSendLastGps.setEnabled(false);
btnSimSend.setEnabled(true);
} else {
//正常模式:真实可用、模拟禁用
btnSendLastGps.setEnabled(true);
btnSimSend.setEnabled(false);
}
}
/**
* 初始化标题栏
*/
private void initToolbar() {
setSupportActionBar(mToolbar);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_about) {
startActivity(new Intent(this, AboutActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* GPS服务开关监听
*/
private void initSwitchEvent() {
mSwitchService.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
if (hasLocationPermission()) {
startGpsService();
} else {
requestLocationPermission();
mSwitchService.setChecked(false);
}
} else {
stopGpsService();
}
}
});
}
/**
* 模拟发送面板 全部事件初始化
*/
private void initSimPanelEvent() {
//1.原按钮发送最后一条真实GPS
btnSendLastGps.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendLastRealGpsBroadcast();
}
});
//2.方位下拉选择 -> 切换角度并刷新预览
spinDirection.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
currentAngle = getDirectionAngle(position);
refreshTargetPreview();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {}
});
//3.距离输入变化自动预览
etSimDistance.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
refreshTargetPreview();
}
}
});
//4.模拟发送按钮:计算偏移并赋值全局模拟坐标
btnSimSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
saveSimGpsData();
ToastUtils.show("已设置当前模拟GPS坐标");
}
});
}
/**
* 保存模拟坐标到全局静态变量 供给MainService使用
*/
private void saveSimGpsData() {
String disText = etSimDistance.getText().toString().trim();
double distance = 10D;
try {
distance = Double.parseDouble(disText);
} catch (Exception e) {
ToastUtils.show("请输入合法距离");
return;
}
double[] target = calculateOffsetLatLng(lastLat, lastLng, distance, currentAngle);
simLat = target[0];
simLng = target[1];
refreshTargetPreview();
}
/**
* 根据下拉position获取对应方位角度
*/
private double getDirectionAngle(int pos) {
switch (pos) {
case 0: return 0.0D; //正北
case 1: return 180.0D; //正南
case 2: return 90.0D; //正东
case 3: return 270.0D; //正西
case 4: return 45.0D; //东北
case 5: return 315.0D; //西北
case 6: return 135.0D; //东南
case 7: return 225.0D; //西南
default:return 0.0D;
}
}
/**
* 根据基准坐标+距离+角度 计算偏移经纬度
*/
private double[] calculateOffsetLatLng(double lat, double lng, double distanceMeter, double angle) {
double radAngle = Math.toRadians(angle);
double radLat = Math.toRadians(lat);
double meterPerLat = 111320D;
double meterPerLng = Math.cos(radLat) * 111320D;
double offsetLat = (distanceMeter * Math.cos(radAngle)) / meterPerLat;
double offsetLng = (distanceMeter * Math.sin(radAngle)) / meterPerLng;
return new double[]{lat + offsetLat , lng + offsetLng};
}
/**
* 刷新目标坐标预览
*/
private void refreshTargetPreview() {
String disText = etSimDistance.getText().toString().trim();
double distance = 10D;
try {
distance = Double.parseDouble(disText);
} catch (Exception e) {}
double[] target = calculateOffsetLatLng(lastLat, lastLng, distance, currentAngle);
String info = "目标模拟坐标:"
+ String.format("%.6f", target[0])
+ " , "
+ String.format("%.6f", target[1]);
tvTargetPreview.setText(info);
}
/**
* 发送【最后真实GPS】广播
*/
private void sendLastRealGpsBroadcast() {
Intent broadcast = new Intent("GPS_DATA_BROADCAST");
broadcast.putExtra("isSim", false);
broadcast.putExtra("lat", lastLat);
broadcast.putExtra("lng", lastLng);
sendBroadcast(broadcast);
LogUtils.d("GPS_SEND", "发送真实GPS -> lat:" + lastLat + " lng:" + lastLng);
}
//—————— 原有权限 & 服务启停 完全原样保留 ——————
private boolean hasLocationPermission() {
boolean basicPermission = checkSelfPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
|| checkSelfPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
if (basicPermission && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
return checkSelfPermission(android.Manifest.permission.ACCESS_BACKGROUND_LOCATION) == PackageManager.PERMISSION_GRANTED;
}
return basicPermission;
}
private void requestLocationPermission() {
String[] permissionArray;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
permissionArray = new String[]{
android.Manifest.permission.ACCESS_FINE_LOCATION,
android.Manifest.permission.ACCESS_COARSE_LOCATION,
android.Manifest.permission.ACCESS_BACKGROUND_LOCATION
};
} else {
permissionArray = new String[]{
android.Manifest.permission.ACCESS_FINE_LOCATION,
android.Manifest.permission.ACCESS_COARSE_LOCATION
};
}
requestPermissions(permissionArray, REQUEST_LOCATION_PERMISSION);
}
private void startGpsService() {
Intent serviceIntent = new Intent(MainActivity.this, MainService.class);
startForegroundService(serviceIntent);
ToastUtils.show("GPS Service started");
LogUtils.d(MainService.TAG, "GPS Service started from MainActivity");
}
private void stopGpsService() {
getSharedPreferences(MainService.PREF_NAME, Context.MODE_PRIVATE)
.edit()
.putBoolean(MainService.KEY_SERVICE_ENABLED, false)
.apply();
Intent serviceIntent = new Intent(MainActivity.this, MainService.class);
stopService(serviceIntent);
ToastUtils.show("GPS Service stopped");
LogUtils.d(MainService.TAG, "GPS Service stopped from MainActivity");
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_LOCATION_PERMISSION) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
mSwitchService.setChecked(true);
startGpsService();
} else {
ToastUtils.show("需要位置权限才能使用GPS服务");
mSwitchService.setChecked(false);
}
}
}
@Override
protected void onResume() {
super.onResume();
mLogView.start();
}
}

View File

@@ -0,0 +1,269 @@
package cc.winboll.studio.gpsrelaysentinel;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import androidx.core.app.NotificationCompat;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libgpsrelaysentinel.manager.GpsSubscribeManager;
import cc.winboll.studio.libgpsrelaysentinel.manager.SubscribeLocationManager;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeMsg;
import java.util.Map;
/**
* WinBoLL Studio
* GPS定位核心前台服务
* 负责GPS持续监听、订阅者步长判断、基准坐标刷新、前台常驻通知
* Java7 | API26~30
* 新增实时同步最新GPS到MainActivity静态坐标
*/
public final class MainService extends Service {
//日志标签
public static final String TAG = "MainService";
//前台通知常量
private static final String CHANNEL_ID = "gps_relay_channel";
private static final int NOTIFICATION_ID = 1;
//SP配置常量
static final String PREF_NAME = "gps_relay_service_prefs";
static final String KEY_SERVICE_ENABLED = "service_enabled";
//系统定位 & 通知控件
private LocationManager mLocationManager;
private LocationListener mLocationListener;
private NotificationManager mNotificationManager;
private NotificationCompat.Builder mNotificationBuilder;
//运行状态 & 计数
private boolean mIsRunning = false;
private int mGpsLocationCount = 0;
//订阅管理器
private GpsSubscribeManager mSubscribeManager;
private SubscribeLocationManager mLocationRuleManager;
@Override
public void onCreate() {
super.onCreate();
LogUtils.d(TAG, "Service onCreate");
initManager();
initNotificationConfig();
//上次开启状态则自动重启GPS监听
if (checkServiceEnableStatus()) {
LogUtils.d(TAG, "历史服务已启用自动启动GPS监听");
startGpsLocationListen();
}
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
LogUtils.d(TAG, "Service onStartCommand");
saveServiceEnableStatus(true);
startGpsLocationListen();
return START_STICKY;
}
/**
* 初始化订阅规则管理器
*/
private void initManager() {
mSubscribeManager = GpsSubscribeManager.getInstance();
mLocationRuleManager = SubscribeLocationManager.getInstance();
}
/**
* 初始化通知渠道与管理类
*/
private void initNotificationConfig() {
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
createSystemNotificationChannel();
}
/**
* 读取服务启用状态
*/
private boolean checkServiceEnableStatus() {
return getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
.getBoolean(KEY_SERVICE_ENABLED, false);
}
/**
* 保存服务启用状态
*/
private void saveServiceEnableStatus(boolean enabled) {
getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
.edit()
.putBoolean(KEY_SERVICE_ENABLED, enabled)
.apply();
LogUtils.d(TAG, "服务启用状态已设置:" + enabled);
}
/**
* 启动GPS定位监听核心逻辑
*/
private void startGpsLocationListen() {
if (mIsRunning) {
LogUtils.d(TAG, "GPS监听已正在运行无需重复启动");
return;
}
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
initLocationListener();
try {
if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
//定位间隔1000毫秒 / 最小位移1米
mLocationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
1000,
1,
mLocationListener
);
mIsRunning = true;
startServiceForegroundNotification();
LogUtils.d(TAG, "GPS定位监听已成功注册");
}
} catch (SecurityException e) {
LogUtils.e(TAG, "定位权限缺失,监听启动失败:" + e.getMessage());
}
}
/**
* 初始化定位监听回调
*/
private void initLocationListener() {
mLocationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
handleLocationUpdate(location);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
LogUtils.d(TAG, "GPS状态变更 -> 提供者:" + provider + " 状态:" + status);
}
@Override
public void onProviderEnabled(String provider) {
LogUtils.d(TAG, "GPS提供者已启用" + provider);
}
@Override
public void onProviderDisabled(String provider) {
LogUtils.d(TAG, "GPS提供者已禁用" + provider);
}
};
}
/**
* 处理每次定位刷新|核心:步长判断 + 基准坐标更新
* 新增同步最新坐标到MainActivity静态变量
*/
private void handleLocationUpdate(Location location) {
mGpsLocationCount ++;
String locationInfo = "纬度:" + location.getLatitude() + " , 经度:" + location.getLongitude();
LogUtils.d(TAG, "定位刷新 -> " + locationInfo);
//========== 新增关键代码实时同步最新真实GPS坐标 ==========
MainActivity.lastLat = location.getLatitude();
MainActivity.lastLng = location.getLongitude();
//==========================================================
//更新前台通知文案
updateForegroundNotification(locationInfo);
//遍历全部订阅者进行推送规则判断
Map<String, GpsSubscribeMsg> subscribeAllMap = mSubscribeManager.getSubscribeMap();
for (Map.Entry<String, GpsSubscribeMsg> entry : subscribeAllMap.entrySet()) {
final String subscribeSid = entry.getKey();
final GpsSubscribeMsg subscribeConfig = entry.getValue();
double currentLat = location.getLatitude();
double currentLng = location.getLongitude();
//判断是否满足推送条件(全订阅/步长阈值)
boolean allowPush = mLocationRuleManager.isNeedPush(subscribeSid, currentLat, currentLng);
if (allowPush) {
//推送成功后刷新该订阅者基准定点坐标
mLocationRuleManager.updateSubscriberPoint(subscribeSid, currentLat, currentLng);
}
}
}
/**
* 创建系统通知渠道
*/
private void createSystemNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(
CHANNEL_ID,
"GPS Relay Service",
NotificationManager.IMPORTANCE_LOW
);
notificationChannel.setDescription("GPSRelaySentinel 后台常驻服务通知");
mNotificationManager.createNotificationChannel(notificationChannel);
}
}
/**
* 开启前台常驻通知
*/
private void startServiceForegroundNotification() {
mNotificationBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("GPS 中继服务")
.setContentText("等待GPS定位数据...")
.setSmallIcon(android.R.drawable.ic_menu_mylocation)
.setOngoing(true);
Notification notification = mNotificationBuilder.build();
startForeground(NOTIFICATION_ID, notification);
}
/**
* 动态更新通知内容
*/
private void updateForegroundNotification(String locationText) {
if (mNotificationBuilder != null) {
mNotificationBuilder.setContentText(locationText + " | 定位次数:" + mGpsLocationCount);
mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build());
}
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onDestroy() {
super.onDestroy();
//注销定位监听
if (mLocationManager != null && mLocationListener != null) {
try {
mLocationManager.removeUpdates(mLocationListener);
} catch (SecurityException e) {
LogUtils.e(TAG, "移除定位监听权限异常:" + e.getMessage());
}
}
mIsRunning = false;
LogUtils.d(TAG, "MainService 已销毁GPS监听已停止");
}
}

View File

@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
android:shape="rectangle">
<!-- 灰色边框 -->
<stroke
android:width="1dp"
android:color="#555555"/>
<!-- 内部深色背景 -->
<solid android:color="#222222"/>
<!-- 轻微圆角 -->
<corners android:radius="4dp"/>
</shape>

View File

@@ -2,169 +2,169 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#FFDCD93D"
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</com.google.android.material.appbar.AppBarLayout>
<cc.winboll.studio.libappbase.views.AboutView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/aboutview"/>
</LinearLayout>
</FrameLayout>

View File

@@ -0,0 +1,198 @@
<?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="#1c1c1c">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</com.google.android.material.appbar.AppBarLayout>
<!-- 数据面板容器 -->
<LinearLayout
android:id="@+id/container_data_panel"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GPSRelaySentinel"
android:textColor="#888888"
android:padding="6dp"
android:background="@drawable/border_gray"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_marginTop="8dp"
android:spacing="12dp">
<CheckBox
android:id="@+id/checkbox_sim_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="模拟模式"
android:textColor="#999999"
android:padding="4dp"
android:background="@drawable/border_gray"
android:textSize="11sp"/>
<Switch
android:id="@+id/switch_service"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GPS Service"
android:textColor="#999999"
android:padding="4dp"
android:background="@drawable/border_gray"
android:checked="false"/>
<Button
android:id="@+id/btn_send_last_gps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="发送最后GPS"
android:textColor="#bbbbbb"
android:background="@drawable/border_gray"
android:textSize="12sp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="16dp"
android:padding="12dp"
android:background="@drawable/border_gray">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="模拟移动GPS发送面板"
android:textColor="#999999"
android:textSize="12sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp"
android:spacing="8dp">
<Spinner
android:id="@+id/spin_direction"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/border_gray"/>
<EditText
android:id="@+id/et_sim_distance"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="移动距离(米)"
android:inputType="numberDecimal"
android:text="10"
android:background="@drawable/border_gray"
android:textColor="#aaaaaa"
android:textColorHint="#666666"/>
</LinearLayout>
<TextView
android:id="@+id/tv_target_point_preview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="目标坐标:等待计算..."
android:textColor="#999999"
android:background="@drawable/border_gray"
android:padding="6dp"
android:textSize="11sp"
android:layout_marginTop="8dp"/>
<Button
android:id="@+id/btn_sim_send_gps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="发送模拟移动GPS"
android:textColor="#bbbbbb"
android:background="@drawable/border_gray"
android:layout_marginTop="10dp"/>
</LinearLayout>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0">
<!-- 订阅面板容器 -->
<LinearLayout
android:id="@+id/container_subscribe_panel"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="12dp">
<cc.winboll.studio.libgpsrelaysentinel.view.GpsSubscribeControlView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/border_gray"/>
<cc.winboll.studio.libgpsrelaysentinel.view.GpsSubscribeControlView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/border_gray"/>
<cc.winboll.studio.libgpsrelaysentinel.view.GpsSubscribeControlView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/border_gray"/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:orientation="vertical"
android:id="@+id/container_log_show"
android:background="@drawable/border_gray">
<cc.winboll.studio.libappbase.LogView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/logview"/>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:textColor="#999999"
android:gravity="center_vertical"/>

View File

@@ -0,0 +1,9 @@
<?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">
<item
android:id="@+id/action_about"
android:title="About"
android:icon="@android:drawable/ic_menu_info_details"
app:showAsAction="ifRoom"/>
</menu>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="direction_list">
<item>正北</item>
<item>正南</item>
<item>正东</item>
<item>正西</item>
<item>东北</item>
<item>西北</item>
<item>东南</item>
<item>西南</item>
</string-array>
</resources>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#009688</color>
<color name="colorPrimaryDark">#00796B</color>
<color name="colorAccent">#FF9800</color>
</resources>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">GPSRelaySentinel</string>
<string name="app_description">A GPS relay tool supporting real and simulated positioning, running in background for location forwarding, debugging and simulation.</string>
</resources>

View File

@@ -0,0 +1,11 @@
<resources>
<!-- Base application theme. -->
<style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>

View File

@@ -0,0 +1,12 @@
<?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

@@ -0,0 +1,35 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply from: '../.winboll/winboll_lib_build.gradle'
apply from: '../.winboll/winboll_lint_build.gradle'
android {
// 适配MIUI12
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
minSdkVersion 26
targetSdkVersion 30
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
// WinBoLL库 nexus.winboll.cc 地址
api 'cc.winboll.studio:libaes:15.15.9'
api 'cc.winboll.studio:libappbase:15.15.21'
api fileTree(dir: 'libs', include: ['*.jar'])
}

View File

@@ -0,0 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Fri May 01 17:09:11 HKT 2026
stageCount=57
libraryProject=libdebugtemp
baseVersion=15.0
publishVersion=15.0.56
buildCount=0
baseBetaVersion=15.0.57

17
libgpsrelaysentinel/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,17 @@
# 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

@@ -0,0 +1,27 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="cc.winboll.studio.libgpsrelaysentinel">
<application>
<service
android:name=".service.GpsSubscribeReceiverService"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="cc.winboll.studio.libgpsrelaysentinel.action.RECEIVE" />
</intent-filter>
</service>
<receiver android:name=".receiver.GpsSubscribeObserverReceiver">
<intent-filter>
<action android:name=".receiver.GpsSubscribeObserverReceiver"/>
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -0,0 +1,75 @@
package cc.winboll.studio.libgpsrelaysentinel.manager;
/**
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
* @Date 2026/05/07 10:25
*/
import android.content.Context;
import android.content.Intent;
import java.util.HashMap;
import java.util.Map;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeConst;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeMsg;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeResult;
public final class GpsSubscribeManager {
private static GpsSubscribeManager instance;
private final Map<String,GpsSubscribeMsg> subscribeMap;
private Context appContext;
private GpsSubscribeManager(){
subscribeMap = new HashMap<String, GpsSubscribeMsg>();
}
public static GpsSubscribeManager getInstance(){
if(instance == null){
instance = new GpsSubscribeManager();
}
return instance;
}
public void initContext(final Context context){
this.appContext = context.getApplicationContext();
}
public void addSubscribe(final GpsSubscribeMsg subscribeMsg){
if(subscribeMsg == null){
return;
}
subscribeMap.put(subscribeMsg.getSubscribeUniqueId(),subscribeMsg);
}
public void removeSubscribe(final String sid){
if(sid == null){
return;
}
subscribeMap.remove(sid);
SubscribeLocationManager.getInstance().removeSubscribe(sid);
}
public boolean isSubscribeExist(final String sid){
return subscribeMap.containsKey(sid);
}
public void sendSubscribeResult(final GpsSubscribeResult result){
if(appContext == null || result == null){
return;
}
Intent intent = new Intent(GpsSubscribeConst.ACTION_SUBSCRIBE_CALLBACK);
intent.putExtra("data",result);
appContext.sendBroadcast(intent);
}
public void clearAllSubscribe(){
subscribeMap.clear();
SubscribeLocationManager.getInstance().clearAll();
}
public Map<String, GpsSubscribeMsg> getSubscribeMap() {
return subscribeMap;
}
}

View File

@@ -0,0 +1,128 @@
package cc.winboll.studio.libgpsrelaysentinel.manager;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeConst;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeMsg;
import cc.winboll.studio.libgpsrelaysentinel.model.LocationPoint;
import java.util.HashMap;
import java.util.Map;
public final class SubscribeLocationManager {
private static SubscribeLocationManager instance;
//订阅配置
private final Map<String,GpsSubscribeMsg> subscribeConfigMap;
//基准定点坐标
private final Map<String,LocationPoint> subscriberPointMap;
//真实推送计数(精准统计)
private final Map<String,Integer> subscriberPushCountMap;
private SubscribeLocationManager(){
subscribeConfigMap = new HashMap<String, GpsSubscribeMsg>();
subscriberPointMap = new HashMap<String, LocationPoint>();
subscriberPushCountMap = new HashMap<String, Integer>();
}
public static SubscribeLocationManager getInstance(){
if(instance == null){
instance = new SubscribeLocationManager();
}
return instance;
}
//========= 订阅配置 =========
public void putSubscribeConfig(String sid,GpsSubscribeMsg msg){
subscribeConfigMap.put(sid,msg);
}
public GpsSubscribeMsg getSubscribeConfig(String sid){
return subscribeConfigMap.get(sid);
}
//========= 基准定点坐标 =========
public void initSubscriberPoint(String sid,double lat,double lng){
subscriberPointMap.put(sid,new LocationPoint(lat,lng,System.currentTimeMillis()));
}
public void updateSubscriberPoint(String sid,double lat,double lng){
subscriberPointMap.put(sid,new LocationPoint(lat,lng,System.currentTimeMillis()));
}
public LocationPoint getLastPoint(String sid){
return subscriberPointMap.get(sid);
}
//========= 精准推送计数 =========
public void addPushCount(String sid){
int current = subscriberPushCountMap.get(sid) == null ? 0 : subscriberPushCountMap.get(sid);
subscriberPushCountMap.put(sid,current + 1);
}
public int getPushCount(String sid){
return subscriberPushCountMap.get(sid) == null ? 0 : subscriberPushCountMap.get(sid);
}
public void clearPushCount(String sid){
subscriberPushCountMap.put(sid,0);
}
//========= 步长规则判断 =========
public boolean isNeedPush(String sid,double nowLat,double nowLng){
GpsSubscribeMsg config = getSubscribeConfig(sid);
if(config == null){
return false;
}
//全量订阅直接放行
if(config.getSubscribeMode() == GpsSubscribeConst.SUB_TYPE_ALL){
return true;
}
//无初始定点 → 先建立第一个基准点
LocationPoint lastPoint = getLastPoint(sid);
if(lastPoint == null){
return true;
}
//计算实际移动距离
double distance = calculateDistance(
lastPoint.getLatitude(),lastPoint.getLongitude(),
nowLat,nowLng
);
return distance >= config.getStepDistanceM();
}
//两点经纬度距离计算(米)
private double calculateDistance(double lat1,double lng1,double lat2,double lng2){
double radLat1 = Math.toRadians(lat1);
double radLat2 = Math.toRadians(lat2);
double radLng1 = Math.toRadians(lng1);
double radLng2 = Math.toRadians(lng2);
double latDiff = radLat1 - radLat2;
double lngDiff = radLng1 - radLng2;
double value = 2 * Math.asin(Math.sqrt(
Math.pow(Math.sin(latDiff / 2),2)
+ Math.cos(radLat1) * Math.cos(radLat2)
* Math.pow(Math.sin(lngDiff / 2),2)
));
return value * 6378137;
}
//========= 移除 & 清空 =========
public void removeSubscribe(String sid){
subscribeConfigMap.remove(sid);
subscriberPointMap.remove(sid);
subscriberPushCountMap.remove(sid);
}
public void clearAll(){
subscribeConfigMap.clear();
subscriberPointMap.clear();
subscriberPushCountMap.clear();
}
}

View File

@@ -0,0 +1,46 @@
package cc.winboll.studio.libgpsrelaysentinel.model;
/**
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
* @Date 2026/05/07 10:22
* WinBoLL Studio
* Java7 | API26-30
*/
public final class GpsSubscribeConst {
// 新增GPS定位推送广播
public static final String ACTION_GPS_LOCATION = "cc.winboll.studio.ACTION_GPS_LOCATION";
//订阅运行模式
public static final int SUB_TYPE_ALL = 1;
public static final int SUB_TYPE_STEP_DISTANCE = 2;
//原始数据订阅类型
public static final int SUBSCRIBE_TYPE_LOCATION = 1;
public static final int SUBSCRIBE_TYPE_SATELLITE = 2;
public static final int SUBSCRIBE_TYPE_NMEA = 3;
//订阅返回码
public static final int RESULT_SUCCESS = 0;
public static final int RESULT_PERMISSION_DENY = 1;
public static final int RESULT_PARAM_ERROR = 2;
public static final int RESULT_GPS_NOT_AVAILABLE = 3;
public static final int RESULT_SYSTEM_LIMIT = 4;
//GPS设备状态
public static final int GPS_STATE_CLOSE = 0;
public static final int GPS_STATE_SCANNING = 1;
public static final int GPS_STATE_LOCATED = 2;
public static final int GPS_STATE_SIGNAL_WEAK = 3;
//广播Action
public static final String ACTION_SUBSCRIBE_REQUEST = "cc.winboll.studio.GPS_SUBSCRIBE_REQUEST";
public static final String ACTION_SUBSCRIBE_CALLBACK = "cc.winboll.studio.GPS_SUBSCRIBE_CALLBACK";
//超时毫秒
public static final long SUBSCRIBE_TIME_OUT = 5000;
//地球半径 距离计算常量
public static final double EARTH_RADIUS = 6378137.0;
}

View File

@@ -0,0 +1,137 @@
package cc.winboll.studio.libgpsrelaysentinel.model;
/**
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
* @Date 2026/05/07 10:24
*/
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
public final class GpsSubscribeMsg implements Parcelable {
private final String subscribePackage;
private final int subscribeMode;
private final float stepDistanceM;
private final int subscribeType;
private final long updateInterval;
private final float minDistance;
private final boolean backgroundPush;
private final String subscribeUniqueId;
public GpsSubscribeMsg(String subscribePackage,
int subscribeMode,
float stepDistanceM,
int subscribeType,
long updateInterval,
float minDistance,
boolean backgroundPush,
String subscribeUniqueId) {
this.subscribePackage = subscribePackage;
this.subscribeMode = subscribeMode;
this.stepDistanceM = stepDistanceM;
this.subscribeType = subscribeType;
this.updateInterval = updateInterval;
this.minDistance = minDistance;
this.backgroundPush = backgroundPush;
this.subscribeUniqueId = subscribeUniqueId;
}
public String getSubscribePackage() {
return subscribePackage;
}
public int getSubscribeMode() {
return subscribeMode;
}
public float getStepDistanceM() {
return stepDistanceM;
}
public int getSubscribeType() {
return subscribeType;
}
public long getUpdateInterval() {
return updateInterval;
}
public float getMinDistance() {
return minDistance;
}
public boolean isBackgroundPush() {
return backgroundPush;
}
public String getSubscribeUniqueId() {
return subscribeUniqueId;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(subscribePackage);
dest.writeInt(subscribeMode);
dest.writeFloat(stepDistanceM);
dest.writeInt(subscribeType);
dest.writeLong(updateInterval);
dest.writeFloat(minDistance);
dest.writeByte((byte) (backgroundPush ? 1 : 0));
dest.writeString(subscribeUniqueId);
}
public static final Creator<GpsSubscribeMsg> CREATOR = new Creator<GpsSubscribeMsg>() {
@Override
public GpsSubscribeMsg createFromParcel(Parcel in) {
return new GpsSubscribeMsg(
in.readString(),
in.readInt(),
in.readFloat(),
in.readInt(),
in.readLong(),
in.readFloat(),
in.readByte() == 1,
in.readString()
);
}
@Override
public GpsSubscribeMsg[] newArray(int size) {
return new GpsSubscribeMsg[size];
}
};
public Bundle convertToBundle() {
Bundle bundle = new Bundle();
bundle.putString("pkg", subscribePackage);
bundle.putInt("subMode",subscribeMode);
bundle.putFloat("stepM",stepDistanceM);
bundle.putInt("type", subscribeType);
bundle.putLong("interval", updateInterval);
bundle.putFloat("distance", minDistance);
bundle.putBoolean("bgPush", backgroundPush);
bundle.putString("sid", subscribeUniqueId);
return bundle;
}
public static GpsSubscribeMsg createByBundle(Bundle bundle) {
return new GpsSubscribeMsg(
bundle.getString("pkg"),
bundle.getInt("subMode"),
bundle.getFloat("stepM"),
bundle.getInt("type"),
bundle.getLong("interval"),
bundle.getFloat("distance"),
bundle.getBoolean("bgPush"),
bundle.getString("sid")
);
}
}

View File

@@ -0,0 +1,115 @@
package cc.winboll.studio.libgpsrelaysentinel.model;
/**
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
* @Date 2026/05/07 10:25
*/
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
public final class GpsSubscribeResult implements Parcelable {
private final String subscribeUniqueId;
private final int resultCode;
private final String resultDesc;
private final int gpsRunningState;
private final long realEffectiveInterval;
private final long currentTimeStamp;
public GpsSubscribeResult(String subscribeUniqueId,
int resultCode,
String resultDesc,
int gpsRunningState,
long realEffectiveInterval,
long currentTimeStamp) {
this.subscribeUniqueId = subscribeUniqueId;
this.resultCode = resultCode;
this.resultDesc = resultDesc;
this.gpsRunningState = gpsRunningState;
this.realEffectiveInterval = realEffectiveInterval;
this.currentTimeStamp = currentTimeStamp;
}
public String getSubscribeUniqueId() {
return subscribeUniqueId;
}
public int getResultCode() {
return resultCode;
}
public String getResultDesc() {
return resultDesc;
}
public int getGpsRunningState() {
return gpsRunningState;
}
public long getRealEffectiveInterval() {
return realEffectiveInterval;
}
public long getCurrentTimeStamp() {
return currentTimeStamp;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(subscribeUniqueId);
dest.writeInt(resultCode);
dest.writeString(resultDesc);
dest.writeInt(gpsRunningState);
dest.writeLong(realEffectiveInterval);
dest.writeLong(currentTimeStamp);
}
public static final Creator<GpsSubscribeResult> CREATOR = new Creator<GpsSubscribeResult>() {
@Override
public GpsSubscribeResult createFromParcel(Parcel in) {
return new GpsSubscribeResult(
in.readString(),
in.readInt(),
in.readString(),
in.readInt(),
in.readLong(),
in.readLong()
);
}
@Override
public GpsSubscribeResult[] newArray(int size) {
return new GpsSubscribeResult[size];
}
};
public Bundle convertToBundle() {
Bundle bundle = new Bundle();
bundle.putString("sid", subscribeUniqueId);
bundle.putInt("code", resultCode);
bundle.putString("desc", resultDesc);
bundle.putInt("gpsState", gpsRunningState);
bundle.putLong("realInterval", realEffectiveInterval);
bundle.putLong("time", currentTimeStamp);
return bundle;
}
public static GpsSubscribeResult createByBundle(Bundle bundle) {
return new GpsSubscribeResult(
bundle.getString("sid"),
bundle.getInt("code"),
bundle.getString("desc"),
bundle.getInt("gpsState"),
bundle.getLong("realInterval"),
bundle.getLong("time")
);
}
}

View File

@@ -0,0 +1,37 @@
package cc.winboll.studio.libgpsrelaysentinel.model;
import java.io.Serializable;
/**
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
* @Date 2026/05/07 10:23
* 订阅者基准定点坐标
* 每次推送成功自动更新
*/
public final class LocationPoint implements Serializable {
private static final long serialVersionUID = 1L;
private final double latitude;
private final double longitude;
private final long recordTime;
public LocationPoint(double latitude, double longitude, long recordTime) {
this.latitude = latitude;
this.longitude = longitude;
this.recordTime = recordTime;
}
public double getLatitude() {
return latitude;
}
public double getLongitude() {
return longitude;
}
public long getRecordTime() {
return recordTime;
}
}

View File

@@ -0,0 +1,42 @@
package cc.winboll.studio.libgpsrelaysentinel.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
* @Date 2026/05/07 10:27
*/
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeConst;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeResult;
public final class GpsSubscribeObserverReceiver extends BroadcastReceiver {
private OnSubscribeResultListener listener;
public void setOnSubscribeResultListener(OnSubscribeResultListener listener){
this.listener = listener;
}
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(GpsSubscribeConst.ACTION_SUBSCRIBE_CALLBACK.equals(action)){
GpsSubscribeResult result = intent.getParcelableExtra("data");
if(listener != null && result != null){
listener.onResultBack(result);
}
}
}
public interface OnSubscribeResultListener{
void onResultBack(GpsSubscribeResult result);
}
}

View File

@@ -0,0 +1,39 @@
package cc.winboll.studio.libgpsrelaysentinel.service;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeMsg;
import cc.winboll.studio.libgpsrelaysentinel.model.LocationPoint;
/**
* 全局消息接收父类服务
* 所有应用内接收服务全部继承此类
*/
public abstract class GpsSubscribeReceiverService extends Service {
public static final String TAG_PARENT = "GpsSubscribeReceiverService";
//当前绑定的视图订阅SID
protected String bindViewSid;
public void bindControlSid(String sid){
this.bindViewSid = sid;
}
/**
* 统一接收GPS推送入口
*/
public void onReceiveGpsData(LocationPoint point, GpsSubscribeMsg config){
//父类统一日志溯源
LogUtils.d(TAG_PARENT,"【消息溯源】接收视图SID" + bindViewSid);
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
}

View File

@@ -0,0 +1,51 @@
package cc.winboll.studio.libgpsrelaysentinel.util;
/**
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
* @Date 2026/05/07 10:26
*/
import android.os.Handler;
import android.os.Message;
public final class TimeCountUtil {
private final Handler mHandler;
private long totalTime;
private boolean isRunning;
public static final int COUNT_FINISH = 1001;
public TimeCountUtil(final OnCountListener listener) {
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if(msg.what == COUNT_FINISH){
isRunning = false;
if(listener != null){
listener.onTimeOut();
}
}
}
};
}
public void start(long time){
if(isRunning){
return;
}
totalTime = time;
isRunning = true;
mHandler.sendEmptyMessageDelayed(COUNT_FINISH,totalTime);
}
public void cancel(){
mHandler.removeMessages(COUNT_FINISH);
isRunning = false;
}
public interface OnCountListener{
void onTimeOut();
}
}

View File

@@ -0,0 +1,226 @@
package cc.winboll.studio.libgpsrelaysentinel.view;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Switch;
import android.widget.TextView;
import cc.winboll.studio.libgpsrelaysentinel.R;
import cc.winboll.studio.libgpsrelaysentinel.manager.GpsSubscribeManager;
import cc.winboll.studio.libgpsrelaysentinel.manager.SubscribeLocationManager;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeConst;
import cc.winboll.studio.libgpsrelaysentinel.model.GpsSubscribeMsg;
import cc.winboll.studio.libgpsrelaysentinel.model.LocationPoint;
import java.util.UUID;
public final class GpsSubscribeControlView extends LinearLayout {
//常量抽取
private static final long REFRESH_INTERVAL = 600;
private RadioGroup rgSubscribeMode;
private RadioButton rbModeAll;
private RadioButton rbModeStep;
private EditText etStepMeter;
private Switch switchSubscribe;
private TextView tvSubscribeSid;
private TextView tvSubscribeRecord;
private String currentSubscribeSid;
//一对一专属绑定的接收服务
private Class<?> mBindReceiverServiceClazz;
//final管理器 构造器初始化
private final GpsSubscribeManager mSubscribeManager;
private final SubscribeLocationManager mLocationManager;
private final Handler mRefreshHandler = new Handler(Looper.getMainLooper());
public GpsSubscribeControlView(Context context) {
super(context);
mSubscribeManager = GpsSubscribeManager.getInstance();
mLocationManager = SubscribeLocationManager.getInstance();
initView(context);
}
public GpsSubscribeControlView(Context context, AttributeSet attrs) {
super(context, attrs);
mSubscribeManager = GpsSubscribeManager.getInstance();
mLocationManager = SubscribeLocationManager.getInstance();
initView(context);
}
private void initView(Context context) {
LayoutInflater.from(context).inflate(R.layout.view_gps_subscribe_control, this, true);
rgSubscribeMode = findViewById(R.id.rg_subscribe_mode);
rbModeAll = findViewById(R.id.rb_mode_all);
rbModeStep = findViewById(R.id.rb_mode_step);
etStepMeter = findViewById(R.id.et_step_meter);
switchSubscribe = findViewById(R.id.switch_subscribe);
tvSubscribeSid = findViewById(R.id.tv_subscribe_sid);
tvSubscribeRecord = findViewById(R.id.tv_subscribe_record);
initDefaultConfig();
initModeSwitch();
initSubscribeSwitch();
startAutoRefreshRecord();
}
private void initDefaultConfig() {
currentSubscribeSid = UUID.randomUUID().toString().substring(0, 16);
tvSubscribeSid.setText("订阅SID" + currentSubscribeSid);
rbModeAll.setChecked(true);
etStepMeter.setText("10");
}
/**
* 外部绑定当前视图专属的接收服务Class
*/
public void bindReceiverService(Class<?> serviceClazz){
this.mBindReceiverServiceClazz = serviceClazz;
}
private void initModeSwitch() {
rgSubscribeMode.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
etStepMeter.setVisibility(checkedId == R.id.rb_mode_step ? VISIBLE : GONE);
}
});
}
private void initSubscribeSwitch() {
switchSubscribe.setOnCheckedChangeListener(new android.widget.CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(android.widget.CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
startSubscribe();
} else {
stopSubscribe();
}
}
});
}
private void startSubscribe() {
int subMode = GpsSubscribeConst.SUB_TYPE_ALL;
float stepVal = 10f;
if (rbModeStep.isChecked()) {
subMode = GpsSubscribeConst.SUB_TYPE_STEP_DISTANCE;
try {
stepVal = Float.parseFloat(etStepMeter.getText().toString().trim());
} catch (Exception ignored) {}
}
GpsSubscribeMsg subscribeMsg = new GpsSubscribeMsg(
getContext().getPackageName(),
subMode,
stepVal,
GpsSubscribeConst.SUBSCRIBE_TYPE_LOCATION,
1000,
1f,
true,
currentSubscribeSid
);
mSubscribeManager.addSubscribe(subscribeMsg);
mLocationManager.putSubscribeConfig(currentSubscribeSid, subscribeMsg);
mLocationManager.clearPushCount(currentSubscribeSid);
//开启订阅自动启动专属接收服务
if(mBindReceiverServiceClazz != null){
Intent startServiceIntent = new Intent(getContext(), mBindReceiverServiceClazz);
getContext().startService(startServiceIntent);
}
}
private void stopSubscribe() {
mSubscribeManager.removeSubscribe(currentSubscribeSid);
mLocationManager.removeSubscribe(currentSubscribeSid);
tvSubscribeRecord.setText("状态:未订阅");
//关闭订阅 同步停止专属接收服务
if(mBindReceiverServiceClazz != null){
Intent stopServiceIntent = new Intent(getContext(), mBindReceiverServiceClazz);
getContext().stopService(stopServiceIntent);
}
}
private void startAutoRefreshRecord() {
mRefreshHandler.postDelayed(new Runnable() {
@Override
public void run() {
refreshRecordInfo();
mRefreshHandler.postDelayed(this, REFRESH_INTERVAL);
}
}, REFRESH_INTERVAL);
}
private void refreshRecordInfo() {
if (!switchSubscribe.isChecked()) {
tvSubscribeRecord.setText("状态:空闲未订阅");
return;
}
GpsSubscribeMsg config = mLocationManager.getSubscribeConfig(currentSubscribeSid);
LocationPoint lastPoint = mLocationManager.getLastPoint(currentSubscribeSid);
if (config == null) {
tvSubscribeRecord.setText("状态:已订阅|等待管理器加载");
return;
}
String modeText = config.getSubscribeMode() == GpsSubscribeConst.SUB_TYPE_ALL
? "全量订阅" : "步长订阅";
int realPushCount = mLocationManager.getPushCount(currentSubscribeSid);
StringBuilder record = new StringBuilder();
record.append("【订阅实时数据表】\n");
record.append("订阅模式:").append(modeText).append("\n");
record.append("步长阈值:").append(config.getStepDistanceM()).append("\n");
if(lastPoint != null){
record.append("基准定点:").append(lastPoint.getLatitude()).append(" , ").append(lastPoint.getLongitude()).append("\n");
}else{
record.append("基准定点:等待首次定位建立\n");
}
record.append("真实推送次数:").append(realPushCount).append("");
tvSubscribeRecord.setText(record);
}
public String getCurrentSid() {
return currentSubscribeSid;
}
public boolean isSubscribeOpen() {
return switchSubscribe.isChecked();
}
/**
* 视图销毁:强制停止订阅 + 停止服务 + 清空刷新任务
*/
@Override
protected void onDetachedFromWindow() {
if(switchSubscribe.isChecked()){
switchSubscribe.setChecked(false);
}
mRefreshHandler.removeCallbacksAndMessages(null);
super.onDetachedFromWindow();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="14dp"
android:layout_marginVertical="6dp"
android:background="#282828"
android:clipToPadding="false">
<!-- SID标识 -->
<TextView
android:id="@+id/tv_subscribe_sid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#999999"
android:textSize="11sp"/>
<!-- 订阅模式选择 -->
<RadioGroup
android:id="@+id/rg_subscribe_mode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp">
<RadioButton
android:id="@+id/rb_mode_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="全量订阅"
android:textColor="#FFFFFF"/>
<RadioButton
android:id="@+id/rb_mode_step"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="步长订阅"
android:layout_marginStart="18dp"
android:textColor="#FFFFFF"/>
</RadioGroup>
<!-- 步长输入 -->
<EditText
android:id="@+id/et_step_meter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="移动阈值(米)"
android:inputType="numberDecimal"
android:text="10"
android:visibility="gone"
android:textColor="#ffffff"
android:textColorHint="#666666"
android:layout_marginTop="8dp"/>
<!-- 订阅开关 -->
<Switch
android:id="@+id/switch_subscribe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="开启独立订阅"
android:textColor="#EEEEEE"
android:layout_marginTop="10dp"/>
<!-- 分割线 -->
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#444444"
android:layout_marginTop="12dp"/>
<!-- 订阅数据记录表【ID完全对应源码 tv_subscribe_record】 -->
<TextView
android:id="@+id/tv_subscribe_record"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#88EE88"
android:textSize="10sp"
android:layout_marginTop="10dp"
android:gravity="start"/>
</LinearLayout>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@android:style/Theme.Material.Light">
</style>
</resources>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="lib_name">libdebugtemp</string>
<string name="hello_world">Hello world!</string>
<string name="text_libraryactivity">LibraryActivity</string>
</resources>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
</style>
</resources>

View File

@@ -1,45 +0,0 @@
# MyMessageManager
#### 介绍
用正则表达式方法自定义短信过滤和语音播报的短信应用。
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码ZhanGSKen(ZhanGSKen<zhangsken@188.com>)
4. 新建 Pull Request
#### 特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
#### 参考文档
使用GitHub Actions实现Android自动打包apk
https://blog.csdn.net/ZZL23333/article/details/115798615?app_version=6.0.0&code=app_1562916241&csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22115798615%22%2C%22source%22%3A%22weixin_38986226%22%7D&uLinkId=usr1mkqgl919blen&utm_source=app
Android中assets的使用用于读取内容
https://blog.csdn.net/qq_27664947/article/details/103924058?app_version=6.0.0&code=app_1562916241&csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22103924058%22%2C%22source%22%3A%22weixin_38986226%22%7D&uLinkId=usr1mkqgl919blen&utm_source=app

View File

@@ -1,8 +0,0 @@
#Created by .winboll/winboll_app_build.gradle
#Fri May 08 20:38:36 CST 2026
stageCount=8
libraryProject=
baseVersion=15.12
publishVersion=15.12.7
buildCount=18
baseBetaVersion=15.12.8

View File

@@ -1,23 +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 -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="cc.winboll.studio.mymessagemanager.beta.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider"/>
</provider>
</application>
</manifest>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">我的短信管家 ☆</string>
</resources>

View File

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

View File

@@ -1,227 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="cc.winboll.studio.mymessagemanager">
<!-- 发送短信 -->
<uses-permission android:name="android.permission.SEND_SMS"/>
<!-- 接收讯息(短信) -->
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<!-- 读取短信 -->
<uses-permission android:name="android.permission.READ_SMS"/>
<!-- WRITE_SMS -->
<uses-permission android:name="android.permission.WRITE_SMS"/>
<!-- 接收讯息(彩信) -->
<uses-permission android:name="android.permission.RECEIVE_MMS"/>
<!-- 开机启动 -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<!-- 运行前台服务 -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<!-- 读取联系人 -->
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<!-- 读取您共享存储空间中的内容 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<!-- 修改或删除您共享存储空间中的内容 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- 接收讯息 (WAP) -->
<uses-permission android:name="android.permission.RECEIVE_WAP_PUSH"/>
<!-- MANAGE_EXTERNAL_STORAGE -->
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<!-- 此应用可显示在其他应用上方 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<queries>
<intent>
<action android:name="android.intent.action.TTS_SERVICE"/>
</intent>
</queries>
<application
android:name=".App"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:roundIcon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyAppTheme"
android:persistent="true"
android:resizeableActivity="true"
android:supportsRtl="true"
android:requestLegacyExternalStorage="true"
android:networkSecurityConfig="@xml/network_security_config">
<activity android:name=".activitys.SMSActivity"/>
<activity android:name=".activitys.SMSReceiveRuleActivity">
</activity>
<activity
android:name=".activitys.SharedJSONReceiveActivity"
android:exported="true">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.SEND"/>
<action android:name="android.intent.action.VIEW"/>
<action android:name="android.intent.action.EDIT"/>
<data android:mimeType="application/json"/>
<data android:mimeType="text/x-json"/>
</intent-filter>
</activity>
<activity android:name=".activitys.TTSPlayRuleActivity"/>
<activity android:name=".activitys.AboutActivity"/>
<activity
android:name=".activitys.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".activitys.ComposeSMSActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<action android:name="android.intent.action.SENDTO"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="sms"/>
<data android:scheme="smsto"/>
<data android:scheme="mms"/>
<data android:scheme="mmsto"/>
</intent-filter>
</activity>
<activity android:name=".activitys.AppSettingsActivity"/>
<service android:name=".services.TTSPlayService"/>
<service android:name=".services.MainService"/>
<service android:name=".services.AssistantService"/>
<service
android:name=".services.DefaultSMSManagerService"
android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.RESPOND_VIA_MESSAGE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="sms"/>
<data android:scheme="smsto"/>
<data android:scheme="mms"/>
<data android:scheme="mmsto"/>
</intent-filter>
</service>
<receiver
android:name=".receivers.MainReceiver"
android:enabled="true"
android:exported="false"
android:directBootAware="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<receiver
android:name=".receivers.SMSRecevier"
android:exported="true"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="1">
<action android:name="android.provider.Telephony.SMS_DELIVER"/>
</intent-filter>
</receiver>
<receiver
android:name=".receivers.MmsReceiver"
android:exported="true"
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter>
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER"/>
<data android:mimeType="application/vnd.wap.mms-message"/>
</intent-filter>
</receiver>
<meta-data
android:name="android.max_aspect"
android:value="4.0"/>
<activity android:name="cc.winboll.studio.mymessagemanager.activitys.SMSRecycleActivity"/>
<activity android:name="cc.winboll.studio.mymessagemanager.activitys.SMSRecycle2Activity"/>
<activity android:name="cc.winboll.studio.mymessagemanager.unittest.UnitTestActivity"/>
<activity android:name="cc.winboll.studio.mymessagemanager.activitys.TTSFloatSettingsActivity"/>
</application>
</manifest>

View File

@@ -1,7 +0,0 @@
[
{
"userId": -1,
"ruleData": ".*",
"isEnable": true
}
]

View File

@@ -1,38 +0,0 @@
[
{
"userId": 1,
"ruleName": "规则1",
"demoSMSText": "【短信应用A】验证码123456",
"patternText": "^(【.*】)验证码(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)$",
"ttdRuleText": "$1验证码是($2)($3)($4)($5)($6)($7)。",
"isSimpleView": false,
"isEnable": true
},
{
"userId": 1,
"ruleName": "规则2",
"demoSMSText": "[短信应用A]验证码123456",
"patternText": "^(\\[.*\\])验证码(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)$",
"ttdRuleText": "$1验证码是($2)($3)($4)($5)($6)($7)。",
"isSimpleView": false,
"isEnable": true
},
{
"userId": 1,
"ruleName": "规则3",
"demoSMSText": "【短信应用A】验证码123456",
"patternText": ".*(【.+】).*",
"ttdRuleText": "短信来自$1。",
"isSimpleView": false,
"isEnable": true
},
{
"userId": 1,
"ruleName": "规则4",
"demoSMSText": "[短信应用A]验证码123456",
"patternText": ".*(\\[.*\\]).*",
"ttdRuleText": "短信来自$1。",
"isSimpleView": false,
"isEnable": true
}
]

View File

@@ -1,52 +0,0 @@
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.libappbase.ToastUtils;
import cc.winboll.studio.mymessagemanager.R;
import java.io.File;
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
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();
setIsDebugging(BuildConfig.DEBUG);
//setIsDebugging(false);
// 初始化窗口管理类
WinBoLLActivityManager.init(this);
// 初始化 Toast 框架
ToastUtils.init(this);
_mszAppExternalFilesDir = getExternalFilesDir(TAG).toString();
_mszConfigUtilPath = _mszAppExternalFilesDir + File.separator + _mszConfigUtilFileName;
_mszSMSReceiveRuleUtilPath = _mszAppExternalFilesDir + File.separator + _mszSMSReceiveRuleUtilFileName;
}
@Override
public void onTerminate() {
super.onTerminate();
ToastUtils.release();
}
}

View File

@@ -1,92 +0,0 @@
package cc.winboll.studio.mymessagemanager.activitys;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/07/14 13:20:33
* @Describe 应用介绍窗口
*/
import android.app.Activity;
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.interfaces.IWinBoLLActivity;
import cc.winboll.studio.libaes.models.APPInfo;
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
import cc.winboll.studio.libaes.views.AboutView;
import cc.winboll.studio.mymessagemanager.App;
import cc.winboll.studio.mymessagemanager.R;
public class AboutActivity extends WinBoLLActivity implements IWinBoLLActivity {
public static final String TAG = "AboutActivity";
Context mContext;
Toolbar mToolbar;
@Override
public Activity getActivity() {
return this;
}
@Override
public String getTag() {
return TAG;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = this;
setContentView(R.layout.activity_about);
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);
WinBoLLActivityManager.getInstance().add(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
WinBoLLActivityManager.getInstance().registeRemove(this);
}
public AboutView CreateAboutView() {
String szBranchName = "mymessagemanager";
APPInfo appInfo = new APPInfo();
appInfo.setAppName(getString(R.string.app_name));
appInfo.setAppIcon(cc.winboll.studio.libaes.R.drawable.ic_winboll);
appInfo.setAppDescription(getString(R.string.app_description));
appInfo.setAppGitName("APPBase");
appInfo.setAppGitOwner("Studio");
appInfo.setAppGitAPPBranch(szBranchName);
appInfo.setAppGitAPPSubProjectFolder(szBranchName);
appInfo.setAppHomePage("https://discuz.winboll.cc/forum.php?mod=viewthread&tid=5&extra=page%3D1");
appInfo.setAppAPKName("MyMessageManager");
appInfo.setAppAPKFolderName("MyMessageManager");
return new AboutView(mContext, appInfo);
}
}

View File

@@ -1,170 +0,0 @@
package cc.winboll.studio.mymessagemanager.activitys;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/05/12 20:03:42
* @Describe 应用设置窗口
*/
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Switch;
import android.widget.Toast;
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
import cc.winboll.studio.libaes.views.AToolbar;
import cc.winboll.studio.libappbase.ToastUtils;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.dialogs.CharsetRefuseEditDialog;
import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil;
import cc.winboll.studio.mymessagemanager.utils.PermissionUtil;
public class AppSettingsActivity extends WinBoLLActivity implements IWinBoLLActivity {
public static final String TAG = "AppSettingsActivity";
// 讯飞语记官网下载页链接
private static final String XUNFEI_YUJI_DOWNLOAD_URL = "https://iflynote.com/h/share-download-app.html";
AppConfigUtil mAppConfigUtil;
AToolbar mAToolbar;
AOHPCTCSeekBar mAOHPCTCSeekBar;
EditText metTTSPlayDelayTimes;
EditText metPhoneMergePrefix;
Switch mswMergePrefixPhone;
Switch mswSMSRecycleProtectMode;
//EditText metProtectModerRefuseChars;
EditText metProtectModerReplaceChars;
String mszProtectModerRefuseChars = "";
RadioGroup mRadioGroupRecycleBin;
@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_appsettings);
// 初始化属性
mAppConfigUtil = AppConfigUtil.getInstance(this);
int nTtsPlayDelayTimes = mAppConfigUtil.mAppConfigBean.getTtsPlayDelayTimes();
metTTSPlayDelayTimes = findViewById(R.id.activityappsettingsEditText1);
metTTSPlayDelayTimes.setText(Integer.toString(nTtsPlayDelayTimes / 1000));
// 初始化标题栏
mAToolbar = findViewById(R.id.activityappsettingsAToolbar1);
mAToolbar.setSubtitle(getString(R.string.activity_name_appsettings));
setActionBar(mAToolbar);
metPhoneMergePrefix = findViewById(R.id.activityappsettingsEditText2);
metPhoneMergePrefix.setText(mAppConfigUtil.mAppConfigBean.getCountryCode());
mswMergePrefixPhone = findViewById(R.id.activityappsettingsSwitch1);
mswMergePrefixPhone.setChecked(mAppConfigUtil.mAppConfigBean.isMergeCountryCodePrefix());
mswSMSRecycleProtectMode = findViewById(R.id.activityappsettingsSwitch3);
mswSMSRecycleProtectMode.setChecked(mAppConfigUtil.mAppConfigBean.isSMSRecycleProtectMode());
//metProtectModerRefuseChars = findViewById(R.id.activityappsettingsEditText3);
//metProtectModerRefuseChars.setText(mAppConfigUtil.mAppConfigBean.getProtectModerRefuseChars());
mszProtectModerRefuseChars = mAppConfigUtil.mAppConfigBean.getProtectModerRefuseChars();
metProtectModerReplaceChars = findViewById(R.id.activityappsettingsEditText4);
metProtectModerReplaceChars.setText(mAppConfigUtil.mAppConfigBean.getProtectModerReplaceChars());
mRadioGroupRecycleBin = findViewById(R.id.activityappsettingsRadioGroup1);
if (mAppConfigUtil.mAppConfigBean.getRecycleBinClass().equals("SMSRecycle2Activity")) {
mRadioGroupRecycleBin.check(R.id.activityappsettingsRadioButton2);
} else {
mRadioGroupRecycleBin.check(R.id.activityappsettingsRadioButton1);
}
mAOHPCTCSeekBar = findViewById(R.id.activityappsettingsAOHPCTCSeekBar1);
mAOHPCTCSeekBar.setThumb(getDrawable(R.drawable.cursor_pointer));
mAOHPCTCSeekBar.setThumbOffset(0);
mAOHPCTCSeekBar.setOnOHPCListener(new AOHPCTCSeekBar.OnOHPCListener(){
@Override
public void onOHPCommit() {
mAppConfigUtil.reLoadConfig();
mAppConfigUtil.mAppConfigBean.setIsSMSRecycleProtectMode(mswSMSRecycleProtectMode.isChecked());
if (mRadioGroupRecycleBin.getCheckedRadioButtonId() == R.id.activityappsettingsRadioButton2) {
mAppConfigUtil.mAppConfigBean.setRecycleBinClass("SMSRecycle2Activity");
} else {
mAppConfigUtil.mAppConfigBean.setRecycleBinClass("SMSRecycleActivity");
}
//mAppConfigUtil.mAppConfigBean.setProtectModerRefuseChars(metProtectModerRefuseChars.getText().toString());
mAppConfigUtil.mAppConfigBean.setProtectModerRefuseChars(mszProtectModerRefuseChars);
mAppConfigUtil.mAppConfigBean.setProtectModerReplaceChars(metProtectModerReplaceChars.getText().toString());
mAppConfigUtil.mAppConfigBean.setCountryCode(metPhoneMergePrefix.getText().toString());
mAppConfigUtil.mAppConfigBean.setIsMergeCountryCodePrefix(mswMergePrefixPhone.isChecked());
int nTtsPlayDelayTimes = 1000 * Integer.parseInt(metTTSPlayDelayTimes.getText().toString());
mAppConfigUtil.mAppConfigBean.setTtsPlayDelayTimes(nTtsPlayDelayTimes);
mAppConfigUtil.saveConfig();
Toast.makeText(getApplication(), "App config data is saved.", Toast.LENGTH_SHORT).show();
//LogUtils.d(TAG, "TTS Play Delay Times is setting to : " + Integer.toString(mAppConfigData.getTtsPlayDelayTimes()));Toast.makeText(getApplication(), "onOHPCommit", Toast.LENGTH_SHORT).show();
}
});
};
public void onOpenSystemDefaultAppSettings(View view) {
Intent intent = new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
startActivity(intent);
}
public void onCheckAndGetAppPermission(View view) {
//LogUtils.d(TAG, "onCheckAndGetAppPermission");
if (PermissionUtil.checkAndGetAppPermission(this)) {
Toast.makeText(getApplication(), "应用已获得所需权限。", Toast.LENGTH_SHORT).show();
}
}
public void onAddTTSSupport(View view) {
try {
// 1. 创建IntentAction为“打开网页”
Intent intent = new Intent(Intent.ACTION_VIEW);
// 2. 设置要跳转的URL
intent.setData(Uri.parse(XUNFEI_YUJI_DOWNLOAD_URL));
// 3. 确保Intent可被解析避免无浏览器时崩溃
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent); // 跳转至浏览器打开下载页
} else {
// 无浏览器时的提示
Toast.makeText(this, "未找到浏览器应用,请安装后重试", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(this, "无法打开下载页面,请稍后再试", Toast.LENGTH_SHORT).show();
}
}
public void onCharsetRefuseEditDialog(View view) {
CharsetRefuseEditDialog dlg = new CharsetRefuseEditDialog(this, new CharsetRefuseEditDialog.OnTextConfirmListener(){
@Override
public void onTextConfirmed(String editText) {
//ToastUtils.show(editText);
mszProtectModerRefuseChars = editText;
}
}, mszProtectModerRefuseChars);
dlg.show();
}
public void onTTSFloatSettingsActivity(View view) {
Intent intent = new Intent(this, TTSFloatSettingsActivity.class);
startActivity(intent);
}
}

View File

@@ -1,375 +0,0 @@
package cc.winboll.studio.mymessagemanager.activitys;
/**
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
* @Date 2025/08/30 14:32
* @Describe 联系人查询与短信发送窗口
*/
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toolbar;
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.ToastUtils;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.beans.PhoneBean;
import cc.winboll.studio.mymessagemanager.utils.PhoneUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
public class ComposeSMSActivity extends WinBoLLActivity implements IWinBoLLActivity {
public static String TAG = "ComposeSMSActivity";
public static String EXTRA_SMSBODY = "sms_body";
private static final String MAP_NAME = "NAME";
private static final String MAP_PHONE = "PHONE";
private String mszSMSBody;
private String mszScheme;
private String mszPhoneTo;
private TextView mtvTOName;
private EditText metTONameSearch;
private EditText metTO;
private EditText metSMSBody;
private SimpleAdapter mSimpleAdapter;
private List<Map<String, Object>> mAdapterData = new ArrayList<Map<String, Object>>();
private ListView mlvContracts;
private List<PhoneBean> mListPhoneBeanContracts;
private Toolbar mToolbar;
private AOHPCTCSeekBar mAOHPCTCSeekBar;
private RelativeLayout mrlContracts;
@Override
public Activity getActivity() {
return this;
}
@Override
public String getTag() {
return TAG;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LogUtils.d(TAG, "onCreate");
setContentView(R.layout.activity_composesms);
// 初始化Intent数据增加空判断避免NullPointerException
Intent intent = getIntent();
if (intent != null) {
mszSMSBody = intent.getStringExtra(EXTRA_SMSBODY);
if (intent.getData() != null) {
mszScheme = intent.getData().getScheme();
mszPhoneTo = intent.getData().getSchemeSpecificPart();
}
}
// 校验启动方式非smsto则退出
if (mszScheme == null || !"smsto".equals(mszScheme)) {
ToastUtils.show("不支持的启动方式");
finish();
return;
}
initView();
initAdapter(null); // 初始加载所有联系人
setListViewPrePositionByPhone();
}
private void initView() {
// 初始化标题栏
mToolbar = (Toolbar) findViewById(R.id.activitycomposesmsASupportToolbar1);
mToolbar.setSubtitle(getString(R.string.activity_name_composesms));
setActionBar(mToolbar);
// 初始化联系人姓名显示和搜索栏
mtvTOName = (TextView) findViewById(R.id.activitycomposesmsTextView2);
mrlContracts = (RelativeLayout) findViewById(R.id.activitycomposesmsRelativeLayout1);
metTONameSearch = (EditText) findViewById(R.id.activitycomposesmsEditText2);
// 姓名搜索框文本变化监听
metTONameSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
metTO.setText(""); // 清空号码输入框,避免冲突
String input = s == null ? "" : s.toString().trim();
if (input.isEmpty()) {
initAdapter(null); // 空搜索时显示所有联系人
} else {
setListViewPrePositionByName(); // 按姓名搜索
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// 无操作
}
@Override
public void afterTextChanged(Editable s) {
// 无操作
}
});
// 初始化联系人列表(关键:设置单选模式,确保选中状态生效)
mlvContracts = (ListView) findViewById(R.id.activitycomposesmsListView1);
mlvContracts.setChoiceMode(ListView.CHOICE_MODE_SINGLE); // 开启单选,与布局中一致
// 初始化号码输入框(核心:优化文本变化监听逻辑)
metTO = (EditText) findViewById(R.id.activitycomposesmsEditText1);
if (mszPhoneTo != null) {
metTO.setText(mszPhoneTo);
}
metTO.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
mtvTOName.setText(""); // 清空姓名显示
String inputPhone = s == null ? "" : s.toString().trim();
if (inputPhone.isEmpty()) {
// 输入为空时,显示所有联系人
initAdapter(null);
} else {
// 输入非空时,按号码搜索并更新列表(无结果则清空)
filterListByPhone(inputPhone);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// 无操作
}
@Override
public void afterTextChanged(Editable s) {
// 无操作
}
});
// 初始化发送控件
mAOHPCTCSeekBar = (AOHPCTCSeekBar) findViewById(R.id.viewsmssendpart1AOHPCTCSeekBar1);
Drawable thumbDrawable = getResources().getDrawable(R.drawable.ic_message); // Java 7兼容写法
mAOHPCTCSeekBar.setThumb(thumbDrawable);
mAOHPCTCSeekBar.setThumbOffset(20);
mAOHPCTCSeekBar.setOnOHPCListener(new AOHPCTCSeekBar.OnOHPCListener() {
@Override
public void onOHPCommit() {
sendSMS();
}
});
// 初始化短信内容输入框
TextView tvAOHPCTCSeekBarMSG = (TextView) findViewById(R.id.viewsmssendpart1TextView1);
tvAOHPCTCSeekBarMSG.setText(R.string.msg_100sendmsg);
metSMSBody = (EditText) findViewById(R.id.viewsmssendpart1EditText1);
if (mszSMSBody != null) {
metSMSBody.setText(mszSMSBody);
}
}
// 核心优化:根据输入号码筛选列表(无结果则显示空列表,优化选中逻辑)
private void filterListByPhone(String inputPhone) {
PhoneUtil phoneUtil = new PhoneUtil(this);
List<PhoneBean> allContacts = phoneUtil.getPhoneList();
List<PhoneBean> matchedContacts = new ArrayList<PhoneBean>();
// 遍历所有联系人,匹配包含输入号码的联系人
for (PhoneBean contact : allContacts) {
if (contact.getTelPhone().contains(inputPhone)
|| phoneUtil.isTheSamePhoneNumber(contact.getTelPhone(), inputPhone)) {
matchedContacts.add(contact);
}
}
LogUtils.d(TAG, "号码搜索:输入'" + inputPhone + "', 匹配" + matchedContacts.size() + "个结果");
// 用筛选结果更新列表(无结果则传入空列表)
initAdapter(matchedContacts.isEmpty() ? new ArrayList<PhoneBean>() : matchedContacts);
// 定位并选中匹配项(如果有)
if (!matchedContacts.isEmpty()) {
boolean isFound = false;
for (int i = 0; i < matchedContacts.size(); i++) {
PhoneBean item = matchedContacts.get(i);
// 精确匹配号码(兼容区域码格式)
if (phoneUtil.isTheSamePhoneNumber(item.getTelPhone(), inputPhone)) {
mtvTOName.setText(item.getName());
// 关键:先滚动到目标位置,再设置选中状态
mlvContracts.setSelection(i);
// 主动设置选中(确保样式生效,兼容部分系统)
mlvContracts.setItemChecked(i, true);
LogUtils.d(TAG, String.format("%s 匹配 %s选中位置%d", inputPhone, item.getTelPhone(), i));
isFound = true;
break;
}
}
// 若未精确匹配,选中第一个结果
/*if (!isFound) {
mlvContracts.setSelection(0);
mlvContracts.setItemChecked(0, true);
mtvTOName.setText(matchedContacts.get(0).getName());
}*/
} else {
mtvTOName.setText(""); // 无结果时清空姓名显示
}
}
// 根据姓名搜索联系人
private void setListViewPrePositionByName() {
String searchName = metTONameSearch.getText().toString().trim();
PhoneUtil phoneUtil = new PhoneUtil(this);
List<PhoneBean> matchedContacts = phoneUtil.getPhonesByName(searchName);
initAdapter(matchedContacts);
if (!matchedContacts.isEmpty()) {
// 选中第一个结果并设置样式
mlvContracts.setSelection(0);
mlvContracts.setItemChecked(0, true);
}
}
// 初始定位号码对应的联系人
private void setListViewPrePositionByPhone() {
String inputPhone = metTO.getText().toString().trim();
if (inputPhone.isEmpty()) {
return;
}
filterListByPhone(inputPhone); // 复用筛选逻辑
}
// 获取号码匹配的位置(兼容旧逻辑)
private int getContractsDataPrePositionByPhone(String szPhone) {
if (mListPhoneBeanContracts == null || mListPhoneBeanContracts.isEmpty()) {
return 0;
}
for (int i = 0; i < mListPhoneBeanContracts.size(); i++) {
PhoneBean bean = mListPhoneBeanContracts.get(i);
if (bean.getTelPhone().compareTo(szPhone) >= 0) {
return i;
}
}
return 0;
}
// 获取姓名匹配的位置(兼容旧逻辑)
private int getContractsDataPrePositionByName(String szName) {
if (mListPhoneBeanContracts == null || mListPhoneBeanContracts.isEmpty()) {
return 0;
}
for (int i = 0; i < mListPhoneBeanContracts.size(); i++) {
if (mListPhoneBeanContracts.get(i).getName().startsWith(szName)) {
return i;
}
}
return 0;
}
// 初始化或更新列表适配器
private void initAdapter(List<PhoneBean> initData) {
mAdapterData.clear(); // 清空旧数据
final PhoneUtil phoneUtil = new PhoneUtil(this);
// 确定数据源:传入的筛选数据或所有联系人
if (initData != null) {
mListPhoneBeanContracts = initData;
} else {
mListPhoneBeanContracts = phoneUtil.getPhoneList();
}
// 转换数据为SimpleAdapter所需格式
if (mListPhoneBeanContracts != null) {
for (PhoneBean bean : mListPhoneBeanContracts) {
Map<String, Object> map = new HashMap<String, Object>();
map.put(MAP_NAME, bean.getName());
map.put(MAP_PHONE, bean.getTelPhone());
mAdapterData.add(map);
}
}
// 初始化或更新适配器
if (mSimpleAdapter == null) {
mSimpleAdapter = new SimpleAdapter(
ComposeSMSActivity.this,
mAdapterData,
R.layout.listview_contracts,
new String[]{MAP_NAME, MAP_PHONE},
new int[]{R.id.listviewcontractsTextView1, R.id.listviewcontractsTextView2}
);
mSimpleAdapter.setDropDownViewResource(R.layout.listview_contracts);
mlvContracts.setAdapter(mSimpleAdapter);
// 列表项点击事件:点击时主动设置选中状态,确保样式突显
mlvContracts.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position < mAdapterData.size()) {
// 1. 主动设置当前项为选中状态
mlvContracts.setItemChecked(position, true);
// 2. 更新号码输入框和姓名显示
String phone = mAdapterData.get(position).get(MAP_PHONE).toString();
metTO.setText(phone);
mtvTOName.setText(phoneUtil.getNameByPhone(phone));
// 3. 滚动到点击位置(确保可见)
mlvContracts.setSelection(position);
}
}
});
// 列表项选中状态变化监听(可选,增强选中反馈)
mlvContracts.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// 选中时可添加额外反馈(如改变文本颜色,可选)
if (view != null) {
TextView tvName = (TextView) view.findViewById(R.id.listviewcontractsTextView1);
TextView tvPhone = (TextView) view.findViewById(R.id.listviewcontractsTextView2);
if (tvName != null) tvName.setTextColor(getResources().getColor(R.color.white));
if (tvPhone != null) tvPhone.setTextColor(getResources().getColor(R.color.white));
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// 未选中时无操作
}
});
} else {
// 数据更新时,先取消所有旧选中状态,再通知适配器刷新
mlvContracts.clearChoices();
mSimpleAdapter.notifyDataSetChanged();
}
}
// 发送短信逻辑
private void sendSMS() {
String phoneTo = metTO.getText().toString().trim();
if (phoneTo.isEmpty()) {
ToastUtils.show("没有设置接收号码。");
return;
}
String smsBody = metSMSBody.getText().toString().trim();
if (smsBody.isEmpty()) {
ToastUtils.show("没有消息内容可发送。");
return;
}
if (SMSUtil.sendMessageByInterface2(ComposeSMSActivity.this, phoneTo, smsBody)) {
finish();
}
}
}

View File

@@ -1,346 +0,0 @@
package cc.winboll.studio.mymessagemanager.activitys;
import android.Manifest;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ScrollView;
import androidx.appcompat.widget.Toolbar;
import cc.winboll.studio.libaes.utils.AESThemeUtil;
import cc.winboll.studio.libaes.utils.DevelopUtils;
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
import cc.winboll.studio.libaes.views.ADsBannerView;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.App;
import cc.winboll.studio.mymessagemanager.BuildConfig;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.MainActivity;
import cc.winboll.studio.mymessagemanager.adapters.PhoneArrayAdapter;
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.AppGoToSettingsUtil;
import cc.winboll.studio.mymessagemanager.utils.PermissionUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
import cc.winboll.studio.mymessagemanager.utils.ViewUtil;
import cc.winboll.studio.mymessagemanager.views.ConfirmSwitchView;
import cc.winboll.studio.mymessagemanager.views.PhoneListViewForScrollView;
import com.baoyz.widget.PullRefreshLayout;
import java.util.ArrayList;
public class MainActivity extends WinBoLLActivity {
public final static String TAG = "MainActivity";
public static final int ACTIVITY_RESULT_APP_SETTINGS = -1;
public final static int MSG_RELOADSMS = 0;
public static final int PERMISSION_SETTING_FOR_RESULT = 0;
public static final int MY_PERMISSIONS_REQUEST = 0;
static MainActivity _mMainActivity;
ADsBannerView mADsBannerView;
//LogView mLogView;
AppConfigUtil mAppConfigUtil;
ConfirmSwitchView msvEnableService;
ConfirmSwitchView msvOnlyReceiveContacts;
ConfirmSwitchView msvEnableTTS;
ConfirmSwitchView msvEnableTTSRuleMode;
PhoneListViewForScrollView mListViewPhone;
Toolbar mToolbar;
PhoneArrayAdapter mPhoneArrayAdapter;
AppGoToSettingsUtil mAppGoToSettingsUtil;
String[] mPermissionList = {Manifest.permission.READ_CONTACTS,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.READ_SMS};
ArrayList<String> listPerms;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
_mMainActivity = MainActivity.this;
// 米盟广告栏
mADsBannerView = findViewById(R.id.adsbanner);
mAppConfigUtil = AppConfigUtil.getInstance(this);
initView();
// 调用调试检查函数
onOnceAndroidStory(null);
}
//
// 这是一个测试函数,
// 用于调试读取 string.xml string-array使用。
//
public void onOnceAndroidStory(View view) {
if (BuildConfig.DEBUG) {
// 获取strings.xml文件中的tab_names数组
String[] tab_names = getResources().getStringArray(R.array.strings_OnceAndroidStory);
// 这里R.array.tab_names是你在XML文件中定义的数组资源ID
// 例如在strings.xml中可能这样定义
/*/ <!-- strings.xml -->
<resources>
<string-array name="tab_names">
<item>Tab 1</item>
<item>Tab 2</item>
<item>Tab 3</item>
</string-array>
</resources>
*/
// 现在你可以遍历这个数组来访问每个元素
for (int i = 0; i < tab_names.length; i++) {
// 创建Random实例并传入任意非负种子这里是1
java.util.Random r = new java.util.Random(1);
// 调用nextInt(6)范围是0到5包括0和5加1后得到1到5
int randomNum = r.nextInt(6) + 1;
System.out.println("Random number between 1 and 5: " + randomNum);
LogUtils.d("OnceAndroidStory", tab_names[i]);
}
}
}
void scrollScrollView() {
ScrollView sv = findViewById(R.id.activitymainScrollView1);
ViewUtil.scrollScrollView(sv);
}
void genTestData() {
for (int i = 0; i < 2; i++) {
SMSUtil.saveReceiveSms(this, "13172887736", "调试阶段生成的短信" + Integer.toString(i), "0", -1, "inbox");
}
}
//
// 初始化视图控件
//
void initView() {
// 设置调试日志
// mLogView = findViewById(R.id.logview);
// mLogView.start();
// 设置消息处理函数
setOnActivityMessageReceived(mIOnActivityMessageReceived);
// 设置标题栏
mToolbar = findViewById(R.id.activitymainASupportToolbar1);
mToolbar.setSubtitle(getString(R.string.activity_name_main));
setSupportActionBar(mToolbar);
boolean isEnableService = mAppConfigUtil.mAppConfigBean.isEnableService();
msvEnableService = findViewById(R.id.activitymainSwitchView1);
msvEnableService.setChecked(isEnableService);
msvEnableService.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isEnable = ((ConfirmSwitchView)v).isChecked();
mAppConfigUtil.reLoadConfig();
mAppConfigUtil.mAppConfigBean.setIsEnableService(isEnable);
mAppConfigUtil.saveConfig();
initService(isEnable);
}
});
boolean isOnlyReceiveContacts = mAppConfigUtil.mAppConfigBean.isEnableOnlyReceiveContacts();
msvOnlyReceiveContacts = findViewById(R.id.activitymainSwitchView2);
msvOnlyReceiveContacts.setChecked(isOnlyReceiveContacts);
msvOnlyReceiveContacts.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isEnable = ((ConfirmSwitchView)v).isChecked();
mAppConfigUtil.reLoadConfig();
mAppConfigUtil.mAppConfigBean.setIsEnableOnlyReceiveContacts(isEnable);
mAppConfigUtil.saveConfig();
}
});
boolean isEnableTTS = mAppConfigUtil.mAppConfigBean.isEnableTTS();
msvEnableTTS = findViewById(R.id.activitymainSwitchView3);
msvEnableTTS.setChecked(isEnableTTS);
msvEnableTTS.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isEnable = ((ConfirmSwitchView)v).isChecked();
mAppConfigUtil.reLoadConfig();
mAppConfigUtil.mAppConfigBean.setIsEnableTTS(isEnable);
mAppConfigUtil.saveConfig();
}
});
boolean isEnableTTSRuleMode = mAppConfigUtil.mAppConfigBean.isEnableTTSRuleMode();
msvEnableTTSRuleMode = findViewById(R.id.activitymainSwitchView4);
msvEnableTTSRuleMode.setChecked(isEnableTTSRuleMode);
msvEnableTTSRuleMode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isEnable = ((ConfirmSwitchView)v).isChecked();
mAppConfigUtil.reLoadConfig();
mAppConfigUtil.mAppConfigBean.setIsEnableTTSRuleMode(isEnable);
mAppConfigUtil.saveConfig();
}
});
initService(isEnableService);
// 短信发送窗口按钮
Button btnSendSMS = findViewById(R.id.activitymainButton1);
btnSendSMS.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri uri = Uri.parse("smsto:");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra("sms_body", "");
startActivity(it);
}
});
mListViewPhone = (PhoneListViewForScrollView) findViewById(R.id.activitymainListView1);
//准备数据
mPhoneArrayAdapter = new PhoneArrayAdapter(MainActivity.this);
final PullRefreshLayout layout = (PullRefreshLayout) findViewById(R.id.activitymainPullRefreshLayout1);
//将适配器加载到控件中
mListViewPhone.setAdapter(mPhoneArrayAdapter);
// listen refresh event
layout.setOnRefreshListener(new PullRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
// start refresh
reloadSMS();
layout.setRefreshing(false);
}
});
}
void initService(boolean isEnableService) {
if (isEnableService) {
Intent service = new Intent(this, MainService.class);
startService(service);
} else {
Intent service = new Intent(this, MainService.class);
stopService(service);
}
}
//
// 定义应用内消息处理函数
//
IOnActivityMessageReceived mIOnActivityMessageReceived = new IOnActivityMessageReceived(){
@Override
public void onActivityMessageReceived(Message msg) {
switch (msg.arg1) {
case MSG_RELOADSMS : {
LogUtils.d(TAG, "MSG_RELOADSMS");
if (PermissionUtil.checkAppPermission(MainActivity.this)) {
mPhoneArrayAdapter.loadData();
mPhoneArrayAdapter.notifyDataSetChanged();
} else {
LogUtils.i(TAG, "遇到应用权限问题,请打开应用设置检查一下应用权限。");
}
break;
}
}
}
};
@Override
public boolean onCreatePanelMenu(int featureId, Menu menu) {
return super.onCreatePanelMenu(featureId, menu);
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mADsBannerView != null) {
mADsBannerView.releaseAdResources();
}
}
@Override
protected void onResume() {
super.onResume();
reloadSMS();
if (mADsBannerView != null) {
mADsBannerView.resumeADs(MainActivity.this);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.toolbar_main_first, menu);
// 主题菜单
AESThemeUtil.inflateMenu(this, menu);
// 调试工具菜单
if (App.isDebugging()) {
DevelopUtils.inflateMenu(this, menu);
getMenuInflater().inflate(R.menu.toolbar_main_debug, menu);
}
getMenuInflater().inflate(R.menu.toolbar_main_last, menu);
return true;
}
public static void reloadSMS() {
if (_mMainActivity != null) {
Message msg = new Message();
msg.arg1 = MSG_RELOADSMS;
_mMainActivity.sendActivityMessage(msg);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int nItemId = item.getItemId();
int menuItemId = item.getItemId();
if (AESThemeUtil.onAppThemeItemSelected(this, item)) {
recreate();
} if (DevelopUtils.onDevelopItemSelected(this, item)) {
LogUtils.d(TAG, String.format("onOptionsItemSelected item.getItemId() %d ", item.getItemId()));
} else if (nItemId == R.id.app_ttsrule) {
Intent i = new Intent(MainActivity.this, TTSPlayRuleActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
} else if (nItemId == R.id.app_smsrule) {
Intent i = new Intent(MainActivity.this, SMSReceiveRuleActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
} else if (nItemId == R.id.app_appsettings) {
Intent i = new Intent(MainActivity.this, AppSettingsActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
} else if (nItemId == R.id.app_unittest) {
Intent i = new Intent(MainActivity.this, UnitTestActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
} else if (nItemId == R.id.app_about) {
Intent i = new Intent(MainActivity.this, AboutActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
} else if (nItemId == R.id.app_smsrecycle) {
Class<?> recycleClass;
if (mAppConfigUtil.mAppConfigBean.getRecycleBinClass().equals("SMSRecycle2Activity")) {
recycleClass = SMSRecycle2Activity.class;
} else {
recycleClass = SMSRecycleActivity.class;
}
Intent i = new Intent(MainActivity.this, recycleClass);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
return super.onOptionsItemSelected(item);
}
}

View File

@@ -1,281 +0,0 @@
package cc.winboll.studio.mymessagemanager.activitys;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.AbsListView;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.Toolbar;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
import cc.winboll.studio.mymessagemanager.R;
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.ViewUtil;
import cc.winboll.studio.mymessagemanager.views.BottomPositionFixedScrollView;
import cc.winboll.studio.mymessagemanager.views.SMSListViewForScrollView;
import android.app.Activity;
public class SMSActivity extends WinBoLLActivity implements IWinBoLLActivity {
public static String TAG = "SMSActivity";
public static final String ACTION_NOTIFY_SMS_CHANGED = "cc.winboll.studio.mymessagemanager.activitys.SMSActivity.ACTION_NOTIFY_SMS_CHANGED";
public static final String EXTRA_PHONE = "Phone";
final static int MSG_SET_FOCUS = 0;
SMSListViewForScrollView mlvSMS;
Toolbar mToolbar;
String mszPhoneTo;
SMSArrayAdapter mSMSArrayAdapter;
BottomPositionFixedScrollView mScrollView1;
EditText metSMSBody;
SMSActivityBroadcastReceiver mSMSActivityBroadcastReceiver;
Handler mSetFocusHandler;
private boolean isImeVisible = false;
@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_sms);
initView();
scrollScrollView();
setupImeStatusListener();
// 新增监听窗口加载完成触发mScrollView1滚动到底部
setupScrollToBottomAfterWindowLoaded();
}
// 新增窗口加载完成后让mScrollView1滚动到底部
private void setupScrollToBottomAfterWindowLoaded() {
final View rootView = findViewById(android.R.id.content);
// 监听根布局绘制完成(窗口加载完成的标志)
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// 滚动到底部
mScrollView1.post(new Runnable() {
@Override
public void run() {
mScrollView1.fullScroll(ScrollView.FOCUS_DOWN);
}
});
// 移除监听,避免重复触发
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
rootView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
});
}
private void setupImeStatusListener() {
final View rootView = findViewById(android.R.id.content);
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int rootViewHeight = rootView.getHeight();
int screenHeight = getResources().getDisplayMetrics().heightPixels;
int imeThreshold = dp2px(200);
boolean currentImeVisible = (screenHeight - rootViewHeight) > imeThreshold;
if (currentImeVisible != isImeVisible) {
isImeVisible = currentImeVisible;
setupScrollView1Height();
if (!isImeVisible) {
metSMSBody.clearFocus();
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
rootView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
setupImeStatusListener();
}
});
}
private int dp2px(int dp) {
return (int) (dp * getResources().getDisplayMetrics().density + 0.5f);
}
/*static class MyHandler extends Handler {
WeakReference<SMSActivity> mActivity;
MyHandler(SMSActivity activity) {
mActivity = new WeakReference<SMSActivity>(activity);
}
public void handleMessage(Message msg) {
SMSActivity theActivity = mActivity.get();
switch (msg.what) {
case MSG_SET_FOCUS:
theActivity.metSMSBody.setFocusable(true);
theActivity.metSMSBody.requestFocus();
theActivity.setupScrollView1Height();
break;
default:
break;
}
super.handleMessage(msg);
}
}*/
@Override
protected void onDestroy() {
super.onDestroy();
LocalBroadcastManager.getInstance(this).unregisterReceiver(mSMSActivityBroadcastReceiver);
}
void initView() {
mszPhoneTo = getIntent().getStringExtra(EXTRA_PHONE);
if (mszPhoneTo == null || mszPhoneTo.trim().equals("")) {
finish();
}
mToolbar = (Toolbar) findViewById(R.id.activitysmsASupportToolbar1);
mToolbar.setSubtitle(getString(R.string.activity_name_smsinphone) + " < Phone : " + AddressUtils.getFormattedAddress(mszPhoneTo) + " >");
setActionBar(mToolbar);
mScrollView1 = (BottomPositionFixedScrollView) findViewById(R.id.activitysmsScrollView1);
metSMSBody = (EditText) findViewById(R.id.viewsmssendpart1EditText1);
metSMSBody.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setupScrollView1Height();
}
});
metSMSBody.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
setupScrollView1Height();
}
});
final AOHPCTCSeekBar aOHPCTCSeekBar = (AOHPCTCSeekBar) findViewById(R.id.viewsmssendpart1AOHPCTCSeekBar1);
aOHPCTCSeekBar.setThumb(getDrawable(R.drawable.ic_message));
aOHPCTCSeekBar.setThumbOffset(20);
aOHPCTCSeekBar.setOnOHPCListener(new AOHPCTCSeekBar.OnOHPCListener() {
@Override
public void onOHPCommit() {
sendSMS();
}
});
TextView tvAOHPCTCSeekBarMSG = (TextView) findViewById(R.id.viewsmssendpart1TextView1);
tvAOHPCTCSeekBarMSG.setText(R.string.msg_100sendmsg);
mlvSMS = (SMSListViewForScrollView) findViewById(R.id.activitysmsSMSListViewForScrollView1);
mSMSArrayAdapter = new SMSArrayAdapter(SMSActivity.this, mszPhoneTo);
mlvSMS.setAdapter(mSMSArrayAdapter);
mlvSMS.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (firstVisibleItem + visibleItemCount == totalItemCount && totalItemCount > 0) {
mSMSArrayAdapter.cancelMessageNotification();
}
}
});
mSMSActivityBroadcastReceiver = new SMSActivityBroadcastReceiver();
IntentFilter intentFilter = new IntentFilter(ACTION_NOTIFY_SMS_CHANGED);
LocalBroadcastManager.getInstance(this).registerReceiver(mSMSActivityBroadcastReceiver, intentFilter);
}
private void setupScrollView1Height() {
mScrollView1.postDelayed(new Runnable() {
@Override
public void run() {
final ScrollView scrollView2 = (ScrollView) findViewById(R.id.activitysmsScrollView2);
final BottomPositionFixedScrollView scrollView1 = (BottomPositionFixedScrollView) findViewById(R.id.activitysmsScrollView1);
final View includeView = findViewById(R.id.activitysmsinclude1);
scrollView2.post(new Runnable() {
@Override
public void run() {
int scrollView2Height = scrollView2.getHeight();
int includeHeight = includeView.getHeight();
int targetHeight = Math.max(scrollView2Height - includeHeight, 0);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) scrollView1.getLayoutParams();
params.height = targetHeight;
scrollView1.setLayoutParams(params);
}
});
}
}, 100);
}
public void updateSMSView() {
mSMSArrayAdapter.reLoadSMSList(SMSActivity.this, mszPhoneTo);
mSMSArrayAdapter.notifyDataSetChanged();
}
void scrollScrollView() {
ViewUtil.scrollScrollView(mScrollView1);
}
void sendSMS() {
String szSMSBody = metSMSBody.getText().toString();
if (szSMSBody.equals("")) {
Toast.makeText(getApplication(), "没有消息内容可发送。", Toast.LENGTH_SHORT).show();
return;
}
if (SMSUtil.sendMessageByInterface2(this, mszPhoneTo, szSMSBody)) {
metSMSBody.setText("");
metSMSBody.clearFocus();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
updateSMSView();
ViewUtil.scrollScrollView(mScrollView1);
}
}, 1000);
}
}
class SMSActivityBroadcastReceiver extends BroadcastReceiver {
public SMSActivityBroadcastReceiver() {}
@Override
public void onReceive(Context context, Intent intent) {
if (ACTION_NOTIFY_SMS_CHANGED.equals(intent.getAction())) {
updateSMSView();
ViewUtil.scrollScrollView(mScrollView1);
} else {
throw new IllegalStateException("Unexpected value: " + intent.getAction());
}
}
}
}

View File

@@ -1,244 +0,0 @@
package cc.winboll.studio.mymessagemanager.activitys;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/07/19 12:50:52
* @Describe 短信匹配过滤规则设置窗口
*/
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
import cc.winboll.studio.mymessagemanager.App;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.SMSReceiveRuleActivity;
import cc.winboll.studio.mymessagemanager.adapters.SMSAcceptRuleArrayAdapter;
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
import cc.winboll.studio.mymessagemanager.utils.FileUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSReceiveRuleUtil;
import com.baoyz.widget.PullRefreshLayout;
import android.app.Activity;
public class SMSReceiveRuleActivity extends WinBoLLActivity implements IWinBoLLActivity {
public static final String TAG = "SMSReceiveRuleActivity";
Context mContext;
RecyclerView mRecyclerView;
Toolbar mToolbar;
RadioButton mrbAccept;
RadioButton mrbRefuse;
CheckBox mcbEnable;
SMSAcceptRuleBean mSMSAcceptRuleBeanAdd;
SMSAcceptRuleArrayAdapter mSMSAcceptRuleArrayAdapter;
@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_smsacceptrulesetting);
mContext = SMSReceiveRuleActivity.this;
initSMSAcceptRuleBeanAdd();
// 初始化视图
initView();
}
//
// 初始化视图
//
public void initView() {
// 初始化标题栏
mToolbar = findViewById(R.id.activitysmsacceptrulesettingASupportToolbar1);
mToolbar.setSubtitle(getString(R.string.text_smsrule));
setSupportActionBar(mToolbar);
mrbAccept = findViewById(R.id.activitysmsacceptrulesettingRadioButton1);
mrbRefuse = findViewById(R.id.activitysmsacceptrulesettingRadioButton2);
mcbEnable = findViewById(R.id.activitysmsacceptrulesettingCheckBox1);
if (mSMSAcceptRuleBeanAdd.getRuleType() == SMSAcceptRuleBean.RuleType.ACCEPT) {
mrbAccept.setChecked(true);
mrbRefuse.setChecked(false);
}
if (mSMSAcceptRuleBeanAdd.getRuleType() == SMSAcceptRuleBean.RuleType.REFUSE) {
mrbAccept.setChecked(false);
mrbRefuse.setChecked(true);
}
mcbEnable.setChecked(mSMSAcceptRuleBeanAdd.isEnable());
Button btnAddSMSAcceptRule = findViewById(R.id.activitysmsacceptrulesettingButton1);
btnAddSMSAcceptRule.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText et = findViewById(R.id.activitysmsacceptrulesettingEditText1);
String szRule = et.getText().toString().trim();
if (szRule.equals("")) {
Toast.makeText(getApplication(), "空字符串规则不能添加", Toast.LENGTH_SHORT).show();
} else {
mSMSAcceptRuleBeanAdd.setRuleData(et.getText().toString());
mSMSAcceptRuleBeanAdd.setIsEnable(mcbEnable.isChecked());
mSMSAcceptRuleBeanAdd.setRuleType(mrbRefuse.isChecked() ?SMSAcceptRuleBean.RuleType.REFUSE: SMSAcceptRuleBean.RuleType.ACCEPT);
mSMSAcceptRuleArrayAdapter.addSMSAcceptRule(mSMSAcceptRuleBeanAdd);
initSMSAcceptRuleBeanAdd();
et.setText("");
Toast.makeText(getApplication(), "已添加规则 : " + szRule, Toast.LENGTH_SHORT).show();
}
}
});
// 绑定控件
mRecyclerView = findViewById(R.id.activitysmsacceptrulesettingRecyclerView1);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(layoutManager);
mSMSAcceptRuleArrayAdapter = new SMSAcceptRuleArrayAdapter(this);
mRecyclerView.setAdapter(mSMSAcceptRuleArrayAdapter);
final PullRefreshLayout pullRefreshLayout = findViewById(R.id.activitysmsacceptrulesettingPullRefreshLayout1);
pullRefreshLayout.setOnRefreshListener(new PullRefreshLayout.OnRefreshListener(){
@Override
public void onRefresh() {
pullRefreshLayout.setRefreshing(false);
mSMSAcceptRuleArrayAdapter.loadConfigData();
mSMSAcceptRuleArrayAdapter.notifyDataSetChanged();
}
});
}
void initSMSAcceptRuleBeanAdd() {
mSMSAcceptRuleBeanAdd = new SMSAcceptRuleBean(App.USER_ID, "", true, SMSAcceptRuleBean.RuleType.REFUSE, true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//return super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.toolbar_rule, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int nItemId = item.getItemId();
if (nItemId == R.id.item_rule_share) {
//SMSReceiveRuleUtil smsAcceptRuleConfig = SMSReceiveRuleUtil.getInstance(this, false);
SMSAcceptRuleBean beanTemp = new SMSAcceptRuleBean();
String szConfigPath = beanTemp.getBeanListJsonFilePath(mContext);
FileUtil.shareJSONFile(SMSReceiveRuleActivity.this, szConfigPath);
} else if (nItemId == R.id.item_rule_reset) {
showResetConfigDialog();
} else if (nItemId == R.id.item_rule_clean) {
showCleanConfigDialog();
}
return true;
}
//
// 短信匹配过滤规则数据重置对话框
//
void showResetConfigDialog() {
Dialog alertDialog = new AlertDialog.Builder(this).
setTitle("确定重置?").
setMessage("您确定重置短信接收规则为默认设置吗?").
setIcon(R.drawable.ic_launcher).
setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
SMSReceiveRuleUtil smsAcceptRuleConfig = SMSReceiveRuleUtil.getInstance(getApplicationContext(), false);
smsAcceptRuleConfig.resetConfig();
mSMSAcceptRuleArrayAdapter.notifyDataSetChanged();
Toast.makeText(getApplication(), "Rules Reset", Toast.LENGTH_SHORT).show();
}
}).
setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).
/*setNeutralButton("查看详情", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).*/
create();
alertDialog.show();
}
//
// 短信匹配过滤规则数据清空对话框
//
void showCleanConfigDialog() {
Dialog alertDialog = new AlertDialog.Builder(this).
setTitle("确定清理").
setMessage("您确定清理所有短信接收规则吗?").
setIcon(R.drawable.ic_launcher).
setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
SMSReceiveRuleUtil smsAcceptRuleConfig = SMSReceiveRuleUtil.getInstance(getApplicationContext(), false);
smsAcceptRuleConfig.cleanConfig();
mSMSAcceptRuleArrayAdapter.notifyDataSetChanged();
Toast.makeText(getApplication(), "Rules Cleaned.", Toast.LENGTH_SHORT).show();
}
}).
setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).
/*setNeutralButton("查看详情", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).*/
create();
alertDialog.show();
}
public void onAcceptRuleType(View view) {
mrbRefuse.setChecked(false);
}
public void onRefuseRuleType(View view) {
mrbAccept.setChecked(false);
}
@Override
protected void onResume() {
super.onResume();
mSMSAcceptRuleArrayAdapter.loadConfigData();
mSMSAcceptRuleArrayAdapter.notifyDataSetChanged();
}
}

View File

@@ -1,120 +0,0 @@
package cc.winboll.studio.mymessagemanager.activitys;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.adapters.SMSRecycle2Adapter;
import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil;
import cc.winboll.studio.mymessagemanager.views.ProtectModeTextView;
import com.baoyz.widget.PullRefreshLayout;
import java.io.File;
public class SMSRecycle2Activity extends WinBoLLActivity implements IWinBoLLActivity {
public static final String TAG = "SMSRecycle2Activity";
private static final String SP_NAME = "smsrecycle2_config";
private static final String KEY_SCALE = "recycle2_scale";
Toolbar mToolbar;
RecyclerView mRecyclerView;
SMSRecycle2Adapter mSMSRecycle2Adapter;
ProtectModeTextView mSampleProtectModeTextView;
SharedPreferences mSP;
@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_smsrecycle2);
mToolbar = findViewById(R.id.activitysmsrecycle2ASupportToolbar1);
mToolbar.setSubtitle(getString(R.string.activity_name_about));
setSupportActionBar(mToolbar);
mSP = getSharedPreferences(SP_NAME, MODE_PRIVATE);
mSampleProtectModeTextView = findViewById(R.id.activitysmsrecycle2SampleProtectModeTextView);
mSampleProtectModeTextView.setContentTextWithScale(
"调节本短信下方刻度滑条,可预览文本打乱效果;同时该进度条数值将作为回收站短信全局默认初始值。\n"
+ "刻度0 = 保持原文不打乱;\n"
+ "刻度数值越小,字符分组越细碎,文本打乱混乱程度越大;\n"
+ "刻度数值越大,字符连串分组越长,文本打乱混乱程度越小。",
mSP.getInt(KEY_SCALE, 0));
mSampleProtectModeTextView.setOnScaleChangedListener(new ProtectModeTextView.OnScaleChangedListener() {
@Override
public void onScaleChanged(int progress) {
mSP.edit().putInt(KEY_SCALE, progress).apply();
mSMSRecycle2Adapter.setScaleProgress(progress);
mSMSRecycle2Adapter.notifyDataSetChanged();
}
});
initView();
}
void initView() {
mRecyclerView = findViewById(R.id.activitysmsrecycle2RecyclerView1);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(layoutManager);
mSMSRecycle2Adapter = new SMSRecycle2Adapter(this, mSP.getInt(KEY_SCALE, 0));
mRecyclerView.setAdapter(mSMSRecycle2Adapter);
final PullRefreshLayout pullRefreshLayout = findViewById(R.id.activitysmsrecycle2PullRefreshLayout1);
pullRefreshLayout.setOnRefreshListener(new PullRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mSMSRecycle2Adapter.loadSMSRecycleList();
mSMSRecycle2Adapter.notifyDataSetChanged();
pullRefreshLayout.setRefreshing(false);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.toolbar_smsrecycle, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int nItemId = item.getItemId();
if (nItemId == R.id.item_cleansmsrecycle) {
YesNoAlertDialog.show(this, "回收站清空确认", "是否清空回收站", mDeleteListener);
}
return true;
}
YesNoAlertDialog.OnDialogResultListener mDeleteListener = new YesNoAlertDialog.OnDialogResultListener() {
@Override
public void onNo() {
}
@Override
public void onYes() {
File file = new File(SMSRecycleUtil.getSMSRecycleListDataPath(SMSRecycle2Activity.this));
file.delete();
mSMSRecycle2Adapter.loadSMSRecycleList();
mSMSRecycle2Adapter.notifyDataSetChanged();
}
};
}

View File

@@ -1,104 +0,0 @@
package cc.winboll.studio.mymessagemanager.activitys;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/07/19 16:56:18
* @Describe 短信回收站
*/
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.SMSRecycleActivity;
import cc.winboll.studio.mymessagemanager.adapters.SMSRecycleAdapter;
import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil;
import com.baoyz.widget.PullRefreshLayout;
import java.io.File;
public class SMSRecycleActivity extends WinBoLLActivity implements IWinBoLLActivity {
public static final String TAG = "SMSRecycleActivity";
Toolbar mToolbar;
RecyclerView mRecyclerView;
SMSRecycleAdapter mSMSRecycleAdapter;
@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_smsrecycle);
// 初始化标题栏
mToolbar = findViewById(R.id.activitysmsrecycleASupportToolbar1);
mToolbar.setSubtitle(getString(R.string.activity_name_about));
setSupportActionBar(mToolbar);
initView();
}
void initView() {
// 绑定控件
mRecyclerView = findViewById(R.id.activitysmsrecycleRecyclerView1);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(layoutManager);
mSMSRecycleAdapter = new SMSRecycleAdapter(this);
mRecyclerView.setAdapter(mSMSRecycleAdapter);
final PullRefreshLayout pullRefreshLayout = findViewById(R.id.activitysmsrecyclePullRefreshLayout1);
pullRefreshLayout.setOnRefreshListener(new PullRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mSMSRecycleAdapter.loadSMSRecycleList();
mSMSRecycleAdapter.notifyDataSetChanged();
pullRefreshLayout.setRefreshing(false);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//return super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.toolbar_smsrecycle, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int nItemId = item.getItemId();
if (nItemId == R.id.item_cleansmsrecycle) {
YesNoAlertDialog.show(this, "回收站清空确认", "是否清空回收站", mDeleteListener);
}
return true;
}
YesNoAlertDialog.OnDialogResultListener mDeleteListener = new YesNoAlertDialog.OnDialogResultListener() {
@Override
public void onNo() {
}
@Override
public void onYes() {
File file = new File(SMSRecycleUtil.getSMSRecycleListDataPath(SMSRecycleActivity.this));
file.delete();
mSMSRecycleAdapter.loadSMSRecycleList();
mSMSRecycleAdapter.notifyDataSetChanged();
}
};
}

View File

@@ -1,154 +0,0 @@
package cc.winboll.studio.mymessagemanager.activitys;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.Toolbar;
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.SMSReceiveRuleActivity;
import cc.winboll.studio.mymessagemanager.activitys.SharedJSONReceiveActivity;
import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity;
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
import cc.winboll.studio.mymessagemanager.beans.TTSPlayRuleBean;
import cc.winboll.studio.mymessagemanager.utils.UriUtil;
import java.util.ArrayList;
import android.app.Activity;
public class SharedJSONReceiveActivity extends WinBoLLActivity implements IWinBoLLActivity {
public static final String TAG = "SharedJSONReceive";
Toolbar mToolbar;
@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_sharedjsonreceive);
StringBuilder sb = new StringBuilder();
// 接收分享数据
Intent intent = getIntent();
String action = intent.getAction();//action
String type = intent.getType();//类型
//LogUtils.d(TAG, "action is " + action);
//LogUtils.d(TAG, "type is " + type);
if ((Intent.ACTION_SEND.equals(action) || Intent.ACTION_VIEW.equals(action) || Intent.ACTION_EDIT.equals(action))
&& type != null && (("application/json".equals(type)) || ("text/x-json".equals(type)))) {
//取出文件uri
Uri uri = intent.getData();
if (uri == null) {
uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
}
//获取文件真实地址
String szSrcJSON = UriUtil.getFileFromUri(getApplication(), uri);
if (TextUtils.isEmpty(szSrcJSON)) {
return;
}
String szCheck = TTSPlayRuleBean.checkIsTheSameBeanListAndFile(szSrcJSON, TTSPlayRuleBean.class);
if (szCheck.equals("")) {
importTTSPlayRuleBean(szSrcJSON);
} else {
sb.append("\n语音规则数据检测结果\n");
sb.append(szCheck);
}
//LogUtils.d(TAG, "szCheck is " + szCheck);
szCheck = SMSAcceptRuleBean.checkIsTheSameBeanListAndFile(szSrcJSON, SMSAcceptRuleBean.class);
if (szCheck.equals("")) {
importSMSAcceptRuleBean(szSrcJSON);
} else {
sb.append("\n短信接收规则数据检测结果\n");
sb.append(szCheck);
}
//LogUtils.d(TAG, "szCheck is " + szCheck);
} else {
sb.append("Not supported action.");
}
mToolbar = findViewById(R.id.activitysharedjsonreceiveASupportToolbar1);
mToolbar.setSubtitle(getString(R.string.activity_name_sharedjsonreceive));
setActionBar(mToolbar);
TextView tvMessage = findViewById(R.id.activitysharedjsonreceiveTextView1);
tvMessage.setText(sb.toString());
}
void importSMSAcceptRuleBean(final String szSrcJSON) {
ArrayList<SMSAcceptRuleBean> beanList = new ArrayList<SMSAcceptRuleBean>();
boolean bCheck = SMSAcceptRuleBean.loadBeanListFromFile(szSrcJSON, beanList, SMSAcceptRuleBean.class);
if (bCheck && beanList.size() > 0) {
YesNoAlertDialog.show(SharedJSONReceiveActivity.this,
"短信接收规则共享提示",
"已收到短信接收规则" + Integer.toString(beanList.size()) + "个,\n是否导入应用"
, (new YesNoAlertDialog.OnDialogResultListener(){
@Override
public void onYes() {
ArrayList<SMSAcceptRuleBean> beanListShare = new ArrayList<SMSAcceptRuleBean>();
SMSAcceptRuleBean.loadBeanListFromFile(szSrcJSON, beanListShare, SMSAcceptRuleBean.class);
ArrayList<SMSAcceptRuleBean> beanListApp = new ArrayList<SMSAcceptRuleBean>();
SMSAcceptRuleBean.loadBeanList(SharedJSONReceiveActivity.this, beanListApp, SMSAcceptRuleBean.class);
beanListApp.addAll(0, beanListShare);
SMSAcceptRuleBean.saveBeanList(SharedJSONReceiveActivity.this, beanListApp, SMSAcceptRuleBean.class);
Toast.makeText(getApplication(), "已导入" + Integer.toString(beanListShare.size()) + "个数据。", Toast.LENGTH_SHORT).show();
finish();
Intent intent = new Intent(SharedJSONReceiveActivity.this, SMSReceiveRuleActivity.class);
startActivity(intent);
}
@Override
public void onNo() {
finish();
}
}));
}
}
void importTTSPlayRuleBean(final String szSrcJSON) {
ArrayList<TTSPlayRuleBean> beanList = new ArrayList<TTSPlayRuleBean>();
boolean bCheck = TTSPlayRuleBean.loadBeanListFromFile(szSrcJSON, beanList, TTSPlayRuleBean.class);
if (bCheck && beanList.size() > 0) {
YesNoAlertDialog.show(SharedJSONReceiveActivity.this,
"语音规则共享提示",
"已收到语音规则" + Integer.toString(beanList.size()) + "个,\n是否导入应用"
, (new YesNoAlertDialog.OnDialogResultListener(){
@Override
public void onYes() {
ArrayList<TTSPlayRuleBean> beanListShare = new ArrayList<TTSPlayRuleBean>();
TTSPlayRuleBean.loadBeanListFromFile(szSrcJSON, beanListShare, TTSPlayRuleBean.class);
ArrayList<TTSPlayRuleBean> beanListApp = new ArrayList<TTSPlayRuleBean>();
TTSPlayRuleBean.loadBeanList(SharedJSONReceiveActivity.this, beanListApp, TTSPlayRuleBean.class);
beanListApp.addAll(0, beanListShare);
TTSPlayRuleBean.saveBeanList(SharedJSONReceiveActivity.this, beanListApp, TTSPlayRuleBean.class);
Toast.makeText(getApplication(), "已导入" + Integer.toString(beanListShare.size()) + "个数据。", Toast.LENGTH_SHORT).show();
finish();
Intent intent = new Intent(SharedJSONReceiveActivity.this, TTSPlayRuleActivity.class);
startActivity(intent);
}
@Override
public void onNo() {
finish();
}
}));
}
}
}

View File

@@ -1,23 +0,0 @@
package cc.winboll.studio.mymessagemanager.activitys;
import android.app.Activity;
import android.os.Bundle;
import cc.winboll.studio.mymessagemanager.R;
/**
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
* @Date 2026/02/11 03:45
* @Describe TTS悬浮窗设置类使用可拖动自定义控件
*/
public class TTSFloatSettingsActivity extends Activity {
public static final String TAG = "TTSFloatSettingsActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 直接加载包含自定义拖动控件的布局
setContentView(R.layout.activity_ttsfloatsettings);
}
}

View File

@@ -1,200 +0,0 @@
package cc.winboll.studio.mymessagemanager.activitys;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/07/19 12:50:52
* @Describe TTS 语音播放规则规则设置窗口
*/
import android.os.Bundle;
import android.os.Message;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.adapters.TTSRuleBeanRecyclerViewAdapter;
import cc.winboll.studio.mymessagemanager.beans.TTSPlayRuleBean;
import cc.winboll.studio.mymessagemanager.utils.FileUtil;
import cc.winboll.studio.mymessagemanager.utils.TTSPlayRuleUtil;
import android.app.Activity;
public class TTSPlayRuleActivity extends WinBoLLActivity implements IWinBoLLActivity {
public static final String TAG = "TTSPlayRuleActivity";
public static final int MSG_RELOAD = 0;
public static final String EXTRA_TTSDEMOTEXT = "EXTRA_TTSDEMOTEXT";
Toolbar mToolbar;
TTSRuleBeanRecyclerViewAdapter mTTSRuleBeanRecyclerViewAdapter;
TTSPlayRuleUtil mTTSPlayRuleUtil;
TTSPlayRuleBean mTTSRuleBeanCurrent;
RecyclerView mRecyclerView;
EditText metCurrentDemoSMSText;
EditText metPatternText;
EditText metCurrentTTSRuleText;
@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_ttsplayrule);
mTTSPlayRuleUtil = TTSPlayRuleUtil.getInstance(TTSPlayRuleActivity.this);
initView();
// 设置窗口消息处理
setOnActivityMessageReceived(new IOnActivityMessageReceived(){
@Override
public void onActivityMessageReceived(Message msg) {
switch (msg.what) {
case MSG_RELOAD : {
//Toast.makeText(getApplication(), "MSG_RELOAD", Toast.LENGTH_SHORT).show();
mTTSRuleBeanRecyclerViewAdapter.reloadConfigData();
break;
}
}
}
});
}
void initView() {
// 初始化标题栏
mToolbar = findViewById(R.id.activityttsplayruleASupportToolbar1);
mToolbar.setSubtitle(getString(R.string.text_ttsrule));
setSupportActionBar(mToolbar);
metCurrentDemoSMSText = findViewById(R.id.activityttsplayruleEditText1);
metPatternText = findViewById(R.id.activityttsplayruleEditText2);
metCurrentTTSRuleText = findViewById(R.id.activityttsplayruleEditText3);
Button btnTestTTSRule = findViewById(R.id.activityttsplayruleButton1);
btnTestTTSRule.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TTSPlayRuleBean ttsRuleBean = new TTSPlayRuleBean();
ttsRuleBean.setDemoSMSText(metCurrentDemoSMSText.getText().toString());
ttsRuleBean.setPatternText(metPatternText.getText().toString());
ttsRuleBean.setTtsRuleText(metCurrentTTSRuleText.getText().toString());
String sz = mTTSPlayRuleUtil.testTTSAnalyzeModeReply(ttsRuleBean);
Toast.makeText(getApplication(), sz, Toast.LENGTH_SHORT).show();
}
});
Button btnAcceptTTSRule = findViewById(R.id.activityttsplayruleButton2);
btnAcceptTTSRule.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mTTSRuleBeanCurrent != null) {
mTTSRuleBeanCurrent.setDemoSMSText(metCurrentDemoSMSText.getText().toString());
mTTSRuleBeanCurrent.setPatternText(metPatternText.getText().toString());
mTTSRuleBeanCurrent.setTtsRuleText(metCurrentTTSRuleText.getText().toString());
mTTSRuleBeanRecyclerViewAdapter.saveConfigData();
} else {
if (!metCurrentDemoSMSText.getText().toString().equals("")) {
mTTSRuleBeanCurrent = new TTSPlayRuleBean();
mTTSRuleBeanCurrent.setDemoSMSText(metCurrentDemoSMSText.getText().toString());
mTTSRuleBeanCurrent.setPatternText(metPatternText.getText().toString());
mTTSRuleBeanCurrent.setTtsRuleText(metCurrentTTSRuleText.getText().toString());
mTTSRuleBeanRecyclerViewAdapter.addNewTTSRuleBean(mTTSRuleBeanCurrent);
LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
layoutManager.scrollToPositionWithOffset(0, 0);
}
}
}
});
// 绑定控件
mRecyclerView = findViewById(R.id.activityttsplayruleRecyclerView1);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(layoutManager);
mTTSRuleBeanRecyclerViewAdapter = new TTSRuleBeanRecyclerViewAdapter(TTSPlayRuleActivity.this, mOnTTSRuleChangeListener);
mRecyclerView.setAdapter(mTTSRuleBeanRecyclerViewAdapter);
// 处理传入的窗口启动参数
//
String szNewDemoText = getIntent().getStringExtra(EXTRA_TTSDEMOTEXT);
metCurrentDemoSMSText.setText(szNewDemoText);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//return super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.toolbar_rule, menu);
return true;
}
public void onScrollToDemoSMSTextMatchingRule(View view) {
int rowIndex = mTTSPlayRuleUtil.speakTTSAnalyzeModeText(metCurrentDemoSMSText.getText().toString());
LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
layoutManager.scrollToPositionWithOffset(rowIndex, 0);
Toast.makeText(getApplication(), "当前文本匹配的规则序号为 " + Integer.toString(rowIndex + 1), Toast.LENGTH_SHORT).show();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int nItemId = item.getItemId();
if (nItemId == R.id.item_rule_share) {
TTSPlayRuleBean bean = new TTSPlayRuleBean();
FileUtil.shareJSONFile(this, bean.getBeanListJsonFilePath(TTSPlayRuleActivity.this));
} else if (nItemId == R.id.item_rule_reset) {
showResetConfigDialog();
} else if (nItemId == R.id.item_rule_clean) {
showCleanConfigDialog();
}
return true;
}
//
// 规则数据重置对话框
//
void showResetConfigDialog() {
mTTSPlayRuleUtil.resetConfig();
}
//
// 规则数据重置对话框
//
void showCleanConfigDialog() {
mTTSPlayRuleUtil.cleanConfig();
}
@Override
protected void onResume() {
super.onResume();
}
//
// 规则项选择事件监听类
//
TTSRuleBeanRecyclerViewAdapter.OnTTSRuleChangeListener mOnTTSRuleChangeListener = new TTSRuleBeanRecyclerViewAdapter.OnTTSRuleChangeListener() {
@Override
public void onTTSRuleChange(TTSPlayRuleBean bean) {
metCurrentDemoSMSText.setText(bean.getDemoSMSText());
metPatternText.setText(bean.getPatternText());
metCurrentTTSRuleText.setText(bean.getTtsRuleText());
mTTSRuleBeanCurrent = bean;
}
};
}

View File

@@ -1,82 +0,0 @@
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.os.Handler;
import android.os.Message;
import android.view.MenuItem;
import androidx.appcompat.app.AppCompatActivity;
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
import cc.winboll.studio.mymessagemanager.enums.ThemeStyleEnum;
public class WinBoLLActivity extends AppCompatActivity implements IWinBoLLActivity {
public static final String TAG = "WinBoLLActivity";
IOnActivityMessageReceived mIOnActivityMessageReceived;
@Override
public Activity getActivity() {
return this;
}
@Override
public String getTag() {
return TAG;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// 1. 优先读取SP中保存的主题必须在setContentView前调用
ThemeStyleEnum savedTheme = ThemeStyleEnum.getThemeFromSP(this);
// 2. 设置主题
setTheme(savedTheme.getStyleId());
super.onCreate(savedInstanceState);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int selectedMenuId = item.getItemId();
// 1. 根据菜单ID获取对应的主题枚举
ThemeStyleEnum selectedTheme = ThemeStyleEnum.getThemeByMenuId(selectedMenuId);
if (selectedTheme != null) {
// 2. 调用枚举自带方法保存主题到SP替代AESThemeUtil
ThemeStyleEnum.saveThemeToSP(this, selectedTheme);
recreate(); // 重建Activity生效主题
} else if (selectedMenuId == android.R.id.home) {
finish();
} else {
return super.onOptionsItemSelected(item);
}
return true;
}
protected interface IOnActivityMessageReceived {
void onActivityMessageReceived(Message msg);
}
public void sendActivityMessage(Message msg) {
mHandler.sendMessage(msg);
}
protected void setOnActivityMessageReceived(IOnActivityMessageReceived iOnActivityMessageReceived) {
mIOnActivityMessageReceived = iOnActivityMessageReceived;
}
Handler mHandler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (mIOnActivityMessageReceived != null) {
mIOnActivityMessageReceived.onActivityMessageReceived(msg);
}
}
};
}

View File

@@ -1,115 +0,0 @@
package cc.winboll.studio.mymessagemanager.adapters;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.SMSActivity;
import cc.winboll.studio.mymessagemanager.beans.PhoneBean;
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.SMSUtil;
import java.util.ArrayList;
import java.util.List;
public class PhoneArrayAdapter extends BaseAdapter {
public final static String TAG = "PhoneArrayAdapter";
Context mContext;
ArrayList<SMSBean> mData;
List<PhoneBean> mlistContacts;
PhoneUtil mPhoneUtil;
public PhoneArrayAdapter(Context context) {
mContext = context;
mData = new ArrayList<SMSBean>();
}
public void loadData() {
ArrayList<SMSBean> listTemp = SMSUtil.getAllSMSList(mContext);
mData.clear();
mData.addAll(listTemp);
mPhoneUtil = new PhoneUtil(mContext);
mlistContacts = mPhoneUtil.getPhoneList();
LogUtils.i(TAG, "SMS List Reload.");
}
@Override
public int getCount() {
return mData.size();
}
@Override
public Object getItem(int p1) {
return mData.get(p1);
}
@Override
public long getItemId(int p1) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder viewHolder;
if (convertView == null) {
viewHolder = new ViewHolder();
convertView = LayoutInflater.from(mContext).inflate(R.layout.listview_phone, parent, false);
//分别获取 image view 和 textview 的实例
viewHolder.tvAddress = convertView.findViewById(R.id.listviewphoneTextView1);
viewHolder.tvName = convertView.findViewById(R.id.listviewphoneTextView2);
viewHolder.ll = convertView.findViewById(R.id.listviewphoneLinearLayout1);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
final String szAddress = ((SMSBean)getItem(position)).getAddress();
viewHolder.tvAddress.setText(AddressUtils.getFormattedAddress(szAddress));
viewHolder.tvName.setText(getName(szAddress));
//Drawable drawableFrame = AppCompatResources.getDrawable(mContext, R.drawable.bg_frame);
//viewHolder.ll.setBackground(drawableFrame);
viewHolder.ll.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
//Toast.makeText(mContext, tv.getText(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(mContext, SMSActivity.class);
intent.putExtra(SMSActivity.EXTRA_PHONE, szAddress);
mContext.startActivity(intent);
}
});
return convertView;
}
String getName(String szAddress) {
for (int i = 0; i < mlistContacts.size(); i++) {
if (mlistContacts.get(i).getTelPhone().equals(szAddress)) {
return mlistContacts.get(i).getName();
}
}
return mContext.getString(R.string.text_notincontacts);
}
class ViewHolder {
TextView tvAddress;
TextView tvName;
LinearLayout ll;
}
}

View File

@@ -1,229 +0,0 @@
package cc.winboll.studio.mymessagemanager.adapters;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/07/20 12:27:34
* @Describe 短信过滤规则数据适配器
*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import cc.winboll.studio.libappbase.ToastUtils;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
import cc.winboll.studio.mymessagemanager.utils.SMSReceiveRuleUtil;
import java.util.ArrayList;
public class SMSAcceptRuleArrayAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
public static final String TAG = "SMSAcceptRuleArrayAdapter";
Context mContext;
ArrayList<SMSAcceptRuleBean> mDataList;
SMSReceiveRuleUtil mSMSReceiveRuleUtil;
public SMSAcceptRuleArrayAdapter(Context context) {
mContext = context;
mSMSReceiveRuleUtil = SMSReceiveRuleUtil.getInstance(mContext, true);
loadConfigData();
}
public void addSMSAcceptRule(SMSAcceptRuleBean bean) {
mSMSReceiveRuleUtil.addRule(bean);
notifyDataSetChanged();
}
public void loadConfigData() {
mDataList = mSMSReceiveRuleUtil.loadConfigData();
for (int i = 0; i < mDataList.size(); i++) {
mDataList.get(i).setIsSimpleView(true);
//LogUtils.d(TAG, "loadConfigData isEnable : " + Boolean.toString(mDataList.get(i).isEnable()));
}
}
void deleteItem(int position) {
mDataList.remove(position);
mSMSReceiveRuleUtil.saveConfigData();
notifyDataSetChanged();
}
@Override
public int getItemViewType(int position) {
if (mDataList.get(position).isSimpleView()) {
return 0;
} else {
return 1;
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == 0) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.listview_smsacceptrule_simple, parent, false);
return new SimpleViewHolder(view);
} else {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.listview_smsacceptrule, parent, false);
return new ComplexViewHolder(view);
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
final SMSAcceptRuleBean item = mDataList.get(position);
if (holder.getItemViewType() == 0) {
final SimpleViewHolder viewHolder = (SimpleViewHolder) holder;
viewHolder.mtvContent.setText(item.getRuleData());
viewHolder.mcbEnable.setChecked(item.isEnable());
viewHolder.mcbEnable.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View p1) {
item.setIsEnable(viewHolder.mcbEnable.isChecked());
item.setIsSimpleView(true);
mSMSReceiveRuleUtil.saveConfigData();
notifyDataSetChanged();
}
});
viewHolder.mtvRuleType.setText(item.getRuleType().toString());
viewHolder.mbtnEdit.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
for (int i = 0; i < mDataList.size(); i++) {
mDataList.get(i).setIsSimpleView(true);
}
item.setIsSimpleView(false);
notifyDataSetChanged();
//ToastUtils.show("setIsSimpleView");
}
});
} else {
final ComplexViewHolder viewHolder = (ComplexViewHolder) holder;
if (item != null) {
//Drawable drawableFrame = AppCompatResources.getDrawable(mContext, R.drawable.bg_frame);
viewHolder.metContent.setText(item.getRuleData());
if (item.getRuleType() == SMSAcceptRuleBean.RuleType.ACCEPT) {
viewHolder.mrbAccept.setChecked(true);
viewHolder.mrbRefuse.setChecked(false);
}
if (item.getRuleType() == SMSAcceptRuleBean.RuleType.REFUSE) {
viewHolder.mrbAccept.setChecked(false);
viewHolder.mrbRefuse.setChecked(true);
}
viewHolder.mrbAccept.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
viewHolder.mrbRefuse.setChecked(false);
item.setRuleType(SMSAcceptRuleBean.RuleType.ACCEPT);
mSMSReceiveRuleUtil.saveConfigData();
notifyDataSetChanged();
}
});
viewHolder.mrbRefuse.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
viewHolder.mrbAccept.setChecked(false);
item.setRuleType(SMSAcceptRuleBean.RuleType.REFUSE);
mSMSReceiveRuleUtil.saveConfigData();
notifyDataSetChanged();
}
});
viewHolder.mbtnUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View p1) {
if (position > 0) {
mDataList.add(position-1, mDataList.get(position));
mDataList.remove(position+1);
mSMSReceiveRuleUtil.saveConfigData();
notifyDataSetChanged();
}
}
});
viewHolder.mbtnDown.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View p1) {
if (position < mDataList.size() - 1) {
//ToastUtils.show("mbtnDown");
ToastUtils.show("position " + Integer.toString(position));
mDataList.add(position+2, mDataList.get(position));
mDataList.remove(position);
mSMSReceiveRuleUtil.saveConfigData();
notifyDataSetChanged();
}
}
});
viewHolder.mbtnOK.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View p1) {
item.setRuleData(viewHolder.metContent.getText().toString());
item.setRuleType(viewHolder.mrbAccept.isChecked() ?SMSAcceptRuleBean.RuleType.ACCEPT: SMSAcceptRuleBean.RuleType.REFUSE);
item.setIsEnable(viewHolder.mcbEnable.isChecked());
item.setIsSimpleView(true);
mSMSReceiveRuleUtil.saveConfigData();
notifyDataSetChanged();
}
});
viewHolder.mbtnDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View p1) {
deleteItem(position);
}
});
viewHolder.mcbEnable.setChecked(item.isEnable());
}
}
}
@Override
public int getItemCount() {
return mDataList.size();
}
@Override
public long getItemId(int posttion) {
return 0;
}
private static class SimpleViewHolder extends RecyclerView.ViewHolder {
TextView mtvContent;
CheckBox mcbEnable;
TextView mtvRuleType;
Button mbtnEdit;
SimpleViewHolder(View itemView) {
super(itemView);
mtvContent = itemView.findViewById(R.id.listviewsmsacceptrulesimpleTextView1);
mcbEnable = itemView.findViewById(R.id.listviewsmsacceptrulesimpleCheckBox1);
mtvRuleType = itemView.findViewById(R.id.listviewsmsacceptrulesimpleTextView2);
mbtnEdit = itemView.findViewById(R.id.listviewsmsacceptrulesimpleButton1);
}
}
private static class ComplexViewHolder extends RecyclerView.ViewHolder {
EditText metContent;
RadioButton mrbAccept;
RadioButton mrbRefuse;
CheckBox mcbEnable;
Button mbtnUp;
Button mbtnDown;
Button mbtnOK;
Button mbtnDelete;
ComplexViewHolder(View itemView) {
super(itemView);
metContent = itemView.findViewById(R.id.listviewsmsacceptruleEditText1);
mrbAccept = itemView.findViewById(R.id.listviewsmsacceptruleRadioButton1);
mrbRefuse = itemView.findViewById(R.id.listviewsmsacceptruleRadioButton2);
mcbEnable = itemView.findViewById(R.id.listviewsmsacceptruleCheckBox1);
mbtnUp = itemView.findViewById(R.id.listviewsmsacceptruleButton3);
mbtnDown = itemView.findViewById(R.id.listviewsmsacceptruleButton4);
mbtnOK = itemView.findViewById(R.id.listviewsmsacceptruleButton1);
mbtnDelete = itemView.findViewById(R.id.listviewsmsacceptruleButton2);
}
}
}

View File

@@ -1,214 +0,0 @@
package cc.winboll.studio.mymessagemanager.adapters;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
import cc.winboll.studio.libappbase.ToastUtils;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity;
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
import cc.winboll.studio.mymessagemanager.beans.SMSBean;
import cc.winboll.studio.mymessagemanager.utils.NotificationHelper;
import cc.winboll.studio.mymessagemanager.utils.SMSReceiveRuleUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
import cc.winboll.studio.mymessagemanager.utils.TTSPlayRuleUtil;
import cc.winboll.studio.mymessagemanager.views.DateAgoTextView;
import cc.winboll.studio.mymessagemanager.views.SMSView;
import java.util.ArrayList;
public class SMSArrayAdapter extends BaseAdapter {
public static String TAG = "SMSArrayAdapter";
Context mContext;
String mszPhone;
ArrayList<SMSBean> mData;
public SMSArrayAdapter(Context context, String szPhone) {
mContext = context;
mszPhone = szPhone;
mData = new ArrayList<SMSBean>();
mData = loadSMSList(context, szPhone);
}
ArrayList<SMSBean> loadSMSList(Context context, String szPhone) {
ArrayList<SMSBean> data = SMSUtil.getSMSListByPhone(context, szPhone);
SMSBean.sortSMSByDateDesc(data, false);
mData.clear();
mData.addAll(data);
return mData;
}
public void cancelMessageNotification() {
for (SMSBean bean : mData) {
NotificationHelper notificationHelper = new NotificationHelper(mContext);
notificationHelper.cancelNotification(bean.getId());
}
}
void deleteSMSById(final int position) {
YesNoAlertDialog.show(mContext,
"短信删除提示",
"请确认删除动作!"
, (new YesNoAlertDialog.OnDialogResultListener(){
@Override
public void onYes() {
SMSRecycleUtil.addSMSRecycleItem(mContext, (SMSBean)getItem(position));
SMSUtil.deleteSMSById(mContext, ((SMSBean)getItem(position)).getId());
mData.remove(position);
notifyDataSetChanged();
Toast.makeText(mContext, "SMS delete.", Toast.LENGTH_SHORT).show();
}
@Override
public void onNo() {
}
}));
}
public void reLoadSMSList(Context context, String szPhone) {
mData = loadSMSList(context, szPhone);
}
@Override
public int getCount() {
return mData.size();
}
@Override
public Object getItem(int p1) {
return mData.get(p1);
}
@Override
public long getItemId(int p1) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder viewHolder;
if (convertView == null) {
viewHolder = new ViewHolder();
convertView = LayoutInflater.from(mContext).inflate(R.layout.listview_sms, parent, false);
viewHolder.mSMSView = convertView.findViewById(R.id.listviewsmsSMSView1);
viewHolder.mllMain = convertView.findViewById(R.id.listviewsmspart1LinearLayout1);
viewHolder.mllContent = convertView.findViewById(R.id.listviewsmspart1LinearLayout2);
viewHolder.mvMenu = convertView.findViewById(R.id.listviewsmspart1View1);
viewHolder.mtvBody = (TextView) convertView
.findViewById(R.id.listviewsmspart1TextView1);
viewHolder.mdatvDate = convertView.findViewById(R.id.listviewsmspart1DateAgoTextView1);
viewHolder.mvLeft = convertView.findViewById(R.id.listviewsmsView1);
viewHolder.mvRight = convertView.findViewById(R.id.listviewsmsView2);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
final SMSBean item = (SMSBean) getItem(position);
if (item != null) {
if (item.getType() == SMSBean.Type.INBOX) {
viewHolder.mvLeft.setVisibility(View.GONE);
viewHolder.mvRight.setVisibility(View.VISIBLE);
viewHolder.mSMSView.setSMSType(SMSView.SMSType.INBOX);
viewHolder.mllMain.setGravity(Gravity.LEFT);
} else {
viewHolder.mvLeft.setVisibility(View.VISIBLE);
viewHolder.mvRight.setVisibility(View.GONE);
viewHolder.mSMSView.setSMSType(SMSView.SMSType.SEND);
}
//Drawable drawableFrame = AppCompatResources.getDrawable(mContext, R.drawable.bg_frame);
//viewHolder.mllContent.setBackground(drawableFrame);
viewHolder.mtvBody.setText(item.getBody());
viewHolder.mdatvDate.setDate(item.getDate());
//viewHolder.mtvType.setText(" [" + item.getType().name() + "] ");
viewHolder.mSMSView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View p1) {
// 弹出复制菜单
PopupMenu menu = new PopupMenu(mContext, viewHolder.mvMenu);
//加载菜单资源
menu.getMenuInflater().inflate(R.menu.toolbar_item_sms, menu.getMenu());
//设置点击事件的响应
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
int nItemId = menuItem.getItemId();
if (nItemId == R.id.copy) {
// Gets a handle to the clipboard service.
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
// Creates a new text clip to put on the clipboard
ClipData clip = ClipData.newPlainText("simple text", item.getBody());
// Set the clipboard's primary clip.
clipboard.setPrimaryClip(clip);
Toast.makeText(mContext, "Copy to clipboard.", Toast.LENGTH_SHORT).show();
} else if (nItemId == R.id.delete) {
deleteSMSById(position);
} else if (nItemId == R.id.addttsrule) {
Intent intent = new Intent(mContext, TTSPlayRuleActivity.class);
intent.putExtra(TTSPlayRuleActivity.EXTRA_TTSDEMOTEXT, viewHolder.mtvBody.getText().toString());
mContext.startActivity(intent);
} else if (nItemId == R.id.testtts) {
//Toast.makeText(mContext, "Testing TTS.", Toast.LENGTH_SHORT).show();
TTSPlayRuleUtil ttsPlayRuleUtil = TTSPlayRuleUtil.getInstance(mContext);
ttsPlayRuleUtil.speakTTSAnalyzeModeText(viewHolder.mtvBody.getText().toString());
} else if (nItemId == R.id.testreceivetule) {
//Toast.makeText(mContext, "Testing Receive Rule.", Toast.LENGTH_SHORT).show();
SMSReceiveRuleUtil smsReceiveRuleUtil = SMSReceiveRuleUtil.getInstance(mContext, true);
SMSReceiveRuleUtil.MatchResult matchResult = smsReceiveRuleUtil.getReceiveRuleMatchResult(mContext, viewHolder.mtvBody.getText().toString());
if (matchResult.matchPositionInRules == SMSReceiveRuleUtil.VALID_MATCHRESULT_POSITION
|| matchResult.matchRuleType == SMSAcceptRuleBean.RuleType.REGEXPPIUTILS_ISPPIOK_FALSE) {
//ToastUtils.show("Test");
ToastUtils.show("Not Receive Rule is Matched.\nResult is : " + matchResult.matchRuleType);
} else {
ToastUtils.show("MatchResult : " + matchResult.matchRuleType + "\nReceiveRule Match Position : " + Integer.toString(matchResult.matchPositionInRules + 1));
}
}
return true;
}
});
//一定要调用show()来显示弹出式菜单
menu.show();
return true;
}
});
}
return convertView;
}
class ViewHolder {
SMSView mSMSView;
LinearLayout mllMain;
LinearLayout mllContent;
TextView mtvBody;
View mvMenu;
DateAgoTextView mdatvDate;
View mvLeft;
View mvRight;
}
}

View File

@@ -1,78 +0,0 @@
package cc.winboll.studio.mymessagemanager.adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.beans.SMSRecycleBean;
import cc.winboll.studio.mymessagemanager.utils.AddressUtils;
import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil;
import cc.winboll.studio.mymessagemanager.views.DateAgoTextView;
import cc.winboll.studio.mymessagemanager.views.ProtectModeTextView;
import java.util.ArrayList;
public class SMSRecycle2Adapter extends RecyclerView.Adapter<SMSRecycle2Adapter.ViewHolder> {
public static final String TAG = "SMSRecycle2Adapter";
Context mContext;
ArrayList<SMSRecycleBean> mDataList;
String mszSMSRecycleListDataPath;
int mScaleProgress;
public SMSRecycle2Adapter(Context context, int scaleProgress) {
mContext = context;
mScaleProgress = scaleProgress;
mszSMSRecycleListDataPath = SMSRecycleUtil.getSMSRecycleListDataPath(mContext);
mDataList = new ArrayList<SMSRecycleBean>();
mDataList = loadSMSRecycleList();
}
public void setScaleProgress(int scaleProgress) {
mScaleProgress = scaleProgress;
}
public ArrayList<SMSRecycleBean> loadSMSRecycleList() {
ArrayList<SMSRecycleBean> list = new ArrayList<SMSRecycleBean>();
SMSRecycleBean.loadBeanListFromFile(mszSMSRecycleListDataPath, list, SMSRecycleBean.class);
SMSRecycleBean.sortSMSByDeleteDateDesc(list, true);
mDataList.clear();
mDataList.addAll(list);
return mDataList;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.listview_smsrecycle2, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
SMSRecycleBean item = mDataList.get(position);
holder.mtvAddress.setText(AddressUtils.getFormattedAddress(item.getAddress()));
holder.mdatvDeleteDate.setDate(item.getDeleteDate());
holder.mProtectModeTextView.setContentTextWithScale(item.getBody(), mScaleProgress);
}
@Override
public int getItemCount() {
return mDataList.size();
}
static class ViewHolder extends RecyclerView.ViewHolder {
TextView mtvAddress;
DateAgoTextView mdatvDeleteDate;
ProtectModeTextView mProtectModeTextView;
ViewHolder(View itemView) {
super(itemView);
mtvAddress = itemView.findViewById(R.id.listviewsmsrecycle2TextViewAddress);
mdatvDeleteDate = itemView.findViewById(R.id.listviewsmsrecycle2DateAgoTextViewDelete);
mProtectModeTextView = itemView.findViewById(R.id.listviewsmsrecycle2ProtectModeTextView);
}
}
}

View File

@@ -1,290 +0,0 @@
package cc.winboll.studio.mymessagemanager.adapters;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/07/19 17:07:34
* @Describe 短信回收站短信数据适配器
*/
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
import androidx.recyclerview.widget.RecyclerView;
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
import cc.winboll.studio.libappbase.ToastUtils;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity;
import cc.winboll.studio.mymessagemanager.beans.SMSBean;
import cc.winboll.studio.mymessagemanager.beans.SMSRecycleBean;
import cc.winboll.studio.mymessagemanager.utils.AddressUtils;
import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
import cc.winboll.studio.mymessagemanager.utils.TTSPlayRuleUtil;
import cc.winboll.studio.mymessagemanager.utils.UserVisionSystemProtectModeUtil;
import cc.winboll.studio.mymessagemanager.views.DateAgoTextView;
import cc.winboll.studio.mymessagemanager.views.SMSView;
import java.util.ArrayList;
public class SMSRecycleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
public static final String TAG = "SMSRecycleAdapter";
Context mContext;
ArrayList<SMSRecycleBean> mDataList;
String mszSMSRecycleListDataPath;
AppConfigUtil mAppConfigUtil;
public SMSRecycleAdapter(Context context) {
mContext = context;
mAppConfigUtil = AppConfigUtil.getInstance(mContext);
mszSMSRecycleListDataPath = SMSRecycleUtil.getSMSRecycleListDataPath(mContext);
mDataList = new ArrayList<SMSRecycleBean>();
mDataList = loadSMSRecycleList();
}
public ArrayList<SMSRecycleBean> loadSMSRecycleList() {
ArrayList<SMSRecycleBean> list = new ArrayList<SMSRecycleBean>();
SMSRecycleBean.loadBeanListFromFile(mszSMSRecycleListDataPath, list, SMSRecycleBean.class);
SMSRecycleBean.sortSMSByDeleteDateDesc(list, true);
mDataList.clear();
mDataList.addAll(list);
for (int i = 0; i < mDataList.size(); i++) {
mDataList.get(i).setIsSimpleView(true);
}
//ToastUtils.show("mDataList.size() : " + Integer.toString(mDataList.size()));
return mDataList;
}
public void saveSMSRecycleList() {
SMSBean.saveBeanListToFile(mszSMSRecycleListDataPath, mDataList);
}
void restoreSMSRecycleItem(final int position) {
YesNoAlertDialog.show(mContext,
"短信恢复提示",
"是否恢复该短信!"
, (new YesNoAlertDialog.OnDialogResultListener(){
@Override
public void onYes() {
SMSBean item = mDataList.get(position);
long nResultId = 0;
//LogUtils.d(TAG, "item.getType() : " + item.getType());
if (item.getType() == SMSBean.Type.INBOX) {
nResultId = SMSUtil.saveReceiveSms(mContext, item.getAddress(), item.getBody(),
(item.getReadStatus() == SMSBean.ReadStatus.READ) ?"1": "0",
item.getDate(), "inbox");
} else if (item.getType() == SMSBean.Type.SENT) {
nResultId = SMSUtil.saveOldSendedSMS(mContext, item);
}
if (nResultId == 0) {
ToastUtils.show("SMS Restored Failed!\nPlease confirm that the application has the SMS management authority.");
} else {
mDataList.remove(position);
SMSBean.saveBeanListToFile(mszSMSRecycleListDataPath, mDataList);
notifyDataSetChanged();
ToastUtils.show("SMS Restored. ID : " + Long.toString(nResultId));
}
}
@Override
public void onNo() {
}
}));
}
void deleteSMSRecycleItem(final int position) {
YesNoAlertDialog.show(mContext,
"短信删除提示",
"请确认删除动作!"
, (new YesNoAlertDialog.OnDialogResultListener(){
@Override
public void onYes() {
mDataList.remove(position);
SMSBean.saveBeanListToFile(mszSMSRecycleListDataPath, mDataList);
notifyDataSetChanged();
Toast.makeText(mContext, "SMS delete.", Toast.LENGTH_SHORT).show();
}
@Override
public void onNo() {
}
}));
}
public void reLoadSMSList(Context context, String szPhone) {
mDataList = loadSMSRecycleList();
}
@Override
public int getItemViewType(int position) {
if (mDataList.get(position).isSimpleView()) {
return 0;
} else {
return 1;
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == 0) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.listview_smsrecycle_simple, parent, false);
return new SimpleViewHolder(view);
} else {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.listview_smsrecycle, parent, false);
return new ComplexViewHolder(view);
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
final SMSRecycleBean item = mDataList.get(position);
if (holder.getItemViewType() == 0) {
SimpleViewHolder viewHolder = (SimpleViewHolder) holder;
viewHolder.mtvAddress.setText(AddressUtils.getFormattedAddress(item.getAddress()));
viewHolder.mbtnViewBody.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
for (int i = 0; i < mDataList.size(); i++) {
mDataList.get(i).setIsSimpleView(true);
}
item.setIsSimpleView(false);
notifyDataSetChanged();
//ToastUtils.show("setIsSimpleView");
}
});
} else {
final ComplexViewHolder viewHolder = (ComplexViewHolder) holder;
if (item.getType() == SMSBean.Type.INBOX) {
viewHolder.mvLeft.setVisibility(View.GONE);
viewHolder.mvRight.setVisibility(View.VISIBLE);
viewHolder.mSMSView.setSMSType(SMSView.SMSType.INBOX);
viewHolder.mllMain.setGravity(Gravity.LEFT);
} else {
viewHolder.mvLeft.setVisibility(View.VISIBLE);
viewHolder.mvRight.setVisibility(View.GONE);
viewHolder.mSMSView.setSMSType(SMSView.SMSType.SEND);
}
viewHolder.mtvAddress.setText(AddressUtils.getFormattedAddress(item.getAddress()));
viewHolder.mdatvDeleteDate.setDate(item.getDeleteDate());
viewHolder.mdatvDate.setDate(item.getDate());
if(mAppConfigUtil.mAppConfigBean.isSMSRecycleProtectMode()) {
viewHolder.mtvBody.setText("ProtectMode : " + UserVisionSystemProtectModeUtil.PreviewShuffleSMS(item.getBody(), mAppConfigUtil.mAppConfigBean.getProtectModerRefuseChars(), mAppConfigUtil.mAppConfigBean.getProtectModerReplaceChars()));
} else {
viewHolder.mtvBody.setText(item.getBody());
}
/*viewHolder.mTagsAdapter = new TagsAdapter(mContext, item);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(mContext);
viewHolder.mTagsRecyclerView.setLayoutManager(layoutManager);
viewHolder.mTagsRecyclerView.setAdapter(viewHolder.mTagsAdapter);
// 这个设置可以解决嵌套listvew的内部listview拉动问题。
viewHolder.mTagsRecyclerView.setParentScrollView(viewHolder.mScrollView);*/
viewHolder.mllMain.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View p1) {
// 弹出复制菜单
PopupMenu menu = new PopupMenu(mContext, viewHolder.mvMenu);
//加载菜单资源
menu.getMenuInflater().inflate(R.menu.toolbar_item_smsrecycle, menu.getMenu());
menu.getMenuInflater().inflate(R.menu.toolbar_item_sms, menu.getMenu());
//设置点击事件的响应
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
int nItemId = menuItem.getItemId();
if (nItemId == R.id.item_restoresms) {
restoreSMSRecycleItem(position);
} else if (nItemId == R.id.copy) {
// Gets a handle to the clipboard service.
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
// Creates a new text clip to put on the clipboard
ClipData clip = ClipData.newPlainText("simple text", item.getBody());
// Set the clipboard's primary clip.
clipboard.setPrimaryClip(clip);
Toast.makeText(mContext, "Copy to clipboard.", Toast.LENGTH_SHORT).show();
} else if (nItemId == R.id.delete) {
deleteSMSRecycleItem(position);
/*loadSMSRecycleList();
mDataList.remove(item);
saveSMSRecycleList();*/
notifyDataSetChanged();
} else if (nItemId == R.id.addttsrule) {
Intent intent = new Intent(mContext, TTSPlayRuleActivity.class);
intent.putExtra(TTSPlayRuleActivity.EXTRA_TTSDEMOTEXT, viewHolder.mtvBody.getText().toString());
mContext.startActivity(intent);
} else if (nItemId == R.id.testtts) {
//Toast.makeText(mContext, "Testing TTS.", Toast.LENGTH_SHORT).show();
TTSPlayRuleUtil ttsPlayRuleUtil = TTSPlayRuleUtil.getInstance(mContext);
ttsPlayRuleUtil.speakTTSAnalyzeModeText(viewHolder.mtvBody.getText().toString());
}
return true;
}
});
//一定要调用show()来显示弹出式菜单
menu.show();
return true;
}
});
}
}
@Override
public int getItemCount() {
return mDataList.size();
}
private static class SimpleViewHolder extends RecyclerView.ViewHolder {
TextView mtvAddress;
Button mbtnViewBody;
SimpleViewHolder(View itemView) {
super(itemView);
mtvAddress = itemView.findViewById(R.id.listviewsmsrecyclesimpleTextView1);
mbtnViewBody = itemView.findViewById(R.id.listviewsmsrecyclesimpleButton1);
}
}
private static class ComplexViewHolder extends RecyclerView.ViewHolder {
TextView mtvAddress;
DateAgoTextView mdatvDeleteDate;
SMSView mSMSView;
LinearLayout mllMain;
LinearLayout mllContent;
TextView mtvBody;
View mvMenu;
DateAgoTextView mdatvDate;
View mvLeft;
View mvRight;
ComplexViewHolder(View itemView) {
super(itemView);
mtvAddress = itemView.findViewById(R.id.listviewsmsrecycleTextView1);
mdatvDeleteDate = itemView.findViewById(R.id.listviewsmsrecycleDateAgoTextView1);
mSMSView = itemView.findViewById(R.id.listviewsmsrecycleSMSView1);
mllMain = itemView.findViewById(R.id.listviewsmspart1LinearLayout1);
mllContent = itemView.findViewById(R.id.listviewsmspart1LinearLayout2);
mvMenu = itemView.findViewById(R.id.listviewsmsrecycleView1);
mtvBody = itemView.findViewById(R.id.listviewsmspart1TextView1);
mdatvDate = itemView.findViewById(R.id.listviewsmspart1DateAgoTextView1);
mvLeft = itemView.findViewById(R.id.listviewsmsrecycleView1);
mvRight = itemView.findViewById(R.id.listviewsmsrecycleView2);
}
}
}

View File

@@ -1,193 +0,0 @@
package cc.winboll.studio.mymessagemanager.adapters;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/05/18 16:08:20
* @Describe TTSRuleBean RecyclerView Adapter
*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity;
import cc.winboll.studio.mymessagemanager.beans.TTSPlayRuleBean;
import cc.winboll.studio.mymessagemanager.utils.TTSPlayRuleUtil;
import cc.winboll.studio.mymessagemanager.views.TTSRuleView;
import java.util.ArrayList;
public class TTSRuleBeanRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
public static final String TAG = "TTSRuleBeanRecyclerViewAdapter";
Context mContext;
ArrayList<TTSPlayRuleBean> mDataList;
OnTTSRuleChangeListener mOnTTSRuleChangeListener;
TTSPlayRuleUtil mTTSPlayRuleUtil;
public TTSRuleBeanRecyclerViewAdapter(TTSPlayRuleActivity ttsPlayRuleActivity, OnTTSRuleChangeListener onTTSRuleChangeListener) {
mContext = ttsPlayRuleActivity;
mOnTTSRuleChangeListener = onTTSRuleChangeListener;
mTTSPlayRuleUtil = TTSPlayRuleUtil.getInstance(ttsPlayRuleActivity);
mTTSPlayRuleUtil.initTTSPlayRuleActivity(ttsPlayRuleActivity);
mDataList = mTTSPlayRuleUtil.loadConfigData();
}
public void addNewTTSRuleBean(TTSPlayRuleBean bean) {
mTTSPlayRuleUtil.addNewTTSRuleBean(bean);
//notifyDataSetChanged();
}
public void saveConfigData() {
mTTSPlayRuleUtil.saveConfigData();
//notifyDataSetChanged();
}
public void reloadConfigData() {
mDataList = mTTSPlayRuleUtil.loadConfigData();
notifyDataSetChanged();
}
public interface OnTTSRuleChangeListener {
abstract void onTTSRuleChange(TTSPlayRuleBean bean);
}
@Override
public int getItemViewType(int position) {
if (mDataList.get(position).isSimpleView()) {
return 0;
} else {
return 1;
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == 0) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.listview_ttsplayrule_simple, parent, false);
return new SimpleViewHolder(view);
} else {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.listview_ttsplayrule, parent, false);
return new ComplexViewHolder(view);
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
final TTSPlayRuleBean item = mDataList.get(position);
if (holder.getItemViewType() == 0) {
SimpleViewHolder viewHolder = (SimpleViewHolder) holder;
viewHolder.mSortNumber.setText(Integer.toString(position + 1));
viewHolder.mtvDemoSMSText.setText(item.getDemoSMSText());
} else {
final ComplexViewHolder viewHolder = (ComplexViewHolder) holder;
viewHolder.mSortNumber.setText(Integer.toString(position + 1));
viewHolder.mtvDemoSMSText.setText(item.getDemoSMSText());
viewHolder.mTTSRuleView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
mOnTTSRuleChangeListener.onTTSRuleChange(item);
}
});
viewHolder.mbtnUp.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
//Toast.makeText(mContext, Integer.toString(position), Toast.LENGTH_SHORT).show();
mTTSPlayRuleUtil.changeBeanPosition(position, true);
//notifyDataSetChanged();
}
});
viewHolder.mbtnDown.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
//Toast.makeText(mContext, Integer.toString(position), Toast.LENGTH_SHORT).show();
mTTSPlayRuleUtil.changeBeanPosition(position, false);
//notifyDataSetChanged();
}
});
viewHolder.mchbEnable.setChecked(item.isEnable());
viewHolder.mchbEnable.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
mTTSPlayRuleUtil.setBeanEnable(position, ((CheckBox)v).isChecked());
//notifyDataSetChanged();
}
});
viewHolder.mTTSRuleView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View p1) {
// 弹出复制菜单
PopupMenu menu = new PopupMenu(mContext, viewHolder.mSortNumber);
//加载菜单资源
menu.getMenuInflater().inflate(R.menu.toolbar_ttsrule, menu.getMenu());
//设置点击事件的响应
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
int nItemId = menuItem.getItemId();
if (nItemId == R.id.deletettsrule) {
mTTSPlayRuleUtil.deleteTTSRuleBean(position);
//notifyDataSetChanged();
}
return true;
}
});
//一定要调用show()来显示弹出式菜单
menu.show();
return true;
}
});
}
}
@Override
public int getItemCount() {
return mDataList.size();
}
private static class SimpleViewHolder extends RecyclerView.ViewHolder {
TextView mSortNumber;
TextView mtvDemoSMSText;
SimpleViewHolder(View itemView) {
super(itemView);
mSortNumber = itemView.findViewById(R.id.itemttsplayrulesimpleTextView2);
mtvDemoSMSText = itemView.findViewById(R.id.itemttsplayrulesimpleTextView1);
}
}
private static class ComplexViewHolder extends RecyclerView.ViewHolder {
TextView mSortNumber;
TTSRuleView mTTSRuleView;
LinearLayout mllMain;
TextView mtvDemoSMSText;
Button mbtnUp;
Button mbtnDown;
CheckBox mchbEnable;
ComplexViewHolder(View itemView) {
super(itemView);
mSortNumber = itemView.findViewById(R.id.itemttsplayruleTextView2);
mTTSRuleView = itemView.findViewById(R.id.listviewttsplayruleTTSRuleView1);
mllMain = itemView.findViewById(R.id.itemttsplayruleLinearLayout1);
mtvDemoSMSText = itemView.findViewById(R.id.itemttsplayruleTextView1);
mbtnUp = itemView.findViewById(R.id.itemttsplayruleButton1);
mbtnDown = itemView.findViewById(R.id.itemttsplayruleButton2);
mchbEnable = itemView.findViewById(R.id.itemttsplayruleCheckBox1);
}
}
}

View File

@@ -1,197 +0,0 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/06/02 20:07:44
* @Describe 应用配置数据类
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class AppConfigBean extends BaseBean {
public static final String TAG = "AppConfigBean";
// 当前国家代码(如+8612345678901代码就是86.)
String countryCode = "86";
// 是否合并的手机号码前缀
boolean isMergeCountryCodePrefix = true;
// TT语音延时播放毫秒数
int ttsPlayDelayTimes = 3000;
boolean isEnableService = false;
boolean isEnableOnlyReceiveContacts = false;
boolean isEnableTTS = false;
boolean isEnableTTSRuleMode = false;
boolean isSMSRecycleProtectMode = false;
// 保护式预览拒绝显示的字符集
String protectModerRefuseChars = "设定被和谐的字符";
// 保护式预览拒绝显示的字符集的替代字符
String protectModerReplaceChars = "当前替代显示字符";
// 回收站打开的窗口类名 SMSRecycleActivity / SMSRecycle2Activity
String recycleBinClass = "SMSRecycleActivity";
//int appThemeID = ThemeUtil.getThemeID(ThemeUtil.BaseTheme.DEFAULT);
public void setProtectModerRefuseChars(String protectModerRefuseChars) {
this.protectModerRefuseChars = protectModerRefuseChars;
}
public String getProtectModerRefuseChars() {
return protectModerRefuseChars;
}
public void setProtectModerReplaceChars(String protectModerReplaceChars) {
this.protectModerReplaceChars = protectModerReplaceChars;
}
public String getProtectModerReplaceChars() {
return protectModerReplaceChars;
}
public void setRecycleBinClass(String recycleBinClass) {
this.recycleBinClass = recycleBinClass;
}
public String getRecycleBinClass() {
return recycleBinClass;
}
public void setIsSMSRecycleProtectMode(boolean isSMSRecycleProtectMode) {
this.isSMSRecycleProtectMode = isSMSRecycleProtectMode;
}
public boolean isSMSRecycleProtectMode() {
return isSMSRecycleProtectMode;
}
public void setCountryCode(String countryCode) {
this.countryCode = countryCode;
}
public String getCountryCode() {
return countryCode;
}
public void setIsMergeCountryCodePrefix(boolean isMergeCountryCodePrefix) {
this.isMergeCountryCodePrefix = isMergeCountryCodePrefix;
}
public boolean isMergeCountryCodePrefix() {
return isMergeCountryCodePrefix;
}
public void setTtsPlayDelayTimes(int ttsPlayDelayTimes) {
this.ttsPlayDelayTimes = ttsPlayDelayTimes;
}
public int getTtsPlayDelayTimes() {
return ttsPlayDelayTimes;
}
public void setIsEnableService(boolean isEnableService) {
this.isEnableService = isEnableService;
}
public boolean isEnableService() {
return isEnableService;
}
public void setIsEnableOnlyReceiveContacts(boolean isEnableOnlyReceiveContacts) {
this.isEnableOnlyReceiveContacts = isEnableOnlyReceiveContacts;
}
public boolean isEnableOnlyReceiveContacts() {
return isEnableOnlyReceiveContacts;
}
public void setIsEnableTTS(boolean isEnableTTS) {
this.isEnableTTS = isEnableTTS;
}
public boolean isEnableTTS() {
return isEnableTTS;
}
public void setIsEnableTTSRuleMode(boolean isEnableTTSRuleMode) {
this.isEnableTTSRuleMode = isEnableTTSRuleMode;
}
public boolean isEnableTTSRuleMode() {
return isEnableTTSRuleMode;
}
/*public void setAppThemeID(int appThemeID) {
this.appThemeID = appThemeID;
}
public int getAppThemeID() {
return appThemeID;
}
public void setAppTheme(ThemeUtil.BaseTheme baseTheme) {
setAppThemeID(ThemeUtil.getThemeID(baseTheme));
}*/
@Override
public String getName() {
return AppConfigBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
AppConfigBean bean = this;
jsonWriter.name("countryCode").value(bean.getCountryCode());
jsonWriter.name("isMergeCountryCodePrefix").value(bean.isMergeCountryCodePrefix());
jsonWriter.name("ttsPlayDelayTimes").value(bean.getTtsPlayDelayTimes());
jsonWriter.name("isEnableService").value(bean.isEnableService());
jsonWriter.name("isEnableOnlyReceiveContacts").value(bean.isEnableOnlyReceiveContacts());
jsonWriter.name("isEnableTTS").value(bean.isEnableTTS());
jsonWriter.name("isEnableTTSRuleMode").value(bean.isEnableTTSRuleMode());
jsonWriter.name("isSMSRecycleProtectMode").value(bean.isSMSRecycleProtectMode());
jsonWriter.name("protectModerRefuseChars").value(bean.getProtectModerRefuseChars());
jsonWriter.name("protectModerReplaceChars").value(bean.getProtectModerReplaceChars());
jsonWriter.name("recycleBinClass").value(bean.getRecycleBinClass());
//jsonWriter.name("appThemeID").value(bean.getAppThemeID());
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
AppConfigBean bean = new AppConfigBean();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (name.equals("countryCode")) {
bean.setCountryCode(jsonReader.nextString());
} else if (name.equals("isMergeCountryCodePrefix")) {
bean.setIsMergeCountryCodePrefix(jsonReader.nextBoolean());
} else if (name.equals("ttsPlayDelayTimes")) {
bean.setTtsPlayDelayTimes(jsonReader.nextInt());
} else if (name.equals("isEnableService")) {
bean.setIsEnableService(jsonReader.nextBoolean());
} else if (name.equals("isEnableOnlyReceiveContacts")) {
bean.setIsEnableOnlyReceiveContacts(jsonReader.nextBoolean());
} else if (name.equals("isEnableTTS")) {
bean.setIsEnableTTS(jsonReader.nextBoolean());
} else if (name.equals("isEnableTTSRuleMode")) {
bean.setIsEnableTTSRuleMode(jsonReader.nextBoolean());
} else if (name.equals("isSMSRecycleProtectMode")) {
bean.setIsSMSRecycleProtectMode(jsonReader.nextBoolean());
} else if (name.equals("protectModerRefuseChars")) {
bean.setProtectModerRefuseChars(jsonReader.nextString());
} else if (name.equals("protectModerReplaceChars")) {
bean.setProtectModerReplaceChars(jsonReader.nextString());
} else if (name.equals("recycleBinClass")) {
bean.setRecycleBinClass(jsonReader.nextString());
} /*else if (name.equals("appThemeID")) {
bean.setAppThemeID(jsonReader.nextInt());
}*/ else {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return bean;
}
}

View File

@@ -1,88 +0,0 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2023/06/30 23:21:27
* @Describe 应用配置数据类V1 旧版。
*/
import cc.winboll.studio.mymessagemanager.utils.ThemeUtil;
public class AppConfigBean_V1 {
// 当前国家代码(如+8612345678901代码就是86.)
String countryCode = "86";
// 是否合并的手机号码前缀
boolean isMergeCountryCodePrefix = true;
// TT语音延时播放毫秒数
int ttsPlayDelayTimes = 3000;
boolean enableService = false;
boolean enableOnlyReceiveContacts = false;
boolean enableTTS = false;
boolean enableTTSRuleMode = false;
//int appThemeID = ThemeUtil.getThemeID(ThemeUtil.BaseTheme.DEFAULT);
public void setCountryCode(String countryCode) {
this.countryCode = countryCode;
}
public String getCountryCode() {
return countryCode;
}
public void setIsMergeCountryCodePrefix(boolean isMergeCountryCodePrefix) {
this.isMergeCountryCodePrefix = isMergeCountryCodePrefix;
}
public boolean isMergeCountryCodePrefix() {
return isMergeCountryCodePrefix;
}
public void setTtsPlayDelayTimes(int ttsPlayDelayTimes) {
this.ttsPlayDelayTimes = ttsPlayDelayTimes;
}
public int getTtsPlayDelayTimes() {
return ttsPlayDelayTimes;
}
public void setEnableService(boolean enableService) {
this.enableService = enableService;
}
public boolean isEnableService() {
return enableService;
}
public void setEnableOnlyReceiveContacts(boolean enableOnlyReceiveContacts) {
this.enableOnlyReceiveContacts = enableOnlyReceiveContacts;
}
public boolean isEnableOnlyReceiveContacts() {
return enableOnlyReceiveContacts;
}
public void setEnableTTS(boolean enableTTS) {
this.enableTTS = enableTTS;
}
public boolean isEnableTTS() {
return enableTTS;
}
public void setEnableTTSRuleMode(boolean enableTTSRuleMode) {
this.enableTTSRuleMode = enableTTSRuleMode;
}
public boolean isEnableTTSRuleMode() {
return enableTTSRuleMode;
}
/*public void setAppThemeID(int appThemeID) {
this.appThemeID = appThemeID;
}
public int getAppThemeID() {
return appThemeID;
}*/
}

View File

@@ -1,29 +0,0 @@
package cc.winboll.studio.mymessagemanager.beans;
public class ContractsBean {
private String mszName;
private String mszTelPhone;
public ContractsBean(String szName, String szTelPhone) {
this.mszName = szName;
this.mszTelPhone = szTelPhone;
}
public void setName(String szName) {
this.mszName = szName;
}
public String getName() {
return mszName;
}
public void setTelPhone(String szTelPhone) {
this.mszTelPhone = szTelPhone;
}
public String getTelPhone() {
return mszTelPhone;
}
}

View File

@@ -1,53 +0,0 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/07/19 13:10:44
* @Describe 短信通知栏消息结构
*/
public class MessageNotificationBean {
private int messageId;
private String mszPhone;
private String mszTitle;
private String mszContent;
public MessageNotificationBean(int messageId, String mszPhone, String mszTitle, String mszContent) {
this.messageId = messageId;
this.mszPhone = mszPhone;
this.mszTitle = mszTitle;
this.mszContent = mszContent;
}
public void setMessageId(int messageId) {
this.messageId = messageId;
}
public int getMessageId() {
return messageId;
}
public void setPhone(String szPhone) {
this.mszPhone = szPhone;
}
public String getPhone() {
return mszPhone;
}
public void setTitle(String szTitle) {
this.mszTitle = szTitle;
}
public String getTitle() {
return mszTitle;
}
public void setContent(String szContent) {
this.mszContent = szContent;
}
public String getContent() {
return mszContent;
}
}

View File

@@ -1,39 +0,0 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/07/19 13:10:44
* @Describe 联系人信息类
*/
public class PhoneBean {
//联系人姓名
private String mszName;
//电话号码
private String mszTelPhone;
public String getName() {
return mszName;
}
public void setName(String szName) {
this.mszName = szName;
}
public String getTelPhone() {
return mszTelPhone;
}
public void setTelPhone(String szTelPhone) {
this.mszTelPhone = szTelPhone;
}
public PhoneBean() {
}
public PhoneBean(String szName, String szTelPhone) {
this.mszName = szName;
this.mszTelPhone = szTelPhone;
}
}

View File

@@ -1,121 +0,0 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/05/30 10:57:14
* @Describe 短信接收规则类
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class SMSAcceptRuleBean extends BaseBean {
public static final String TAG = "SMSAcceptRuleBean";
// 规则类型枚举
public enum RuleType { ACCEPT, REFUSE, REGEXPPIUTILS_ISPPIOK_FALSE }
// 用户ID
int userId = -1;
// 规则数据
String ruleData = "";
// 是否启用
boolean isEnable = false;
// 规则类型
RuleType ruleType = RuleType.REFUSE;
// 是否简单视图
boolean isSimpleView = false;
public SMSAcceptRuleBean() {}
public SMSAcceptRuleBean(int userId, String ruleData, boolean isEnable, RuleType ruleType, boolean isSimpleView) {
this.userId = userId;
this.ruleData = ruleData;
this.isEnable = isEnable;
this.ruleType = ruleType;
this.isSimpleView = isSimpleView;
}
public void setRuleType(RuleType ruleType) {
this.ruleType = ruleType;
}
public RuleType getRuleType() {
return ruleType;
}
public void setIsSimpleView(boolean isSimpleView) {
this.isSimpleView = isSimpleView;
}
public boolean isSimpleView() {
return isSimpleView;
}
public void setUserId(int userID) {
this.userId = userID;
}
public int getUserId() {
return userId;
}
public void setRuleData(String ruleData) {
this.ruleData = ruleData;
}
public String getRuleData() {
return ruleData;
}
public void setIsEnable(boolean isEnable) {
this.isEnable = isEnable;
}
public boolean isEnable() {
return isEnable;
}
@Override
public String getName() {
return SMSAcceptRuleBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
SMSAcceptRuleBean bean = this;
jsonWriter.name("userId").value(bean.getUserId());
jsonWriter.name("ruleData").value(bean.getRuleData());
jsonWriter.name("isEnable").value(bean.isEnable());
jsonWriter.name("ruleType").value(bean.getRuleType().ordinal());
jsonWriter.name("isSimpleView").value(bean.isSimpleView());
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
SMSAcceptRuleBean bean = new SMSAcceptRuleBean();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (name.equals("userId")) {
bean.setUserId(jsonReader.nextInt());
} else if (name.equals("ruleData")) {
bean.setRuleData(jsonReader.nextString());
} else if (name.equals("isEnable")) {
bean.setIsEnable(jsonReader.nextBoolean());
} else if (name.equals("ruleType")) {
bean.setRuleType(RuleType.values()[jsonReader.nextInt()]);
} else if (name.equals("isSimpleView")) {
bean.setIsSimpleView(jsonReader.nextBoolean());
} else {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return bean;
}
}

View File

@@ -1,50 +0,0 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/05/30 10:57:14
* @Describe 短信接收规则类V1 旧版。
*/
public class SMSAcceptRuleBean_V1 {
public static final String TAG = "SMSAcceptRuleBean_V1";
// 用户ID
String userID = "";
// 规则数据
String ruleData = "";
// 是否启用
boolean enable = false;
public SMSAcceptRuleBean_V1() {}
public SMSAcceptRuleBean_V1(String userID, String ruleData, boolean enable) {
this.userID = userID;
this.ruleData = ruleData;
this.enable = enable;
}
public void setUserID(String userID) {
this.userID = userID;
}
public String getUserID() {
return userID;
}
public void setRuleData(String ruleData) {
this.ruleData = ruleData;
}
public String getRuleData() {
return ruleData;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
public boolean isEnable() {
return enable;
}
}

View File

@@ -1,272 +0,0 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/05/30 10:57:14
* @Describe 短信信息类
参考资料:
https://blog.csdn.net/freeking101/article/details/121575985
获取短信只需要得到 ContentResolver 就行了,它的 URI 主要有:
content://sms/ 所有短信
content://sms/inbox 收件箱
content://sms/sent 已发送
content://sms/draft 草稿
content://sms/outbox 发件箱
content://sms/failed 发送失败
content://sms/queued 待发送列表
SMS 数据库中的字段如下:
_id 一个自增字段从1开始
thread_id 序号同一发信人的id相同
address 发件人手机号码
person 联系人列表里的序号陌生人为null
date 发件日期
protocol 协议,分为: 0 SMS_RPOTO, 1 MMS_PROTO
read 是否阅读 0未读 1已读
status 状态 -1接收0 complete, 64 pending, 128 failed
type ALL = 0;INBOX = 1;SENT = 2;DRAFT = 3;OUTBOX = 4;FAILED = 5; QUEUED = 6;
body 短信内容
service_center 短信服务中心号码编号。如+8613800755500
subject 短信的主题
reply_path_present TP-Reply-Path
locked
*/
import android.content.ContentValues;
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
public class SMSBean extends BaseBean {
//public enum Type { ALL(8), INBOX(0), SENT, DRAFT, OUTBOX, FAILED, QUEUED, TRASH }
public enum Type { ALL(0), INBOX(1), SENT(2), DRAFT(3), OUTBOX(4), FAILED(5), QUEUED(6), TRASH(7);
static String[] _mlistName = { "所有短信", "接收", "发送", "草稿", "发件箱", "发送失败", "待发送列表", "回收站" };
private int value = 0;
private Type(int value) { //必须是private的否则编译错误
this.value = value;
}
}
public enum ReadStatus { UNREAD, READ }
transient private static String _ContentValuesName_address = "address";
transient private static String _ContentValuesName_body = "body";
transient private static String _ContentValuesName_read = "read";
transient private static String _ContentValuesName_date = "date";
// 短信标识
protected int id;
// 发件人手机号码
protected String mszAddress;
// 短信内容
protected String mszBody;
// 发件日期
protected long mnDate;
// 短息归类
protected Type mType;
// 是否阅读
protected ReadStatus mReadStatus;
// 联系人列表里的序号陌生人为null
protected int mnPerson;
public SMSBean() {
this.id = -1;
this.mszAddress = "";
this.mszBody = "";
this.mnDate = 0;
this.mType = Type.INBOX;
this.mReadStatus = ReadStatus.UNREAD;
this.mnPerson = 0;
}
public SMSBean(int id, String mszAddress, String mszBody, long mnDate, Type mType, ReadStatus mReadStatus, int mnPerson) {
this.id = id;
this.mszAddress = mszAddress;
this.mszBody = mszBody;
this.mnDate = mnDate;
this.mType = mType;
this.mReadStatus = mReadStatus;
this.mnPerson = mnPerson;
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
public void setAddress(String szAddress) {
this.mszAddress = szAddress;
}
public String getAddress() {
return mszAddress;
}
public void setBody(String szBody) {
this.mszBody = szBody;
}
public String getBody() {
return mszBody;
}
public void setDate(long date) {
this.mnDate = date;
}
public long getDate() {
return mnDate;
}
public void setType(Type type) {
this.mType = type;
}
public Type getType() {
return mType;
}
public void setReadStatus(ReadStatus readStatus) {
this.mReadStatus = readStatus;
}
public ReadStatus getReadStatus() {
return mReadStatus;
}
public void setPerson(int person) {
this.mnPerson = person;
}
public int getPerson() {
return mnPerson;
}
@Override
public String getName() {
return SMSBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
SMSBean bean = this;
jsonWriter.name("id").value(bean.getId());
jsonWriter.name("mszAddress").value(bean.getAddress());
jsonWriter.name("mszBody").value(bean.getBody());
jsonWriter.name("mnDate").value(bean.getDate());
jsonWriter.name("mType").value(bean.getType().ordinal());
jsonWriter.name("mReadStatus").value(bean.getReadStatus().ordinal());
jsonWriter.name("mnPerson").value(bean.getPerson());
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if(super.initObjectsFromJsonReader(jsonReader, name)) { return true; }
else{
if (name.equals("id")) {
setId(jsonReader.nextInt());
} else if (name.equals("mszAddress")) {
setAddress(jsonReader.nextString());
} else if (name.equals("mszBody")) {
setBody(jsonReader.nextString());
} else if (name.equals("mnDate")) {
setDate(jsonReader.nextLong());
} else if (name.equals("mType")) {
setType(Type.values()[jsonReader.nextInt()]);
} else if (name.equals("mReadStatus")) {
setReadStatus(ReadStatus.values()[jsonReader.nextInt()]);
} else if (name.equals("mnPerson")) {
setPerson(jsonReader.nextInt());
} 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;
}
public static ContentValues createOldSendedSMSContentValues(SMSBean smsBean) {
ContentValues result = new ContentValues();
result.put(_ContentValuesName_address, smsBean.mszAddress);
result.put(_ContentValuesName_body, smsBean.mszBody);
result.put(_ContentValuesName_read, smsBean.mReadStatus.toString()); //"0" for have not read sms and "1" for have read sms
result.put(_ContentValuesName_date, Long.toString(smsBean.getDate()));
return result;
}
public static ContentValues createSendedSMSContentValues(SMSBean smsBean) {
ContentValues result = new ContentValues();
result.put(_ContentValuesName_address, smsBean.mszAddress);
result.put(_ContentValuesName_body, smsBean.mszBody);
result.put(_ContentValuesName_read, smsBean.mReadStatus.toString()); //"0" for have not read sms and "1" for have read sms
result.put(_ContentValuesName_date, Long.toString(System.currentTimeMillis()));
return result;
}
public static String getTypeName(Type type) {
return Type._mlistName[type.ordinal()];
}
@Override
public String toString() {
String szResult = "\n";
szResult += "mszAddress is (" + mszAddress + ")\n";
szResult += "mszBody is (" + mszBody + ")\n";
szResult += "mnDate is (" + Long.toString(mnDate) + ")\n";
szResult += "mType is (" + mType.name() + ")\n";
if (mReadStatus != null) {
szResult += "mReadStatus is (" + mReadStatus.name() + ")\n";
}
szResult += "mnPerson is (" + Integer.toString(mnPerson) + ")\n";
return szResult;
}
public static void sortSMSByDateDesc(ArrayList<SMSBean> list, boolean isDesc) {
Collections.sort(list, new SortSMSByDateDesc(isDesc));
}
private static class SortSMSByDateDesc implements Comparator<SMSBean> {
private boolean mIsDesc = true;
// isDesc 是否降序排列
public SortSMSByDateDesc(boolean isDesc) {
mIsDesc = isDesc;
}
Collator cmp = Collator.getInstance(java.util.Locale.CHINA);
@Override
public int compare(SMSBean o1, SMSBean o2) {
boolean b0_1 = (o1.getDate() < o2.getDate());
if (mIsDesc) {
return b0_1 ?1: -1;
} else {
return b0_1 ?-1: 1;
}
}
}
}

View File

@@ -1,127 +0,0 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/07/20 01:51:44
* @Describe 回收站短信存储类
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
public class SMSRecycleBean extends SMSBean {
public static final String TAG = "SMSRecycleBean";
// 短信删除日期
long deleteDate;
// 当前是否是简单视图
boolean isSimpleView;
public void setDeleteDate(long deleteDate) {
this.deleteDate = deleteDate;
}
public long getDeleteDate() {
return deleteDate;
}
public void setIsSimpleView(boolean isSimpleView) {
this.isSimpleView = isSimpleView;
}
public boolean isSimpleView() {
return isSimpleView;
}
public SMSRecycleBean() {
}
public SMSRecycleBean(SMSBean smsBean, long deleteDate) {
super.id = smsBean.getId();
super.mszAddress = smsBean.getAddress();
super.mszBody = smsBean.getBody();
super.mnDate = smsBean.getDate();
super.mType = smsBean.getType();
super.mReadStatus = smsBean.getReadStatus();
super.mnPerson = smsBean.getPerson();
this.deleteDate = deleteDate;
this.isSimpleView = true;
}
@Override
public String getName() {
return SMSRecycleBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
SMSRecycleBean bean = this;
jsonWriter.name("deleteDate").value(bean.getDeleteDate());
jsonWriter.name("isSimpleView").value(bean.isSimpleView());
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
/*SMSRecycleBean bean = new SMSRecycleBean((SMSBean)super.readBeanFromJsonReader(jsonReader), 0);
// 只有在读取完成后才能获取整个JSON字符串
String completeJson = jsonReader.toString();
JsonReader newJsonReader = new JsonReader(new StringReader(completeJson));
newJsonReader.setLenient(true);
LogUtils.d(TAG, completeJson);*/
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (!initObjectsFromJsonReader(jsonReader, name)) {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return this;
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if(super.initObjectsFromJsonReader(jsonReader, name)) { return true; }
else{
if (name.equals("deleteDate")) {
setDeleteDate(jsonReader.nextLong());
} else if (name.equals("isSimpleView")) {
setIsSimpleView(jsonReader.nextBoolean());
} else {
return false;
}
}
return true;
}
public static void sortSMSByDeleteDateDesc(ArrayList<SMSRecycleBean> list, boolean isDesc) {
Collections.sort(list, new SortSMSByDeleteDateDesc(isDesc));
}
private static class SortSMSByDeleteDateDesc implements Comparator<SMSRecycleBean> {
private boolean mIsDesc = true;
// isDesc 是否降序排列
public SortSMSByDeleteDateDesc(boolean isDesc) {
mIsDesc = isDesc;
}
Collator cmp = Collator.getInstance(java.util.Locale.CHINA);
@Override
public int compare(SMSRecycleBean o1, SMSRecycleBean o2) {
boolean b0_1 = (o1.getDeleteDate() < o2.getDeleteDate());
if (mIsDesc) {
return b0_1 ?1: -1;
} else {
return b0_1 ?-1: 1;
}
}
}
}

View File

@@ -1,147 +0,0 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
* @Date 2024/05/28 20:22:12
* @Describe TTS 语音播放规则类
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class TTSPlayRuleBean extends BaseBean {
public static final String TAG = "TTSPlayRuleBean";
// 用户ID
int userId = -1;
// TTS语音规则名称
String ruleName = "";
// 短信测试文本
String demoSMSText = "";
// 短信内容查询正则文本
String patternText = "";
// TTS语音播报正则文本
String ttsRuleText = "";
// 是否启用简单视图
boolean isSimpleView = false;
// 是否启用规则
boolean isEnable = false;
public TTSPlayRuleBean() {}
public TTSPlayRuleBean(int userId, String ruleName, String demoSMSText, String patternText, String ttsRuleText, boolean isSimpleView, boolean isEnable) {
this.userId = userId;
this.ruleName = ruleName;
this.demoSMSText = demoSMSText;
this.patternText = patternText;
this.ttsRuleText = ttsRuleText;
this.isSimpleView = isSimpleView;
this.isEnable = isEnable;
}
public void setUserId(int userId) {
this.userId = userId;
}
public int getUserId() {
return userId;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public String getRuleName() {
return ruleName;
}
public void setDemoSMSText(String demoSMSText) {
this.demoSMSText = demoSMSText;
}
public String getDemoSMSText() {
return demoSMSText;
}
public void setPatternText(String patternText) {
this.patternText = patternText;
}
public String getPatternText() {
return patternText;
}
public void setTtsRuleText(String ttsRuleText) {
this.ttsRuleText = ttsRuleText;
}
public String getTtsRuleText() {
return ttsRuleText;
}
public void setIsSimpleView(boolean isSimpleView) {
this.isSimpleView = isSimpleView;
}
public boolean isSimpleView() {
return isSimpleView;
}
public void setIsEnable(boolean isEnable) {
this.isEnable = isEnable;
}
public boolean isEnable() {
return isEnable;
}
@Override
public String getName() {
return TTSPlayRuleBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
TTSPlayRuleBean bean = this;
jsonWriter.name("userId").value(bean.userId);
jsonWriter.name("ruleName").value(bean.ruleName);
jsonWriter.name("demoSMSText").value(bean.demoSMSText);
jsonWriter.name("patternText").value(bean.patternText);
jsonWriter.name("ttdRuleText").value(bean.ttsRuleText);
jsonWriter.name("isSimpleView").value(bean.isSimpleView);
jsonWriter.name("isEnable").value(bean.isEnable);
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
TTSPlayRuleBean bean = new TTSPlayRuleBean();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (name.equals("userId")) {
bean.setUserId(jsonReader.nextInt());
} else if (name.equals("ruleName")) {
bean.setRuleName(jsonReader.nextString());
} else if (name.equals("demoSMSText")) {
bean.setDemoSMSText(jsonReader.nextString());
} else if (name.equals("patternText")) {
bean.setPatternText(jsonReader.nextString());
} else if (name.equals("ttdRuleText")) {
bean.setTtsRuleText(jsonReader.nextString());
} else if (name.equals("isSimpleView")) {
bean.setIsSimpleView(jsonReader.nextBoolean());
} else if (name.equals("isEnable")) {
bean.setIsEnable(jsonReader.nextBoolean());
} else {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return bean;
}
}

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