mirror of
https://gitea.winboll.cc/ZhanGSKen/MyWinBoLL.git
synced 2026-08-14 13:37:11 +08:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 000afbe971 | |||
| be3b9360dd | |||
| 80da1c63a6 | |||
| 75c790417c | |||
| 25a9e4b230 | |||
| 1de0a36d79 | |||
| f7968e55c6 | |||
| 97f42054d2 |
@@ -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:40:59 HKT 2026
|
||||
stageCount=27
|
||||
libraryProject=
|
||||
baseVersion=15.15
|
||||
publishVersion=15.15.22
|
||||
publishVersion=15.15.26
|
||||
buildCount=0
|
||||
baseBetaVersion=15.15.23
|
||||
baseBetaVersion=15.15.27
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AboutActivity extends WinBoLLActivity {
|
||||
appInfo.setAppName(getString(R.string.app_name));
|
||||
appInfo.setAppIcon(R.drawable.ic_winboll);
|
||||
appInfo.setAppDescription(getString(R.string.app_description));
|
||||
appInfo.setAppGitName("MyWinBoLL");
|
||||
appInfo.setAppGitName("PowerBell");
|
||||
appInfo.setAppGitOwner("ZhanGSKen");
|
||||
appInfo.setAppGitAPPBranch(branchName);
|
||||
appInfo.setAppGitAPPSubProjectFolder(branchName);
|
||||
|
||||
+8
-2
@@ -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: 关闭充电邮件通知悬浮窗");
|
||||
|
||||
+32
-18
@@ -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: 提醒流程执行完毕");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -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;
|
||||
|
||||
+12
@@ -1,6 +1,7 @@
|
||||
package cc.winboll.studio.powerbell.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.view.Gravity;
|
||||
@@ -8,6 +9,7 @@ import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import cc.winboll.studio.powerbell.MainActivity;
|
||||
|
||||
/**
|
||||
* 充电邮件通知悬浮窗工具类(单例)
|
||||
@@ -84,6 +86,16 @@ public class ChargeMailNotifyFloatWindow {
|
||||
|
||||
// 加载悬浮窗布局
|
||||
mView = View.inflate(mContext, R.layout.view_charge_mail_notify, null);
|
||||
// 点击悬浮窗打开主窗口
|
||||
mView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogUtils.d(TAG, "onClick: 悬浮窗被点击,打开主窗口");
|
||||
Intent intent = new Intent(mContext, MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
});
|
||||
mWindowManager.addView(mView, params);
|
||||
LogUtils.d(TAG, "show() 悬浮窗显示成功");
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -15,11 +15,40 @@
|
||||
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="@string/app_name"
|
||||
android:textColor="#FF000000"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user