From 643b84aecef66d1a99fd031928c7ed263224c7d3 Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Wed, 19 Nov 2025 19:21:40 +0800 Subject: [PATCH 01/20] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E8=B0=83=E8=AF=95=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- powerbell/build.properties | 4 +- powerbell/src/main/AndroidManifest.xml | 34 +++++++------ .../unittest/BackgroundViewTestFragment.java | 30 +++++++++++ .../powerbell/unittest/BaseTestFragment.java | 33 ++++++++++++ .../unittest/MainUnitTestActivity.java | 39 +++++++++++++++ .../powerbell/views/BackgroundView.java | 50 +++++++++++++++++++ .../main/res/layout/activity_mainunittest.xml | 15 ++++++ .../layout/fragment_test_backgroundview.xml | 27 ++++++++++ .../src/main/res/layout/view_background.xml | 17 +++++++ 9 files changed, 232 insertions(+), 17 deletions(-) create mode 100644 powerbell/src/main/java/cc/winboll/studio/powerbell/unittest/BackgroundViewTestFragment.java create mode 100644 powerbell/src/main/java/cc/winboll/studio/powerbell/unittest/BaseTestFragment.java create mode 100644 powerbell/src/main/java/cc/winboll/studio/powerbell/unittest/MainUnitTestActivity.java create mode 100644 powerbell/src/main/java/cc/winboll/studio/powerbell/views/BackgroundView.java create mode 100644 powerbell/src/main/res/layout/activity_mainunittest.xml create mode 100644 powerbell/src/main/res/layout/fragment_test_backgroundview.xml create mode 100644 powerbell/src/main/res/layout/view_background.xml diff --git a/powerbell/build.properties b/powerbell/build.properties index 2fed1875..ffec9c61 100644 --- a/powerbell/build.properties +++ b/powerbell/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Wed Nov 19 09:09:24 HKT 2025 +#Wed Nov 19 11:20:40 GMT 2025 stageCount=4 libraryProject= baseVersion=15.11 publishVersion=15.11.3 -buildCount=0 +buildCount=11 baseBetaVersion=15.11.4 diff --git a/powerbell/src/main/AndroidManifest.xml b/powerbell/src/main/AndroidManifest.xml index af149d28..0844c9b2 100644 --- a/powerbell/src/main/AndroidManifest.xml +++ b/powerbell/src/main/AndroidManifest.xml @@ -1,13 +1,14 @@ - - - - - + + + + + + @@ -36,22 +37,22 @@ - + + - - + - - + - - + + + diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/unittest/BackgroundViewTestFragment.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/unittest/BackgroundViewTestFragment.java new file mode 100644 index 00000000..b6f0c576 --- /dev/null +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/unittest/BackgroundViewTestFragment.java @@ -0,0 +1,30 @@ +package cc.winboll.studio.powerbell.unittest; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import cc.winboll.studio.libappbase.ToastUtils; +import cc.winboll.studio.powerbell.R; + +/** + * @Author ZhanGSKen&豆包大模型 + * @Date 2025/11/19 18:16 + * @Describe BackgroundViewTestFragment + */ +public class BackgroundViewTestFragment extends BaseTestFragment { + + public static final String TAG = "BackgroundViewTestFragment"; + + View mainView; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + super.onCreateView(inflater, container, savedInstanceState); + mainView = inflater.inflate(R.layout.fragment_test_backgroundview, container, false); + + ToastUtils.show(String.format("%s onCreate", TAG)); + + return mainView; + } +} diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/unittest/BaseTestFragment.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/unittest/BaseTestFragment.java new file mode 100644 index 00000000..2dcd29fe --- /dev/null +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/unittest/BaseTestFragment.java @@ -0,0 +1,33 @@ +package cc.winboll.studio.powerbell.unittest; + +/** + * @Author ZhanGSKen&豆包大模型 + * @Date 2025/11/19 18:56 + * @Describe BaseTestFragment + */ +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import androidx.fragment.app.Fragment; +import cc.winboll.studio.libappbase.GlobalApplication; +import cc.winboll.studio.libappbase.ToastUtils; + +public class BaseTestFragment extends Fragment { + + public static final String TAG = "BaseTestFragment"; + + View mainView; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + // 非调试状态就结束本线程 + if (!GlobalApplication.isDebugging()) { + Thread.currentThread().destroy(); + } + + ToastUtils.show(String.format("%s onCreate", TAG)); + + return super.onCreateView(inflater, container, savedInstanceState); + } +} diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/unittest/MainUnitTestActivity.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/unittest/MainUnitTestActivity.java new file mode 100644 index 00000000..a5c91248 --- /dev/null +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/unittest/MainUnitTestActivity.java @@ -0,0 +1,39 @@ +package cc.winboll.studio.powerbell.unittest; + +import android.os.Bundle; +import android.widget.FrameLayout; +import androidx.appcompat.app.AppCompatActivity; +import cc.winboll.studio.libappbase.GlobalApplication; +import cc.winboll.studio.powerbell.R; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; +import android.nfc.tech.TagTechnology; +import cc.winboll.studio.libappbase.ToastUtils; + +/** + * @Author ZhanGSKen&豆包大模型 + * @Date 2025/11/19 18:04 + * @Describe 单元测试启动主页窗口 + */ +public class MainUnitTestActivity extends AppCompatActivity { + + public static final String TAG = "MainUnitTestActivity"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // 非调试状态就退出 + if (!GlobalApplication.isDebugging()) { + finish(); + } + setContentView(R.layout.activity_mainunittest); + + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); + fragmentTransaction.add(R.id.activitymainunittestFrameLayout1, new BackgroundViewTestFragment(), BackgroundViewTestFragment.TAG); + fragmentTransaction.commit(); + + ToastUtils.show(String.format("%s onCreate", TAG)); + } + +} diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/views/BackgroundView.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/views/BackgroundView.java new file mode 100644 index 00000000..3c34576e --- /dev/null +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/views/BackgroundView.java @@ -0,0 +1,50 @@ +package cc.winboll.studio.powerbell.views; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; +import android.widget.LinearLayout; +import cc.winboll.studio.powerbell.R; + +/** + * @Author ZhanGSKen&豆包大模型 + * @Date 2025/11/19 18:01 + * @Describe 背景图片视图控件 + */ +public class BackgroundView extends LinearLayout { + + public static final String TAG = "BackgroundView"; + + Context mContext; + View mMianView; + + public BackgroundView(Context context) { + super(context); + this.mContext = context; + initView(); + } + + public BackgroundView(Context context, AttributeSet attrs) { + super(context, attrs); + this.mContext = context; + initView(); + } + + public BackgroundView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + this.mContext = context; + initView(); + } + + public BackgroundView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + this.mContext = context; + initView(); + } + + void initView() { + this.mMianView = inflate(this.mContext, R.layout.view_background, this); + //addView(this.mMianView); + } + +} diff --git a/powerbell/src/main/res/layout/activity_mainunittest.xml b/powerbell/src/main/res/layout/activity_mainunittest.xml new file mode 100644 index 00000000..f9adbc36 --- /dev/null +++ b/powerbell/src/main/res/layout/activity_mainunittest.xml @@ -0,0 +1,15 @@ + + + + + + + diff --git a/powerbell/src/main/res/layout/fragment_test_backgroundview.xml b/powerbell/src/main/res/layout/fragment_test_backgroundview.xml new file mode 100644 index 00000000..2cc148e7 --- /dev/null +++ b/powerbell/src/main/res/layout/fragment_test_backgroundview.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/powerbell/src/main/res/layout/view_background.xml b/powerbell/src/main/res/layout/view_background.xml new file mode 100644 index 00000000..a0b1058d --- /dev/null +++ b/powerbell/src/main/res/layout/view_background.xml @@ -0,0 +1,17 @@ + + + + + + + From f8980446a86903ca19887196a03acc4decabc1f6 Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Wed, 19 Nov 2025 20:25:48 +0800 Subject: [PATCH 02/20] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=B5=84=E6=BA=90=E4=B8=8B=E8=BD=BD=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- powerbell/build.properties | 4 +- .../activities/BackgroundPictureActivity.java | 30 +++++ .../dialogs/NetworkBackgroundDialog.java | 122 ++++++++++++++++++ .../res/layout/activity_backgroundpicture.xml | 23 +++- .../res/layout/dialog_networkbackground.xml | 60 +++++++++ 5 files changed, 234 insertions(+), 5 deletions(-) create mode 100644 powerbell/src/main/java/cc/winboll/studio/powerbell/dialogs/NetworkBackgroundDialog.java create mode 100644 powerbell/src/main/res/layout/dialog_networkbackground.xml diff --git a/powerbell/build.properties b/powerbell/build.properties index ffec9c61..a1cddcaf 100644 --- a/powerbell/build.properties +++ b/powerbell/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Wed Nov 19 11:20:40 GMT 2025 +#Wed Nov 19 12:22:35 GMT 2025 stageCount=4 libraryProject= baseVersion=15.11 publishVersion=15.11.3 -buildCount=11 +buildCount=15 baseBetaVersion=15.11.4 diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/activities/BackgroundPictureActivity.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/activities/BackgroundPictureActivity.java index 9bf3d440..2110dbca 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/activities/BackgroundPictureActivity.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/activities/BackgroundPictureActivity.java @@ -33,6 +33,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import cc.winboll.studio.powerbell.dialogs.NetworkBackgroundDialog; public class BackgroundPictureActivity extends WinBoLLActivity implements BackgroundPicturePreviewDialog.IOnRecivedPictureListener { @@ -589,5 +590,34 @@ public class BackgroundPictureActivity extends WinBoLLActivity implements Backgr super.onResume(); setBackgroundColor(); } + + public void onNetworkBackgroundDialog(View view) { + // 在需要显示对话框的地方(如网络状态监听回调中) + NetworkBackgroundDialog dialog = new NetworkBackgroundDialog(this, new NetworkBackgroundDialog.OnDialogClickListener() { + @Override + public void onConfirm() { + ToastUtils.show("onConfirm"); + // 处理确认逻辑(如允许后台网络使用) + LogUtils.d("MainActivity", "用户允许后台网络使用"); + // 执行具体业务:如开启后台网络请求服务 + } + + @Override + public void onCancel() { + ToastUtils.show("onCancel"); + // 处理取消逻辑(如禁止后台网络使用) + LogUtils.d("MainActivity", "用户禁止后台网络使用"); + // 执行具体业务:如关闭后台网络请求 + } + }); + + // 可选:修改对话框标题和内容(适配自定义场景) + dialog.setTitle("网络图片下载对话框"); + dialog.setContent("是否下载地址中的图片资源,作为应用背景图片?"); + + // 显示对话框 + dialog.show(); + + } } diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/dialogs/NetworkBackgroundDialog.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/dialogs/NetworkBackgroundDialog.java new file mode 100644 index 00000000..f5a53474 --- /dev/null +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/dialogs/NetworkBackgroundDialog.java @@ -0,0 +1,122 @@ +package cc.winboll.studio.powerbell.dialogs; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; // AndroidX 对话框 +import cc.winboll.studio.powerbell.R; +import cc.winboll.studio.libappbase.LogUtils; + +/** + * @Author ZhanGSKen&豆包大模型 + * @Date 2025/11/19 20:11 + * @Describe 网络后台使用提示对话框 + * 继承 AndroidX AlertDialog,绑定自定义布局 dialog_networkbackground.xml + */ +public class NetworkBackgroundDialog extends AlertDialog { + + // 控件引用 + private TextView tvTitle; + private TextView tvContent; + private Button btnCancel; + private Button btnConfirm; + + // 按钮点击回调接口(Java7 接口实现) + public interface OnDialogClickListener { + void onConfirm(); // 确认按钮点击 + void onCancel(); // 取消按钮点击 + } + + private OnDialogClickListener listener; + + // Java7 显式构造(必须传入 Context) + public NetworkBackgroundDialog(@NonNull Context context) { + super(context); + initView(); // 初始化布局和控件 + } + + // 带回调的构造(便于外部处理点击事件) + public NetworkBackgroundDialog(@NonNull Context context, OnDialogClickListener listener) { + super(context); + this.listener = listener; + initView(); + } + + /** + * 初始化布局和控件 + */ + private void initView() { + // 加载自定义布局 + View dialogView = LayoutInflater.from(getContext()) + .inflate(R.layout.dialog_networkbackground, null); + // 设置对话框内容视图 + setView(dialogView); + + // 绑定控件 + tvTitle = (TextView) dialogView.findViewById(R.id.tv_dialog_title); + tvContent = (TextView) dialogView.findViewById(R.id.tv_dialog_content); + btnCancel = (Button) dialogView.findViewById(R.id.btn_cancel); + btnConfirm = (Button) dialogView.findViewById(R.id.btn_confirm); + + // 设置按钮点击事件 + setButtonClickListeners(); + } + + /** + * 设置按钮点击监听 + */ + private void setButtonClickListeners() { + // 取消按钮:关闭对话框 + 回调外部 + btnCancel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + LogUtils.d("NetworkBackgroundDialog", "取消按钮点击"); + dismiss(); // 关闭对话框 + if (listener != null) { + listener.onCancel(); + } + } + }); + + // 确认按钮:关闭对话框 + 回调外部 + btnConfirm.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + LogUtils.d("NetworkBackgroundDialog", "确认按钮点击"); + dismiss(); // 关闭对话框 + if (listener != null) { + listener.onConfirm(); + } + } + }); + } + + /** + * 对外提供方法:修改对话框标题(灵活适配不同场景) + */ + public void setTitle(String title) { + if (tvTitle != null) { + tvTitle.setText(title); + } + } + + /** + * 对外提供方法:修改对话框内容(灵活适配不同场景) + */ + public void setContent(String content) { + if (tvContent != null) { + tvContent.setText(content); + } + } + + /** + * 对外提供方法:设置按钮点击回调(替代带参构造) + */ + public void setOnDialogClickListener(OnDialogClickListener listener) { + this.listener = listener; + } +} + diff --git a/powerbell/src/main/res/layout/activity_backgroundpicture.xml b/powerbell/src/main/res/layout/activity_backgroundpicture.xml index d3f329a3..2375b2ee 100644 --- a/powerbell/src/main/res/layout/activity_backgroundpicture.xml +++ b/powerbell/src/main/res/layout/activity_backgroundpicture.xml @@ -21,7 +21,6 @@ android:layout_height="match_parent" android:id="@+id/activitybackgroundpictureRelativeLayout1"/> - + + + + + + - + - + + diff --git a/powerbell/src/main/res/layout/dialog_networkbackground.xml b/powerbell/src/main/res/layout/dialog_networkbackground.xml new file mode 100644 index 00000000..635b6292 --- /dev/null +++ b/powerbell/src/main/res/layout/dialog_networkbackground.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + +