20251129_170510_937

This commit is contained in:
2025-11-29 17:05:15 +08:00
parent 34356b8116
commit c9bc5c88d8
4 changed files with 29 additions and 22 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Sat Nov 29 08:15:05 GMT 2025
#Sat Nov 29 09:04:04 GMT 2025
stageCount=11
libraryProject=
baseVersion=15.11
publishVersion=15.11.10
buildCount=35
buildCount=42
baseBetaVersion=15.11.11

View File

@@ -46,9 +46,9 @@ public class NetworkBackgroundDialog extends AlertDialog {
Context mContext;
// 主线程 Handler用于接收子线程消息并更新 UI
private Handler mUiHandler;
String previewFilePath;
String previewFileUrl;
String downloadSavedPath;
String mPreviewFilePath;
String mPreviewFileUrl;
String mDownloadSavedPath;
// 按钮点击回调接口Java7 接口实现)
public interface OnDialogClickListener {
@@ -90,8 +90,8 @@ public class NetworkBackgroundDialog extends AlertDialog {
switch (msg.what) {
case MSG_IMAGE_LOAD_SUCCESS:
// 图片加载成功,获取文件路径并设置背景
downloadSavedPath = (String) msg.obj;
previewBackground(downloadSavedPath);
mDownloadSavedPath = (String) msg.obj;
previewBackground(mDownloadSavedPath);
break;
case MSG_IMAGE_LOAD_FAILED:
// 图片加载失败,设置默认背景
@@ -155,7 +155,7 @@ public class NetworkBackgroundDialog extends AlertDialog {
LogUtils.d("NetworkBackgroundDialog", "取消按钮点击");
BackgroundSourceUtils utils = BackgroundSourceUtils.getInstance(mContext);
utils.setCurrentSourceToPreview();
dismiss(); // 关闭对话框
if (listener != null) {
listener.onCancel();
@@ -170,11 +170,11 @@ public class NetworkBackgroundDialog extends AlertDialog {
LogUtils.d("NetworkBackgroundDialog", "确认按钮点击");
// 确定预览背景资源
BackgroundSourceUtils utils = BackgroundSourceUtils.getInstance(mContext);
utils.saveFileToPreviewBean(new File(previewFilePath), previewFileUrl);
utils.saveFileToPreviewBean(new File(mPreviewFilePath), mPreviewFileUrl);
dismiss(); // 关闭对话框
if (listener != null) {
listener.onConfirm(previewFilePath, previewFileUrl);
listener.onConfirm(mPreviewFilePath, mPreviewFileUrl);
}
}
});
@@ -192,26 +192,24 @@ public class NetworkBackgroundDialog extends AlertDialog {
* 根据文件路径设置 BackgroundView 背景(主线程调用)
* @param filePath 图片文件路径
*/
private void previewBackground(String filePath) {
private void previewBackground(String previewFilePath) {
FileInputStream fis = null;
try {
File imageFile = new File(filePath);
File imageFile = new File(previewFilePath);
if (!imageFile.exists()) {
LogUtils.e(TAG, "图片文件不存在:" + filePath);
ToastUtils.show("图片文件不存在:" + previewFilePath);
LogUtils.e(TAG, "图片文件不存在:" + previewFilePath);
bvBackgroundPreview.setBackgroundResource(R.drawable.ic_launcher);
return;
}
// 预览背景
previewFilePath = filePath;
mPreviewFilePath = previewFilePath;
BackgroundSourceUtils utils = BackgroundSourceUtils.getInstance(mContext);
utils.saveFileToPreviewBean(new File(previewFilePath), previewFileUrl);
utils.saveFileToPreviewBean(new File(mPreviewFilePath), mPreviewFileUrl);
bvBackgroundPreview.reloadPreviewBackground();
//bvBackgroundPreview.previewBackgroundImage(previewFilePath);
LogUtils.d(TAG, "图片预览成功:" + filePath);
//ToastUtils.show("预览背景中。。。");
} catch (Exception e) {
e.printStackTrace();
bvBackgroundPreview.setBackgroundResource(R.drawable.ic_launcher);
@@ -255,8 +253,8 @@ public class NetworkBackgroundDialog extends AlertDialog {
void downloadImageToAlbumAndPreview() {
//String previewFileUrl = "https://example.com/test.jpg";
previewFileUrl = etURL.getText().toString();
ImageDownloader.getInstance(mContext).downloadImage(previewFileUrl, new ImageDownloader.DownloadCallback(){
mPreviewFileUrl = etURL.getText().toString();
ImageDownloader.getInstance(mContext).downloadImage(mPreviewFileUrl, new ImageDownloader.DownloadCallback(){
@Override
public void onSuccess(String savePath) {
// 发送消息到主线程,携带图片路径

View File

@@ -4,6 +4,7 @@ import android.content.Context;
import cc.winboll.studio.powerbell.model.BackgroundBean;
import java.io.File;
import java.util.UUID;
import cc.winboll.studio.libappbase.ToastUtils;
/**
* @Author ZhanGSKen<zhangsken@qq.com>
@@ -116,12 +117,17 @@ public class BackgroundSourceUtils {
*/
public BackgroundBean saveFileToPreviewBean(File sourceFile, String fileInfo) {
File previewBackgroundFile = new File(fBackgroundSourceDir, FileUtils.createUniqueFileName(sourceFile));
//ToastUtils.show(String.format("saveFileToPreviewBean previewBackgroundFile : %s", previewBackgroundFile.getAbsolutePath()));
FileUtils.copyFile(sourceFile, previewBackgroundFile);
previewBackgroundBean = new BackgroundBean();
previewBackgroundBean.setBackgroundFileName(previewBackgroundFile.getName());
previewBackgroundBean.setBackgroundScaledCompressFileName("ScaledCompress_"+previewBackgroundFile.getName());
previewBackgroundBean.setBackgroundFileName(fileInfo);
saveSettings();
ToastUtils.show(String.format("saveFileToPreviewBean getPreviewBackgroundFilePath() : %s", getPreviewBackgroundFilePath()));
return previewBackgroundBean;
}

View File

@@ -15,6 +15,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import cc.winboll.studio.powerbell.utils.BackgroundSourceUtils;
import cc.winboll.studio.libappbase.ToastUtils;
/**
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
@@ -249,9 +250,11 @@ public class BackgroundView extends RelativeLayout {
*/
private void loadAndSetImageViewBackground() {
if (backgroundSourceFilePath == null) {
LogUtils.d(TAG, "backgroundSourceFilePath == null");
setDefaultImageViewBackground();
return;
}
//ToastUtils.show(String.format("backgroundSourceFilePath : %s", backgroundSourceFilePath));
File backgroundFile = new File(backgroundSourceFilePath);
if (!backgroundFile.exists() || !backgroundFile.isFile()) {