添加主窗口空转状态日志UI切换。

This commit is contained in:
2026-05-03 13:43:04 +08:00
parent 4a65e16427
commit 389300433c
5 changed files with 60 additions and 8 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Sun May 03 05:15:51 GMT 2026
#Sun May 03 05:39:16 GMT 2026
stageCount=20
libraryProject=
baseVersion=15.12
publishVersion=15.12.19
buildCount=1
buildCount=7
baseBetaVersion=15.12.20

View File

@@ -46,7 +46,7 @@ import cc.winboll.studio.positions.R;
* 4. 全局权限申请与权限结果回调处理
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
* @CreateTime 2026/05/03 12:23:00
* @EditTime 2026/05/03 14:36:21
* @EditTime 2026/05/03 15:26:13
*/
public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
@@ -112,6 +112,8 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
mADsBannerView = findViewById(R.id.adsbanner);
initAppIdleHandler();
// 初始化自动根据空转状态刷新日志面板
refreshIdleLogLayout();
}
@Override
@@ -186,6 +188,8 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
setOnAppIdleRunningListener(new OnAppIdleRunningListener() {
@Override
public void onIdleStatusChange(boolean isRunning) {
// 状态变更立刻刷新边框与日志
refreshIdleLogLayout();
appendIdleLog("IdleRunning Status : " + isRunning);
}
@@ -229,6 +233,26 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
});
}
/**
* 日志面板样式自动控制
* 非空转 = 清空日志 + 去除边框
* 空转开启 = 恢复边框
*/
private void refreshIdleLogLayout() {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (App.isAppIdleRunning()) {
mScrollIdleLog.setBackgroundResource(R.drawable.shape_log_border);
} else {
mTvIdleLog.setText("");
mScrollIdleLog.setBackgroundColor(Color.TRANSPARENT);
LogUtils.d(TAG, "refreshIdleLogLayout -> 非空转状态:日志清空、边框已移除");
}
}
});
}
// ===================== 权限处理相关 =====================
/**
* 检查前台+后台定位权限
@@ -307,6 +331,16 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
recreate();
} else if (DevelopUtils.onDevelopItemSelected(this, item)) {
LogUtils.d(TAG, "onOptionsItemSelected -> 进入开发工具菜单");
} else if (menuItemId == R.id.item_idle_switch) {
// 菜单切换应用空转状态
boolean idleNow = App.isAppIdleRunning();
boolean idleNew = !idleNow;
App.setAppIdleRunning(idleNew);
AppIdleRunningModeHandler.sendIdleSwitch(idleNew);
AppIdleRunningModeHandler.sendIdleLog("菜单手动切换空转状态:" + idleNew);
LogUtils.d(TAG, "onOptionsItemSelected -> 空转状态已切换,当前:" + idleNew);
// 切换立刻刷新UI样式
refreshIdleLogLayout();
} else if (menuItemId == R.id.item_settings) {
Intent intent = new Intent();
intent.setClass(this, SettingsActivity.class);

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00000000"/>
<stroke
android:width="5px"
android:color="#888888"/>
<corners android:radius="6dp"/>
</shape>

View File

@@ -38,7 +38,7 @@
android:text="GPS服务开关"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="120dp"
android:layout_marginTop="100dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:background="@drawable/shape_2px_border"
@@ -47,7 +47,7 @@
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:onClick="onPositions"
@@ -61,10 +61,13 @@
android:id="@+id/scroll_idle_log"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="20dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_weight="1.0">
android:layout_weight="1.0"
android:background="@drawable/shape_log_border"
android:padding="8dp"
android:layout_marginBottom="80dp">
<TextView
android:id="@+id/tv_idle_log"

View File

@@ -1,7 +1,11 @@
<?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_idle_switch"
android:title="空转状态切换"/>
<item
android:id="@+id/item_settings"
android:title="Settings"/>
@@ -9,4 +13,6 @@
<item
android:id="@+id/item_about"
android:title="@string/item_about"/>
</menu>