背景像素拾取功能测试完成

This commit is contained in:
2025-12-14 04:46:17 +08:00
parent e59034e48d
commit cff26b3d11
4 changed files with 25 additions and 16 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Sat Dec 13 20:16:32 GMT 2025
#Sat Dec 13 20:44:35 GMT 2025
stageCount=2
libraryProject=
baseVersion=15.14
publishVersion=15.14.1
buildCount=41
buildCount=47
baseBetaVersion=15.14.2

View File

@@ -48,7 +48,7 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
public static final int REQUEST_SELECT_PICTURE = 0;
public static final int REQUEST_TAKE_PHOTO = 1;
public static final int REQUEST_CROP_IMAGE = 2;
private static final int REQUEST_READ_MEDIA = 1001;
private static final int REQUEST_PIXELPICKER = 1001;
// ====================== 成员变量 ======================
private BackgroundSourceUtils mBgSourceUtils;
@@ -139,6 +139,9 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
break;
case REQUEST_CROP_IMAGE:
handleCropImageResult(requestCode, resultCode, data);
break;
case REQUEST_PIXELPICKER:
handlePixelPickerResult(requestCode, resultCode, data);
break;
default:
LogUtils.d(TAG, "【回调忽略】未知requestCode");
@@ -295,10 +298,11 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
};
private View.OnClickListener onPixelPickerClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
LogUtils.d(TAG, "【按钮点击】像素拾取");
String targetImagePath = mBgSourceUtils.getCurrentBackgroundBean().getBackgroundFilePath();
String targetImagePath = mBgSourceUtils.getPreviewBackgroundBean().getBackgroundFilePath();
File targetFile = new File(targetImagePath);
if (targetFile == null || !targetFile.exists() || targetFile.length() <= 0) {
ToastUtils.show("无有效图片可拾取像素");
@@ -307,7 +311,7 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
}
Intent intent = new Intent(getApplicationContext(), PixelPickerActivity.class);
intent.putExtra("imagePath", targetImagePath);
startActivity(intent);
startActivityForResult(intent, REQUEST_PIXELPICKER);
LogUtils.d(TAG, "【像素拾取启动】路径:" + targetImagePath);
}
};
@@ -316,7 +320,7 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
@Override
public void onClick(View v) {
LogUtils.d(TAG, "【按钮点击】清空像素颜色");
BackgroundBean bean = mBgSourceUtils.getCurrentBackgroundBean();
BackgroundBean bean = mBgSourceUtils.getPreviewBackgroundBean();
int oldColor = bean.getPixelColor();
bean.setPixelColor(0);
mBgSourceUtils.saveSettings();
@@ -366,6 +370,7 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
try {
mBgSourceUtils.loadSettings();
mBackgroundView.loadBackgroundBean(mBgSourceUtils.getPreviewBackgroundBean(), true);
mBackgroundView.setBackgroundColor(mBgSourceUtils.getPreviewBackgroundBean().getPixelColor());
LogUtils.d(TAG, "【双重刷新】第一重完成");
} catch (Exception e) {
LogUtils.e(TAG, "【双重刷新】第一重异常:" + e.getMessage());
@@ -380,6 +385,7 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
try {
mBgSourceUtils.loadSettings();
mBackgroundView.loadBackgroundBean(mBgSourceUtils.getPreviewBackgroundBean(), true);
mBackgroundView.setBackgroundColor(mBgSourceUtils.getPreviewBackgroundBean().getPixelColor());
LogUtils.d(TAG, "【双重刷新】第二重完成");
} catch (Exception e) {
LogUtils.e(TAG, "【双重刷新】第二重异常:" + e.getMessage());
@@ -852,5 +858,9 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
handleOperationCancelOrFail();
}
}
private void handlePixelPickerResult(int requestCode, int resultCode, Intent data) {
doubleRefreshPreview();
}
}

View File

@@ -194,7 +194,7 @@ public class PixelPickerActivity extends WinBoLLActivity implements IWinBoLLActi
dialog.dismiss();
// 可以在这里添加确定后的回调逻辑
BackgroundSourceUtils utils = BackgroundSourceUtils.getInstance(PixelPickerActivity.this);
BackgroundBean bean = utils.getCurrentBackgroundBean();
BackgroundBean bean = utils.getPreviewBackgroundBean();
bean.setPixelColor(pixelColor);
utils.saveSettings();
Toast.makeText(PixelPickerActivity.this, "已记录像素值", Toast.LENGTH_SHORT).show();
@@ -218,7 +218,7 @@ public class PixelPickerActivity extends WinBoLLActivity implements IWinBoLLActi
void setBackgroundColor() {
BackgroundSourceUtils utils = BackgroundSourceUtils.getInstance(PixelPickerActivity.this);
BackgroundBean bean = utils.getCurrentBackgroundBean();
BackgroundBean bean = utils.getPreviewBackgroundBean();
int nPixelColor = bean.getPixelColor();
RelativeLayout mainLayout = findViewById(R.id.activitypixelpickerRelativeLayout1);
mainLayout.setBackgroundColor(nPixelColor);
@@ -247,9 +247,11 @@ public class PixelPickerActivity extends WinBoLLActivity implements IWinBoLLActi
@Override
public void onBackPressed() {
super.onBackPressed();
Intent intent = new Intent();
intent.setClass(this, BackgroundSettingsActivity.class);
startActivity(intent);
setResult(RESULT_OK);
finish();
// Intent intent = new Intent();
// intent.setClass(this, BackgroundSettingsActivity.class);
// startActivity(intent);
//GlobalApplication.getWinBoLLActivityManager().startWinBoLLActivity(getApplicationContext(), BackgroundPictureActivity.class);
}
}

View File

@@ -20,8 +20,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF28C000">
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
@@ -32,7 +31,6 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF3243E2"
android:id="@+id/background_view">
</cc.winboll.studio.powerbell.views.BackgroundView>
@@ -42,8 +40,7 @@
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="#B92FABE6">
android:layout_height="400dp">
<RelativeLayout
android:layout_width="match_parent"