Compare commits

...

4 Commits

Author SHA1 Message Date
ZhanGSKen 25a9e4b230 <powerbell>APK 15.15.24 release Publish. 2026-07-18 10:07:32 +08:00
MiMo 1de0a36d79 <powerbell> 优化 ChargeMailNotify 提醒方式切换逻辑
1. RemindThread 提醒线程
   - ChargeMailNotify 启用:使用 APPMSGMailRemindThread 邮件提醒
   - ChargeMailNotify 未启用:使用 TTSRemindThread 语音提醒
   - 停止线程时同步切换逻辑

2. ControlCenterServiceHandler 消息处理
   - ChargeMailNotify 启用:使用 Toast 代替通知栏提醒
   - ChargeMailNotify 未启用:正常发送通知栏提醒

3. 悬浮窗提示信息更新
   - 新增TTS语音播放功能已禁用提示
   - 新增电量提醒通知栏功能已禁用提示
2026-07-18 10:05:08 +08:00
ZhanGSKen f7968e55c6 <powerbell>APK 15.15.23 release Publish. 2026-07-18 05:24:20 +08:00
MiMo 97f42054d2 <powerbell> 优化 ChargeMailNotify 开关联动逻辑
1. SettingsActivity 充电邮件通知开关
   - 开启时:先 stopService 再 startService 重启 ControlCenterService
   - 关闭时:停止 RemindThread 并关闭悬浮窗

2. ControlCenterService 服务销毁
   - onDestroy 中关闭 ChargeMailNotifyFloatWindow 悬浮窗
   - 资源释放顺序:前台服务 → 线程 → 悬浮窗 → 广播接收器 → Handler → 通知
2026-07-18 05:21:48 +08:00
6 changed files with 80 additions and 35 deletions
+4 -4
View File
@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Sat Jul 18 04:46:59 HKT 2026
stageCount=23
#Sat Jul 18 10:07:32 HKT 2026
stageCount=25
libraryProject=
baseVersion=15.15
publishVersion=15.15.22
publishVersion=15.15.24
buildCount=0
baseBetaVersion=15.15.23
baseBetaVersion=15.15.25
@@ -22,6 +22,7 @@ import cc.winboll.studio.powerbell.models.ThoughtfulServiceBean;
import cc.winboll.studio.powerbell.utils.ChargeMailNotifyHelper;
import cc.winboll.studio.powerbell.utils.ChargeMailNotifyFloatWindow;
import cc.winboll.studio.powerbell.threads.RemindThread;
import cc.winboll.studio.powerbell.services.ControlCenterService;
import android.widget.Switch;
import java.lang.reflect.Field;
@@ -262,8 +263,13 @@ public class SettingsActivity extends WinBoLLActivity implements IWinBoLLActivit
LogUtils.d(TAG, "onChargeMailNotifySwitchChanged: 充电邮件通知开关状态=" + isChecked);
ChargeMailNotifyHelper.setEnabled(this, isChecked);
updateSMTPConfigViewEnabled(isChecked);
// 关闭时停止RemindThread并关闭悬浮窗
if (!isChecked) {
if (isChecked) {
// 开启时重启ControlCenterService
LogUtils.d(TAG, "onChargeMailNotifySwitchChanged: 开启充电邮件通知,重启ControlCenterService");
stopService(new Intent(this, ControlCenterService.class));
startService(new Intent(this, ControlCenterService.class));
} else {
// 关闭时停止RemindThread并关闭悬浮窗
LogUtils.d(TAG, "onChargeMailNotifySwitchChanged: 关闭充电邮件通知,停止RemindThread");
RemindThread.stopRemindThread();
LogUtils.d(TAG, "onChargeMailNotifySwitchChanged: 关闭充电邮件通知悬浮窗");
@@ -3,10 +3,12 @@ package cc.winboll.studio.powerbell.handlers;
import android.os.Handler;
import android.os.Message;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.ToastUtils;
import cc.winboll.studio.powerbell.models.NotificationMessage;
import cc.winboll.studio.powerbell.models.ThoughtfulServiceBean;
import cc.winboll.studio.powerbell.services.ControlCenterService;
import cc.winboll.studio.powerbell.threads.TTSRemindThread;
import cc.winboll.studio.powerbell.utils.ChargeMailNotifyHelper;
import java.lang.ref.WeakReference;
/**
@@ -85,11 +87,7 @@ public class ControlCenterServiceHandler extends Handler {
private void handleRemindMessage(ControlCenterService service, String remindType, int currentBattery, boolean isCharging) {
LogUtils.d(TAG, "handleRemindMessage: 开始处理提醒消息 | type=" + remindType + " | battery=" + currentBattery + " | isCharging=" + isCharging);
// 1. 前置校验:通知工具类+参数有效性
if (service.getNotificationManager() == null) {
LogUtils.e(TAG, "handleRemindMessage: 通知管理工具类未初始化,无法发送提醒");
return;
}
// 1. 前置校验:参数有效性
if (!REMIND_TYPE_CHARGE.equals(remindType) && !REMIND_TYPE_USAGE.equals(remindType)) {
LogUtils.w(TAG, "handleRemindMessage: 提醒类型无效,忽略 | type=" + remindType + " | 允许值:" + REMIND_TYPE_CHARGE + "/" + REMIND_TYPE_USAGE);
return;
@@ -99,24 +97,40 @@ public class ControlCenterServiceHandler extends Handler {
return;
}
// 2. 构建通知模型,使用统一格式
NotificationMessage remindMsg = new NotificationMessage();
// 2. 构建提醒内容
String chargeStateDesc = isCharging ? CHARGE_STATE_CHARGING : CHARGE_STATE_NOT_CHARGING;
String content;
if (REMIND_TYPE_CHARGE.equals(remindType)) {
remindMsg.setTitle(CHARGE_REMIND_TITLE);
remindMsg.setContent(String.format(CHARGE_REMIND_CONTENT_FORMAT, currentBattery, chargeStateDesc));
remindMsg.setRemindMSG("charge_remind");
content = String.format(CHARGE_REMIND_CONTENT_FORMAT, currentBattery, chargeStateDesc);
} else {
remindMsg.setTitle(USAGE_REMIND_TITLE);
remindMsg.setContent(String.format(USAGE_REMIND_CONTENT_FORMAT, currentBattery, chargeStateDesc));
remindMsg.setRemindMSG("usage_remind");
content = String.format(USAGE_REMIND_CONTENT_FORMAT, currentBattery, chargeStateDesc);
}
LogUtils.d(TAG, "handleRemindMessage: 通知模型构建完成 | title=" + remindMsg.getTitle() + " | content=" + remindMsg.getContent());
LogUtils.d(TAG, "handleRemindMessage: 提醒内容构建完成 | content=" + content);
// 3. 调用通知工具类发送提醒
LogUtils.d(TAG, "handleRemindMessage: 调用通知工具类发送提醒 | remindMSG=" + remindMsg.getRemindMSG());
service.getNotificationManager().showRemindNotification(service, remindMsg);
LogUtils.d(TAG, "handleRemindMessage: 提醒通知发送流程执行完毕");
// 3. 根据 ChargeMailNotify 状态选择提醒方式
if (ChargeMailNotifyHelper.isEnabled(service)) {
// 启用邮件通知时,使用 Toast 代替通知栏
LogUtils.d(TAG, "handleRemindMessage: 充电邮件通知已启用,使用 Toast 提醒");
ToastUtils.show(content);
} else {
// 未启用邮件通知时,使用通知栏提醒
if (service.getNotificationManager() == null) {
LogUtils.e(TAG, "handleRemindMessage: 通知管理工具类未初始化,无法发送提醒");
return;
}
NotificationMessage remindMsg = new NotificationMessage();
if (REMIND_TYPE_CHARGE.equals(remindType)) {
remindMsg.setTitle(CHARGE_REMIND_TITLE);
remindMsg.setRemindMSG("charge_remind");
} else {
remindMsg.setTitle(USAGE_REMIND_TITLE);
remindMsg.setRemindMSG("usage_remind");
}
remindMsg.setContent(content);
LogUtils.d(TAG, "handleRemindMessage: 调用通知工具类发送提醒 | remindMSG=" + remindMsg.getRemindMSG());
service.getNotificationManager().showRemindNotification(service, remindMsg);
}
LogUtils.d(TAG, "handleRemindMessage: 提醒流程执行完毕");
}
}
@@ -95,9 +95,10 @@ public class ControlCenterService extends Service {
LogUtils.d(TAG, "onDestroy() 执行:服务销毁流程启动");
super.onDestroy();
// 资源释放顺序:前台服务 → 线程 → 广播接收器 → Handler → 通知 → 引用(避免内存泄漏)
// 资源释放顺序:前台服务 → 线程 → 悬浮窗 → 广播接收器 → Handler → 通知 → 引用(避免内存泄漏)
stopForegroundService();
RemindThread.stopRemindThread();
ChargeMailNotifyFloatWindow.dismissWindow();
releaseBroadcastReceiver();
destroyHandler();
releaseNotificationResource();
@@ -190,11 +190,13 @@ public class RemindThread extends Thread {
break;
}
// 启动电量通知 TTS 语音提醒线程
TTSRemindThread.start(this.mContext, App.sQuantityOfElectricity, isCharging);
// 启动电量通知邮件提醒线程(仅在充电邮件通知功能启用时)
// 根据 ChargeMailNotify 功能状态选择提醒方式
if (ChargeMailNotifyHelper.isEnabled(this.mContext)) {
// 启用电邮件提醒,不使用 TTS
APPMSGMailRemindThread.start(this.mContext, App.sQuantityOfElectricity, isCharging);
} else {
// 未启用邮件提醒,使用 TTS 语音提醒
TTSRemindThread.start(this.mContext, App.sQuantityOfElectricity, isCharging);
}
// 安全休眠,保留中断标记
@@ -288,10 +290,11 @@ public class RemindThread extends Thread {
*/
private void cleanThreadStateInternal() {
LogUtils.d(TAG, String.format("cleanThreadStateInternal() 调用 | threadId=%d", getId()));
TTSRemindThread.stopTTS();
// 仅在充电邮件通知功能启用时停止邮件提醒线程
// 根据 ChargeMailNotify 功能状态停止对应的提醒线程
if (ChargeMailNotifyHelper.isEnabled(this.mContext)) {
APPMSGMailRemindThread.stopMail();
} else {
TTSRemindThread.stopTTS();
}
isReminding = false;
isExist = true;
@@ -15,11 +15,32 @@
android:src="@drawable/ic_email"
android:layout_marginRight="8dp"/>
<TextView
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="充电邮件通知服务已启用"
android:textColor="#FF000000"
android:textSize="14sp"/>
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="充电邮件通知服务已启用"
android:textColor="#FF000000"
android:textSize="14sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TTS语音播放功能已禁用"
android:textColor="#FF666666"
android:textSize="12sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="电量提醒通知栏功能已禁用"
android:textColor="#FF666666"
android:textSize="12sp"/>
</LinearLayout>
</LinearLayout>