位图大小设置调试完成
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Wed Dec 24 11:16:45 GMT 2025
|
#Wed Dec 24 12:16:27 GMT 2025
|
||||||
stageCount=29
|
stageCount=29
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=15.14
|
baseVersion=15.14
|
||||||
publishVersion=15.14.28
|
publishVersion=15.14.28
|
||||||
buildCount=82
|
buildCount=97
|
||||||
baseBetaVersion=15.14.29
|
baseBetaVersion=15.14.29
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import android.provider.MediaStore;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
@@ -102,13 +103,59 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
|
|||||||
initPreviewEnvironment();
|
initPreviewEnvironment();
|
||||||
LogUtils.d(TAG, "生命周期 onCreate 初始化完成");
|
LogUtils.d(TAG, "生命周期 onCreate 初始化完成");
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected void onPostCreate(Bundle savedInstanceState) {
|
||||||
|
// super.onPostCreate(savedInstanceState);
|
||||||
|
// LogUtils.d(TAG, "生命周期 onPostCreate 执行双重刷新预览");
|
||||||
|
//
|
||||||
|
// // 初始化配置工具类并保存默认相框尺寸
|
||||||
|
// AppConfigUtils appConfigUtils = AppConfigUtils.getInstance(this);
|
||||||
|
// appConfigUtils.loadAppConfig();
|
||||||
|
// if (mBackgroundView.getWidth() > -1 && mBackgroundView.getHeight() > -1) {
|
||||||
|
// ToastUtils.show("mBackgroundView.getWidth() > 0 && mBackgroundView.getHeight() > 0");
|
||||||
|
// appConfigUtils.mAppConfigBean.setDefaultFrameWidth(mBackgroundView.getWidth());
|
||||||
|
// appConfigUtils.mAppConfigBean.setDefaultFrameHeight(mBackgroundView.getHeight());
|
||||||
|
// appConfigUtils.saveAppConfig();
|
||||||
|
// LogUtils.d(TAG, String.format("loadImage() 保存默认相框尺寸 | width=%d | height=%d", mBackgroundView.getWidth(), mBackgroundView.getHeight()));
|
||||||
|
// }
|
||||||
|
// LogUtils.d(TAG, String.format("mBackgroundView is %s", mBackgroundView));
|
||||||
|
// LogUtils.d(TAG, String.format("mBackgroundView.getWidth() %d, mBackgroundView.getHeight() %d", mBackgroundView.getWidth(), mBackgroundView.getHeight()));
|
||||||
|
// doubleRefreshPreview();
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostCreate(Bundle savedInstanceState) {
|
||||||
|
super.onPostCreate(savedInstanceState);
|
||||||
|
LogUtils.d(TAG, "生命周期 onPostCreate 执行双重刷新预览");
|
||||||
|
|
||||||
|
// 监听视图布局完成事件
|
||||||
|
mBackgroundView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
// 移除监听,避免重复回调
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
mBackgroundView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
|
} else {
|
||||||
|
mBackgroundView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 此时已获取真实宽高
|
||||||
|
int width = mBackgroundView.getWidth();
|
||||||
|
int height = mBackgroundView.getHeight();
|
||||||
|
if (width > 0 && height > 0) {
|
||||||
|
AppConfigUtils appConfigUtils = AppConfigUtils.getInstance(BackgroundSettingsActivity.this);
|
||||||
|
appConfigUtils.loadAppConfig();
|
||||||
|
appConfigUtils.mAppConfigBean.setDefaultFrameWidth(width);
|
||||||
|
appConfigUtils.mAppConfigBean.setDefaultFrameHeight(height);
|
||||||
|
appConfigUtils.saveAppConfig();
|
||||||
|
LogUtils.d(TAG, String.format("保存默认相框尺寸 | width=%d | height=%d", width, height));
|
||||||
|
doubleRefreshPreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostCreate(Bundle savedInstanceState) {
|
|
||||||
super.onPostCreate(savedInstanceState);
|
|
||||||
LogUtils.d(TAG, "生命周期 onPostCreate 执行双重刷新预览");
|
|
||||||
doubleRefreshPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ public class AppConfigBean extends BaseBean implements Serializable, Parcelable
|
|||||||
private static final int BATTERY_MIN = 0; // 电量最小值
|
private static final int BATTERY_MIN = 0; // 电量最小值
|
||||||
private static final int BATTERY_MAX = 100; // 电量最大值
|
private static final int BATTERY_MAX = 100; // 电量最大值
|
||||||
private static final int INVALID_BATTERY = -1; // 无效电量标识
|
private static final int INVALID_BATTERY = -1; // 无效电量标识
|
||||||
private static final int MIN_FRAME_SIZE = 100; // 最小相框尺寸(px)
|
|
||||||
private static final int MAX_FRAME_SIZE = 2000; // 最大相框尺寸(px)
|
|
||||||
private static final int DEFAULT_FRAME_WIDTH = 500; // 默认相框宽度(px)
|
private static final int DEFAULT_FRAME_WIDTH = 500; // 默认相框宽度(px)
|
||||||
private static final int DEFAULT_FRAME_HEIGHT = 500; // 默认相框高度(px)
|
private static final int DEFAULT_FRAME_HEIGHT = 500; // 默认相框高度(px)
|
||||||
|
|
||||||
@@ -184,7 +182,7 @@ public class AppConfigBean extends BaseBean implements Serializable, Parcelable
|
|||||||
* @param defaultFrameWidth 相框宽度(px,范围 MIN_FRAME_SIZE - MAX_FRAME_SIZE)
|
* @param defaultFrameWidth 相框宽度(px,范围 MIN_FRAME_SIZE - MAX_FRAME_SIZE)
|
||||||
*/
|
*/
|
||||||
public void setDefaultFrameWidth(int defaultFrameWidth) {
|
public void setDefaultFrameWidth(int defaultFrameWidth) {
|
||||||
this.defaultFrameWidth = Math.min(Math.max(defaultFrameWidth, MIN_FRAME_SIZE), MAX_FRAME_SIZE);
|
this.defaultFrameWidth = defaultFrameWidth;
|
||||||
LogUtils.d(TAG, String.format("setDefaultFrameWidth: 默认相框宽度设置为 %dpx(输入值:%d)",
|
LogUtils.d(TAG, String.format("setDefaultFrameWidth: 默认相框宽度设置为 %dpx(输入值:%d)",
|
||||||
this.defaultFrameWidth, defaultFrameWidth));
|
this.defaultFrameWidth, defaultFrameWidth));
|
||||||
}
|
}
|
||||||
@@ -198,7 +196,7 @@ public class AppConfigBean extends BaseBean implements Serializable, Parcelable
|
|||||||
* @param defaultFrameHeight 相框高度(px,范围 MIN_FRAME_SIZE - MAX_FRAME_SIZE)
|
* @param defaultFrameHeight 相框高度(px,范围 MIN_FRAME_SIZE - MAX_FRAME_SIZE)
|
||||||
*/
|
*/
|
||||||
public void setDefaultFrameHeight(int defaultFrameHeight) {
|
public void setDefaultFrameHeight(int defaultFrameHeight) {
|
||||||
this.defaultFrameHeight = Math.min(Math.max(defaultFrameHeight, MIN_FRAME_SIZE), MAX_FRAME_SIZE);
|
this.defaultFrameHeight = defaultFrameHeight;
|
||||||
LogUtils.d(TAG, String.format("setDefaultFrameHeight: 默认相框高度设置为 %dpx(输入值:%d)",
|
LogUtils.d(TAG, String.format("setDefaultFrameHeight: 默认相框高度设置为 %dpx(输入值:%d)",
|
||||||
this.defaultFrameHeight, defaultFrameHeight));
|
this.defaultFrameHeight, defaultFrameHeight));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,12 +161,8 @@ public class BackgroundView extends RelativeLayout {
|
|||||||
// 初始化配置工具类并保存默认相框尺寸
|
// 初始化配置工具类并保存默认相框尺寸
|
||||||
AppConfigUtils appConfigUtils = AppConfigUtils.getInstance(mContext);
|
AppConfigUtils appConfigUtils = AppConfigUtils.getInstance(mContext);
|
||||||
appConfigUtils.loadAppConfig();
|
appConfigUtils.loadAppConfig();
|
||||||
if (getWidth() > 0 && getHeight() > 0) {
|
LogUtils.d(TAG, String.format("W : %d, H : %d", appConfigUtils.mAppConfigBean.getDefaultFrameWidth(),
|
||||||
appConfigUtils.mAppConfigBean.setDefaultFrameWidth(getWidth());
|
appConfigUtils.mAppConfigBean.getDefaultFrameHeight()));
|
||||||
appConfigUtils.mAppConfigBean.setDefaultFrameHeight(getHeight());
|
|
||||||
appConfigUtils.saveAppConfig();
|
|
||||||
LogUtils.d(TAG, String.format("loadImage() 保存默认相框尺寸 | width=%d | height=%d", getWidth(), getHeight()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 刷新逻辑:重新解码原始品质图片并更新缓存
|
// 刷新逻辑:重新解码原始品质图片并更新缓存
|
||||||
if (isRefresh) {
|
if (isRefresh) {
|
||||||
@@ -178,16 +174,20 @@ public class BackgroundView extends RelativeLayout {
|
|||||||
|
|
||||||
// 合成纯色背景图片(固定尺寸1197x2287)
|
// 合成纯色背景图片(固定尺寸1197x2287)
|
||||||
Bitmap combinedBitmap = ImageUtils.drawBitmapOnSolidBackground(bgColor,
|
Bitmap combinedBitmap = ImageUtils.drawBitmapOnSolidBackground(bgColor,
|
||||||
1197,
|
appConfigUtils.mAppConfigBean.getDefaultFrameWidth(),
|
||||||
2287,
|
appConfigUtils.mAppConfigBean.getDefaultFrameHeight(),
|
||||||
newBitmap);
|
newBitmap);
|
||||||
|
// Bitmap combinedBitmap = ImageUtils.drawBitmapOnSolidBackground(bgColor,
|
||||||
|
// 1200,
|
||||||
|
// 2283,
|
||||||
|
// newBitmap);
|
||||||
|
|
||||||
if (combinedBitmap == null) {
|
if (combinedBitmap == null) {
|
||||||
ToastUtils.show("合成背景图片失败,使用原始图片");
|
//ToastUtils.show("合成背景图片失败,使用原始图片");
|
||||||
LogUtils.e(TAG, "loadImage() 纯色背景合成失败,使用原始Bitmap");
|
LogUtils.e(TAG, "loadImage() 纯色背景合成失败,使用原始Bitmap");
|
||||||
combinedBitmap = newBitmap;
|
combinedBitmap = newBitmap;
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.show("合成背景图片成功");
|
//ToastUtils.show("合成背景图片成功");
|
||||||
LogUtils.d(TAG, String.format("loadImage() 纯色背景合成成功 | combinedBitmap=%dx%d",
|
LogUtils.d(TAG, String.format("loadImage() 纯色背景合成成功 | combinedBitmap=%dx%d",
|
||||||
combinedBitmap.getWidth(), combinedBitmap.getHeight()));
|
combinedBitmap.getWidth(), combinedBitmap.getHeight()));
|
||||||
// 回收原始Bitmap(避免重复缓存)
|
// 回收原始Bitmap(避免重复缓存)
|
||||||
|
|||||||
Reference in New Issue
Block a user