修复空白图片背景按钮与图片背景按钮。

This commit is contained in:
2025-12-21 09:49:40 +08:00
parent bf051dcc9f
commit 36bdd059b0
3 changed files with 38 additions and 31 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Sun Dec 21 09:22:26 HKT 2025 #Sun Dec 21 01:45:57 GMT 2025
stageCount=14 stageCount=14
libraryProject= libraryProject=
baseVersion=15.14 baseVersion=15.14
publishVersion=15.14.13 publishVersion=15.14.13
buildCount=0 buildCount=6
baseBetaVersion=15.14.14 baseBetaVersion=15.14.14

View File

@@ -216,9 +216,10 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
LogUtils.d(TAG, "【按钮点击】取消背景图片"); LogUtils.d(TAG, "【按钮点击】取消背景图片");
BackgroundBean previewBackgroundBean = mBgSourceUtils.getPreviewBackgroundBean(); mBgSourceUtils.getPreviewBackgroundBean().setIsUseBackgroundFile(false);
previewBackgroundBean.setIsUseBackgroundFile(false); mBgSourceUtils.saveSettings();
doubleRefreshPreview(); doubleRefreshPreview();
isPreviewBackgroundChanged = true;
} }
}; };
@@ -293,8 +294,10 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
private View.OnClickListener onReceivedPictureClickListener = new View.OnClickListener() { private View.OnClickListener onReceivedPictureClickListener = new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
ToastUtils.show("图片接收功能暂未实现"); mBgSourceUtils.getPreviewBackgroundBean().setIsUseBackgroundFile(true);
LogUtils.d(TAG, "【按钮点击】图片接收"); mBgSourceUtils.saveSettings();
doubleRefreshPreview();
isPreviewBackgroundChanged = true;
} }
}; };

View File

@@ -183,38 +183,42 @@ public class BackgroundSourceUtils {
/** /**
* 检查背景是否为空并创建空白背景Bean * 检查背景是否为空并创建空白背景Bean
*/ */
boolean checkEmptyBackgroundAndCreateBlankBackgroundBean(BackgroundBean checkBackgroundBean) { public boolean checkEmptyBackgroundAndCreateBlankBackgroundBean(BackgroundBean checkBackgroundBean) {
LogUtils.d(TAG, "【checkEmptyBackgroundAndCreateBlankBackgroundBean调用】开始检查背景Bean"); LogUtils.d(TAG, "【checkEmptyBackgroundAndCreateBlankBackgroundBean调用】开始检查背景Bean");
File fCheckBackgroundFile = new File(checkBackgroundBean.getBackgroundFilePath()); File fCheckBackgroundFile = new File(checkBackgroundBean.getBackgroundFilePath());
if (!fCheckBackgroundFile.exists()) { if (!fCheckBackgroundFile.exists()) {
String newCropFileName = genNewCropFileName(); return createBlankBackgroundBean(checkBackgroundBean.getPixelColor());
String fileSuffix = "png";
mCropSourceFile = new File(fCropCacheDir, newCropFileName + "." + fileSuffix);
mCropResultFile = new File(fCropCacheDir, "SelectCompress_" + newCropFileName + "." + fileSuffix);
AssetsCopyUtils.copyAssetsFileToDir(mContext, "images/blank100x100.png", mCropSourceFile.getAbsolutePath());
try {
mCropResultFile.createNewFile();
} catch (IOException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
loadSettings();
previewBackgroundBean.setPixelColor(0xFFFFFFFF);
previewBackgroundBean.setIsUseBackgroundFile(true);
previewBackgroundBean.setIsUseBackgroundScaledCompressFile(false);
previewBackgroundBean.setBackgroundFileName(mCropSourceFile.getName());
previewBackgroundBean.setBackgroundFilePath(mCropSourceFile.getAbsolutePath());
previewBackgroundBean.setBackgroundScaledCompressFileName(mCropResultFile.getName());
previewBackgroundBean.setBackgroundScaledCompressFilePath(mCropResultFile.getAbsolutePath());
saveSettings();
LogUtils.d(TAG, "背景Bean为空已创建空白背景并更新配置");
return true;
} }
LogUtils.d(TAG, "背景Bean文件存在无需创建空白背景"); LogUtils.d(TAG, "背景Bean文件存在无需创建空白背景");
return false; return false;
} }
public boolean createBlankBackgroundBean(int nBackgroundPixelColor) {
String newCropFileName = genNewCropFileName();
String fileSuffix = "png";
mCropSourceFile = new File(fCropCacheDir, newCropFileName + "." + fileSuffix);
mCropResultFile = new File(fCropCacheDir, "SelectCompress_" + newCropFileName + "." + fileSuffix);
AssetsCopyUtils.copyAssetsFileToDir(mContext, "images/blank100x100.png", mCropSourceFile.getAbsolutePath());
try {
mCropResultFile.createNewFile();
} catch (IOException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
loadSettings();
previewBackgroundBean.setPixelColor(nBackgroundPixelColor);
previewBackgroundBean.setIsUseBackgroundFile(true);
previewBackgroundBean.setIsUseBackgroundScaledCompressFile(false);
previewBackgroundBean.setBackgroundFileName(mCropSourceFile.getName());
previewBackgroundBean.setBackgroundFilePath(mCropSourceFile.getAbsolutePath());
previewBackgroundBean.setBackgroundScaledCompressFileName(mCropResultFile.getName());
previewBackgroundBean.setBackgroundScaledCompressFilePath(mCropResultFile.getAbsolutePath());
saveSettings();
LogUtils.d(TAG, "背景Bean为空已创建空白背景并更新配置");
return true;
}
String genNewCropFileName() { String genNewCropFileName() {
return UUID.randomUUID().toString() + System.currentTimeMillis(); return UUID.randomUUID().toString() + System.currentTimeMillis();
} }