From 6bf3ebe2fdaadc8cef1c514eda9743140c234f38 Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Fri, 12 Dec 2025 00:27:07 +0800 Subject: [PATCH] 20251212_002702_716 --- powerbell/build.properties | 4 +- .../BackgroundSettingsActivity.java | 16 ++- .../BackgroundPicturePreviewDialog.java | 118 +++++++++--------- .../dialog_backgroundpicturepreview.xml | 10 +- 4 files changed, 73 insertions(+), 75 deletions(-) diff --git a/powerbell/build.properties b/powerbell/build.properties index 37c51da..c9e6bc1 100644 --- a/powerbell/build.properties +++ b/powerbell/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Thu Dec 11 20:54:28 HKT 2025 +#Thu Dec 11 16:22:39 GMT 2025 stageCount=16 libraryProject= baseVersion=15.12 publishVersion=15.12.15 -buildCount=0 +buildCount=1 baseBetaVersion=15.12.16 diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/activities/BackgroundSettingsActivity.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/activities/BackgroundSettingsActivity.java index 3c3ecb6..d2445f3 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/activities/BackgroundSettingsActivity.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/activities/BackgroundSettingsActivity.java @@ -38,7 +38,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -public class BackgroundSettingsActivity extends WinBoLLActivity implements BackgroundPicturePreviewDialog.IOnRecivedPictureListener { +public class BackgroundSettingsActivity extends WinBoLLActivity { // ====================== 常量定义 ====================== public static final String TAG = "BackgroundSettingsActivity"; @@ -573,7 +573,12 @@ public class BackgroundSettingsActivity extends WinBoLLActivity implements Backg String action = intent.getAction(); String type = intent.getType(); if (Intent.ACTION_SEND.equals(action) && type != null && isImageType(type)) { - BackgroundPicturePreviewDialog dlg = new BackgroundPicturePreviewDialog(this); + BackgroundPicturePreviewDialog dlg = new BackgroundPicturePreviewDialog(this, new BackgroundPicturePreviewDialog.IOnRecivedPictureListener(){ + @Override + public void onAcceptRecivedPicture(Uri uriRecivedPicture) { + ToastUtils.show(String.format("uriRecivedPicture %s", uriRecivedPicture)); + } + }); dlg.show(); LogUtils.d(TAG, "【分享处理】收到分享图片意图"); return true; @@ -876,12 +881,5 @@ public class BackgroundSettingsActivity extends WinBoLLActivity implements Backg handleOperationCancelOrFail(); } } - - // ====================== 接口实现 ====================== - @Override - public void onAcceptRecivedPicture(String szPreRecivedPictureName) { - ToastUtils.show("图片接收功能暂未实现"); - LogUtils.d(TAG, "【分享接收】图片名:" + szPreRecivedPictureName); - } } diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/dialogs/BackgroundPicturePreviewDialog.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/dialogs/BackgroundPicturePreviewDialog.java index cc89fd1..9867762 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/dialogs/BackgroundPicturePreviewDialog.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/dialogs/BackgroundPicturePreviewDialog.java @@ -2,22 +2,19 @@ package cc.winboll.studio.powerbell.dialogs; import android.app.Dialog; import android.content.Context; import android.content.Intent; -import android.graphics.drawable.Drawable; import android.net.Uri; import android.text.TextUtils; import android.view.View; import android.widget.Button; -import android.widget.ImageView; import android.widget.Toast; import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.powerbell.MainActivity; import cc.winboll.studio.powerbell.R; import cc.winboll.studio.powerbell.activities.BackgroundSettingsActivity; import cc.winboll.studio.powerbell.utils.BackgroundSourceUtils; -import cc.winboll.studio.powerbell.utils.FileUtils; import cc.winboll.studio.powerbell.utils.UriUtil; +import cc.winboll.studio.powerbell.views.BackgroundView; import java.io.File; -import java.io.IOException; /** * @Author ZhanGSKen @@ -29,21 +26,25 @@ public class BackgroundPicturePreviewDialog extends Dialog { public static final String TAG = "BackgroundPicturePreviewDialog"; Context mContext; - BackgroundSourceUtils mBackgroundPictureUtils; + //BackgroundSourceUtils mBackgroundPictureUtils; Button dialogbackgroundpicturepreviewButton1; Button dialogbackgroundpicturepreviewButton2; - String mszPreReceivedFileName; + //String mszPreReceivedFileName; + IOnRecivedPictureListener mIOnRecivedPictureListener; + Uri mUriRecivedPicture; + BackgroundView mBackgroundView; - public BackgroundPicturePreviewDialog(Context context) { + public BackgroundPicturePreviewDialog(Context context, IOnRecivedPictureListener iOnRecivedPictureListener) { super(context); setContentView(R.layout.dialog_backgroundpicturepreview); - initEnv(); + mIOnRecivedPictureListener = iOnRecivedPictureListener; + //initEnv(); mContext = context; - mBackgroundPictureUtils = BackgroundSourceUtils.getInstance(mContext); + //mBackgroundPictureUtils = BackgroundSourceUtils.getInstance(mContext); - ImageView imageView = findViewById(R.id.dialogbackgroundpicturepreviewImageView1); - copyAndViewRecivePicture(imageView); + mBackgroundView = findViewById(R.id.backgroundview); + previewRecivedPicture(); dialogbackgroundpicturepreviewButton1 = findViewById(R.id.dialogbackgroundpicturepreviewButton1); dialogbackgroundpicturepreviewButton1.setOnClickListener(new View.OnClickListener() { @@ -53,6 +54,7 @@ public class BackgroundPicturePreviewDialog extends Dialog { // 跳转到主窗口 Intent i = new Intent(mContext, MainActivity.class); mContext.startActivity(i); + dismiss(); } }); @@ -62,79 +64,77 @@ public class BackgroundPicturePreviewDialog extends Dialog { @Override public void onClick(View v) { // 使用分享到的图片 - // - //LogUtils.d(TAG, "mszReceivedFileName : " + mszReceivedFileName); - ((IOnRecivedPictureListener)mContext).onAcceptRecivedPicture(mszPreReceivedFileName); + mIOnRecivedPictureListener.onAcceptRecivedPicture(mUriRecivedPicture); // 关闭对话框 dismiss(); } }); } - void initEnv() { - LogUtils.d(TAG, "initEnv()"); - mszPreReceivedFileName = "PreReceived.data"; - } +// void initEnv() { +// LogUtils.d(TAG, "initEnv()"); +// mszPreReceivedFileName = "PreReceived.data"; +// } - void copyAndViewRecivePicture(ImageView imageView) { - //AppConfigUtils appConfigUtils = AppConfigUtils.getInstance((GlobalApplication)mContext.getApplicationContext()); + void previewRecivedPicture() { BackgroundSettingsActivity activity = ((BackgroundSettingsActivity)mContext); //取出文件uri - Uri uri = activity.getIntent().getData(); - if (uri == null) { - uri = activity.getIntent().getParcelableExtra(Intent.EXTRA_STREAM); + mUriRecivedPicture = activity.getIntent().getData(); + if (mUriRecivedPicture == null) { + mUriRecivedPicture = activity.getIntent().getParcelableExtra(Intent.EXTRA_STREAM); } //获取文件真实地址 - String szSrcImage = UriUtil.getFilePathFromUri(mContext, uri); + String szSrcImage = UriUtil.getFilePathFromUri(mContext, mUriRecivedPicture); if (TextUtils.isEmpty(szSrcImage)) { Toast.makeText(mContext, "接收到的文件为空。", Toast.LENGTH_SHORT).show(); dismiss(); return; } - - File fSrcImage = new File(szSrcImage); - //mszPreReceivedFileName = DateUtils.getDateNowString() + "-" + fSrcImage.getName(); - File mfPreReceivedPhoto = new File(BackgroundSourceUtils.getInstance(mContext).getBackgroundSourceDirPath(), mszPreReceivedFileName); - // 复制源图片到剪裁文件 - try { - FileUtils.copyFileUsingFileChannels(fSrcImage, mfPreReceivedPhoto); - LogUtils.d(TAG, "copyFileUsingFileChannels"); - Drawable drawable = Drawable.createFromPath(mfPreReceivedPhoto.getPath()); - imageView.setBackground(drawable); - //LogUtils.d(TAG, "mszPreReceivedFileName : " + mszPreReceivedFileName); - } catch (IOException e) { - LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); - } + mBackgroundView.loadImage(szSrcImage); +// +// File fSrcImage = new File(szSrcImage); +// //mszPreReceivedFileName = DateUtils.getDateNowString() + "-" + fSrcImage.getName(); +// File mfPreReceivedPhoto = new File(BackgroundSourceUtils.getInstance(mContext).getBackgroundSourceDirPath(), mszPreReceivedFileName); +// // 复制源图片到剪裁文件 +// try { +// FileUtils.copyFileUsingFileChannels(fSrcImage, mfPreReceivedPhoto); +// LogUtils.d(TAG, "copyFileUsingFileChannels"); +// Drawable drawable = Drawable.createFromPath(mfPreReceivedPhoto.getPath()); +// imageView.setBackground(drawable); +// //LogUtils.d(TAG, "mszPreReceivedFileName : " + mszPreReceivedFileName); +// } catch (IOException e) { +// LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); +// } } // // 创建图片背景图片目录 // - boolean createBackgroundFolder2(String szBackgroundFolder) { - // 文件路径参数为空值或无效值时返回false. - if (szBackgroundFolder == null | szBackgroundFolder.equals("")) { - return false; - } - - LogUtils.d(TAG, "Background Folder Is : " + szBackgroundFolder); - File f = new File(szBackgroundFolder); - if (f.exists()) { - if (f.isDirectory()) { - return true; - } else { - // 工作路径不是一个目录 - LogUtils.d(TAG, "createImageWorkFolder() error : szImageCacheFolder isDirectory return false. -->" + szBackgroundFolder); - return false; - } - } else { - return f.mkdirs(); - } - } +// boolean createBackgroundFolder2(String szBackgroundFolder) { +// // 文件路径参数为空值或无效值时返回false. +// if (szBackgroundFolder == null | szBackgroundFolder.equals("")) { +// return false; +// } +// +// LogUtils.d(TAG, "Background Folder Is : " + szBackgroundFolder); +// File f = new File(szBackgroundFolder); +// if (f.exists()) { +// if (f.isDirectory()) { +// return true; +// } else { +// // 工作路径不是一个目录 +// LogUtils.d(TAG, "createImageWorkFolder() error : szImageCacheFolder isDirectory return false. -->" + szBackgroundFolder); +// return false; +// } +// } else { +// return f.mkdirs(); +// } +// } public interface IOnRecivedPictureListener { - void onAcceptRecivedPicture(String szBackgroundFileName); + void onAcceptRecivedPicture(Uri uriRecivedPicture); } } diff --git a/powerbell/src/main/res/layout/dialog_backgroundpicturepreview.xml b/powerbell/src/main/res/layout/dialog_backgroundpicturepreview.xml index 4b5a700..a255164 100644 --- a/powerbell/src/main/res/layout/dialog_backgroundpicturepreview.xml +++ b/powerbell/src/main/res/layout/dialog_backgroundpicturepreview.xml @@ -25,11 +25,11 @@ android:layout_height="wrap_content" android:gravity="center_vertical|center_horizontal"> - +