Compare commits
5 Commits
powerbell-
...
powerbell-
| Author | SHA1 | Date | |
|---|---|---|---|
| de34c33706 | |||
|
|
10b8da2e21 | ||
|
|
ca4e4c7feb | ||
| 4108371c20 | |||
|
|
e5c8624d9b |
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Wed Oct 22 16:57:21 HKT 2025
|
#Wed Oct 22 18:58:26 HKT 2025
|
||||||
stageCount=15
|
stageCount=17
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=15.4
|
baseVersion=15.4
|
||||||
publishVersion=15.4.14
|
publishVersion=15.4.16
|
||||||
buildCount=0
|
buildCount=0
|
||||||
baseBetaVersion=15.4.15
|
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;
|
||||||
@@ -51,13 +49,15 @@ public class BatteryReportActivity extends Activity {
|
|||||||
private EditText etSearch;
|
private EditText etSearch;
|
||||||
// 应用运行时长缓存(key:包名,value:时长ms)
|
// 应用运行时长缓存(key:包名,value:时长ms)
|
||||||
private Map<String, Long> appRunTimeCache = new HashMap<String, Long>();
|
private Map<String, Long> appRunTimeCache = new HashMap<String, Long>();
|
||||||
|
// 新增:包名-应用名称映射缓存(用于搜索匹配名称,避免重复查询)
|
||||||
|
private Map<String, String> packageToAppNameCache = new HashMap<String, String>();
|
||||||
// 包管理工具(全局持有,避免重复获取)
|
// 包管理工具(全局持有,避免重复获取)
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
|
|
||||||
@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();
|
||||||
|
|
||||||
@@ -74,25 +74,25 @@ public class BatteryReportActivity extends Activity {
|
|||||||
|
|
||||||
// 1. 加载所有应用(仅存包名,不查名称)
|
// 1. 加载所有应用(仅存包名,不查名称)
|
||||||
loadAllAppPackage();
|
loadAllAppPackage();
|
||||||
// 2. 强制添加目标应用(包名兜底)
|
// 2. 预缓存所有包名对应的应用名称(为搜索名称做准备)
|
||||||
//forceAddTargetPackage();
|
preCacheAllAppNames();
|
||||||
// 3. 首次获取运行时长(key:包名)
|
// 4. 首次获取运行时长(key:包名)
|
||||||
appRunTimeCache = getAppRunTime();
|
appRunTimeCache = getAppRunTime();
|
||||||
// 4. 更新时长到数据模型(用包名匹配)
|
// 5. 更新时长到数据模型(用包名匹配)
|
||||||
updateAppRunTimeToModel();
|
updateAppRunTimeToModel();
|
||||||
// 5. 初始化过滤列表和适配器(传入包管理工具供显示时查名称)
|
// 6. 初始化过滤列表和适配器(传入包管理工具+名称缓存)
|
||||||
filteredList.addAll(dataList);
|
filteredList.addAll(dataList);
|
||||||
adapter = new BatteryReportAdapter(this, filteredList, mPackageManager);
|
adapter = new BatteryReportAdapter(this, filteredList, mPackageManager, packageToAppNameCache);
|
||||||
rvBatteryReport.setAdapter(adapter);
|
rvBatteryReport.setAdapter(adapter);
|
||||||
|
|
||||||
// 搜索监听(按包名过滤,不涉及名称)
|
// 搜索监听:修改为“包名+应用名称”双匹配
|
||||||
etSearch.addTextChangedListener(new TextWatcher() {
|
etSearch.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
filterAppsByPackage(s.toString());
|
filterAppsByPackageAndName(s.toString()); // 替换为新的双维度过滤方法
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -149,69 +149,57 @@ public class BatteryReportActivity extends Activity {
|
|||||||
// 仅遍历包名,不处理名称(避免名称获取异常影响)
|
// 仅遍历包名,不处理名称(避免名称获取异常影响)
|
||||||
for (ApplicationInfo appInfo : appList) {
|
for (ApplicationInfo appInfo : appList) {
|
||||||
String packageName = appInfo.packageName;
|
String packageName = appInfo.packageName;
|
||||||
/*if (packageName.equals("cc.winboll.studio.powerbell.beta")) {
|
// 模型仅存包名、初始耗电0、初始时长0(名称显示/搜索时用缓存)
|
||||||
//if (packageName.equals("aidepro.top")) {
|
|
||||||
LogUtils.d(TAG, "aidepro.top OK5");
|
|
||||||
}*/
|
|
||||||
// 模型仅存包名、初始耗电0、初始时长0(名称显示时再查)
|
|
||||||
dataList.add(new AppBatteryModel(packageName, "0.0", 0));
|
dataList.add(new AppBatteryModel(packageName, "0.0", 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*for (AppBatteryModel appBatteryModel : dataList) {
|
LogUtils.d(TAG, "应用包名列表加载完成,共添加" + dataList.size() + "个包名。");
|
||||||
if (appBatteryModel.getPackageName().equals("aidepro.top")) {
|
|
||||||
LogUtils.d(TAG, "aidepro.top OK4");
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
LogUtils.d(TAG, "应用包名列表加载完成,共添加" + dataList.size() + "个包名。" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 强制添加目标包名(兜底逻辑,仅操作包名)
|
* 新增:预缓存所有包名对应的应用名称(为搜索提供支持,避免重复查询)
|
||||||
*/
|
*/
|
||||||
private void forceAddTargetPackage() {
|
private void preCacheAllAppNames() {
|
||||||
// 1. 先检查列表中是否已存在目标包名
|
packageToAppNameCache.clear(); // 清空旧缓存
|
||||||
boolean isTargetExists = false;
|
LogUtils.d(TAG, "开始预缓存包名-应用名称映射");
|
||||||
|
|
||||||
for (AppBatteryModel model : dataList) {
|
for (AppBatteryModel model : dataList) {
|
||||||
if (TARGET_APP_PACKAGE.equals(model.getPackageName())) {
|
String packageName = model.getPackageName();
|
||||||
isTargetExists = true;
|
String appName = getAppNameByPackage(packageName); // 复用工具方法获取名称
|
||||||
break;
|
packageToAppNameCache.put(packageName, appName); // 缓存映射关系
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTargetExists) {
|
LogUtils.d(TAG, "预缓存完成,共缓存" + packageToAppNameCache.size() + "个应用名称");
|
||||||
LogUtils.d(TAG, "目标包名已在列表中,无需重复添加");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 仅用包名创建模型,强制添加(不依赖名称查询)
|
/**
|
||||||
dataList.add(0, new AppBatteryModel(TARGET_APP_PACKAGE, "0.0", 0));
|
* 工具方法:通过包名获取应用名称(带异常处理,避免崩溃)
|
||||||
LogUtils.d(TAG, "强制添加目标包名成功:" + TARGET_APP_PACKAGE);
|
*/
|
||||||
|
private String getAppNameByPackage(String packageName) {
|
||||||
|
try {
|
||||||
|
ApplicationInfo appInfo = mPackageManager.getApplicationInfo(packageName, 0);
|
||||||
|
return mPackageManager.getApplicationLabel(appInfo).toString();
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
// 包名不存在(如应用已卸载),用包名兜底
|
||||||
|
LogUtils.e(TAG, "包名" + packageName + "对应的应用未找到:" + e.getMessage());
|
||||||
|
return packageName;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 其他异常(如权限问题),同样用包名兜底
|
||||||
|
LogUtils.e(TAG, "查询应用名称失败(包名:" + packageName + "):" + e.getMessage());
|
||||||
|
return packageName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新运行时长到模型(用包名匹配,不涉及名称)
|
* 更新运行时长到模型(用包名匹配,不涉及名称)
|
||||||
*/
|
*/
|
||||||
private void updateAppRunTimeToModel() {
|
private void updateAppRunTimeToModel() {
|
||||||
/*if(appRunTimeCache.containsKey("aidepro.top"))
|
|
||||||
{
|
|
||||||
LogUtils.d(TAG, "aidepro.top OK2");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
int nCount = 0;
|
int nCount = 0;
|
||||||
for (AppBatteryModel model : dataList) {
|
for (AppBatteryModel model : dataList) {
|
||||||
String packageName = model.getPackageName();
|
String packageName = model.getPackageName();
|
||||||
/*if(packageName.equals("aidepro.top"))
|
|
||||||
{
|
|
||||||
LogUtils.d(TAG, "aidepro.top OK3");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
Long runTime;
|
Long runTime;
|
||||||
// Java7 显式判断包名是否在缓存中
|
// Java7 显式判断包名是否在缓存中
|
||||||
if (appRunTimeCache.containsKey(packageName)) {
|
if (appRunTimeCache.containsKey(packageName)) {
|
||||||
/*if(packageName.equals("cc.winboll.studio.powerbell.beta")) {
|
|
||||||
LogUtils.d(TAG, String.format("特殊查询 %s 查询有结果。", packageName));
|
|
||||||
}*/
|
|
||||||
runTime = appRunTimeCache.get(packageName);
|
runTime = appRunTimeCache.get(packageName);
|
||||||
LogUtils.d(TAG, String.format("应用包 %s 运行时长已更新。", packageName));
|
LogUtils.d(TAG, String.format("应用包 %s 运行时长已更新。", packageName));
|
||||||
nCount++;
|
nCount++;
|
||||||
@@ -225,38 +213,30 @@ public class BatteryReportActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按包名过滤应用(搜索逻辑仅操作包名)
|
* 新增:双维度过滤(包名+应用名称)
|
||||||
|
* 搜索关键词同时匹配“包名(不区分大小写)”或“应用名称(不区分大小写)”
|
||||||
*/
|
*/
|
||||||
private void filterAppsByPackage(String keyword) {
|
private void filterAppsByPackageAndName(String keyword) {
|
||||||
filteredList.clear();
|
filteredList.clear();
|
||||||
if (keyword == null || keyword.isEmpty()) {
|
if (keyword == null || keyword.isEmpty()) {
|
||||||
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 packageNameLower = model.getPackageName().toLowerCase();
|
String packageName = model.getPackageName();
|
||||||
// 仅按包名包含关键词过滤
|
String packageNameLower = packageName.toLowerCase();
|
||||||
boolean isMatched = packageNameLower.contains(lowerKeyword);
|
// 从缓存中获取应用名称(避免重复查询PackageManager)
|
||||||
|
String appName = packageToAppNameCache.get(packageName);
|
||||||
|
String appNameLower = appName.toLowerCase();
|
||||||
|
|
||||||
|
// 匹配规则:包名包含关键词 OR 应用名称包含关键词
|
||||||
|
boolean isMatched = packageNameLower.contains(lowerKeyword)
|
||||||
|
|| appNameLower.contains(lowerKeyword);
|
||||||
|
|
||||||
if (isMatched) {
|
if (isMatched) {
|
||||||
filteredList.add(model);
|
filteredList.add(model);
|
||||||
// 检查是否是目标包名
|
|
||||||
if (TARGET_APP_PACKAGE.equals(model.getPackageName())) {
|
|
||||||
isTargetMatched = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 兜底:目标包名未匹配时强制添加
|
|
||||||
if (!isTargetMatched) {
|
|
||||||
for (AppBatteryModel model : dataList) {
|
|
||||||
if (TARGET_APP_PACKAGE.equals(model.getPackageName())) {
|
|
||||||
filteredList.add(0, model);
|
|
||||||
LogUtils.d(TAG, "搜索兜底:强制添加目标包名到结果列表");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,11 +272,6 @@ public class BatteryReportActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(runTimeMap.containsKey("aidepro.top"))
|
|
||||||
{
|
|
||||||
LogUtils.d(TAG, "aidepro.top OK");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
LogUtils.d(TAG, String.format("应用运行时长列表数量%d。", runTimeMap.size()));
|
LogUtils.d(TAG, String.format("应用运行时长列表数量%d。", runTimeMap.size()));
|
||||||
return runTimeMap;
|
return runTimeMap;
|
||||||
}
|
}
|
||||||
@@ -359,8 +334,8 @@ public class BatteryReportActivity extends Activity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 重新应用包名过滤
|
// 重新应用“包名+名称”双维度过滤
|
||||||
filterAppsByPackage(etSearch.getText().toString());
|
filterAppsByPackageAndName(etSearch.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -423,18 +398,21 @@ public class BatteryReportActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RecyclerView 适配器(仅在显示时通过包名查询应用名称)
|
* RecyclerView 适配器(支持从缓存获取名称,避免重复查询)
|
||||||
*/
|
*/
|
||||||
public static class BatteryReportAdapter extends RecyclerView.Adapter<BatteryReportAdapter.ViewHolder> {
|
public static class BatteryReportAdapter extends RecyclerView.Adapter<BatteryReportAdapter.ViewHolder> {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private List<AppBatteryModel> mDataList;
|
private List<AppBatteryModel> mDataList;
|
||||||
private PackageManager mPm; // 用于显示时查询应用名称
|
private PackageManager mPm; // 兜底用:缓存无名称时查询
|
||||||
|
private Map<String, String> mPackageToNameCache; // 新增:名称缓存映射
|
||||||
|
|
||||||
// Java7 显式构造(传入包管理工具)
|
// Java7 显式构造(新增名称缓存参数)
|
||||||
public BatteryReportAdapter(Context context, List<AppBatteryModel> dataList, PackageManager pm) {
|
public BatteryReportAdapter(Context context, List<AppBatteryModel> dataList,
|
||||||
|
PackageManager pm, Map<String, String> packageToNameCache) {
|
||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
this.mDataList = dataList;
|
this.mDataList = dataList;
|
||||||
this.mPm = pm; // 持有包管理工具,供显示时查名称
|
this.mPm = pm;
|
||||||
|
this.mPackageToNameCache = packageToNameCache; // 接收名称缓存
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -444,7 +422,7 @@ public class BatteryReportActivity extends Activity {
|
|||||||
return new ViewHolder(itemView);
|
return new ViewHolder(itemView);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绑定数据:核心修改——仅在此处通过包名查询应用名称并显示
|
// 绑定数据:优先从缓存取名称,无缓存时兜底查询
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||||
// Java7 显式非空判断(避免空指针)
|
// Java7 显式非空判断(避免空指针)
|
||||||
@@ -458,21 +436,28 @@ public class BatteryReportActivity extends Activity {
|
|||||||
String packageName = model.getPackageName();
|
String packageName = model.getPackageName();
|
||||||
String appName = "";
|
String appName = "";
|
||||||
|
|
||||||
// 关键步骤:通过包名查询应用名称(仅显示时执行,不影响数据计算)
|
// 优先从缓存获取名称(避免重复调用PackageManager,提升性能)
|
||||||
|
if (mPackageToNameCache != null && mPackageToNameCache.containsKey(packageName)) {
|
||||||
|
appName = mPackageToNameCache.get(packageName);
|
||||||
|
} else {
|
||||||
|
// 缓存无数据时,兜底查询名称(兼容异常场景)
|
||||||
try {
|
try {
|
||||||
ApplicationInfo appInfo = mPm.getApplicationInfo(packageName, 0);
|
ApplicationInfo appInfo = mPm.getApplicationInfo(packageName, 0);
|
||||||
appName = mPm.getApplicationLabel(appInfo).toString();
|
appName = mPm.getApplicationLabel(appInfo).toString();
|
||||||
|
// 同步更新到缓存,后续复用
|
||||||
|
if (mPackageToNameCache != null) {
|
||||||
|
mPackageToNameCache.put(packageName, appName);
|
||||||
|
}
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
// 包名不存在(如应用已卸载),用包名作为名称兜底
|
|
||||||
appName = packageName;
|
appName = packageName;
|
||||||
LogUtils.e("Adapter", "包名" + packageName + "对应的应用未找到:" + e.getMessage());
|
LogUtils.e("Adapter", "包名" + packageName + "对应的应用未找到:" + e.getMessage());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 其他异常(如权限问题),同样用包名兜底
|
|
||||||
appName = packageName;
|
appName = packageName;
|
||||||
LogUtils.e("Adapter", "查询应用名称失败(包名:" + packageName + "):" + e.getMessage());
|
LogUtils.e("Adapter", "查询应用名称失败(包名:" + packageName + "):" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 显示应用名称(查询到则显示名称,否则显示包名)
|
// 显示应用名称(缓存/兜底结果)
|
||||||
holder.tvAppName.setText(appName);
|
holder.tvAppName.setText(appName);
|
||||||
|
|
||||||
// 格式化运行时长(调用 Activity 的工具方法)
|
// 格式化运行时长(调用 Activity 的工具方法)
|
||||||
@@ -483,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);
|
||||||
@@ -504,7 +489,7 @@ public class BatteryReportActivity extends Activity {
|
|||||||
|
|
||||||
// ViewHolder(绑定系统布局的两个 TextView)
|
// ViewHolder(绑定系统布局的两个 TextView)
|
||||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
TextView tvAppName; // 显示应用名称(通过包名查询)
|
TextView tvAppName; // 显示应用名称(缓存/兜底获取)
|
||||||
TextView tvConsumption; // 显示耗电+运行时长(包名计算结果)
|
TextView tvConsumption; // 显示耗电+运行时长(包名计算结果)
|
||||||
|
|
||||||
// Java7 显式构造
|
// Java7 显式构造
|
||||||
|
|||||||
@@ -6,19 +6,19 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="@android:color/white">
|
android:background="@android:color/white">
|
||||||
|
|
||||||
<!-- 搜索框:使用系统兼容背景 -->
|
<!-- 搜索框:提示文本改为“搜索应用名称或包名” -->
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/et_search"
|
android:id="@+id/et_search"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:hint="搜索应用包名"
|
android:hint="搜索应用名称或包名"
|
||||||
android:background="@android:drawable/btn_default_small"
|
android:background="@android:drawable/btn_default_small"
|
||||||
android:inputType="text"
|
android:inputType="text"
|
||||||
android:textSize="16sp"/>
|
android:textSize="16sp"/>
|
||||||
|
|
||||||
<!-- 应用列表:不依赖系统分割线,避免资源缺失 -->
|
<!-- 应用列表 -->
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/rv_battery_report"
|
android:id="@+id/rv_battery_report"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -28,4 +28,3 @@
|
|||||||
android:layout_marginRight="8dp"/>
|
android:layout_marginRight="8dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -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