Compare commits
3 Commits
powerbell-
...
powerbell-
| Author | SHA1 | Date | |
|---|---|---|---|
| de34c33706 | |||
|
|
10b8da2e21 | ||
|
|
ca4e4c7feb |
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Wed Oct 22 17:45:14 HKT 2025
|
#Wed Oct 22 18:58:26 HKT 2025
|
||||||
stageCount=16
|
stageCount=17
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=15.4
|
baseVersion=15.4
|
||||||
publishVersion=15.4.15
|
publishVersion=15.4.16
|
||||||
buildCount=0
|
buildCount=0
|
||||||
baseBetaVersion=15.4.16
|
baseBetaVersion=15.4.17
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ public class MainActivity extends WinBoLLActivity {
|
|||||||
if (menuItemId == R.id.action_about) {
|
if (menuItemId == R.id.action_about) {
|
||||||
Intent intent = new Intent(this, AboutActivity.class);
|
Intent intent = new Intent(this, AboutActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (menuItemId == R.id.action_battery_reporter) {
|
} else if (menuItemId == R.id.action_battery_report) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setClass(this, BatteryReportActivity.class);
|
intent.setClass(this, BatteryReportActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ import cc.winboll.studio.libappbase.LogUtils;
|
|||||||
|
|
||||||
public class BatteryReportActivity extends Activity {
|
public class BatteryReportActivity extends Activity {
|
||||||
public static final String TAG = "BatteryReportActivity";
|
public static final String TAG = "BatteryReportActivity";
|
||||||
// 目标应用包名常量(统一维护,数据计算核心标识)
|
|
||||||
private static final String TARGET_APP_PACKAGE = "cc.winboll.studio.mymessagemanager";
|
|
||||||
|
|
||||||
private RecyclerView rvBatteryReport;
|
private RecyclerView rvBatteryReport;
|
||||||
private BatteryReportAdapter adapter;
|
private BatteryReportAdapter adapter;
|
||||||
@@ -59,7 +57,7 @@ public class BatteryReportActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_batteryreport);
|
setContentView(R.layout.activity_battery_report);
|
||||||
// 初始化包管理工具(仅一次,供后续查询名称使用)
|
// 初始化包管理工具(仅一次,供后续查询名称使用)
|
||||||
mPackageManager = getPackageManager();
|
mPackageManager = getPackageManager();
|
||||||
|
|
||||||
@@ -78,8 +76,6 @@ public class BatteryReportActivity extends Activity {
|
|||||||
loadAllAppPackage();
|
loadAllAppPackage();
|
||||||
// 2. 预缓存所有包名对应的应用名称(为搜索名称做准备)
|
// 2. 预缓存所有包名对应的应用名称(为搜索名称做准备)
|
||||||
preCacheAllAppNames();
|
preCacheAllAppNames();
|
||||||
// 3. 强制添加目标应用(包名兜底)
|
|
||||||
//forceAddTargetPackage();
|
|
||||||
// 4. 首次获取运行时长(key:包名)
|
// 4. 首次获取运行时长(key:包名)
|
||||||
appRunTimeCache = getAppRunTime();
|
appRunTimeCache = getAppRunTime();
|
||||||
// 5. 更新时长到数据模型(用包名匹配)
|
// 5. 更新时长到数据模型(用包名匹配)
|
||||||
@@ -157,7 +153,7 @@ public class BatteryReportActivity extends Activity {
|
|||||||
dataList.add(new AppBatteryModel(packageName, "0.0", 0));
|
dataList.add(new AppBatteryModel(packageName, "0.0", 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
LogUtils.d(TAG, "应用包名列表加载完成,共添加" + dataList.size() + "个包名。" );
|
LogUtils.d(TAG, "应用包名列表加载完成,共添加" + dataList.size() + "个包名。");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -194,31 +190,6 @@ public class BatteryReportActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 强制添加目标包名(兜底逻辑,仅操作包名)
|
|
||||||
*/
|
|
||||||
private void forceAddTargetPackage() {
|
|
||||||
// 1. 先检查列表中是否已存在目标包名
|
|
||||||
boolean isTargetExists = false;
|
|
||||||
for (AppBatteryModel model : dataList) {
|
|
||||||
if (TARGET_APP_PACKAGE.equals(model.getPackageName())) {
|
|
||||||
isTargetExists = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isTargetExists) {
|
|
||||||
LogUtils.d(TAG, "目标包名已在列表中,无需重复添加");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 仅用包名创建模型,强制添加(不依赖名称查询)
|
|
||||||
dataList.add(0, new AppBatteryModel(TARGET_APP_PACKAGE, "0.0", 0));
|
|
||||||
// 同步更新名称缓存
|
|
||||||
packageToAppNameCache.put(TARGET_APP_PACKAGE, getAppNameByPackage(TARGET_APP_PACKAGE));
|
|
||||||
LogUtils.d(TAG, "强制添加目标包名成功:" + TARGET_APP_PACKAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新运行时长到模型(用包名匹配,不涉及名称)
|
* 更新运行时长到模型(用包名匹配,不涉及名称)
|
||||||
*/
|
*/
|
||||||
@@ -251,7 +222,6 @@ public class BatteryReportActivity extends Activity {
|
|||||||
filteredList.addAll(dataList);
|
filteredList.addAll(dataList);
|
||||||
} else {
|
} else {
|
||||||
String lowerKeyword = keyword.toLowerCase(); // 统一转为小写,实现不区分大小写搜索
|
String lowerKeyword = keyword.toLowerCase(); // 统一转为小写,实现不区分大小写搜索
|
||||||
boolean isTargetMatched = false;
|
|
||||||
|
|
||||||
for (AppBatteryModel model : dataList) {
|
for (AppBatteryModel model : dataList) {
|
||||||
String packageName = model.getPackageName();
|
String packageName = model.getPackageName();
|
||||||
@@ -266,21 +236,7 @@ public class BatteryReportActivity extends Activity {
|
|||||||
|
|
||||||
if (isMatched) {
|
if (isMatched) {
|
||||||
filteredList.add(model);
|
filteredList.add(model);
|
||||||
// 检查是否是目标包名
|
|
||||||
if (TARGET_APP_PACKAGE.equals(packageName)) {
|
|
||||||
isTargetMatched = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 兜底:目标包名未匹配时强制添加
|
|
||||||
if (!isTargetMatched) {
|
|
||||||
for (AppBatteryModel model : dataList) {
|
|
||||||
if (TARGET_APP_PACKAGE.equals(model.getPackageName())) {
|
|
||||||
filteredList.add(0, model);
|
|
||||||
LogUtils.d(TAG, "搜索兜底:强制添加目标包名到结果列表");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -512,13 +468,13 @@ public class BatteryReportActivity extends Activity {
|
|||||||
holder.tvConsumption.setText(consumptionText);
|
holder.tvConsumption.setText(consumptionText);
|
||||||
|
|
||||||
// 优化显示:目标应用文字标蓝(通过包名匹配)
|
// 优化显示:目标应用文字标蓝(通过包名匹配)
|
||||||
if (BatteryReportActivity.TARGET_APP_PACKAGE.equals(packageName)) {
|
|
||||||
holder.tvAppName.setTextColor(mContext.getResources().getColor(android.R.color.holo_blue_dark));
|
holder.tvAppName.setTextColor(mContext.getResources().getColor(android.R.color.holo_blue_dark));
|
||||||
holder.tvConsumption.setTextColor(mContext.getResources().getColor(android.R.color.holo_blue_dark));
|
holder.tvConsumption.setTextColor(mContext.getResources().getColor(android.R.color.holo_blue_dark));
|
||||||
} else {
|
|
||||||
holder.tvAppName.setTextColor(mContext.getResources().getColor(android.R.color.black));
|
//holder.tvAppName.setTextColor(mContext.getResources().getColor(android.R.color.black));
|
||||||
holder.tvConsumption.setTextColor(mContext.getResources().getColor(android.R.color.darker_gray));
|
//holder.tvConsumption.setTextColor(mContext.getResources().getColor(android.R.color.darker_gray));
|
||||||
}
|
|
||||||
|
|
||||||
// 调整文字大小(提升可读性)
|
// 调整文字大小(提升可读性)
|
||||||
holder.tvAppName.setTextSize(16);
|
holder.tvAppName.setTextSize(16);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_battery_reporter"
|
android:id="@+id/action_battery_report"
|
||||||
android:title="@string/item_battery_reporter"/>
|
android:title="@string/item_battery_report"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_clearrecord"
|
android:id="@+id/action_clearrecord"
|
||||||
android:title="@string/item_clearrecord"/>
|
android:title="@string/item_clearrecord"/>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<string name="about_crashed">This application has crashed, the author level is limited, please understand!</string>
|
<string name="about_crashed">This application has crashed, the author level is limited, please understand!</string>
|
||||||
<string name="item_mainview">Main View</string>
|
<string name="item_mainview">Main View</string>
|
||||||
<string name="item_aboutview">About</string>
|
<string name="item_aboutview">About</string>
|
||||||
<string name="item_battery_reporter">Battery Reporter</string>
|
<string name="item_battery_report">Battery Report</string>
|
||||||
<string name="item_clearrecord">Clear Record</string>
|
<string name="item_clearrecord">Clear Record</string>
|
||||||
<string name="item_changepicture">Change Picture</string>
|
<string name="item_changepicture">Change Picture</string>
|
||||||
<string name="item_devoloperoptionsview">Developer View</string>
|
<string name="item_devoloperoptionsview">Developer View</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user