20251212_002702_716

This commit is contained in:
2025-12-12 00:27:07 +08:00
parent a44f7fe6d4
commit 6bf3ebe2fd
4 changed files with 73 additions and 75 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #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 stageCount=16
libraryProject= libraryProject=
baseVersion=15.12 baseVersion=15.12
publishVersion=15.12.15 publishVersion=15.12.15
buildCount=0 buildCount=1
baseBetaVersion=15.12.16 baseBetaVersion=15.12.16

View File

@@ -38,7 +38,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
public class BackgroundSettingsActivity extends WinBoLLActivity implements BackgroundPicturePreviewDialog.IOnRecivedPictureListener { public class BackgroundSettingsActivity extends WinBoLLActivity {
// ====================== 常量定义 ====================== // ====================== 常量定义 ======================
public static final String TAG = "BackgroundSettingsActivity"; public static final String TAG = "BackgroundSettingsActivity";
@@ -573,7 +573,12 @@ public class BackgroundSettingsActivity extends WinBoLLActivity implements Backg
String action = intent.getAction(); String action = intent.getAction();
String type = intent.getType(); String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null && isImageType(type)) { 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(); dlg.show();
LogUtils.d(TAG, "【分享处理】收到分享图片意图"); LogUtils.d(TAG, "【分享处理】收到分享图片意图");
return true; return true;
@@ -876,12 +881,5 @@ public class BackgroundSettingsActivity extends WinBoLLActivity implements Backg
handleOperationCancelOrFail(); handleOperationCancelOrFail();
} }
} }
// ====================== 接口实现 ======================
@Override
public void onAcceptRecivedPicture(String szPreRecivedPictureName) {
ToastUtils.show("图片接收功能暂未实现");
LogUtils.d(TAG, "【分享接收】图片名:" + szPreRecivedPictureName);
}
} }

View File

@@ -2,22 +2,19 @@ package cc.winboll.studio.powerbell.dialogs;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast; import android.widget.Toast;
import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.powerbell.MainActivity; import cc.winboll.studio.powerbell.MainActivity;
import cc.winboll.studio.powerbell.R; import cc.winboll.studio.powerbell.R;
import cc.winboll.studio.powerbell.activities.BackgroundSettingsActivity; import cc.winboll.studio.powerbell.activities.BackgroundSettingsActivity;
import cc.winboll.studio.powerbell.utils.BackgroundSourceUtils; 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.utils.UriUtil;
import cc.winboll.studio.powerbell.views.BackgroundView;
import java.io.File; import java.io.File;
import java.io.IOException;
/** /**
* @Author ZhanGSKen<zhangsken@qq.com> * @Author ZhanGSKen<zhangsken@qq.com>
@@ -29,21 +26,25 @@ public class BackgroundPicturePreviewDialog extends Dialog {
public static final String TAG = "BackgroundPicturePreviewDialog"; public static final String TAG = "BackgroundPicturePreviewDialog";
Context mContext; Context mContext;
BackgroundSourceUtils mBackgroundPictureUtils; //BackgroundSourceUtils mBackgroundPictureUtils;
Button dialogbackgroundpicturepreviewButton1; Button dialogbackgroundpicturepreviewButton1;
Button dialogbackgroundpicturepreviewButton2; Button dialogbackgroundpicturepreviewButton2;
String mszPreReceivedFileName; //String mszPreReceivedFileName;
IOnRecivedPictureListener mIOnRecivedPictureListener;
Uri mUriRecivedPicture;
BackgroundView mBackgroundView;
public BackgroundPicturePreviewDialog(Context context) { public BackgroundPicturePreviewDialog(Context context, IOnRecivedPictureListener iOnRecivedPictureListener) {
super(context); super(context);
setContentView(R.layout.dialog_backgroundpicturepreview); setContentView(R.layout.dialog_backgroundpicturepreview);
initEnv(); mIOnRecivedPictureListener = iOnRecivedPictureListener;
//initEnv();
mContext = context; mContext = context;
mBackgroundPictureUtils = BackgroundSourceUtils.getInstance(mContext); //mBackgroundPictureUtils = BackgroundSourceUtils.getInstance(mContext);
ImageView imageView = findViewById(R.id.dialogbackgroundpicturepreviewImageView1); mBackgroundView = findViewById(R.id.backgroundview);
copyAndViewRecivePicture(imageView); previewRecivedPicture();
dialogbackgroundpicturepreviewButton1 = findViewById(R.id.dialogbackgroundpicturepreviewButton1); dialogbackgroundpicturepreviewButton1 = findViewById(R.id.dialogbackgroundpicturepreviewButton1);
dialogbackgroundpicturepreviewButton1.setOnClickListener(new View.OnClickListener() { dialogbackgroundpicturepreviewButton1.setOnClickListener(new View.OnClickListener() {
@@ -53,6 +54,7 @@ public class BackgroundPicturePreviewDialog extends Dialog {
// 跳转到主窗口 // 跳转到主窗口
Intent i = new Intent(mContext, MainActivity.class); Intent i = new Intent(mContext, MainActivity.class);
mContext.startActivity(i); mContext.startActivity(i);
dismiss();
} }
}); });
@@ -62,79 +64,77 @@ public class BackgroundPicturePreviewDialog extends Dialog {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// 使用分享到的图片 // 使用分享到的图片
// mIOnRecivedPictureListener.onAcceptRecivedPicture(mUriRecivedPicture);
//LogUtils.d(TAG, "mszReceivedFileName : " + mszReceivedFileName);
((IOnRecivedPictureListener)mContext).onAcceptRecivedPicture(mszPreReceivedFileName);
// 关闭对话框 // 关闭对话框
dismiss(); dismiss();
} }
}); });
} }
void initEnv() { // void initEnv() {
LogUtils.d(TAG, "initEnv()"); // LogUtils.d(TAG, "initEnv()");
mszPreReceivedFileName = "PreReceived.data"; // mszPreReceivedFileName = "PreReceived.data";
} // }
void copyAndViewRecivePicture(ImageView imageView) { void previewRecivedPicture() {
//AppConfigUtils appConfigUtils = AppConfigUtils.getInstance((GlobalApplication)mContext.getApplicationContext());
BackgroundSettingsActivity activity = ((BackgroundSettingsActivity)mContext); BackgroundSettingsActivity activity = ((BackgroundSettingsActivity)mContext);
//取出文件uri //取出文件uri
Uri uri = activity.getIntent().getData(); mUriRecivedPicture = activity.getIntent().getData();
if (uri == null) { if (mUriRecivedPicture == null) {
uri = activity.getIntent().getParcelableExtra(Intent.EXTRA_STREAM); mUriRecivedPicture = activity.getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
} }
//获取文件真实地址 //获取文件真实地址
String szSrcImage = UriUtil.getFilePathFromUri(mContext, uri); String szSrcImage = UriUtil.getFilePathFromUri(mContext, mUriRecivedPicture);
if (TextUtils.isEmpty(szSrcImage)) { if (TextUtils.isEmpty(szSrcImage)) {
Toast.makeText(mContext, "接收到的文件为空。", Toast.LENGTH_SHORT).show(); Toast.makeText(mContext, "接收到的文件为空。", Toast.LENGTH_SHORT).show();
dismiss(); dismiss();
return; return;
} }
mBackgroundView.loadImage(szSrcImage);
File fSrcImage = new File(szSrcImage); //
//mszPreReceivedFileName = DateUtils.getDateNowString() + "-" + fSrcImage.getName(); // File fSrcImage = new File(szSrcImage);
File mfPreReceivedPhoto = new File(BackgroundSourceUtils.getInstance(mContext).getBackgroundSourceDirPath(), mszPreReceivedFileName); // //mszPreReceivedFileName = DateUtils.getDateNowString() + "-" + fSrcImage.getName();
// 复制源图片到剪裁文件 // File mfPreReceivedPhoto = new File(BackgroundSourceUtils.getInstance(mContext).getBackgroundSourceDirPath(), mszPreReceivedFileName);
try { // // 复制源图片到剪裁文件
FileUtils.copyFileUsingFileChannels(fSrcImage, mfPreReceivedPhoto); // try {
LogUtils.d(TAG, "copyFileUsingFileChannels"); // FileUtils.copyFileUsingFileChannels(fSrcImage, mfPreReceivedPhoto);
Drawable drawable = Drawable.createFromPath(mfPreReceivedPhoto.getPath()); // LogUtils.d(TAG, "copyFileUsingFileChannels");
imageView.setBackground(drawable); // Drawable drawable = Drawable.createFromPath(mfPreReceivedPhoto.getPath());
//LogUtils.d(TAG, "mszPreReceivedFileName : " + mszPreReceivedFileName); // imageView.setBackground(drawable);
} catch (IOException e) { // //LogUtils.d(TAG, "mszPreReceivedFileName : " + mszPreReceivedFileName);
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); // } catch (IOException e) {
} // LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
// }
} }
// //
// 创建图片背景图片目录 // 创建图片背景图片目录
// //
boolean createBackgroundFolder2(String szBackgroundFolder) { // boolean createBackgroundFolder2(String szBackgroundFolder) {
// 文件路径参数为空值或无效值时返回false. // // 文件路径参数为空值或无效值时返回false.
if (szBackgroundFolder == null | szBackgroundFolder.equals("")) { // if (szBackgroundFolder == null | szBackgroundFolder.equals("")) {
return false; // return false;
} // }
//
LogUtils.d(TAG, "Background Folder Is : " + szBackgroundFolder); // LogUtils.d(TAG, "Background Folder Is : " + szBackgroundFolder);
File f = new File(szBackgroundFolder); // File f = new File(szBackgroundFolder);
if (f.exists()) { // if (f.exists()) {
if (f.isDirectory()) { // if (f.isDirectory()) {
return true; // return true;
} else { // } else {
// 工作路径不是一个目录 // // 工作路径不是一个目录
LogUtils.d(TAG, "createImageWorkFolder() error : szImageCacheFolder isDirectory return false. -->" + szBackgroundFolder); // LogUtils.d(TAG, "createImageWorkFolder() error : szImageCacheFolder isDirectory return false. -->" + szBackgroundFolder);
return false; // return false;
} // }
} else { // } else {
return f.mkdirs(); // return f.mkdirs();
} // }
} // }
public interface IOnRecivedPictureListener { public interface IOnRecivedPictureListener {
void onAcceptRecivedPicture(String szBackgroundFileName); void onAcceptRecivedPicture(Uri uriRecivedPicture);
} }
} }

View File

@@ -25,11 +25,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"> android:gravity="center_vertical|center_horizontal">
<ImageView <cc.winboll.studio.powerbell.views.BackgroundView
android:layout_width="wrap_content" android:orientation="vertical"
android:layout_height="wrap_content" android:layout_width="200dp"
android:scaleType="centerCrop" android:layout_height="200dp"
android:id="@+id/dialogbackgroundpicturepreviewImageView1"/> android:id="@+id/backgroundview"/>
</LinearLayout> </LinearLayout>