diff --git a/powerbell/build.gradle b/powerbell/build.gradle index e53b7c4..60afa4f 100644 --- a/powerbell/build.gradle +++ b/powerbell/build.gradle @@ -42,7 +42,10 @@ android { } } - + packagingOptions { + exclude 'META-INF/NOTICE.md' + exclude 'META-INF/LICENSE.md' + } } dependencies { @@ -90,4 +93,8 @@ dependencies { //api fileTree(dir: 'libs', include: ['*.aar']) api fileTree(dir: 'libs', include: ['*.jar']) + + // JavaMail(APPMSGMailUtils 发送邮件依赖,Android 专用版) + implementation 'com.sun.mail:android-mail:1.6.7' + implementation 'com.sun.mail:android-activation:1.6.7' } diff --git a/powerbell/build.properties b/powerbell/build.properties index ed0b691..5eef4cb 100644 --- a/powerbell/build.properties +++ b/powerbell/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Fri Jul 17 15:59:06 CST 2026 +#Fri Jul 17 17:35:09 CST 2026 stageCount=19 libraryProject= baseVersion=15.15 publishVersion=15.15.18 -buildCount=6 +buildCount=13 baseBetaVersion=15.15.19 diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/activities/SettingsActivity.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/activities/SettingsActivity.java index fca94e6..9e2ae8c 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/activities/SettingsActivity.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/activities/SettingsActivity.java @@ -14,6 +14,7 @@ import android.widget.Toast; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.Toolbar; import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity; +import cc.winboll.studio.libaes.views.SMTPConfigView; import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.ToastUtils; import cc.winboll.studio.powerbell.R; @@ -40,6 +41,7 @@ public class SettingsActivity extends WinBoLLActivity implements IWinBoLLActivit private CheckBox cbUseageTtsBattary; // 用电TTS带电量提醒(子开关) private CheckBox cbChargeTtsBattary; // 充电TTS带电量提醒(子开关) private CheckBox cbTtsWhenNotifyBattery; // 👉 新增:通知电量时同时播放TTS + private SMTPConfigView smtpConfigView; // SMTP邮件配置视图 // ======================== 接口实现区 ========================= @Override @@ -62,6 +64,7 @@ public class SettingsActivity extends WinBoLLActivity implements IWinBoLLActivit initToolbar(); initTtsCheckBoxes(); initTtsCheckBoxStatus(); + initSMTPConfigView(); LogUtils.d(TAG, "onCreate: 应用设置页面初始化完成"); } @@ -126,6 +129,15 @@ public class SettingsActivity extends WinBoLLActivity implements IWinBoLLActivit LogUtils.d(TAG, "initTtsCheckBoxStatus: TTS复选框状态初始化完成"); } + /** + * 初始化SMTP邮件配置视图 + */ + private void initSMTPConfigView() { + LogUtils.d(TAG, "initSMTPConfigView: SMTP邮件配置视图初始化开始"); + smtpConfigView = findViewById(R.id.smtp_config_view); + LogUtils.d(TAG, "initSMTPConfigView: SMTP邮件配置视图初始化完成"); + } + // ======================== 事件响应区 ========================= /** * 悬浮窗权限检查入口 diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/threads/APPMSGMailRemindThread.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/threads/APPMSGMailRemindThread.java new file mode 100644 index 0000000..d5849a0 --- /dev/null +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/threads/APPMSGMailRemindThread.java @@ -0,0 +1,115 @@ +package cc.winboll.studio.powerbell.threads; + +import android.content.Context; +import cc.winboll.studio.libaes.utils.APPMSGMailUtils; +import cc.winboll.studio.libappbase.LogUtils; +import cc.winboll.studio.powerbell.App; + +/** + * APPMSG 邮件通知提醒线程(单例 + 继承 Thread) + * 功能:定时每30秒调用 APPMSGMailUtils 发送电量状态邮件给预设收件人 + * 适配:Java7 | API30 + * @Author ZhanGSKen + * @Date 2026/07/17 + */ +public class APPMSGMailRemindThread extends Thread { + + public static final String TAG = "APPMSGMailRemindThread"; + + // 邮件发送间隔(毫秒) + private static final long MAIL_SEND_INTERVAL = 30000; + + // 单例实例 + private static APPMSGMailRemindThread sInstance; + + // 运行标志 + private volatile boolean mIsRunning = false; + private volatile int mBattery; + private volatile boolean mIsCharging; + + private Context mContext; + + /** + * 私有构造,单例禁用外部 new + */ + private APPMSGMailRemindThread(Context context) { + this.mContext = context.getApplicationContext(); + } + + /** + * 获取单例(DCL 双重校验) + */ + public static APPMSGMailRemindThread getInstance(Context context) { + if (sInstance == null) { + synchronized (APPMSGMailRemindThread.class) { + if (sInstance == null) { + sInstance = new APPMSGMailRemindThread(context); + } + } + } + return sInstance; + } + + /** + * 对外静态启动入口 + */ + public static void start(Context context, int battery, boolean isCharging) { + APPMSGMailRemindThread instance = getInstance(context); + instance.mBattery = battery; + instance.mIsCharging = isCharging; + if (!instance.mIsRunning) { + LogUtils.d(TAG, "start() 邮件提醒线程启动"); + instance.mIsRunning = true; + instance.start(); + } + } + + /** + * 对外静态停止入口 + */ + public static void stopMail() { + if (sInstance != null) { + LogUtils.d(TAG, "stopMail() 邮件提醒线程停止"); + sInstance.mIsRunning = false; + sInstance = null; + } + } + + /** + * 线程主逻辑:定时发送邮件 + */ + @Override + public void run() { + super.run(); + LogUtils.d(TAG, "run() 邮件线程已开始循环"); + + while (mIsRunning) { + try { + String chargingText = mIsCharging ? "充电" : "用电"; + String subject = "PowerBell 电量状态通知"; + String content = String.format( + "当前状态:%s,电量为百分之%d", + chargingText, mBattery); + String recipient = APPMSGMailUtils.getRecipient(mContext); + + LogUtils.d(TAG, String.format("run() 发送邮件 | 收件人:%s | 内容:%s", recipient, content)); + APPMSGMailUtils.sendMail(mContext, subject, content, recipient); + + sleep(MAIL_SEND_INTERVAL); + } catch (InterruptedException e) { + LogUtils.e(TAG, "邮件线程被中断", e); + break; + } + } + + mIsRunning = false; + LogUtils.d(TAG, "run() 邮件线程已退出"); + } + + /** + * 是否正在运行 + */ + public boolean isRunning() { + return mIsRunning; + } +} diff --git a/powerbell/src/main/res/layout/activity_settings.xml b/powerbell/src/main/res/layout/activity_settings.xml index 8e3a349..c8038f7 100644 --- a/powerbell/src/main/res/layout/activity_settings.xml +++ b/powerbell/src/main/res/layout/activity_settings.xml @@ -153,6 +153,12 @@ + +