Compare commits

..

22 Commits

Author SHA1 Message Date
ZhanGSKen
e7633e53ed <contacts>APK 1.0.2 release Publish. 2025-02-26 04:37:18 +08:00
ZhanGSKen
3734a659ff 添加主要服务启动设置 2025-02-26 04:35:14 +08:00
ZhanGSKen
b9f740c386 添加系统设置静音时的权限异常处理,添加固定的应用铃声音量设置。忽略其他应用设置的铃声音量。 2025-02-26 03:40:41 +08:00
ZhanGSKen
820574a4ba 2025-02-25 23:47:18 +08:00
ZhanGSKen
36368bd28e 1133 2025-02-25 23:33:40 +08:00
ZhanGSKen
90e66889a9 添加MyMessageManager项目 2025-02-25 18:53:54 +08:00
ZhanGSKen
3031c9bfe0 <libappbase>Library Release 2.0.2 2025-02-25 16:51:23 +08:00
ZhanGSKen
51acbb1f54 <appbase>APK 2.0.2 release Publish. 2025-02-25 16:51:09 +08:00
ZhanGSKen
26fc0b4684 <libappbase>Library Release 2.0.1 2025-02-25 16:51:01 +08:00
ZhanGSKen
0bf0a1497a <contacts>APK 1.0.1 release Publish. 2025-02-25 00:17:29 +08:00
ZhanGSKen
2cc3850c95 优化铃声设置 2025-02-25 00:15:48 +08:00
ZhanGSKen
63c10e6dc9 添加溯源地址 2025-02-22 00:02:48 +08:00
ZhanGSKen
539afd0861 <contacts>APK 1.0.0 release Publish. 2025-02-21 12:18:00 +08:00
ZhanGSKen
234d2d57de 添加黑名单规则和区号规则设定 2025-02-21 11:37:22 +08:00
ZhanGSKen
c16c6bba74 接收电话时预先静音模式调试完成 2025-02-21 09:47:43 +08:00
ZhanGSKen
c590c96fa6 基本电话接听与拨打功能完成 2025-02-21 06:13:51 +08:00
ZhanGSKen
64a9712294 添加电话拨打功能 2025-02-20 17:29:33 +08:00
ZhanGSKen
e5dfd5b975 拨号基本框架设计完成 2025-02-20 14:59:09 +08:00
ZhanGSKen
ffac543f6f 精简代码 2025-02-20 11:28:57 +08:00
ZhanGSKen
1baa0c5a61 更新类库,不同应用包之间广播消息接收调试通过。 2025-02-14 03:12:43 +08:00
ZhanGSKen
b0e81fc960 添加主服务 2025-02-13 07:29:48 +08:00
ZhanGSKen
75b2245061 添加初始 Contacts 项目 2025-02-12 23:28:42 +08:00
197 changed files with 14837 additions and 8 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Feb 25 16:50:23 HKT 2025
stageCount=2
#Tue Feb 25 16:51:17 HKT 2025
stageCount=3
libraryProject=libappbase
baseVersion=2.0
publishVersion=2.0.1
publishVersion=2.0.2
buildCount=0
baseBetaVersion=2.0.2
baseBetaVersion=2.0.3

40
contacts/README.md Normal file
View File

@@ -0,0 +1,40 @@
# Contacts
源码参考自:
https://github.com/aJIEw/PhoneCallApp.git
#### 介绍
通讯录与拨号
#### 软件架构
适配安卓应用 [AIDE Pro] 的 Gradle 编译结构。
也适配安卓应用 [AndroidIDE] 的 Gradle 编译结构。
#### Gradle 编译说明
调试版编译命令 gradle assembleBetaDebug
阶段版编译命令 gradle assembleStageRelease
#### 使用说明
在安卓系统中需要设置两个权限允许。
1.自启动权限允许。
2.省电策略-无限制权限允许。
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码 : ZhanGSKen(ZhanGSKen@AliYun.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/)
#### 参考文档

View File

@@ -0,0 +1 @@

71
contacts/build.gradle Normal file
View File

@@ -0,0 +1,71 @@
apply plugin: 'com.android.application'
apply from: '../.winboll/winboll_app_build.gradle'
apply from: '../.winboll/winboll_lint_build.gradle'
def genVersionName(def versionName){
// 检查编译标志位配置
assert (winbollBuildProps['stageCount'] != null)
assert (winbollBuildProps['baseVersion'] != null)
// 保存基础版本号
winbollBuildProps.setProperty("baseVersion", "${versionName}");
//保存编译标志配置
FileOutputStream fos = new FileOutputStream(winbollBuildPropsFile)
winbollBuildProps.store(fos, "${winbollBuildPropsDesc}");
fos.close();
// 返回编译版本号
return "${versionName}." + winbollBuildProps['stageCount']
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "cc.winboll.studio.contacts"
minSdkVersion 26
targetSdkVersion 29
versionCode 1
// versionName 更新后需要手动设置
// 项目模块目录的 build.gradle 文件的 stageCount=0
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
versionName "1.0"
if(true) {
versionName = genVersionName("${versionName}")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}
dependencies {
// 二维码使用的类库
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.github.getActivity:ToastUtils:10.5'
api 'com.jcraft:jsch:0.1.55'
api 'org.jsoup:jsoup:1.13.1'
api 'com.squareup.okhttp3:okhttp:4.4.1'
api 'androidx.appcompat:appcompat:1.1.0'
api 'androidx.viewpager:viewpager:1.0.0'
api 'androidx.fragment:fragment:1.1.0'
api 'com.google.android.material:material:1.4.0'
api 'cc.winboll.studio:libapputils:9.3.2'
api 'cc.winboll.studio:libappbase:1.5.6'
api fileTree(dir: 'libs', include: ['*.jar'])
}

View File

@@ -0,0 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Wed Feb 26 04:37:17 HKT 2025
stageCount=3
libraryProject=
baseVersion=1.0
publishVersion=1.0.2
buildCount=0
baseBetaVersion=1.0.3

17
contacts/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,13 @@
<?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
tools:replace="android:icon"
android:icon="@drawable/ic_winbollbeta">
<!-- Put flavor specific code here -->
</application>
</manifest>

View File

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

View File

@@ -0,0 +1,187 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="cc.winboll.studio.contacts">
<!-- BIND_AUTOFILL_SERVICE -->
<uses-permission android:name="android.permission.BIND_AUTOFILL_SERVICE"/>
<!-- 拨打电话 -->
<uses-permission android:name="android.permission.CALL_PHONE"/>
<!-- 读取手机状态和身份 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<!-- 修改系统设置 -->
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<!-- 重新设置外拨电话的路径 -->
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
<!-- 读取联系人 -->
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<!-- 修改您的通讯录 -->
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<!-- 此应用可显示在其他应用上方 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<!-- 更改您的音频设置 -->
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<application
android:name=".App"
android:allowBackup="true"
android:icon="@drawable/ic_winboll"
android:label="@string/app_name"
android:theme="@style/MyAppTheme"
android:supportsRtl="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
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=".activities.CallActivity"
android:label="CallActivity"
android:launchMode="singleTask"
android:exported="true">
</activity>
<activity
android:name=".phonecallui.PhoneCallActivity"
android:launchMode="singleInstance"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.DIAL"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="tel"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.DIAL"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="cc.winboll.studio.contacts.activities.SettingsActivity"/>
<service
android:name="cc.winboll.studio.contacts.services.MainService"
android:exported="true"/>
<service android:name="cc.winboll.studio.contacts.services.AssistantService"/>
<service
android:name=".phonecallui.PhoneCallService"
android:permission="android.permission.BIND_INCALL_SERVICE"
android:exported="false">
<meta-data
android:name="android.telecom.IN_CALL_SERVICE_UI"
android:value="true"/>
<intent-filter>
<action android:name="android.telecom.InCallService"/>
</intent-filter>
</service>
<service
android:name=".listenphonecall.CallListenerService"
android:enabled="true"
android:exported="false">
<intent-filter android:priority="1000">
<action android:name=".service.CallShowService"/>
</intent-filter>
</service>
<receiver android:name=".receivers.MainReceiver">
<intent-filter>
<action android:name="cc.winboll.studio.contacts.receivers.MainReceiver"/>
</intent-filter>
</receiver>
<receiver
android:name=".widgets.APPStatusWidget"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
<action android:name="cc.winboll.studio.contacts.widgets.APPStatusWidget.ACTION_STATUS_ACTIVE"/>
<action android:name="cc.winboll.studio.contacts.widgets.APPStatusWidget.ACTION_STATUS_NOACTIVE"/>
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/appwidget_provider_info"/>
</receiver>
<receiver android:name=".widgets.APPStatusWidgetClickListener">
<intent-filter>
<action android:name="cc.winboll.studio.contacts.widgets.APPStatusWidgetClickListener.ACTION_APPICON_CLICK"/>
</intent-filter>
</receiver>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/studio_provider"/>
</provider>
</application>
</manifest>

View File

@@ -0,0 +1,59 @@
package cc.winboll.studio.contacts;
import android.app.Activity;
import java.util.ArrayList;
import java.util.List;
public class ActivityStack {
private static final ActivityStack INSTANCE = new ActivityStack();
private List<Activity> activities = new ArrayList<>();
public static ActivityStack getInstance() {
return INSTANCE;
}
public void addActivity(Activity activity) {
activities.add(activity);
}
public Activity getTopActivity() {
if (activities.isEmpty()) {
return null;
}
return activities.get(activities.size() - 1);
}
public void finishTopActivity() {
if (!activities.isEmpty()) {
activities.remove(activities.size() - 1).finish();
}
}
public void finishActivity(Activity activity) {
if (activity != null) {
activities.remove(activity);
activity.finish();
}
}
public void finishActivity(Class activityClass) {
for (Activity activity : activities) {
if (activity.getClass().equals(activityClass)) {
finishActivity(activity);
}
}
}
public void finishAllActivity() {
if (!activities.isEmpty()) {
for (Activity activity : activities) {
activity.finish();
activities.remove(activity);
}
}
}
}

View File

@@ -0,0 +1,28 @@
package cc.winboll.studio.contacts;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/12/08 15:10:51
* @Describe 全局应用类
*/
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libapputils.app.WinBollActivityManager;
public class App extends GlobalApplication {
public static final String TAG = "App";
@Override
public void onCreate() {
// 必须在调用基类前设置应用调试标志,
// 这样可以预先设置日志与数据的存储根目录。
setIsDebuging(this, BuildConfig.DEBUG);
super.onCreate();
// 设置 WinBoll 应用 UI 类型
WinBollActivityManager.getInstance(this).setWinBollUI_TYPE(WinBollActivityManager.WinBollUI_TYPE.Aplication);
LogUtils.d(TAG, "onCreate");
}
}

View File

@@ -0,0 +1,416 @@
package cc.winboll.studio.contacts;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.role.RoleManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.telecom.TelecomManager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.viewpager.widget.ViewPager;
import cc.winboll.studio.contacts.R;
import cc.winboll.studio.contacts.activities.CallActivity;
import cc.winboll.studio.contacts.adapters.MyPagerAdapter;
import cc.winboll.studio.contacts.beans.MainServiceBean;
import cc.winboll.studio.contacts.services.MainService;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.LogView;
import cc.winboll.studio.libapputils.app.IWinBollActivity;
import cc.winboll.studio.libapputils.app.WinBollActivityManager;
import cc.winboll.studio.libapputils.bean.APPInfo;
import cc.winboll.studio.libapputils.view.YesNoAlertDialog;
import cc.winboll.studio.contacts.listenphonecall.CallListenerService;
import com.google.android.material.tabs.TabLayout;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import android.content.DialogInterface;
import cc.winboll.studio.contacts.activities.SettingsActivity;
import cc.winboll.studio.contacts.beans.MainServiceBean;
import cc.winboll.studio.contacts.services.MainService;
final public class MainActivity extends AppCompatActivity implements IWinBollActivity, ViewPager.OnPageChangeListener, View.OnClickListener {
public static final String TAG = "MainActivity";
public static final int REQUEST_HOME_ACTIVITY = 0;
public static final int REQUEST_ABOUT_ACTIVITY = 1;
public static final String ACTION_SOS = "cc.winboll.studio.libappbase.WinBoll.ACTION_SOS";
LogView mLogView;
Toolbar mToolbar;
CheckBox cbMainService;
MainServiceBean mMainServiceBean;
ViewPager viewPager;
private List<View> views; //用来存放放进ViewPager里面的布局
//实例化存储imageView导航原点的集合
ImageView[] imageViews;
//MyPagerAdapter adapter;//适配器
MyPagerAdapter pagerAdapter;
LinearLayout linearLayout;//下标所在在LinearLayout布局里
int currentPoint = 0;//当前被选中中页面的下标
private static final int DIALER_REQUEST_CODE = 1;
@Override
public AppCompatActivity getActivity() {
return this;
}
@Override
public APPInfo getAppInfo() {
// String szBranchName = "contacts";
//
// APPInfo appInfo = AboutActivityFactory.buildDefaultAPPInfo();
// appInfo.setAppName("Contacts");
// appInfo.setAppIcon(cc.winboll.studio.libapputils.R.drawable.ic_winboll);
// appInfo.setAppDescription("Contacts Description");
// appInfo.setAppGitName("APP");
// appInfo.setAppGitOwner("Studio");
// appInfo.setAppGitAPPBranch(szBranchName);
// appInfo.setAppGitAPPSubProjectFolder(szBranchName);
// appInfo.setAppHomePage("https://www.winboll.cc/studio/details.php?app=Contacts");
// appInfo.setAppAPKName("Contacts");
// appInfo.setAppAPKFolderName("Contacts");
// return appInfo;
return null;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// 接收并处理 Intent 数据,函数 Intent 处理接收就直接返回
//if (prosessIntents(getIntent())) return;
// 以下正常创建主窗口
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 初始化工具栏
mToolbar = findViewById(R.id.activitymainToolbar1);
setSupportActionBar(mToolbar);
if (isEnableDisplayHomeAsUp()) {
// 显示后退按钮
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
getSupportActionBar().setSubtitle(getTag());
initData();
initView();
//initPoint();//调用初始化导航原点的方法
viewPager.addOnPageChangeListener(this);//滑动事件
ViewPager viewPager = findViewById(R.id.activitymainViewPager1);
MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(pagerAdapter);
TabLayout tabLayout = findViewById(R.id.activitymainTabLayout1);
tabLayout.setupWithViewPager(viewPager);
// mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
// if (mMainServiceBean == null) {
// mMainServiceBean = new MainServiceBean();
// }
// cbMainService = findViewById(R.id.activitymainCheckBox1);
// cbMainService.setChecked(mMainServiceBean.isEnable());
// cbMainService.setOnClickListener(new View.OnClickListener(){
// @Override
// public void onClick(View view) {
// if (cbMainService.isChecked()) {
// MainService.startMainService(MainActivity.this);
// } else {
// MainService.stopMainService(MainActivity.this);
// }
// }
// });
MainServiceBean mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
if (mMainServiceBean == null) {
mMainServiceBean = new MainServiceBean();
MainServiceBean.saveBean(this, mMainServiceBean);
}
if (mMainServiceBean.isEnable()) {
MainService.startMainService(this);
}
}
//初始化view即显示的图片
void initView() {
viewPager = findViewById(R.id.activitymainViewPager1);
pagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(pagerAdapter);
//adapter = new MyPagerAdapter(views);
//viewPager = findViewById(R.id.activitymainViewPager1);
//viewPager.setAdapter(adapter);
//linearLayout = findViewById(R.id.activitymainLinearLayout1);
//initPoint();//初始化页面下方的点
viewPager.setOnPageChangeListener(this);
}
//初始化所要显示的布局
void initData() {
ViewPager viewPager = findViewById(R.id.activitymainViewPager1);
LayoutInflater inflater = LayoutInflater.from(getActivity());
View view1 = inflater.inflate(R.layout.fragment_call, viewPager, false);
View view2 = inflater.inflate(R.layout.fragment_contacts, viewPager, false);
View view3 = inflater.inflate(R.layout.fragment_log, viewPager, false);
views = new ArrayList<>();
views.add(view1);
views.add(view2);
views.add(view3);
}
// void initPoint() {
// imageViews = new ImageView[5];//实例化5个图片
// for (int i = 0; i < linearLayout.getChildCount(); i++) {
// imageViews[i] = (ImageView) linearLayout.getChildAt(i);
// imageViews[i].setImageResource(R.drawable.ic_launcher);
// imageViews[i].setOnClickListener(this);//点击导航点,即可跳转
// imageViews[i].setTag(i);//重复利用实例化的对象
// }
// currentPoint = 0;//默认第一个坐标
// imageViews[currentPoint].setImageResource(R.drawable.ic_launcher);
// }
//OnPageChangeListener接口要实现的三个方法
/* onPageScrollStateChanged(int state)
此方法是在状态改变的时候调用其中state这个参数有三种状态
SCROLL_STATE_DRAGGING1表示用户手指“按在屏幕上并且开始拖动”的状态
手指按下但是还没有拖动的时候还不是这个状态只有按下并且手指开始拖动后log才打出。
SCROLL_STATE_IDLE0滑动动画做完的状态。
SCROLL_STATE_SETTLING2在“手指离开屏幕”的状态。*/
@Override
public void onPageScrollStateChanged(int state) {
}
/* onPageScrolled(int position, float positionOffset, int positionOffsetPixels)
当页面在滑动的时候会调用此方法,在滑动被停止之前,此方法回一直得到调用。其中三个参数的含义分别为:
position :当前页面即你点击滑动的页面从A滑B则是A页面的position。
positionOffset:当前页面偏移的百分比
positionOffsetPixels:当前页面偏移的像素位置*/
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
/* onPageSelected(int position)
此方法是页面滑动完后得到调用position是你当前选中的页面的Position位置编号
(从A滑动到B就是B的position)*/
public void onPageSelected(int position) {
// ImageView preView = imageViews[currentPoint];
// preView.setImageResource(R.drawable.ic_launcher);
// ImageView currView = imageViews[position];
// currView.setImageResource(R.drawable.ic_launcher);
// currentPoint = position;
}
//小圆点点击事件
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//通过getTag(),可以判断是哪个控件
// int i = (Integer) v.getTag();
// viewPager.setCurrentItem(i);//直接跳转到某一个页面的情况
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
//setSubTitle("");
}
@Override
protected void onDestroy() {
super.onDestroy();
LogUtils.d(TAG, "onDestroy() SOS");
}
//
// 处理传入的 Intent 数据
//
// boolean prosessIntents(Intent intent) {
// if (intent == null
// || intent.getAction() == null
// || intent.getAction().equals(""))
// return false;
//
// if (intent.getAction().equals(StringToQrCodeView.ACTION_UNITTEST_QRCODE)) {
// try {
// WinBollActivity clazzActivity = UnitTestActivity.class.newInstance();
// String tag = clazzActivity.getTag();
// LogUtils.d(TAG, "String tag = clazzActivity.getTag(); tag " + tag);
// Intent subIntent = new Intent(this, UnitTestActivity.class);
// subIntent.setAction(intent.getAction());
// File file = new File(getCacheDir(), UUID.randomUUID().toString());
// //取出文件uri
// Uri uri = intent.getData();
// if (uri == null) {
// uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
// }
// //获取文件真实地址
// String szSrcPath = UriUtils.getFileFromUri(getApplication(), uri);
// if (TextUtils.isEmpty(szSrcPath)) {
// return false;
// }
//
// Files.copy(Paths.get(szSrcPath), Paths.get(file.getPath()));
// //startWinBollActivity(subIntent, tag);
// WinBollActivityManager.getInstance(this).startWinBollActivity(this, subIntent, UnitTestActivity.class);
// } catch (IllegalAccessException | InstantiationException | IOException e) {
// LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
// // 函数处理异常返回失败
// return false;
// }
// } else {
// LogUtils.d(TAG, "prosessIntents|" + intent.getAction() + "|yet");
// return false;
// }
// return true;
// }
@Override
public String getTag() {
return TAG;
}
@Override
public Toolbar initToolBar() {
return findViewById(R.id.activitymainToolbar1);
}
@Override
public boolean isAddWinBollToolBar() {
return true;
}
@Override
public boolean isEnableDisplayHomeAsUp() {
return false;
}
@Override
public void onBackPressed() {
exit();
}
void exit() {
YesNoAlertDialog.OnDialogResultListener listener = new YesNoAlertDialog.OnDialogResultListener(){
@Override
public void onYes() {
WinBollActivityManager.getInstance(getApplicationContext()).finishAll();
}
@Override
public void onNo() {
}
};
YesNoAlertDialog.show(this, "[ " + getString(R.string.app_name) + " ]", "Exit(Yes/No).\nIs close all activity?", listener);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.toolbar_main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.item_call) {
Intent intent = new Intent(this, CallActivity.class);
startActivity(intent);
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, CallActivity.class);
} else if (item.getItemId() == R.id.item_settings) {
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, CallActivity.class);
}
// } else
// if (item.getItemId() == R.id.item_exit) {
// exit();
// return true;
// }
return super.onOptionsItemSelected(item);
}
@Override
protected void onResume() {
super.onResume();
}
/**
* Android M 及以上检查是否是系统默认电话应用
*/
public boolean isDefaultPhoneCallApp() {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
TelecomManager manger = (TelecomManager) getSystemService(TELECOM_SERVICE);
if (manger != null && manger.getDefaultDialerPackage() != null) {
return manger.getDefaultDialerPackage().equals(getPackageName());
}
}
return false;
}
public boolean isServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
if (manager == null) return false;
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(
Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// switch (resultCode) {
// case REQUEST_HOME_ACTIVITY : {
// LogUtils.d(TAG, "REQUEST_HOME_ACTIVITY");
// break;
// }
// case REQUEST_ABOUT_ACTIVITY : {
// LogUtils.d(TAG, "REQUEST_ABOUT_ACTIVITY");
// break;
// }
// default : {
// super.onActivityResult(requestCode, resultCode, data);
// }
// }
if (requestCode == DIALER_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
Toast.makeText(MainActivity.this, getString(R.string.app_name) + " 已成为默认电话应用",
Toast.LENGTH_SHORT).show();
}
}
}
}

View File

@@ -0,0 +1,35 @@
package cc.winboll.studio.contacts;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/20 21:14:52
* @Describe PhoneCallManager
*/
import android.telecom.Call;
import android.telecom.VideoProfile;
public class PhoneCallManager {
public static final String TAG = "PhoneCallManager";
public static Call call;
/**
* 接听电话
*/
public void answer() {
if (call != null) {
call.answer(VideoProfile.STATE_AUDIO_ONLY);
}
}
/**
* 断开电话,包括来电时的拒接以及接听后的挂断
*/
public void disconnect() {
if (call != null) {
call.disconnect();
}
}
}

View File

@@ -0,0 +1,118 @@
package cc.winboll.studio.contacts.activities;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/20 17:15:46
* @Describe 拨号窗口
*/
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import cc.winboll.studio.contacts.MainActivity;
import cc.winboll.studio.contacts.R;
public class CallActivity extends AppCompatActivity {
public static final String TAG = "CallActivity";
private static final int REQUEST_CALL_PHONE = 1;
private EditText phoneNumberEditText;
private TextView callStatusTextView;
private TelephonyManager telephonyManager;
private MyPhoneStateListener phoneStateListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
setContentView(R.layout.activity_call);
phoneNumberEditText = findViewById(R.id.phone_number);
Button dialButton = findViewById(R.id.dial_button);
callStatusTextView = findViewById(R.id.call_status);
dialButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String phoneNumber = phoneNumberEditText.getText().toString().trim();
if (!phoneNumber.isEmpty()) {
if (ContextCompat.checkSelfPermission(CallActivity.this, Manifest.permission.CALL_PHONE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(CallActivity.this,
new String[]{Manifest.permission.CALL_PHONE},
REQUEST_CALL_PHONE);
} else {
dialPhoneNumber(phoneNumber);
}
} else {
Toast.makeText(CallActivity.this, "请输入电话号码", Toast.LENGTH_SHORT).show();
}
}
});
// 初始化TelephonyManager和PhoneStateListener
telephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
phoneStateListener = new MyPhoneStateListener();
telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_CALL_PHONE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
String phoneNumber = phoneNumberEditText.getText().toString().trim();
dialPhoneNumber(phoneNumber);
} else {
Toast.makeText(this, "未授予拨打电话权限", Toast.LENGTH_SHORT).show();
}
}
}
private void dialPhoneNumber(String phoneNumber) {
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(android.net.Uri.parse("tel:" + phoneNumber));
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(intent);
}
private class MyPhoneStateListener extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
callStatusTextView.setText("电话已挂断");
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
callStatusTextView.setText("正在通话中");
break;
case TelephonyManager.CALL_STATE_RINGING:
callStatusTextView.setText("来电: " + incomingNumber);
break;
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
// 取消监听
if (telephonyManager != null) {
telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
}
}
}

View File

@@ -0,0 +1,40 @@
package cc.winboll.studio.contacts.activities;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/20 20:18:26
*/
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
import cc.winboll.studio.contacts.R;
public class DialerActivity extends AppCompatActivity {
public static final String TAG = "DialerActivity";
private EditText phoneNumberEditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialer);
phoneNumberEditText = findViewById(R.id.phone_number_edit_text);
Button dialButton = findViewById(R.id.dial_button);
dialButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String phoneNumber = phoneNumberEditText.getText().toString();
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
startActivity(intent);
}
});
}
}

View File

@@ -0,0 +1,216 @@
package cc.winboll.studio.contacts.activities;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/21 05:37:42
*/
import android.app.NotificationManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.view.WindowManager;
import android.widget.Switch;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import cc.winboll.studio.contacts.R;
import cc.winboll.studio.contacts.beans.RingTongBean;
import cc.winboll.studio.libappbase.IWinBollActivity;
import cc.winboll.studio.libappbase.bean.APPInfo;
import com.hjq.toast.ToastUtils;
import java.lang.reflect.Field;
import android.widget.SeekBar;
import android.widget.TextView;
import cc.winboll.studio.contacts.beans.MainServiceBean;
import cc.winboll.studio.contacts.services.MainService;
public class SettingsActivity extends AppCompatActivity implements IWinBollActivity {
public static final String TAG = "SettingsActivity";
Toolbar mToolbar;
Switch swSilent;
SeekBar msbVolume;
TextView mtvVolume;
int mnStreamMaxVolume;
int mnStreamVolume;
Switch mswMainService;
@Override
public APPInfo getAppInfo() {
return null;
}
@Override
public AppCompatActivity getActivity() {
return this;
}
@Override
public String getTag() {
return TAG;
}
@Override
public Toolbar initToolBar() {
return findViewById(R.id.activitymainToolbar1);
}
@Override
public boolean isAddWinBollToolBar() {
return true;
}
@Override
public boolean isEnableDisplayHomeAsUp() {
return false;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
// 初始化工具栏
mToolbar = findViewById(R.id.activitymainToolbar1);
setSupportActionBar(mToolbar);
if (isEnableDisplayHomeAsUp()) {
// 显示后退按钮
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
getSupportActionBar().setSubtitle(getTag());
mswMainService = findViewById(R.id.sw_mainservice);
MainServiceBean mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
mswMainService.setChecked(mMainServiceBean.isEnable());
mswMainService.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO: Implement this method
if (mswMainService.isChecked()) {
//ToastUtils.show("Is Checked");
MainService.startMainService(SettingsActivity.this);
} else {
//ToastUtils.show("Not Checked");
MainService.stopMainService(SettingsActivity.this);
}
}
});
msbVolume = findViewById(R.id.bellvolume);
mtvVolume = findViewById(R.id.tv_volume);
final AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
// 设置SeekBar的最大值为系统铃声音量的最大刻度
mnStreamMaxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
msbVolume.setMax(mnStreamMaxVolume);
// 获取当前铃声音量并设置为SeekBar的初始进度
mnStreamVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
msbVolume.setProgress(mnStreamVolume);
updateStreamVolumeTextView();
msbVolume.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
// 设置铃声音量
audioManager.setStreamVolume(AudioManager.STREAM_RING, progress, 0);
RingTongBean bean = RingTongBean.loadBean(SettingsActivity.this, RingTongBean.class);
if (bean == null) {
bean = new RingTongBean();
}
bean.setStreamVolume(progress);
RingTongBean.saveBean(SettingsActivity.this, bean);
mnStreamVolume = progress;
updateStreamVolumeTextView();
//Toast.makeText(SettingsActivity.this, "音量设置为: " + progress, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// 当开始拖动SeekBar时的操作
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// 当停止拖动SeekBar时的操作
}
});
}
void updateStreamVolumeTextView() {
mtvVolume.setText(String.format("%d/%d", mnStreamVolume, mnStreamMaxVolume));
}
public void onDefaultPhone(View view) {
Intent intent = new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
startActivity(intent);
}
public void onCanDrawOverlays(View view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(this)) {
// 请求 悬浮框 权限
askForDrawOverlay();
} else {
ToastUtils.show("悬浮窗已开启");
}
}
private void askForDrawOverlay() {
AlertDialog alertDialog = new AlertDialog.Builder(this)
.setTitle("允许显示悬浮框")
.setMessage("为了使电话监听服务正常工作,请允许这项权限")
.setPositiveButton("去设置", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
openDrawOverlaySettings();
dialog.dismiss();
}
})
.setNegativeButton("稍后再说", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.create();
//noinspection ConstantConditions
alertDialog.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
alertDialog.show();
}
/**
* 跳转悬浮窗管理设置界面
*/
private void openDrawOverlaySettings() {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// Android M 以上引导用户去系统设置中打开允许悬浮窗
// 使用反射是为了用尽可能少的代码保证在大部分机型上都可用
try {
Context context = this;
Class clazz = Settings.class;
Field field = clazz.getDeclaredField("ACTION_MANAGE_OVERLAY_PERMISSION");
Intent intent = new Intent(field.get(null).toString());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("package:" + context.getPackageName()));
context.startActivity(intent);
} catch (Exception e) {
Toast.makeText(this, "请在悬浮窗管理中打开权限", Toast.LENGTH_LONG).show();
}
}
}
}

View File

@@ -0,0 +1,14 @@
package cc.winboll.studio.contacts.adapters;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/20 14:20:38
* @Describe ImagePagerAdapter
*/
public class ImagePagerAdapter {
public static final String TAG = "ImagePagerAdapter";
}

View File

@@ -0,0 +1,42 @@
package cc.winboll.studio.contacts.adapters;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/20 13:33:04
* @Describe MyPagerAdapter
*/
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import cc.winboll.studio.contacts.fragments.CallFragment;
import cc.winboll.studio.contacts.fragments.ContactsFragment;
import cc.winboll.studio.contacts.fragments.LogFragment;
public class MyPagerAdapter extends FragmentPagerAdapter {
public static final String TAG = "MyPagerAdapter";
private static final int PAGE_COUNT = 3;
public MyPagerAdapter(@NonNull FragmentManager fm) {
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
}
@NonNull
@Override
public Fragment getItem(int position) {
if(position == 1) {
return ContactsFragment.newInstance(position);
} else if(position == 2) {
return LogFragment.newInstance(position);
} else {
return CallFragment.newInstance(position);
}
}
@Override
public int getCount() {
return PAGE_COUNT;
}
}

View File

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

View File

@@ -0,0 +1,88 @@
package cc.winboll.studio.contacts.beans;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/21 09:52:10
* @Describe 电话黑名单规则
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class PhoneBlackRuleBean extends BaseBean {
public static final String TAG = "PhoneBlackRuleBean";
String ruleText;
boolean isEnable;
public PhoneBlackRuleBean() {
this.ruleText = "";
this.isEnable = false;
}
public PhoneBlackRuleBean(String ruleText, boolean isEnable) {
this.ruleText = ruleText;
this.isEnable = isEnable;
}
public void setRuleText(String ruleText) {
this.ruleText = ruleText;
}
public String getRuleText() {
return ruleText;
}
public void setIsEnable(boolean isEnable) {
this.isEnable = isEnable;
}
public boolean isEnable() {
return isEnable;
}
@Override
public String getName() {
return PhoneBlackRuleBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
jsonWriter.name("ruleText").value(getRuleText());
jsonWriter.name("isEnable").value(isEnable());
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
if (name.equals("ruleText")) {
setRuleText(jsonReader.nextString());
} else if (name.equals("isEnable")) {
setIsEnable(jsonReader.nextBoolean());
} else {
return false;
}
}
return true;
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (!initObjectsFromJsonReader(jsonReader, name)) {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return this;
}
}

View File

@@ -0,0 +1,74 @@
package cc.winboll.studio.contacts.beans;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/24 18:47:11
* @Describe 手机铃声设置参数类
*/
import cc.winboll.studio.libappbase.BaseBean;
import android.util.JsonWriter;
import java.io.IOException;
import android.media.AudioManager;
import android.util.JsonReader;
public class RingTongBean extends BaseBean {
public static final String TAG = "AudioRingTongBean";
// 铃声音量
int streamVolume;
public RingTongBean() {
this.streamVolume = 100;
}
public RingTongBean(int streamVolume) {
this.streamVolume = streamVolume;
}
public void setStreamVolume(int streamVolume) {
this.streamVolume = streamVolume;
}
public int getStreamVolume() {
return streamVolume;
}
@Override
public String getName() {
return RingTongBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
jsonWriter.name("streamVolume").value(getStreamVolume());
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
if (name.equals("streamVolume")) {
setStreamVolume(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;
}
}

View File

@@ -0,0 +1,76 @@
package cc.winboll.studio.contacts.dun;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/21 06:15:10
* @Describe 云盾防御规则
*/
import cc.winboll.studio.contacts.beans.PhoneBlackRuleBean;
import java.util.ArrayList;
import java.util.regex.Pattern;
import android.content.Context;
public class Rules {
public static final String TAG = "Rules";
ArrayList<PhoneBlackRuleBean> _PhoneBlacRuleBeanList;
static volatile Rules _Rules;
Context mContext;
Rules(Context context) {
mContext = context;
_PhoneBlacRuleBeanList = new ArrayList<PhoneBlackRuleBean>();
PhoneBlackRuleBean.loadBeanList(mContext, _PhoneBlacRuleBeanList, PhoneBlackRuleBean.class);
}
public static synchronized Rules getInstance(Context context) {
if (_Rules == null) {
_Rules = new Rules(context);
}
return _Rules;
}
public boolean isAllowed(String phoneNumber) {
// 黑名单拒接
for (int i = 0; i < _PhoneBlacRuleBeanList.size(); i++) {
if (_PhoneBlacRuleBeanList.get(i).isEnable()) {
String regex = _PhoneBlacRuleBeanList.get(i).getRuleText();
if (Pattern.matches(regex, phoneNumber)) {
return false;
}
}
}
// 手机号码允许
// 中国手机号码正则表达式以1开头第二位可以是3、4、5、6、7、8、9后面跟9位数字
String regex = "^1[3-9]\\d{9}$";
if (Pattern.matches(regex, phoneNumber)) {
return true;
}
// 指定区号号码允许
regex = "^0660\\d+$";
if (Pattern.matches(regex, phoneNumber)) {
return true;
}
// 指定区号号码允许
regex = "^020\\d+$";
if (Pattern.matches(regex, phoneNumber)) {
return true;
}
// 其他拒接
return false;
}
public void add(String phoneRuleBlack, boolean isEnable) {
_PhoneBlacRuleBeanList.add(new PhoneBlackRuleBean(phoneRuleBlack, isEnable));
PhoneBlackRuleBean.saveBeanList(mContext, _PhoneBlacRuleBeanList, PhoneBlackRuleBean.class);
}
public ArrayList<PhoneBlackRuleBean> getPhoneBlacRuleBeanList() {
return _PhoneBlacRuleBeanList;
}
}

View File

@@ -0,0 +1,51 @@
package cc.winboll.studio.contacts.fragments;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/20 12:57:00
* @Describe 拨号
*/
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import cc.winboll.studio.contacts.R;
import cc.winboll.studio.libappbase.LogView;
import androidx.annotation.Nullable;
import androidx.annotation.NonNull;
import android.widget.TextView;
public class CallFragment extends Fragment {
public static final String TAG = "CallFragment";
private static final String ARG_PAGE = "ARG_PAGE";
private int mPage;
public static CallFragment newInstance(int page) {
Bundle args = new Bundle();
args.putInt(ARG_PAGE, page);
CallFragment fragment = new CallFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments()!= null) {
mPage = getArguments().getInt(ARG_PAGE);
}
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_call, container, false);
TextView textView = view.findViewById(R.id.page_text);
textView.setText("这是第 " + mPage + "");
return view;
}
}

View File

@@ -0,0 +1,50 @@
package cc.winboll.studio.contacts.fragments;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/20 12:57:50
* @Describe 联系人
*/
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import cc.winboll.studio.contacts.R;
public class ContactsFragment extends Fragment {
public static final String TAG = "ContactsFragment";
private static final String ARG_PAGE = "ARG_PAGE";
private int mPage;
public static ContactsFragment newInstance(int page) {
Bundle args = new Bundle();
args.putInt(ARG_PAGE, page);
ContactsFragment fragment = new ContactsFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments()!= null) {
mPage = getArguments().getInt(ARG_PAGE);
}
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_contacts, container, false);
TextView textView = view.findViewById(R.id.page_text);
textView.setText("这是第 " + mPage + "");
return view;
}
}

View File

@@ -0,0 +1,50 @@
package cc.winboll.studio.contacts.fragments;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/20 12:58:15
* @Describe 应用日志
*/
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import cc.winboll.studio.contacts.R;
import cc.winboll.studio.libappbase.LogView;
public class LogFragment extends Fragment {
public static final String TAG = "LogFragment";
private static final String ARG_PAGE = "ARG_PAGE";
private int mPage;
public static LogFragment newInstance(int page) {
Bundle args = new Bundle();
args.putInt(ARG_PAGE, page);
LogFragment fragment = new LogFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mPage = getArguments().getInt(ARG_PAGE);
}
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_log, container, false);
LogView logView = view.findViewById(R.id.logview);
logView.start();
return view;
}
}

View File

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

View File

@@ -0,0 +1,206 @@
package cc.winboll.studio.contacts.listenphonecall;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.PixelFormat;
import android.os.Build;
import android.os.IBinder;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import cc.winboll.studio.contacts.MainActivity;
import cc.winboll.studio.contacts.R;
public class CallListenerService extends Service {
private View phoneCallView;
private TextView tvCallNumber;
private Button btnOpenApp;
private WindowManager windowManager;
private WindowManager.LayoutParams params;
private PhoneStateListener phoneStateListener;
private TelephonyManager telephonyManager;
private String callNumber;
private boolean hasShown;
private boolean isCallingIn;
@Override
public void onCreate() {
super.onCreate();
initPhoneStateListener();
initPhoneCallView();
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
/**
* 初始化来电状态监听器
*/
private void initPhoneStateListener() {
phoneStateListener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
callNumber = incomingNumber;
switch (state) {
case TelephonyManager.CALL_STATE_IDLE: // 待机,即无电话时,挂断时触发
dismiss();
break;
case TelephonyManager.CALL_STATE_RINGING: // 响铃,来电时触发
isCallingIn = true;
updateUI();
show();
break;
case TelephonyManager.CALL_STATE_OFFHOOK: // 摘机,接听或拨出电话时触发
updateUI();
show();
break;
default:
break;
}
}
};
// 设置来电监听器
telephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
if (telephonyManager != null) {
telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}
}
private void initPhoneCallView() {
windowManager = (WindowManager) getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE);
int width = windowManager.getDefaultDisplay().getWidth();
int height = windowManager.getDefaultDisplay().getHeight();
params = new WindowManager.LayoutParams();
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
params.width = width;
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
// 设置图片格式,效果为背景透明
params.format = PixelFormat.TRANSLUCENT;
// 设置 Window flag 为系统级弹框 | 覆盖表层
params.type = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY :
WindowManager.LayoutParams.TYPE_PHONE;
// 不可聚集(不响应返回键)| 全屏
params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_FULLSCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
// API 19 以上则还可以开启透明状态栏与导航栏
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
params.flags = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_FULLSCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
}
FrameLayout interceptorLayout = new FrameLayout(this) {
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
return true;
}
}
return super.dispatchKeyEvent(event);
}
};
phoneCallView = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.view_phone_call, interceptorLayout);
tvCallNumber = phoneCallView.findViewById(R.id.tv_call_number);
btnOpenApp = phoneCallView.findViewById(R.id.btn_open_app);
btnOpenApp.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
CallListenerService.this.startActivity(intent);
}
});
}
/**
* 显示顶级弹框展示通话信息
*/
private void show() {
if (!hasShown) {
windowManager.addView(phoneCallView, params);
hasShown = true;
}
}
/**
* 取消显示
*/
private void dismiss() {
if (hasShown) {
windowManager.removeView(phoneCallView);
isCallingIn = false;
hasShown = false;
}
}
private void updateUI() {
tvCallNumber.setText(formatPhoneNumber(callNumber));
int callTypeDrawable = isCallingIn ? R.drawable.ic_phone_call_in : R.drawable.ic_phone_call_out;
tvCallNumber.setCompoundDrawablesWithIntrinsicBounds(null, null,
getResources().getDrawable(callTypeDrawable), null);
}
public static String formatPhoneNumber(String phoneNum) {
if (!TextUtils.isEmpty(phoneNum) && phoneNum.length() == 11) {
return phoneNum.substring(0, 3) + "-"
+ phoneNum.substring(3, 7) + "-"
+ phoneNum.substring(7);
}
return phoneNum;
}
@Override
public void onDestroy() {
super.onDestroy();
telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
}
}

View File

@@ -0,0 +1,166 @@
package cc.winboll.studio.contacts.phonecallui;
import static cc.winboll.studio.contacts.listenphonecall.CallListenerService.formatPhoneNumber;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import cc.winboll.studio.contacts.ActivityStack;
import cc.winboll.studio.contacts.R;
import java.util.Timer;
import java.util.TimerTask;
/**
* 提供接打电话的界面,仅支持 Android M (6.0, API 23) 及以上的系统
*
* @author aJIEw
*/
@RequiresApi(api = Build.VERSION_CODES.M)
public class PhoneCallActivity extends AppCompatActivity implements View.OnClickListener {
private TextView tvCallNumberLabel;
private TextView tvCallNumber;
private TextView tvPickUp;
private TextView tvCallingTime;
private TextView tvHangUp;
private PhoneCallManager phoneCallManager;
private PhoneCallService.CallType callType;
private String phoneNumber;
private Timer onGoingCallTimer;
private int callingTime;
public static void actionStart(Context context, String phoneNumber,
PhoneCallService.CallType callType) {
Intent intent = new Intent(context, PhoneCallActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_MIME_TYPES, callType);
intent.putExtra(Intent.EXTRA_PHONE_NUMBER, phoneNumber);
context.startActivity(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_phone_call);
ActivityStack.getInstance().addActivity(this);
initData();
initView();
}
private void initData() {
phoneCallManager = new PhoneCallManager(this);
onGoingCallTimer = new Timer();
if (getIntent() != null) {
phoneNumber = getIntent().getStringExtra(Intent.EXTRA_PHONE_NUMBER);
callType = (PhoneCallService.CallType) getIntent().getSerializableExtra(Intent.EXTRA_MIME_TYPES);
}
}
private void initView() {
int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION //hide navigationBar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
getWindow().getDecorView().setSystemUiVisibility(uiOptions);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
tvCallNumberLabel = findViewById(R.id.tv_call_number_label);
tvCallNumber = findViewById(R.id.tv_call_number);
tvPickUp = findViewById(R.id.tv_phone_pick_up);
tvCallingTime = findViewById(R.id.tv_phone_calling_time);
tvHangUp = findViewById(R.id.tv_phone_hang_up);
tvCallNumber.setText(formatPhoneNumber(phoneNumber));
tvPickUp.setOnClickListener(this);
tvHangUp.setOnClickListener(this);
// 打进的电话
if (callType == PhoneCallService.CallType.CALL_IN) {
tvCallNumberLabel.setText("来电号码");
tvPickUp.setVisibility(View.VISIBLE);
}
// 打出的电话
else if (callType == PhoneCallService.CallType.CALL_OUT) {
tvCallNumberLabel.setText("呼叫号码");
tvPickUp.setVisibility(View.GONE);
phoneCallManager.openSpeaker();
}
showOnLockScreen();
}
public void showOnLockScreen() {
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
WindowManager.LayoutParams.FLAG_FULLSCREEN |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.tv_phone_pick_up) {
phoneCallManager.answer();
tvPickUp.setVisibility(View.GONE);
tvCallingTime.setVisibility(View.VISIBLE);
onGoingCallTimer.schedule(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@SuppressLint("SetTextI18n")
@Override
public void run() {
callingTime++;
tvCallingTime.setText("通话中:" + getCallingTime());
}
});
}
}, 0, 1000);
} else if (v.getId() == R.id.tv_phone_hang_up) {
phoneCallManager.disconnect();
stopTimer();
}
}
private String getCallingTime() {
int minute = callingTime / 60;
int second = callingTime % 60;
return (minute < 10 ? "0" + minute : minute) +
":" +
(second < 10 ? "0" + second : second);
}
private void stopTimer() {
if (onGoingCallTimer != null) {
onGoingCallTimer.cancel();
}
callingTime = 0;
}
@Override
protected void onDestroy() {
super.onDestroy();
phoneCallManager.destroy();
}
}

View File

@@ -0,0 +1,62 @@
package cc.winboll.studio.contacts.phonecallui;
import android.content.Context;
import android.media.AudioManager;
import android.os.Build;
import android.telecom.Call;
import android.telecom.VideoProfile;
import androidx.annotation.RequiresApi;
import cc.winboll.studio.contacts.dun.Rules;
@RequiresApi(api = Build.VERSION_CODES.M)
public class PhoneCallManager {
public static Call call;
private Context context;
private AudioManager audioManager;
public PhoneCallManager(Context context) {
this.context = context;
audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
}
/**
* 接听电话
*/
public void answer() {
if (call != null) {
call.answer(VideoProfile.STATE_AUDIO_ONLY);
openSpeaker();
}
}
/**
* 断开电话,包括来电时的拒接以及接听后的挂断
*/
public void disconnect() {
if (call != null) {
call.disconnect();
}
}
/**
* 打开免提
*/
public void openSpeaker() {
if (audioManager != null) {
audioManager.setMode(AudioManager.MODE_IN_CALL);
audioManager.setSpeakerphoneOn(true);
}
}
/**
* 销毁资源
*/
public void destroy() {
call = null;
context = null;
audioManager = null;
}
}

View File

@@ -0,0 +1,140 @@
package cc.winboll.studio.contacts.phonecallui;
/**
* 监听电话通信状态的服务,实现该类的同时必须提供电话管理的 UI
*
* @author aJIEw
* @see PhoneCallActivity
* @see android.telecom.InCallService
*/
import android.media.AudioManager;
import android.os.Build;
import android.telecom.Call;
import android.telecom.InCallService;
import androidx.annotation.RequiresApi;
import cc.winboll.studio.contacts.ActivityStack;
import cc.winboll.studio.contacts.beans.RingTongBean;
import cc.winboll.studio.contacts.dun.Rules;
import cc.winboll.studio.libappbase.LogUtils;
@RequiresApi(api = Build.VERSION_CODES.M)
public class PhoneCallService extends InCallService {
public static final String TAG = "PhoneCallService";
private final Call.Callback callback = new Call.Callback() {
@Override
public void onStateChanged(Call call, int state) {
super.onStateChanged(call, state);
switch (state) {
case Call.STATE_ACTIVE: {
break;
}
case Call.STATE_DISCONNECTED: {
ActivityStack.getInstance().finishActivity(PhoneCallActivity.class);
break;
}
}
}
};
@Override
public void onCallAdded(Call call) {
super.onCallAdded(call);
call.registerCallback(callback);
PhoneCallManager.call = call;
CallType callType = null;
if (call.getState() == Call.STATE_RINGING) {
callType = CallType.CALL_IN;
} else if (call.getState() == Call.STATE_CONNECTING) {
callType = CallType.CALL_OUT;
}
if (callType != null) {
Call.Details details = call.getDetails();
String phoneNumber = details.getHandle().getSchemeSpecificPart();
// 记录原始铃声音量
//
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
// 恢复铃声音量,预防其他意外条件导致的音量变化问题
//
// 读取应用配置,未配置就初始化配置文件
RingTongBean bean = RingTongBean.loadBean(this, RingTongBean.class);
if (bean == null) {
// 初始化配置
bean = new RingTongBean();
RingTongBean.saveBean(this, bean);
}
// 如果当前音量和应用保存的不一致就恢复为应用设定值
// 恢复铃声音量
try {
audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0);
//audioManager.setMode(AudioManager.RINGER_MODE_NORMAL);
} catch (java.lang.SecurityException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
// 检查电话接收规则
if (!Rules.getInstance(this).isAllowed(phoneNumber)) {
// 调低音量
try {
audioManager.setStreamVolume(AudioManager.STREAM_RING, 0, 0);
//audioManager.setMode(AudioManager.RINGER_MODE_SILENT);
} catch (java.lang.SecurityException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
// 断开电话
call.disconnect();
// 停顿1秒预防第一声铃声响动
try {
Thread.sleep(500);
} catch (InterruptedException e) {
LogUtils.d(TAG, "");
}
// 恢复铃声音量
try {
audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0);
//audioManager.setMode(AudioManager.RINGER_MODE_NORMAL);
} catch (java.lang.SecurityException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
// 屏蔽电话结束
return;
}
// 正常接听电话
PhoneCallActivity.actionStart(this, phoneNumber, callType);
}
}
void resumeStreamVolume(AudioManager audioManager, int originalRingVolume) {
// 如果当前音量和应用保存的不一致就恢复为应用设定值
RingTongBean bean = RingTongBean.loadBean(this, RingTongBean.class);
if (bean == null) {
bean = new RingTongBean();
}
if (originalRingVolume != bean.getStreamVolume()) {
// 恢复铃声音量
audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0);
}
}
@Override
public void onCallRemoved(Call call) {
super.onCallRemoved(call);
call.unregisterCallback(callback);
PhoneCallManager.call = null;
}
public enum CallType {
CALL_IN,
CALL_OUT,
}
}

View File

@@ -0,0 +1,47 @@
package cc.winboll.studio.contacts.receivers;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/13 06:58:04
* @Describe 主要广播接收器
*/
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioManager;
import cc.winboll.studio.contacts.services.MainService;
import cc.winboll.studio.libappbase.LogUtils;
import com.hjq.toast.ToastUtils;
import java.lang.ref.WeakReference;
public class MainReceiver extends BroadcastReceiver {
public static final String TAG = "MainReceiver";
public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
WeakReference<MainService> mwrService;
public MainReceiver(MainService service) {
mwrService = new WeakReference<MainService>(service);
}
@Override
public void onReceive(Context context, Intent intent) {
String szAction = intent.getAction();
if (szAction.equals(ACTION_BOOT_COMPLETED)) {
ToastUtils.show("ACTION_BOOT_COMPLETED");
MainService.startMainService(context);
} else {
ToastUtils.show(szAction);
}
}
// 注册 Receiver
//
public void registerAction(Context context) {
IntentFilter filter=new IntentFilter();
filter.addAction(ACTION_BOOT_COMPLETED);
//filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
context.registerReceiver(this, filter);
}
}

View File

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

View File

@@ -0,0 +1,276 @@
package cc.winboll.studio.contacts.services;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/13 06:56:41
* @Describe 拨号主服务
* 参考:
* 进程保活-双进程守护的正确姿势
* https://blog.csdn.net/sinat_35159441/article/details/75267380
* Android Service之onStartCommand方法研究
* https://blog.csdn.net/cyp331203/article/details/38920491
*/
import android.app.Service;
import cc.winboll.studio.contacts.listenphonecall.CallListenerService;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Binder;
import android.os.IBinder;
import cc.winboll.studio.contacts.beans.MainServiceBean;
import cc.winboll.studio.contacts.handlers.MainServiceHandler;
import cc.winboll.studio.contacts.receivers.MainReceiver;
import cc.winboll.studio.contacts.services.MainService;
import cc.winboll.studio.contacts.threads.MainServiceThread;
import cc.winboll.studio.contacts.widgets.APPStatusWidget;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.SOS;
import cc.winboll.studio.libappbase.bean.APPSOSBean;
import cc.winboll.studio.contacts.dun.Rules;
import android.media.AudioManager;
import com.hjq.toast.ToastUtils;
import java.util.Timer;
import java.util.TimerTask;
import cc.winboll.studio.contacts.beans.RingTongBean;
public class MainService extends Service {
public static final String TAG = "MainService";
public static final int MSG_UPDATE_STATUS = 0;
static MainService _mControlCenterService;
volatile boolean isServiceRunning;
MainServiceBean mMainServiceBean;
MainServiceThread mMainServiceThread;
MainServiceHandler mMainServiceHandler;
MyServiceConnection mMyServiceConnection;
AssistantService mAssistantService;
boolean isBound = false;
MainReceiver mMainReceiver;
Timer mStreamVolumeCheckTimer;
@Override
public IBinder onBind(Intent intent) {
return new MyBinder();
}
public MainServiceThread getRemindThread() {
return mMainServiceThread;
}
@Override
public void onCreate() {
super.onCreate();
LogUtils.d(TAG, "onCreate()");
_mControlCenterService = MainService.this;
isServiceRunning = false;
mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
if (mMyServiceConnection == null) {
mMyServiceConnection = new MyServiceConnection();
}
mMainServiceHandler = new MainServiceHandler(this);
// 铃声检查定时器
mStreamVolumeCheckTimer = new Timer();
mStreamVolumeCheckTimer.schedule(new TimerTask() {
@Override
public void run() {
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
// 恢复铃声音量,预防其他意外条件导致的音量变化问题
//
// 读取应用配置,未配置就初始化配置文件
RingTongBean bean = RingTongBean.loadBean(MainService.this, RingTongBean.class);
if (bean == null) {
// 初始化配置
bean = new RingTongBean();
RingTongBean.saveBean(MainService.this, bean);
}
// 如果当前音量和应用保存的不一致就恢复为应用设定值
// 恢复铃声音量
try {
audioManager.setStreamVolume(AudioManager.STREAM_RING, bean.getStreamVolume(), 0);
//audioManager.setMode(AudioManager.RINGER_MODE_NORMAL);
} catch (java.lang.SecurityException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
}, 1000, 60000);
// 运行服务内容
mainService();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
LogUtils.d(TAG, "onStartCommand(...)");
// 运行服务内容
mainService();
return (mMainServiceBean.isEnable()) ? START_STICKY : super.onStartCommand(intent, flags, startId);
}
// 运行服务内容
//
void mainService() {
LogUtils.d(TAG, "mainService()");
mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
if (mMainServiceBean.isEnable() && isServiceRunning == false) {
LogUtils.d(TAG, "mainService() start running");
isServiceRunning = true;
// 唤醒守护进程
wakeupAndBindAssistant();
// 召唤 WinBoll APP 绑定本服务
SOS.bindToAPPService(this, new APPSOSBean(getPackageName(), MainService.class.getName()));
if (mMainReceiver == null) {
// 注册广播接收器
mMainReceiver = new MainReceiver(this);
mMainReceiver.registerAction(this);
}
Rules.getInstance(this);
//Rules.getInstance(this).add("18888888888", true);
//Rules.getInstance(this).add("16769764848", true);
startPhoneCallListener();
MainServiceThread.getInstance(this, mMainServiceHandler).start();
LogUtils.i(TAG, "Main Service Is Start.");
}
}
// 唤醒和绑定守护进程
//
void wakeupAndBindAssistant() {
LogUtils.d(TAG, "wakeupAndBindAssistant()");
// if (ServiceUtils.isServiceAlive(getApplicationContext(), AssistantService.class.getName()) == false) {
// startService(new Intent(MainService.this, AssistantService.class));
// //LogUtils.d(TAG, "call wakeupAndBindAssistant() : Binding... AssistantService");
// bindService(new Intent(MainService.this, AssistantService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
// }
Intent intent = new Intent(this, AssistantService.class);
startService(intent);
// 绑定服务的Intent
//Intent intent = new Intent(this, AssistantService.class);
bindService(intent, mMyServiceConnection, Context.BIND_IMPORTANT);
// Intent intent = new Intent(this, AssistantService.class);
// startService(intent);
// LogUtils.d(TAG, "startService(intent)");
// bindService(new Intent(this, AssistantService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
}
void startPhoneCallListener() {
Intent callListener = new Intent(this, CallListenerService.class);
startService(callListener);
}
@Override
public void onDestroy() {
//LogUtils.d(TAG, "onDestroy");
mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
//LogUtils.d(TAG, "onDestroy done");
if (mMainServiceBean.isEnable() == false) {
// 设置运行状态
isServiceRunning = false;// 解除绑定
if (isBound) {
unbindService(mMyServiceConnection);
isBound = false;
}
// 停止守护进程
Intent intent = new Intent(this, AssistantService.class);
stopService(intent);
// 停止Receiver
if (mMainReceiver != null) {
unregisterReceiver(mMainReceiver);
mMainReceiver = null;
}
// 停止前台通知栏
stopForeground(true);
// 停止主要进程
MainServiceThread.getInstance(this, mMainServiceHandler).setIsExit(true);
}
super.onDestroy();
}
// 主进程与守护进程连接时需要用到此类
//
private class MyServiceConnection implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
LogUtils.d(TAG, "onServiceConnected(...)");
AssistantService.MyBinder binder = (AssistantService.MyBinder) service;
mAssistantService = binder.getService();
isBound = true;
}
@Override
public void onServiceDisconnected(ComponentName name) {
LogUtils.d(TAG, "onServiceDisconnected(...)");
if (mMainServiceBean.isEnable()) {
// 唤醒守护进程
wakeupAndBindAssistant();
SOS.sosWinBollService(getApplicationContext(), new APPSOSBean(getPackageName(), MainService.class.getName()));
}
isBound = false;
mAssistantService = null;
}
}
// 用于返回服务实例的Binder
public class MyBinder extends Binder {
MainService getService() {
LogUtils.d(TAG, "MainService MyBinder getService()");
return MainService.this;
}
}
// //
// // 启动服务
// //
// public static void startControlCenterService(Context context) {
// Intent intent = new Intent(context, MainService.class);
// context.startForegroundService(intent);
// }
//
// //
// // 停止服务
// //
// public static void stopControlCenterService(Context context) {
// Intent intent = new Intent(context, MainService.class);
// context.stopService(intent);
// }
public void appenMessage(String message) {
LogUtils.d(TAG, String.format("Message : %s", message));
}
public static void stopMainService(Context context) {
LogUtils.d(TAG, "stopMainService");
MainServiceBean bean = new MainServiceBean();
bean.setIsEnable(false);
MainServiceBean.saveBean(context, bean);
context.stopService(new Intent(context, MainService.class));
}
public static void startMainService(Context context) {
LogUtils.d(TAG, "startMainService");
MainServiceBean bean = new MainServiceBean();
bean.setIsEnable(true);
MainServiceBean.saveBean(context, bean);
context.startService(new Intent(context, MainService.class));
}
}

View File

@@ -0,0 +1,77 @@
package cc.winboll.studio.contacts.threads;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/14 03:46:44
*/
import android.content.Context;
import cc.winboll.studio.contacts.handlers.MainServiceHandler;
import cc.winboll.studio.contacts.services.MainService;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.SOS;
import cc.winboll.studio.libappbase.bean.APPSOSBean;
import com.hjq.toast.ToastUtils;
import java.lang.ref.WeakReference;
public class MainServiceThread extends Thread {
public static final String TAG = "MainServiceThread";
volatile static MainServiceThread _MainServiceThread;
// 控制线程是否退出的标志
volatile boolean isExit = false;
volatile boolean isStarted = false;
Context mContext;
// 服务Handler, 用于线程发送消息使用
WeakReference<MainServiceHandler> mwrMainServiceHandler;
MainServiceThread(Context context, MainServiceHandler handler) {
mContext = context;
mwrMainServiceHandler = new WeakReference<MainServiceHandler>(handler);
}
public void setIsExit(boolean isExit) {
this.isExit = isExit;
}
public boolean isExit() {
return isExit;
}
public void setIsStarted(boolean isStarted) {
this.isStarted = isStarted;
}
public boolean isStarted() {
return isStarted;
}
public static MainServiceThread getInstance(Context context, MainServiceHandler handler) {
if (_MainServiceThread != null) {
_MainServiceThread.setIsExit(true);
}
_MainServiceThread = new MainServiceThread(context, handler);
return _MainServiceThread;
}
@Override
public void run() {
if (isStarted == false) {
isStarted = true;
LogUtils.d(TAG, "run()");
while (!isExit()) {
//ToastUtils.show("run");
//LogUtils.d(TAG, "run()");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
_MainServiceThread = null;
LogUtils.d(TAG, "run() exit");
}
}
}

View File

@@ -0,0 +1,76 @@
package cc.winboll.studio.contacts.widgets;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/17 14:49:31
* @Describe APPStatusWidget
*/
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;
import cc.winboll.studio.contacts.R;
import cc.winboll.studio.contacts.threads.MainServiceThread;
import cc.winboll.studio.libappbase.LogUtils;
import com.hjq.toast.ToastUtils;
public class APPStatusWidget extends AppWidgetProvider {
public static final String TAG = "APPSOSReportWidget";
public static final String ACTION_STATUS_ACTIVE = "cc.winboll.studio.contacts.widgets.APPStatusWidget.ACTION_STATUS_ACTIVE";
public static final String ACTION_STATUS_NOACTIVE = "cc.winboll.studio.contacts.widgets.APPStatusWidget.ACTION_STATUS_NOACTIVE";
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
}
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
if (intent.getAction().equals(ACTION_STATUS_ACTIVE)) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, APPStatusWidget.class));
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
} else if (intent.getAction().equals(ACTION_STATUS_NOACTIVE)) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, APPStatusWidget.class));
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
}
}
private void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
LogUtils.d(TAG, "updateAppWidget(...)");
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
//设置按钮点击事件
Intent intentAppButton = new Intent(context, APPStatusWidgetClickListener.class);
intentAppButton.setAction(APPStatusWidgetClickListener.ACTION_APPICON_CLICK);
PendingIntent pendingIntentAppButton = PendingIntent.getBroadcast(context, 0, intentAppButton, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.widgetlayoutImageView1, pendingIntentAppButton);
// boolean isActive = !MainServiceThread.isExist();
// if (isActive) {
// views.setImageViewResource(R.id.widgetlayoutImageView1, R.drawable.ic_launcher);
// } else {
// views.setImageViewResource(R.id.widgetlayoutImageView1, R.drawable.ic_launcher_disable);
//
// }
appWidgetManager.updateAppWidget(appWidgetId, views);
}
public static void onAPPStatusWidgetClick(Context context) {
ToastUtils.show("onAPPStatusWidgetClick");
}
}

View File

@@ -0,0 +1,32 @@
package cc.winboll.studio.contacts.widgets;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/17 14:59:55
* @Describe WidgetButtonClickListener
*/
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
import cc.winboll.studio.libappbase.LogUtils;
public class APPStatusWidgetClickListener extends BroadcastReceiver {
public static final String TAG = "APPStatusWidgetClickListener";
public static final String ACTION_APPICON_CLICK = "cc.winboll.studio.contacts.widgets.APPStatusWidgetClickListener.ACTION_APPICON_CLICK";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action == null) {
LogUtils.d(TAG, String.format("action %s", action));
return;
}
if (action.equals(ACTION_APPICON_CLICK)) {
LogUtils.d(TAG, "ACTION_APPICON_CLICK");
Toast.makeText(context, "ACTION_APPICON_CLICK", Toast.LENGTH_SHORT).show();
}
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:clickable="true">
<item android:drawable="@drawable/ic_launcher_background"/>
<item
android:left="15dp"
android:top="15dp"
android:right="15dp"
android:bottom="15dp"
android:drawable="@drawable/ic_launcher_foreground"/>
</layer-list>

View File

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

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:clickable="true">
<item android:drawable="@drawable/ic_launcher_background"/>
<item
android:left="15dp"
android:top="15dp"
android:right="15dp"
android:bottom="15dp"
android:drawable="@drawable/ic_launcher_foreground_disable"/>
</layer-list>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M16.61,15.15C16.15,15.15 15.77,14.78 15.77,14.32S16.15,13.5 16.61,13.5H16.61C17.07,13.5 17.45,13.86 17.45,14.32C17.45,14.78 17.07,15.15 16.61,15.15M7.41,15.15C6.95,15.15 6.57,14.78 6.57,14.32C6.57,13.86 6.95,13.5 7.41,13.5H7.41C7.87,13.5 8.24,13.86 8.24,14.32C8.24,14.78 7.87,15.15 7.41,15.15M16.91,10.14L18.58,7.26C18.67,7.09 18.61,6.88 18.45,6.79C18.28,6.69 18.07,6.75 18,6.92L16.29,9.83C14.95,9.22 13.5,8.9 12,8.91C10.47,8.91 9,9.24 7.73,9.82L6.04,6.91C5.95,6.74 5.74,6.68 5.57,6.78C5.4,6.87 5.35,7.08 5.44,7.25L7.1,10.13C4.25,11.69 2.29,14.58 2,18H22C21.72,14.59 19.77,11.7 16.91,10.14H16.91Z"/>
</vector>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#FFAAAAAA"
android:pathData="M16.61,15.15C16.15,15.15 15.77,14.78 15.77,14.32S16.15,13.5 16.61,13.5H16.61C17.07,13.5 17.45,13.86 17.45,14.32C17.45,14.78 17.07,15.15 16.61,15.15M7.41,15.15C6.95,15.15 6.57,14.78 6.57,14.32C6.57,13.86 6.95,13.5 7.41,13.5H7.41C7.87,13.5 8.24,13.86 8.24,14.32C8.24,14.78 7.87,15.15 7.41,15.15M16.91,10.14L18.58,7.26C18.67,7.09 18.61,6.88 18.45,6.79C18.28,6.69 18.07,6.75 18,6.92L16.29,9.83C14.95,9.22 13.5,8.9 12,8.91C10.47,8.91 9,9.24 7.73,9.82L6.04,6.91C5.95,6.74 5.74,6.68 5.57,6.78C5.4,6.87 5.35,7.08 5.44,7.25L7.1,10.13C4.25,11.69 2.29,14.58 2,18H22C21.72,14.59 19.77,11.7 16.91,10.14H16.91Z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="36dp"
android:height="36dp"
android:viewportHeight="1024"
android:viewportWidth="1024">
<path
android:fillColor="#fff"
android:pathData="M847.53,307.03L597.5,307.03c-8.54,0.17 -13.66,-11.26 -13.66,-19.97 0.17,-8.7 5.12,-14.17 13.66,-14.17h250.02c30.21,-0.34 31.41,34.14 0,34.14zM736.6,428.71c-6.14,6.32 -16.05,6.32 -22.02,0.17l-128.34,-130.56c-5.98,-6.14 -5.8,-16.22 0.17,-22.53l122.37,-124.76c6.14,-6.31 16.05,-6.31 22.02,-0.34 5.98,6.14 5.81,16.22 -0.34,22.36L623.1,289.62l113.5,116.22a16.33,16.33 0,0 1,0 22.87zM833.02,717.99c-18.78,-12.63 -122.37,-64.85 -141.99,-77.14 -2.05,0 -7.34,0.68 -14.85,4.43 -8.02,4.1 -31.23,16.9 -63.66,34.99l-25.26,14.16 -23.9,-16.38c-17.75,-12.11 -56.32,-41.3 -115.03,-98.64 -58.88,-57.69 -88.58,-95.23 -101.04,-112.47l-16.72,-23.38L345.09,418.82c13.99,-23.9 30.72,-52.9 35.84,-62.46 4.1,-7.51 4.44,-12.63 4.44,-14.17v-0.51C374.27,324.44 303.27,219.65 290.3,201.22c-1.88,-0.34 -5.8,0 -10.75,3.42 -40.28,28.5 -82.43,68.95 -88.41,84.65C195.24,373.42 270.85,491.52 404.48,622.25c133.8,130.73 251.22,205.49 336.9,209.41 16.22,-5.63 62.81,-52.05 91.65,-91.14 2.05,-2.9 3.24,-3.58 3.24,-6.99 0,-0.51 -3.07,-15.02 -3.24,-15.53zM867.5,770.73c-0.68,1.02 -81.58,108.03 -126.12,106.67 -125.1,-3.93 -265.73,-128.86 -366.94,-227.84 -101.38,-98.99 -225.45,-238.25 -229.38,-360.96v-1.02c0,-43.01 124.76,-128 125.78,-128.69 19.62,-13.14 36.35,-13.82 52.39,10.41 7.85,10.92 87.73,123.9 96.94,138.58 3.92,6.49 11.09,25.94 11.09,34.48 0,10.92 -3.24,23.21 -9.73,34.98 -6.31,11.61 -26.62,46.59 -36.69,63.83 10.92,15.19 46.76,61.44 103.94,117.25 56.83,55.63 85.16,72.19 100.69,82.77 17.58,-9.73 53.42,-29.7 65.2,-35.67 22.18,-11.44 44.37,-12.8 59.39,-3.42 14.16,8.7 136.02,88.41 147.79,96.6 10.93,7.68 16.9,21.67 16.9,36.69 0.17,11.78 -3.58,24.41 -11.26,35.33z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="36dp"
android:height="36dp"
android:viewportHeight="1024"
android:viewportWidth="1024">
<path
android:fillColor="#fff"
android:pathData="M861.86,307.03L614.4,307.03c-31.06,-0.17 -29.86,-34.48 0,-34.14h247.46c8.54,0.17 13.31,5.46 13.49,14.17 0,8.87 -4.95,20.14 -13.49,19.97zM872.96,298.5l-126.98,130.56c-5.98,6.14 -15.7,5.98 -21.85,-0.17 -6.14,-6.32 -6.14,-16.38 -0.17,-22.36l112.3,-116.22L730.11,173.74c-6.14,-6.31 -6.14,-16.38 -0.17,-22.35 5.97,-6.14 15.7,-5.98 21.84,0.34L872.96,276.48c5.8,5.8 5.98,15.87 0,22.02zM833.02,717.99c-18.78,-12.63 -122.37,-64.85 -141.99,-77.14 -2.05,0 -7.34,0.68 -14.85,4.43 -8.02,4.1 -31.23,16.9 -63.66,34.99l-25.26,14.16 -23.9,-16.38c-17.75,-12.11 -56.32,-41.3 -115.03,-98.64 -58.88,-57.69 -88.41,-95.23 -100.86,-112.47L330.75,443.56l14.5,-24.74c14,-23.9 30.72,-52.9 35.84,-62.46 4.1,-7.51 4.44,-12.63 4.44,-14.17v-0.51C374.44,324.44 303.45,219.65 290.3,201.22c-1.88,-0.34 -5.8,0 -10.75,3.42 -40.28,28.5 -82.43,68.95 -88.41,84.65C195.24,373.42 270.85,491.52 404.48,622.25c133.63,130.73 251.05,205.49 336.9,209.41 16.22,-5.63 62.81,-52.05 91.65,-91.14 2.05,-2.9 3.24,-3.58 3.24,-6.99 0,-0.51 -3.07,-15.02 -3.24,-15.53zM867.5,770.73c-0.68,1.02 -81.58,108.03 -126.12,106.67 -125.1,-3.93 -265.56,-128.86 -366.94,-227.84 -101.38,-98.99 -225.45,-238.25 -229.38,-360.96v-1.02c0,-43.01 124.76,-128 125.78,-128.69 19.62,-13.14 36.35,-13.82 52.39,10.41 7.85,10.92 87.73,123.9 96.94,138.58 4.1,6.49 11.09,25.94 11.09,34.48 0,10.92 -3.24,23.21 -9.73,34.98 -6.14,11.61 -26.62,46.59 -36.69,63.83 10.75,15.19 46.76,61.44 103.94,117.25 56.83,55.63 85.16,72.19 100.69,82.77 17.58,-9.73 53.42,-29.7 65.2,-35.67 22.18,-11.44 44.37,-12.8 59.39,-3.42 14.16,8.7 136.19,88.41 147.79,96.6 10.93,7.68 16.9,21.67 16.9,36.69 0.17,11.78 -3.58,24.41 -11.26,35.33z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="64dp"
android:viewportHeight="1024"
android:viewportWidth="1024">
<path
android:fillColor="#201f1f"
android:pathData="M841.22,856.06c185.86,-185.86 185.86,-487.42 0,-673.79C655.36,-3.58 353.79,-3.58 167.42,182.27c-185.86,185.86 -185.86,487.42 0,673.79 186.37,185.86 487.94,185.86 673.79,0zM218.62,495.1c0,-47.62 111.1,-113.66 285.7,-113.66 175.1,0 285.7,66.05 285.7,113.66 0,40.96 10.75,102.4 -73.73,93.18 -84.48,-9.22 -78.85,-40.96 -78.85,-83.46 0,-29.7 -68.61,-36.35 -133.12,-36.35 -65.02,0 -133.12,6.66 -133.12,36.35 0,42.5 5.63,74.24 -78.85,83.46 -84.99,9.22 -73.73,-51.71 -73.73,-93.18z" />
</vector>

View File

@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="64dp"
android:viewportHeight="1024"
android:viewportWidth="1024">
<path
android:fillColor="#FFFFFF"
android:pathData="M277.9,742s167.9,-294.1 465.3,-465.3C575.7,577.8 277.9,742 277.9,742z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M743.1,742S575.2,447.9 277.8,276.7C445.3,577.8 743.1,742 743.1,742z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M284.1,343m-49,0a49,49 0,1 0,98 0,49 49,0 1,0 -98,0Z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M284.1,515.5m-49,0a49,49 0,1 0,98 0,49 49,0 1,0 -98,0Z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M284.1,683.5m-49,0a49,49 0,1 0,98 0,49 49,0 1,0 -98,0Z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M808.4,341.6s-208.5,-61.2 -420,0c211.5,64.8 420,0 420,0zM808.4,516.6s-208.5,-61.2 -420,0c211.5,64.8 420,0 420,0zM808.4,684.6s-208.5,-61.2 -420,0c211.5,64.8 420,0 420,0z" />
<path
android:fillColor="#0EC469"
android:pathData="M512,512m-448,0a448,448 0,1 0,896 0,448 448,0 1,0 -896,0Z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M701.4,786.8h-0.3c-3.2,-0.3 -6.4,-0.8 -9.5,-1.4C290,725.2 237.2,331.5 237.2,331.5h0.1c-5.9,-27.8 0.8,-56.8 22.5,-78.5 9.5,-9.5 22.5,-18.1 31.3,-19.2l111.6,111.6c-1.1,8.8 -9.6,21.7 -19.1,31.2 -8.5,8.5 -17.9,14.4 -28.4,18.6 57.7,214.5 272.1,271.5 272.1,271.5l0.3,0.2c4.2,-10.5 9.6,-19.3 18.1,-27.8 9.5,-9.5 22.6,-18.1 31.4,-19.2l111.6,111.6c-1.1,8.8 -9.6,21.7 -19.1,31.2 -18.9,19 -43.4,26.3 -68.2,24.1z" />
</vector>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="180"
android:endColor="#FFFFFFFF"
android:startColor="#FFFFFFFF"
android:type="linear" />
<corners android:radius="10dp" />
</shape>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<EditText
android:id="@+id/phone_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入电话号码"/>
<Button
android:id="@+id/dial_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="拨号"/>
<TextView
android:id="@+id/call_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"/>
</LinearLayout>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<EditText
android:id="@+id/phone_number_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter phone number" />
<Button
android:id="@+id/dial_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Dial" />
</LinearLayout>

View File

@@ -0,0 +1,27 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/activitymainToolbar1"/>
<androidx.viewpager.widget.ViewPager
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:id="@+id/activitymainViewPager1"/>
<com.google.android.material.tabs.TabLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/activitymainTabLayout1"/>
</LinearLayout>

View File

@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".phonecallui.PhoneCallActivity">
<RelativeLayout
android:id="@+id/rl_user_info"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="@color/colorPrimaryDark">
<TextView
android:id="@+id/tv_call_number_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/tv_call_number"
android:layout_marginBottom="16dp"
android:gravity="center"
android:text="来电号码"
android:textColor="@android:color/white"
android:textSize="18sp" />
<TextView
android:id="@+id/tv_call_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="28sp"
android:textStyle="bold"
android:layout_centerInParent="true"
tools:text="133-9527-9527" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<TextView
android:id="@+id/tv_phone_calling_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:text="通话中01:33"
android:textColor="@android:color/black"
android:textSize="18sp"
android:visibility="gone"
tools:visibility="visible" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<TextView
android:id="@+id/tv_phone_hang_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="16dp"
android:drawableTop="@drawable/ic_phone_hang_up"
android:foreground="?android:attr/selectableItemBackground"
android:gravity="center"
android:padding="8dp"
android:text="挂 断"
android:textColor="@android:color/black"
tools:visibility="visible" />
<TextView
android:id="@+id/tv_phone_pick_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_toRightOf="@id/tv_phone_hang_up"
android:drawablePadding="16dp"
android:drawableTop="@drawable/ic_phone_pick_up"
android:foreground="?android:attr/selectableItemBackground"
android:gravity="center"
android:padding="8dp"
android:text="接 听"
android:textColor="@android:color/black"
android:visibility="gone"
tools:visibility="visible" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

View File

@@ -0,0 +1,96 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/activitymainToolbar1"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="服务设置:"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Switch
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="主要服务"
android:id="@+id/sw_mainservice"
android:layout_margin="10dp"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="应用权限设置:"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="悬浮窗设置"
android:id="@+id/activitysettingsButton2"
android:onClick="onCanDrawOverlays"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="默认拨号设置"
android:id="@+id/activitysettingsButton1"
android:onClick="onDefaultPhone"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="音量设置:"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:id="@+id/tv_volume"/>
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:max="100"
android:id="@+id/bellvolume"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="0dp"
android:ems="10"
android:layout_height="wrap_content"
android:layout_weight="1.0"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text"
android:id="@+id/page_text"/>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text"
android:id="@+id/page_text"/>
</LinearLayout>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<cc.winboll.studio.libappbase.LogView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/logview"/>
</LinearLayout>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rl_user_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary">
<TextView
android:id="@+id/tv_call_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:gravity="center"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="18sp"
tools:text="133-8892-9579" />
<Button
android:id="@+id/btn_open_app"
style="@style/Base.Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="match_parent"
android:textColor="@android:color/white"
android:layout_height="wrap_content"
android:layout_below="@id/tv_call_number"
android:gravity="center"
android:text="打开 Phone Call App"
android:textAlignment="center"
android:textSize="16sp" />
</RelativeLayout>

View File

@@ -0,0 +1,32 @@
<?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="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_gradient"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/ic_launcher"/>
<TextView
android:id="@android:id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:textColor="#FF000000"
android:textSize="16sp"/>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="40dp"
android:layout_height="40dp">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/widgetlayoutImageView1"/>
</LinearLayout>

View File

@@ -0,0 +1,12 @@
<?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/item_call"
android:title="CallActivity"/>
<item
android:id="@+id/item_settings"
android:title="SettingsActivity"/>
</menu>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- WinBoll 默认方案 -->
<color name="colorPrimary">#FF196ABC</color>
<color name="colorPrimaryDark">#FF002B57</color>
<color name="colorAccent">#FF80BFFF</color>
</resources>

View File

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

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyAppTheme" parent="APPBaseTheme">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<style name="GlobalCrashActivityTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
<item name="colorTittle">@color/colorAccent</item>
<item name="colorTittleBackgound">@color/colorPrimary</item>
<item name="colorText">@color/colorAccent</item>
<item name="colorTextBackgound">@color/colorPrimaryDark</item>
</style>
</resources>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="40dp"
android:minHeight="40dp"
android:updatePeriodMillis="0"
android:initialLayout="@layout/widget_layout"
android:resizeMode="none">
</appwidget-provider>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path
name="external_storage_root"
path="." />
<files-path
name="files_path"
path="." />
<cache-path
name="cache_path"
path="." />
<!--/storage/emulated/0/Android/data/...-->
<external-files-path
name="external_file_path"
path="." />
<!--代表app 外部存储区域根目录下的文件 Context.getExternalCacheDir目录下的目录-->
<external-cache-path
name="external_cache_path"
path="." />
<!--配置root-path。这样子可以读取到sd卡和一些应用分身的目录否则微信分身保存的图片就会导致 java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/999/tencent/MicroMsg/WeiXin/export1544062754693.jpg在小米6的手机上微信分身有这个crash华为没有
-->
<root-path
name="root_path"
path="" />
</paths>

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,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Put flavor specific strings here -->
</resources>

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Feb 25 16:50:23 HKT 2025
stageCount=2
#Tue Feb 25 16:51:09 HKT 2025
stageCount=3
libraryProject=libappbase
baseVersion=2.0
publishVersion=2.0.1
publishVersion=2.0.2
buildCount=0
baseBetaVersion=2.0.2
baseBetaVersion=2.0.3

1
mymessagemanager/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,45 @@
# MyMessageManager
#### 介绍
用正则表达式方法自定义短信过滤和语音播报的短信应用。
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码ZhanGSKen(ZhanGSKen@QQ.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

@@ -0,0 +1 @@

View File

@@ -0,0 +1,69 @@
apply plugin: 'com.android.application'
apply from: '../.winboll/winboll_app_build.gradle'
apply from: '../.winboll/winboll_lint_build.gradle'
def genVersionName(def versionName){
// 检查编译标志位配置
assert (winbollBuildProps['stageCount'] != null)
assert (winbollBuildProps['baseVersion'] != null)
// 保存基础版本号
winbollBuildProps.setProperty("baseVersion", "${versionName}");
//保存编译标志配置
FileOutputStream fos = new FileOutputStream(winbollBuildPropsFile)
winbollBuildProps.store(fos, "${winbollBuildPropsDesc}");
fos.close();
// 返回编译版本号
return "${versionName}." + winbollBuildProps['stageCount']
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "cc.winboll.studio.mymessagemanager"
minSdkVersion 26
targetSdkVersion 29
versionCode 8
// versionName 更新后需要手动设置
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
versionName "4.1"
if(true) {
versionName = genVersionName("${versionName}")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api 'cc.winboll.studio:winboll-shared:1.6.4'
api 'io.github.medyo:android-about-page:2.0.0'
api 'com.github.getActivity:ToastUtils:10.5'
api 'com.jcraft:jsch:0.1.55'
api 'org.jsoup:jsoup:1.13.1'
api 'com.squareup.okhttp3:okhttp:4.4.1'
api 'androidx.appcompat:appcompat:1.0.0'
api 'androidx.fragment:fragment:1.0.0'
api 'com.google.android.material:material:1.0.0'
// 权限请求框架https://github.com/getActivity/XXPermissions
api 'com.github.getActivity:XXPermissions:18.63'
api 'com.baoyz.pullrefreshlayout:library:1.2.0'
api 'androidx.appcompat:appcompat:1.0.0'
api 'androidx.fragment:fragment:1.0.0'
api 'com.google.android.material:material:1.0.0'
api 'cc.winboll.studio:libaes:7.6.0'
api fileTree(dir: 'libs', include: ['*.jar'])
}

View File

@@ -0,0 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Feb 25 10:52:41 GMT 2025
stageCount=14
libraryProject=
baseVersion=4.1
publishVersion=4.1.13
buildCount=5
baseBetaVersion=4.1.14

17
mymessagemanager/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,23 @@
<?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

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

View File

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

View File

@@ -0,0 +1,231 @@
<?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=".GlobalApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:roundIcon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/WinBoll.SupportThemeNoActionBar"
android:persistent="true"
android:resizeableActivity="true"
android:supportsRtl="true"
android:requestLegacyExternalStorage="true">
<activity
android:name=".activitys.SMSActivity"
android:process=":sms"/>
<activity
android:name=".activitys.SMSReceiveRuleActivity"
android:process=":smsars">
</activity>
<activity
android:name=".activitys.SharedJSONReceiveActivity"
android:process=":smssjr"
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"
android:process=":ttsrule"/>
<activity
android:name=".activitys.AboutActivity"
android:process=":about"/>
<activity
android:name=".activitys.MainActivity"
android:exported="true"
android:process=":main">
<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"
android:process=":csms">
<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"/>
</application>
</manifest>

View File

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

View File

@@ -0,0 +1,38 @@
[
{
"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

@@ -0,0 +1,52 @@
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.mymessagemanager.R;
import cc.winboll.studio.shared.app.WinBollApplication;
import cc.winboll.studio.shared.log.LogUtils;
import com.hjq.toast.ToastUtils;
import java.io.File;
public class GlobalApplication extends WinBollApplication {
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();
//setIsDebug(cc.winboll.studio.mymessagemanager.BuildConfig.DEBUG);
// 初始化 Toast 框架
ToastUtils.init(this);
// 设置 Toast 布局样式
ToastUtils.setView(R.layout.toast_custom_view);
//ToastUtils.setStyle(new WhiteToastStyle());
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
//LogUtils.d(TAG, "BuildConfig.DEBUG " + Boolean.toString(BuildConfig.DEBUG));
_mszAppExternalFilesDir = getExternalFilesDir(TAG).toString();
_mszConfigUtilPath = _mszAppExternalFilesDir + File.separator + _mszConfigUtilFileName;
_mszSMSReceiveRuleUtilPath = _mszAppExternalFilesDir + File.separator + _mszSMSReceiveRuleUtilFileName;
}
public static void showApplicationMessage(String szMessage) {
LogUtils.i(TAG, szMessage);
}
}

View File

@@ -0,0 +1,74 @@
package cc.winboll.studio.mymessagemanager.activitys;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/07/14 13:20:33
* @Describe 应用关于对话窗口
*/
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import androidx.appcompat.widget.Toolbar;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.shared.app.WinBollActivity;
import cc.winboll.studio.shared.app.WinBollActivityManager;
import com.hjq.toast.ToastUtils;
import cc.winboll.studio.libaes.utils.AESThemeUtil;
import android.content.Context;
final public class AboutActivity extends WinBollActivity {
public static final String TAG = "AboutActivity";
Context mContext;
@Override
public String getTag() {
return TAG;
}
@Override
protected boolean isEnableDisplayHomeAsUp() {
return false;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(AESThemeUtil.getThemeTypeID(getApplicationContext()));
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
mContext = getApplicationContext();
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
setTitle(mContext.getString(R.string.text_about) + mContext.getString(R.string.app_name));
}
@Override
protected boolean isAddWinBollToolBar() {
return false;
}
@Override
protected Toolbar initToolBar() {
return findViewById(R.id.activityaboutASupportToolbar1);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.toolbar_about, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
/*if (item.getItemId() == R.id.item_help) {
ToastUtils.show("R.id.item_help");
} else */if (item.getItemId() == android.R.id.home) {
WinBollActivityManager.getInstance(getApplicationContext()).finish(this);
}
return super.onOptionsItemSelected(item);
}
}

View File

@@ -0,0 +1,99 @@
package cc.winboll.studio.mymessagemanager.activitys;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/05/12 20:03:42
* @Describe 应用设置窗口
*/
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.Toast;
import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
import cc.winboll.studio.libaes.views.AToolbar;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil;
import cc.winboll.studio.mymessagemanager.utils.PermissionUtil;
public class AppSettingsActivity extends BaseActivity {
public static final String TAG = "AppSettingsActivity";
AppConfigUtil mAppConfigUtil;
AToolbar mAToolbar;
AOHPCTCSeekBar mAOHPCTCSeekBar;
EditText metTTSPlayDelayTimes;
EditText metPhoneMergePrefix;
Switch mswMergePrefixPhone;
Switch mswSMSRecycleProtectMode;
EditText metProtectModerRefuseChars;
EditText metProtectModerReplaceChars;
@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());
metProtectModerReplaceChars = findViewById(R.id.activityappsettingsEditText4);
metProtectModerReplaceChars.setText(mAppConfigUtil.mAppConfigBean.getProtectModerReplaceChars());
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());
mAppConfigUtil.mAppConfigBean.setProtectModerRefuseChars(metProtectModerRefuseChars.getText().toString());
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();
}
}
}

View File

@@ -0,0 +1,113 @@
package cc.winboll.studio.mymessagemanager.activitys;
import cc.winboll.studio.mymessagemanager.R;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.view.MenuItem;
import androidx.appcompat.app.AppCompatActivity;
import cc.winboll.studio.libaes.utils.AESThemeUtil;
import cc.winboll.studio.shared.log.LogUtils;
import com.hjq.toast.ToastUtils;
import cc.winboll.studio.libaes.beans.AESThemeBean;
abstract public class BaseActivity extends AppCompatActivity {
public static final String TAG = "BaseActivity";
IOnActivityMessageReceived mIOnActivityMessageReceived;
@Override
protected void onCreate(Bundle savedInstanceState) {
//AppConfigUtil configUtil = AppConfigUtil.getInstance(this);
//setTheme(configUtil.mAppConfigBean.getAppThemeID());
LogUtils.d(TAG, "AESThemeUtil.getThemeTypeID(this) is : " + Integer.toString(AESThemeUtil.getThemeTypeID(this)));
setTheme(AESThemeUtil.getThemeTypeID(this));
super.onCreate(savedInstanceState);
}
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);
}
}
};
protected interface IOnActivityMessageReceived {
void onActivityMessageReceived(Message msg);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
AESThemeUtil.inflateMenu(this, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
/*if (AESThemeUtil.onAppCompatThemeItemSelected(this, item)) {
ToastUtils.show("onAppCompatThemeItemSelected");
recreate();
}*/
/*int nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.DEFAULT);
if (R.id.item_depththeme == item.getItemId()) {
nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.DEPTH);
AESThemeUtil.saveThemeStyleID(this, nThemeStyleID);
recreate();
} else if (R.id.item_skytheme == item.getItemId()) {
nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.SKY);
AESThemeUtil.saveThemeStyleID(this, nThemeStyleID);
recreate();
} else if (R.id.item_goldentheme == item.getItemId()) {
nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.GOLDEN);
AESThemeUtil.saveThemeStyleID(this, nThemeStyleID);
recreate();
} else if (R.id.item_taotheme == item.getItemId()) {
nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.TAO);
AESThemeUtil.saveThemeStyleID(this, nThemeStyleID);
recreate();
} else if (R.id.item_defaulttheme == item.getItemId()) {
nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.DEFAULT);
AESThemeUtil.saveThemeStyleID(this, nThemeStyleID);
recreate();
}*/
//int nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.DEFAULT);
if (R.id.item_depththeme == item.getItemId()) {
AESThemeUtil.saveThemeStyleID(this, R.style.MyDepthAESTheme);
recreate();
} else if (R.id.item_skytheme == item.getItemId()) {
AESThemeUtil.saveThemeStyleID(this, R.style.MySkyAESTheme);
recreate();
} else if (R.id.item_goldentheme == item.getItemId()) {
AESThemeUtil.saveThemeStyleID(this, R.style.MyGoldenAESTheme);
recreate();
} else if (R.id.item_memortheme == item.getItemId()) {
AESThemeUtil.saveThemeStyleID(this, R.style.MyMemorAESTheme);
recreate();
} else if (R.id.item_taotheme == item.getItemId()) {
AESThemeUtil.saveThemeStyleID(this, R.style.MyTaoAESTheme);
recreate();
} else if (R.id.item_defaulttheme == item.getItemId()) {
AESThemeUtil.saveThemeStyleID(this, R.style.MyDefaultAESTheme);
recreate();
}
//ToastUtils.show("nThemeStyleID " + Integer.toString(nThemeStyleID));
return super.onOptionsItemSelected(item);
}
}

View File

@@ -0,0 +1,192 @@
package cc.winboll.studio.mymessagemanager.activitys;
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.Toast;
import android.widget.Toolbar;
import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.ComposeSMSActivity;
import cc.winboll.studio.mymessagemanager.beans.PhoneBean;
import cc.winboll.studio.mymessagemanager.utils.PhoneUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
import com.hjq.toast.ToastUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ComposeSMSActivity extends BaseActivity {
public static String TAG = "ComposeSMSActivity";
public static String EXTRA_SMSBODY = "sms_body";
static String MAP_NAME = "NAME";
static String MAP_PHONE = "PHONE";
String mszSMSBody;
String mszScheme;
String mszPhoneTo;
EditText metTO;
EditText metSMSBody;
SimpleAdapter mSimpleAdapter;
List<Map<String,Object>> mAdapterData = new ArrayList<>();
ListView mlvContracts;
List<PhoneBean> mListPhoneBeanContracts;
Toolbar mToolbar;
AOHPCTCSeekBar mAOHPCTCSeekBar;
RelativeLayout mrlContracts;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_composesms);
mszSMSBody = getIntent().getStringExtra(EXTRA_SMSBODY);
mszScheme = getIntent().getData().getScheme();
mszPhoneTo = getIntent().getData().getSchemeSpecificPart();
if (!mszScheme.equals("smsto")) {
// 其他方式未支持就退出
finish();
}
// 初始化视图
initView();
// 设置适配器
initAdapter();
// 设置搜索到的匹配位置
setListViewPrePosition();
}
//
// 初始化视图
//
void initView() {
//Drawable drawableFrame = AppCompatResources.getDrawable(this, R.drawable.bg_frame);
// 初始化标题栏
mToolbar = findViewById(R.id.activitycomposesmsASupportToolbar1);
mToolbar.setSubtitle(getString(R.string.activity_name_composesms));
setActionBar(mToolbar);
// 初始化联系人栏目框
mrlContracts = findViewById(R.id.activitycomposesmsRelativeLayout1);
//mrlContracts.setBackground(drawableFrame);
// 初始化联系人列表
mlvContracts = findViewById(R.id.activitycomposesmsListView1);
// 初始化联系人输入框
metTO = findViewById(R.id.activitycomposesmsEditText1);
metTO.setText(mszPhoneTo);
metTO.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
setListViewPrePosition();
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
// 初始化发送拉动控件
mAOHPCTCSeekBar = findViewById(R.id.viewsmssendpart1AOHPCTCSeekBar1);
mAOHPCTCSeekBar.setThumb(getDrawable(R.drawable.ic_message));
mAOHPCTCSeekBar.setThumbOffset(20);
mAOHPCTCSeekBar.setOnOHPCListener(new AOHPCTCSeekBar.OnOHPCListener() {
@Override
public void onOHPCommit() {
// 空号码不发送
mszPhoneTo = metTO.getText().toString();
if (mszPhoneTo.trim().equals("")) {
ToastUtils.show("没有设置接收号码。");
return;
}
// 空消息不发送
mszSMSBody = metSMSBody.getText().toString();
if (mszSMSBody.equals("")) {
ToastUtils.show("没有消息内容可发送。");
return;
}
// 发送消息
if (SMSUtil.sendMessageByInterface2(ComposeSMSActivity.this, mszPhoneTo, mszSMSBody)) {
ComposeSMSActivity.this.finish();
}
}
});
// 初始化提示框
TextView tvAOHPCTCSeekBarMSG = findViewById(R.id.viewsmssendpart1TextView1);
tvAOHPCTCSeekBarMSG.setText(R.string.msg_100sendmsg);
// 初始化发送消息框
metSMSBody = findViewById(R.id.viewsmssendpart1EditText1);
//metSMSBody.setBackground(drawableFrame);
metSMSBody.setText(mszSMSBody);
}
//
// 设置搜索到的匹配位置
//
void setListViewPrePosition() {
int nPrePosition = getContractsDataPrePosition(metTO.getText().toString());
mlvContracts.setSelected(false);
mlvContracts.setSelection(nPrePosition);
}
//
// 返回搜索到的匹配位置
//
int getContractsDataPrePosition(String szPhone) {
for (int i = 0; i < mListPhoneBeanContracts.size(); i++) {
if (mListPhoneBeanContracts.get(i).getTelPhone().compareTo(szPhone) > -1) {
return i;
}
}
return 0;
}
//
// 初始化适配器
//
void initAdapter() {
// 初始化联系人数据适配器
mAdapterData = new ArrayList<>();
// 读取联系人数据
PhoneUtil phoneUtils = new PhoneUtil(this);
mListPhoneBeanContracts = phoneUtils.getPhoneList();
// 映射联系人数据给适配器数据对象
for (int i = 0;i < mListPhoneBeanContracts.size();i++) {
Map<String,Object> map =new HashMap<>();
map.put(MAP_NAME, mListPhoneBeanContracts.get(i).getName());
map.put(MAP_PHONE, mListPhoneBeanContracts.get(i).getTelPhone());
mAdapterData.add(map);
}
// 绑定适配器与数据
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 ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
metTO.setText(mAdapterData.get(position).get(MAP_PHONE).toString());
}
});
}
}

View File

@@ -0,0 +1,333 @@
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 cc.winboll.studio.libaes.views.AToolbar;
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.utils.AppConfigUtil;
import cc.winboll.studio.mymessagemanager.utils.AppGoToSettingsUtil;
import cc.winboll.studio.mymessagemanager.utils.NotificationUtil;
import cc.winboll.studio.mymessagemanager.utils.PermissionUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
import cc.winboll.studio.mymessagemanager.utils.ThemeUtil;
import cc.winboll.studio.mymessagemanager.utils.ViewUtil;
import cc.winboll.studio.mymessagemanager.views.ConfirmSwitchView;
import cc.winboll.studio.mymessagemanager.views.PhoneListViewForScrollView;
import cc.winboll.studio.shared.log.LogUtils;
import cc.winboll.studio.shared.log.LogView;
import com.baoyz.widget.PullRefreshLayout;
import java.util.ArrayList;
import cc.winboll.studio.libaes.utils.AESThemeUtil;
import cc.winboll.studio.libaes.views.ASupportToolbar;
import androidx.appcompat.widget.Toolbar;
public class MainActivity extends BaseActivity {
public 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;
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;
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);
// 创建通知频道
NotificationUtil nu = new NotificationUtil();
nu.createServiceNotificationChannel(MainActivity.this);
nu.createSMSNotificationChannel(MainActivity.this);
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();
}
@Override
protected void onResume() {
super.onResume();
reloadSMS();
mLogView.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//return super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.toolbar_main, menu);
/*ThemeUtil.BaseTheme baseTheme = ThemeUtil.getTheme(mAppConfigUtil.mAppConfigBean.getAppThemeID());
if (baseTheme == ThemeUtil.BaseTheme.DEFAULT) {
menu.findItem(R.id.app_defaulttheme).setChecked(true);
} else if (baseTheme == ThemeUtil.BaseTheme.SKY) {
menu.findItem(R.id.app_skytheme).setChecked(true);
} else if (baseTheme == ThemeUtil.BaseTheme.GOLDEN) {
menu.findItem(R.id.app_goldentheme).setChecked(true);
}*/
return super.onCreateOptionsMenu(menu);
}
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();
if (nItemId == R.id.app_ttsrule) {
Intent i = new Intent(MainActivity.this, TTSPlayRuleActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | 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_LAUNCH_ADJACENT | 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_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
} else if (nItemId == R.id.app_crashtest) {
for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
getString(i);
}
} else if (nItemId == R.id.app_about) {
Intent i = new Intent(MainActivity.this, AboutActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
} else if (nItemId == R.id.app_smsrecycle) {
Intent i = new Intent(MainActivity.this, SMSRecycleActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
return super.onOptionsItemSelected(item);
}
}

View File

@@ -0,0 +1,228 @@
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.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.AbsListView;
import android.widget.EditText;
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.views.AOHPCTCSeekBar;
import cc.winboll.studio.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.SMSActivity;
import cc.winboll.studio.mymessagemanager.adapters.SMSArrayAdapter;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
import cc.winboll.studio.mymessagemanager.utils.ViewUtil;
import cc.winboll.studio.mymessagemanager.views.SMSListViewForScrollView;
import cc.winboll.studio.mymessagemanager.views.SMSView;
import java.lang.ref.WeakReference;
public class SMSActivity extends BaseActivity {
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;
ScrollView mScrollView;
EditText metSMSBody;
SMSActivityBroadcastReceiver mSMSActivityBroadcastReceiver;
Handler mSetFocusHandler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sms);
initView();
mSetFocusHandler = new MyHandler(SMSActivity.this);
scrollScrollView();
// 每隔一定时间设置输入框获得焦点
//
new Thread() {
@Override
public void run() {
while (true) {
try {
Thread.sleep(1500);
} catch (InterruptedException e) {}
Message message = mSetFocusHandler.obtainMessage(MSG_SET_FOCUS);
mSetFocusHandler.sendMessage(message);
}
}}.start();
}
//
// 设置输入框获得焦点的类
//
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();
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 = findViewById(R.id.activitysmsASupportToolbar1);
mToolbar.setSubtitle(getString(R.string.activity_name_smsinphone) + " < Phone : " + mszPhoneTo + " >");
setActionBar(mToolbar);
// 初始化滚动窗口
mScrollView = findViewById(R.id.activitysmsinphoneScrollView1);
// 初始化发送消息框
//Drawable drawableFrame = AppCompatResources.getDrawable(this, R.drawable.bg_frame);
metSMSBody = findViewById(R.id.viewsmssendpart1EditText1);
//metSMSBody.setBackground(drawableFrame);
// 初始化发送拉动控件
final 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() {
//Toast.makeText(getApplication(), "Send", Toast.LENGTH_SHORT).show();
sendSMS();
}
});
// 初始化提示框
TextView tvAOHPCTCSeekBarMSG = findViewById(R.id.viewsmssendpart1TextView1);
tvAOHPCTCSeekBarMSG.setText(R.string.msg_100sendmsg);
mlvSMS = (SMSListViewForScrollView) findViewById(R.id.activitysmsinphoneListView1);
// 准备数据
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();
intentFilter.addAction(ACTION_NOTIFY_SMS_CHANGED);
LocalBroadcastManager.getInstance(this).registerReceiver(mSMSActivityBroadcastReceiver, intentFilter);
/*SMSView mSMSView = findViewById(R.id.viewsmssendSMSView1);
mSMSView.setSMSType(SMSView.SMSType.SEND);*/
}
//
// 更新信息列表
//
public void updateSMSView() {
mSMSArrayAdapter.reLoadSMSList(SMSActivity.this, mszPhoneTo);
mSMSArrayAdapter.notifyDataSetChanged();
}
//
// 滚动消息文本框
//
void scrollScrollView() {
ViewUtil.scrollScrollView(mScrollView);
}
//
// 发送短信
//
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("");
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
updateSMSView();
ViewUtil.scrollScrollView(mScrollView);
}
}, 1000);
}
}
class SMSActivityBroadcastReceiver extends BroadcastReceiver {
public SMSActivityBroadcastReceiver() {
//LogUtils.d(TAG, "SMSActivityBroadcastReceiver()");
}
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()) {
case ACTION_NOTIFY_SMS_CHANGED :
//Toast.makeText(context, "ACTION_NOTIFY_SMS_CHANGED", Toast.LENGTH_SHORT).show();
updateSMSView();
ViewUtil.scrollScrollView(mScrollView);
//LogUtils.d(TAG, "ACTION_NOTIFY_SMS_CHANGED");
break;
default:
throw new IllegalStateException("Unexpected value: " + intent.getAction());
}
}
}
}

View File

@@ -0,0 +1,232 @@
package cc.winboll.studio.mymessagemanager.activitys;
/**
* @Author 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.mymessagemanager.GlobalApplication;
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;
public class SMSReceiveRuleActivity extends BaseActivity {
public static final String TAG = "SMSReceiveRuleActivity";
Context mContext;
RecyclerView mRecyclerView;
Toolbar mToolbar;
RadioButton mrbAccept;
RadioButton mrbRefuse;
CheckBox mcbEnable;
SMSAcceptRuleBean mSMSAcceptRuleBeanAdd;
SMSAcceptRuleArrayAdapter mSMSAcceptRuleArrayAdapter;
@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(GlobalApplication.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

@@ -0,0 +1,92 @@
package cc.winboll.studio.mymessagemanager.activitys;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/07/19 16:56:18
* @Describe 短信回收站
*/
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
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 cc.winboll.studio.shared.view.YesNoAlertDialog;
import com.baoyz.widget.PullRefreshLayout;
import java.io.File;
import androidx.appcompat.widget.Toolbar;
public class SMSRecycleActivity extends BaseActivity {
public static final String TAG = "SMSRecycleActivity";
Toolbar mToolbar;
RecyclerView mRecyclerView;
SMSRecycleAdapter mSMSRecycleAdapter;
@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

@@ -0,0 +1,139 @@
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.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
import cc.winboll.studio.mymessagemanager.beans.TTSPlayRuleBean;
import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog;
import cc.winboll.studio.mymessagemanager.utils.UriUtil;
import java.util.ArrayList;
public class SharedJSONReceiveActivity extends BaseActivity {
public static final String TAG = "SharedJSONReceive";
Toolbar mToolbar;
@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

@@ -0,0 +1,188 @@
package cc.winboll.studio.mymessagemanager.activitys;
/**
* @Author 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.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;
public class TTSPlayRuleActivity extends BaseActivity {
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
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

@@ -0,0 +1,114 @@
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.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.PhoneUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
import cc.winboll.studio.shared.log.LogUtils;
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();
}
String szAddress = ((SMSBean)getItem(position)).getAddress();
viewHolder.tvAddress.setText(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, viewHolder.tvAddress.getText());
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

@@ -0,0 +1,229 @@
package cc.winboll.studio.mymessagemanager.adapters;
/**
* @Author 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.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
import cc.winboll.studio.mymessagemanager.utils.SMSReceiveRuleUtil;
import com.hjq.toast.ToastUtils;
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

@@ -0,0 +1,213 @@
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.mymessagemanager.R;
import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity;
import cc.winboll.studio.mymessagemanager.beans.SMSBean;
import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog;
import cc.winboll.studio.mymessagemanager.utils.NotificationUtil;
import cc.winboll.studio.mymessagemanager.utils.SMSReceiveRuleUtil;
import cc.winboll.studio.mymessagemanager.utils.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 com.hjq.toast.ToastUtils;
import java.util.ArrayList;
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
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) {
NotificationUtil.cancelNotification(mContext, 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

@@ -0,0 +1,289 @@
package cc.winboll.studio.mymessagemanager.adapters;
/**
* @Author 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.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.dialogs.YesNoAlertDialog;
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 com.hjq.toast.ToastUtils;
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(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(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

@@ -0,0 +1,193 @@
package cc.winboll.studio.mymessagemanager.adapters;
/**
* @Author 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

@@ -0,0 +1,185 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/06/02 20:07:44
* @Describe 应用配置数据类
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.mymessagemanager.utils.ThemeUtil;
import cc.winboll.studio.shared.app.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 = "当前替代显示字符";
//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 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("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("appThemeID")) {
bean.setAppThemeID(jsonReader.nextInt());
}*/ else {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return bean;
}
}

View File

@@ -0,0 +1,88 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author 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

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

@@ -0,0 +1,53 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author 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

@@ -0,0 +1,39 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author 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

@@ -0,0 +1,121 @@
package cc.winboll.studio.mymessagemanager.beans;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2024/05/30 10:57:14
* @Describe 短信接收规则类
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.shared.app.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;
}
}

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