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 #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 stageCount=11
libraryProject= libraryProject=
baseVersion=15.11 baseVersion=15.11
publishVersion=15.11.10 publishVersion=15.11.10
buildCount=35 buildCount=42
baseBetaVersion=15.11.11 baseBetaVersion=15.11.11

View File

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

View File

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

View File

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