20251201_040959_262

This commit is contained in:
2025-12-01 04:10:10 +08:00
parent 9b010df881
commit 66e3e602e5
5 changed files with 708 additions and 349 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Sun Nov 30 18:31:19 GMT 2025
#Sun Nov 30 20:02:18 GMT 2025
stageCount=13
libraryProject=
baseVersion=15.11
publishVersion=15.11.12
buildCount=15
buildCount=20
baseBetaVersion=15.11.13

View File

@@ -2,7 +2,6 @@ package cc.winboll.studio.powerbell;
import android.content.Context;
import android.os.Environment;
import android.view.Gravity;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.ToastUtils;
import cc.winboll.studio.powerbell.receivers.GlobalApplicationReceiver;

View File

@@ -14,14 +14,16 @@ public class BackgroundBean extends BaseBean {
public static final String TAG = "BackgroundPictureBean";
// 核心字段:背景图片文件名(对应BackgroundSource目录下的图片文件
// 核心字段:背景图片文件名(对应应用私有目录下的图片文件与BackgroundSettingsActivity的_mSourceCroppedFile匹配
private String backgroundFileName = "";
// 附加字段图片信息如Uri、网络地址等仅作备注不参与路径生成
private String backgroundFileInfo = "";
// 控制字段是否启用背景图片true-显示背景图false-显示透明背景)
private boolean isUseBackgroundFile = false;
// 核心字段:压缩后背景图片文件名(对应BackgroundSource目录下的压缩图片
// 核心字段:压缩后背景图片文件名(对应应用私有目录下的压缩图片与saveCropBitmap的压缩图匹配
private String backgroundScaledCompressFileName = "";
// 新增压缩后背景图片完整路径解决仅存文件名导致的路径拼接错误适配BackgroundSettingsActivity的私有目录
private String backgroundScaledCompressFilePath = "";
// 控制字段是否启用压缩背景图true-加载压缩图false-加载原图)
private boolean isUseScaledCompress = false;
// 裁剪比例字段背景图宽高比默认1:1用于固定比例裁剪
@@ -69,6 +71,17 @@ public class BackgroundBean extends BaseBean {
this.backgroundScaledCompressFileName = backgroundScaledCompressFileName == null ? "" : backgroundScaledCompressFileName; // 防null
}
/**
* 新增:压缩图完整路径 Getter/Setter适配BackgroundSettingsActivity的saveCropBitmap方法
*/
public String getBackgroundScaledCompressFilePath() {
return backgroundScaledCompressFilePath;
}
public void setBackgroundScaledCompressFilePath(String backgroundScaledCompressFilePath) {
this.backgroundScaledCompressFilePath = backgroundScaledCompressFilePath == null ? "" : backgroundScaledCompressFilePath; // 防null避免路径错误
}
public boolean isUseScaledCompress() {
return isUseScaledCompress;
}
@@ -109,7 +122,7 @@ public class BackgroundBean extends BaseBean {
/**
* 将Bean数据写入JSON序列化保存到文件
* 确保所有字段都被写入,无遗漏
* 确保所有字段都被写入,无遗漏新增backgroundScaledCompressFilePath字段
*/
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
@@ -119,6 +132,7 @@ public class BackgroundBean extends BaseBean {
jsonWriter.name("backgroundFileInfo").value(bean.getBackgroundFileInfo());
jsonWriter.name("isUseBackgroundFile").value(bean.isUseBackgroundFile());
jsonWriter.name("backgroundScaledCompressFileName").value(bean.getBackgroundScaledCompressFileName());
jsonWriter.name("backgroundScaledCompressFilePath").value(bean.getBackgroundScaledCompressFilePath()); // 新增字段序列化
jsonWriter.name("isUseScaledCompress").value(bean.isUseScaledCompress());
jsonWriter.name("backgroundWidth").value(bean.getBackgroundWidth());
jsonWriter.name("backgroundHeight").value(bean.getBackgroundHeight());
@@ -127,7 +141,7 @@ public class BackgroundBean extends BaseBean {
/**
* 从JSON读取数据到Bean反序列化从文件加载
* 确保所有字段都被读取,兼容旧版本(无字段时设默认值)
* 确保所有字段都被读取,兼容旧版本(无字段时设默认值,新增字段兼容
*/
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
@@ -148,6 +162,9 @@ public class BackgroundBean extends BaseBean {
case "backgroundScaledCompressFileName":
bean.setBackgroundScaledCompressFileName(jsonReader.nextString());
break;
case "backgroundScaledCompressFilePath":
bean.setBackgroundScaledCompressFilePath(jsonReader.nextString()); // 新增字段反序列化
break;
case "isUseScaledCompress":
bean.setIsUseScaledCompress(jsonReader.nextBoolean());
break;
@@ -168,5 +185,32 @@ public class BackgroundBean extends BaseBean {
jsonReader.endObject();
return bean;
}
}
// ====================================== 辅助方法优化BackgroundSettingsActivity调用体验======================================
/**
* 重置背景配置(适配“取消背景”功能,避免残留无效数据)
*/
public void resetBackgroundConfig() {
this.backgroundFileName = "";
this.backgroundScaledCompressFileName = "";
this.backgroundScaledCompressFilePath = "";
this.backgroundFileInfo = "";
this.isUseBackgroundFile = false;
this.isUseScaledCompress = false;
this.backgroundWidth = 100;
this.backgroundHeight = 100;
}
/**
* 检查背景配置是否有效适配BackgroundSettingsActivity的预览/保存校验)
* @return true-配置有效可显示背景图false-配置无效
*/
public boolean isBackgroundConfigValid() {
// 启用背景图时,需确保文件名或完整路径非空
if (!isUseBackgroundFile) {
return false;
}
return !((backgroundFileName.isEmpty() && backgroundScaledCompressFileName.isEmpty())
|| backgroundScaledCompressFilePath.isEmpty());
}
}

View File

@@ -1,22 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<!-- 保留root-path适配特殊机型如微信分身 -->
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 保留root-path适配特殊机型如微信分身,谨慎启用(部分机型可能报安全警告) -->
<root-path
name="root_path"
path="" />
<!-- 核心修复1替换files-path为external-files-path对应外部存储应用目录 -->
<!-- 适配mfBackgroundDirBackgroundSource目录对应BackgroundSourceUtils.getBackgroundSourceDirPath() -->
<!-- 核心适配1BackgroundSourceUtils的背景图片目录对应mfBackgroundDir -->
<!-- 路径:/Android/data/${applicationId}/files/BackgroundPictureUtils/BackgroundSource/ -->
<external-files-path
name="background_source"
path="BackgroundPictureUtils/BackgroundSource/" /> <!--代码中目录完全一致 -->
path="BackgroundPictureUtils/BackgroundSource/" /> <!--BackgroundSourceUtils.initDirs()完全一致 -->
<!-- 适配mfPictureDir(临时目录):对应App.getTempDirPath() -->
<!-- 核心适配2App的临时目录对应mfPictureDir = App.getTempDirPath() -->
<!-- 路径:/Android/data/${applicationId}/files/temp/ -->
<external-files-path
name="temp"
path="temp/" /> <!--代码中App.getTempDirPath()的路径后缀一致 -->
name="app_temp"
path="temp/" /> <!-- 与App.getTempDirPath()的路径后缀严格匹配 -->
<!-- 保留其他配置适配分享/拍照等场景 -->
<!-- 核心适配3拍照/裁剪临时文件目录适配mfTakePhoto、_mSourceCropTempFile -->
<!-- 路径:/Android/data/${applicationId}/files/Pictures/对应BackgroundSettingsActivity的appPrivateDir -->
<external-files-path
name="app_private_pictures"
path="Pictures/" /> <!-- 适配onCreate中getExternalFilesDir(Environment.DIRECTORY_PICTURES) -->
<!-- 保留通用配置,适配分享/拍照等场景(多包名自动适配${applicationId} -->
<external-path
name="external_storage_root"
path="." />
@@ -25,7 +32,7 @@
path="." />
<external-files-path
name="external_file_path"
path="." />
path="." /> <!-- 通用外部文件路径,多包名自动适配 -->
<external-files-path
name="files_root"
path="mimoDownload" />