mirror of
https://gitea.winboll.cc/ZhanGSKen/MyWinBoLL.git
synced 2026-08-15 05:52:09 +08:00
feat: 绿色通道状态广播通信机制
- 新增绿色通道状态变更本地广播 Action 和参数常量 - 新增 sendGreenChannelStateChangedBroadcast() 静态方法 - 开关切换时发送状态广播通知 Activity 更新状态栏 - 服务销毁时发送关闭广播确保状态同步
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Mon Jul 20 04:45:26 GMT 2026
|
||||
#Mon Jul 20 14:47:50 CST 2026
|
||||
stageCount=12
|
||||
libraryProject=
|
||||
baseVersion=15.20
|
||||
publishVersion=15.20.11
|
||||
buildCount=2
|
||||
buildCount=17
|
||||
baseBetaVersion=15.20.12
|
||||
|
||||
+16
@@ -32,6 +32,10 @@ public class LimitedTimeGreenChannelService extends Service {
|
||||
|
||||
// 倒计时心跳广播 Action
|
||||
public static final String ACTION_COUNTDOWN_TICK = "cc.winboll.studio.contacts.services.ACTION_COUNTDOWN_TICK";
|
||||
// 绿色通道状态变更广播 Action
|
||||
public static final String ACTION_GREEN_CHANNEL_STATE_CHANGED = "cc.winboll.studio.contacts.services.ACTION_GREEN_CHANNEL_STATE_CHANGED";
|
||||
// 广播携带的额外参数:绿色通道是否开启
|
||||
public static final String EXTRA_GREEN_CHANNEL_ENABLED = "EXTRA_GREEN_CHANNEL_ENABLED";
|
||||
// 广播携带的额外参数:剩余秒数
|
||||
public static final String EXTRA_REMAINING_SECONDS = "EXTRA_REMAINING_SECONDS";
|
||||
// 广播携带的额外参数:总定时秒数
|
||||
@@ -106,6 +110,18 @@ public class LimitedTimeGreenChannelService extends Service {
|
||||
return sIsServiceRunning;
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共静态方法:发送绿色通道状态变更广播
|
||||
* @param context 上下文
|
||||
* @param isEnabled 绿色通道是否开启
|
||||
*/
|
||||
public static void sendGreenChannelStateChangedBroadcast(Context context, boolean isEnabled) {
|
||||
LogUtils.i(TAG, "sendGreenChannelStateChangedBroadcast: 发送绿色通道状态变更广播, isEnabled=" + isEnabled);
|
||||
Intent intent = new Intent(ACTION_GREEN_CHANNEL_STATE_CHANGED);
|
||||
intent.putExtra(EXTRA_GREEN_CHANNEL_ENABLED, isEnabled);
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 【核心单元测试方法】
|
||||
* 执行完整的单元测试流程
|
||||
|
||||
+7
@@ -199,6 +199,9 @@ public class LimitedTimeGreenChannelView extends LinearLayout {
|
||||
// 保存绿色通道启用状态到持久化存储
|
||||
saveGreenChannelState(isChecked);
|
||||
|
||||
// 发送绿色通道状态变更广播
|
||||
LimitedTimeGreenChannelService.sendGreenChannelStateChangedBroadcast(mContext, isChecked);
|
||||
|
||||
if (isChecked) {
|
||||
startLimitedTimeGreenChannelService();
|
||||
} else {
|
||||
@@ -314,6 +317,10 @@ public class LimitedTimeGreenChannelView extends LinearLayout {
|
||||
LogUtils.i(TAG, "已将EditText设置为剩余秒数: " + remainingSeconds);
|
||||
}
|
||||
|
||||
// 5. 保存绿色通道关闭状态并发送广播
|
||||
saveGreenChannelState(false);
|
||||
LimitedTimeGreenChannelService.sendGreenChannelStateChangedBroadcast(mContext, false);
|
||||
|
||||
//ToastUtils.show("服务已销毁,恢复倒计时剩余状态");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user