diff --git a/powerbell/build.properties b/powerbell/build.properties
index 2b4b12b0..26837bcc 100644
--- a/powerbell/build.properties
+++ b/powerbell/build.properties
@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
-#Fri Nov 21 12:03:39 GMT 2025
+#Fri Nov 21 13:17:50 GMT 2025
stageCount=7
libraryProject=
baseVersion=15.11
publishVersion=15.11.6
-buildCount=17
+buildCount=26
baseBetaVersion=15.11.7
diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/MainActivity.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/MainActivity.java
index f4da79e9..0a299231 100644
--- a/powerbell/src/main/java/cc/winboll/studio/powerbell/MainActivity.java
+++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/MainActivity.java
@@ -171,7 +171,7 @@ public class MainActivity extends WinBoLLActivity {
public static void reloadBackground() {
// 修复:添加非空校验,避免Activity已销毁时调用
if (_mMainActivity != null && !_mMainActivity.isFinishing() && !_mMainActivity.isDestroyed()) {
- _mMainActivity.mMainViewFragment.loadBackground();
+ _mMainActivity.mMainViewFragment.reloadBackground();
}
}
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 2110dbca..05d7d242 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
@@ -7,16 +7,16 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
+import android.text.TextUtils;
import android.view.View;
-import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
+import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
import cc.winboll.studio.libaes.views.AToolbar;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.ToastUtils;
@@ -24,16 +24,17 @@ import cc.winboll.studio.powerbell.App;
import cc.winboll.studio.powerbell.R;
import cc.winboll.studio.powerbell.beans.BackgroundPictureBean;
import cc.winboll.studio.powerbell.dialogs.BackgroundPicturePreviewDialog;
+import cc.winboll.studio.powerbell.dialogs.NetworkBackgroundDialog;
import cc.winboll.studio.powerbell.utils.BackgroundPictureUtils;
import cc.winboll.studio.powerbell.utils.FileUtils;
import cc.winboll.studio.powerbell.utils.UriUtil;
+import cc.winboll.studio.powerbell.views.BackgroundView;
import java.io.BufferedOutputStream;
import java.io.File;
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 {
@@ -54,6 +55,10 @@ public class BackgroundPictureActivity extends WinBoLLActivity implements Backgr
private File mfTempCropPicture; // 剪裁临时文件
private File mfRecivedCropPicture; // 剪裁后的目标文件
+ private String preViewFileBackgroundView = "";
+ BackgroundView bvPreviewBackground;
+ boolean isCommitSettings = false;
+
// 静态变量
public static String _mszRecivedCropPicture = "RecivedCrop.jpg";
private static String _mszCommonFileType = "jpeg";
@@ -103,7 +108,7 @@ public class BackgroundPictureActivity extends WinBoLLActivity implements Backgr
mAToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- finish();
+ finish(); // 点击导航栏返回按钮,触发 finish()
}
});
@@ -158,31 +163,36 @@ public class BackgroundPictureActivity extends WinBoLLActivity implements Backgr
*/
public void updatePreviewBackground() {
LogUtils.d(TAG, "updatePreviewBackground");
- ImageView ivPreviewBackground = (ImageView) findViewById(R.id.activitybackgroundpictureImageView1);
+ //ImageView ivPreviewBackground = (ImageView) findViewById(R.id.activitybackgroundpictureImageView1);
+ bvPreviewBackground = (BackgroundView) findViewById(R.id.activitybackgroundpictureBackgroundView1);
BackgroundPictureUtils utils = BackgroundPictureUtils.getInstance(this);
utils.loadBackgroundPictureBean();
boolean isUseBackgroundFile = utils.getBackgroundPictureBean().isUseBackgroundFile();
if (isUseBackgroundFile && mfRecivedCropPicture.exists()) {
- try {
- String filePath = utils.getBackgroundDir() + getBackgroundFileName();
- Drawable drawable = FileUtils.getImageDrawable(filePath);
- if (drawable != null) {
- //drawable.setAlpha(120);
- ivPreviewBackground.setImageDrawable(drawable);
- }
- //ToastUtils.show("背景图片已更新");
- } catch (IOException e) {
- LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
- ToastUtils.show("背景图片加载失败");
- }
+ //try {
+ String filePath = utils.getBackgroundDir() + getBackgroundFileName();
+ preViewFileBackgroundView = filePath;
+ bvPreviewBackground.previewBackgroundImage(preViewFileBackgroundView);
+ /*Drawable drawable = FileUtils.getImageDrawable(filePath);
+ if (drawable != null) {
+ //drawable.setAlpha(120);
+ //bvPreviewBackground.setImageDrawable(drawable);
+ }*/
+ //ToastUtils.show("背景图片已更新");
+// } catch (IOException e) {
+// LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
+// ToastUtils.show("背景图片加载失败");
+// }
} else {
ToastUtils.show("未使用背景图片");
- Drawable drawable = getResources().getDrawable(R.drawable.blank10x10);
- if (drawable != null) {
- drawable.setAlpha(120);
- ivPreviewBackground.setImageDrawable(drawable);
- }
+ preViewFileBackgroundView = "";
+ bvPreviewBackground.previewBackgroundImage(preViewFileBackgroundView);
+// Drawable drawable = getResources().getDrawable(R.drawable.blank10x10);
+// if (drawable != null) {
+// drawable.setAlpha(120);
+// bvPreviewBackground.setImageDrawable(drawable);
+// }
}
}
@@ -434,13 +444,13 @@ public class BackgroundPictureActivity extends WinBoLLActivity implements Backgr
fos.close();
} catch (IOException e) {
LogUtils.e(TAG, "流关闭异常" + e);
- }
- }
- if (scaledBitmap != null && !scaledBitmap.isRecycled()) {
- scaledBitmap.recycle();
- }
- }
- }
+ }
+ }
+ if (scaledBitmap != null && !scaledBitmap.isRecycled()) {
+ scaledBitmap.recycle();
+ }
+ }
+ }
/**
* 缩放Bitmap
@@ -619,5 +629,31 @@ public class BackgroundPictureActivity extends WinBoLLActivity implements Backgr
dialog.show();
}
+
+ /**
+ * 重写finish方法,确保所有退出场景都触发Toast
+ */
+ @Override
+ public void finish() {
+ if (!isCommitSettings) {
+ YesNoAlertDialog.show(this, "应用背景更改提示:", "是否应用预览图片?", new YesNoAlertDialog.OnDialogResultListener(){
+
+ @Override
+ public void onNo() {
+ isCommitSettings = true;
+ finish();
+ }
+
+ @Override
+ public void onYes() {
+ bvPreviewBackground.saveToBackgroundSources(preViewFileBackgroundView);
+ isCommitSettings = true;
+ finish();
+ }
+ });
+ } else {
+ super.finish();
+ }
+ }
}
diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/fragments/MainViewFragment.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/fragments/MainViewFragment.java
index 6819a656..10c6ae4b 100644
--- a/powerbell/src/main/java/cc/winboll/studio/powerbell/fragments/MainViewFragment.java
+++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/fragments/MainViewFragment.java
@@ -9,7 +9,6 @@ import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ViewTreeObserver;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
@@ -20,15 +19,12 @@ import android.widget.TextView;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.powerbell.App;
import cc.winboll.studio.powerbell.R;
-import cc.winboll.studio.powerbell.activities.BackgroundPictureActivity;
-import cc.winboll.studio.powerbell.beans.BackgroundPictureBean;
import cc.winboll.studio.powerbell.services.ControlCenterService;
import cc.winboll.studio.powerbell.utils.AppConfigUtils;
-import cc.winboll.studio.powerbell.utils.BackgroundPictureUtils;
import cc.winboll.studio.powerbell.utils.ServiceUtils;
+import cc.winboll.studio.powerbell.views.BackgroundView;
import cc.winboll.studio.powerbell.views.BatteryDrawable;
import cc.winboll.studio.powerbell.views.VerticalSeekBar;
-import java.io.File;
public class MainViewFragment extends Fragment {
@@ -72,6 +68,7 @@ public class MainViewFragment extends Fragment {
TextView mtvUsegeReminderValue;
CheckBox mcbUsegeReminderValue;
TextView mtvCurrentValue;
+ BackgroundView bvPreviewBackground;
@Override
@@ -79,27 +76,28 @@ public class MainViewFragment extends Fragment {
mView = inflater.inflate(R.layout.fragment_mainview, container, false);
_mMainViewFragment = MainViewFragment.this;
mAppConfigUtils = App.getAppConfigUtils(getActivity());
-
+
// 获取指定ID的View实例
- final View mainImageView = mView.findViewById(R.id.fragmentmainviewImageView1);
+ bvPreviewBackground = mView.findViewById(R.id.fragmentmainviewBackgroundView1);
+ /*final View mainImageView = mView.findViewById(R.id.fragmentmainviewImageView1);
- // 注册OnGlobalLayoutListener
- mainImageView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- // 获取宽度和高度
- int width = mainImageView.getMeasuredWidth();
- int height = mainImageView.getMeasuredHeight();
+ // 注册OnGlobalLayoutListener
+ mainImageView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ // 获取宽度和高度
+ int width = mainImageView.getMeasuredWidth();
+ int height = mainImageView.getMeasuredHeight();
- BackgroundPictureUtils utils = BackgroundPictureUtils.getInstance(getActivity());
- BackgroundPictureBean bean = utils.loadBackgroundPictureBean();
- bean.setBackgroundWidth(width);
- bean.setBackgroundHeight(height);
- utils.saveData();
- // 移除监听器以避免内存泄漏
- mainImageView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
- }
- });
+ BackgroundPictureUtils utils = BackgroundPictureUtils.getInstance(getActivity());
+ BackgroundPictureBean bean = utils.loadBackgroundPictureBean();
+ bean.setBackgroundWidth(width);
+ bean.setBackgroundHeight(height);
+ utils.saveData();
+ // 移除监听器以避免内存泄漏
+ mainImageView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+ }
+ });*/
mDrawableFrame = getActivity().getDrawable(R.drawable.bg_frame);
mllLeftSeekBar = (LinearLayout) mView.findViewById(R.id.fragmentmainviewLinearLayout1);
@@ -302,22 +300,23 @@ public class MainViewFragment extends Fragment {
}
}
- public void loadBackground() {
- BackgroundPictureBean bean = BackgroundPictureUtils.getInstance(getActivity()).getBackgroundPictureBean();
- ImageView imageView = mView.findViewById(R.id.fragmentmainviewImageView1);
- String szBackgroundFilePath = BackgroundPictureUtils.getInstance(getActivity()).getBackgroundDir() + BackgroundPictureActivity.getBackgroundFileName();
- File fBackgroundFilePath = new File(szBackgroundFilePath);
- LogUtils.d(TAG, "szBackgroundFilePath : " + szBackgroundFilePath);
- LogUtils.d(TAG, String.format("fBackgroundFilePath.exists() %s", fBackgroundFilePath.exists()));
- if (bean.isUseBackgroundFile() && fBackgroundFilePath.exists()) {
- Drawable drawableBackground = Drawable.createFromPath(szBackgroundFilePath);
- //drawableBackground.setAlpha(120);
- imageView.setImageDrawable(drawableBackground);
- } else {
- Drawable drawableBackground = getActivity().getDrawable(R.drawable.blank10x10);
- //drawableBackground.setAlpha(120);
- imageView.setImageDrawable(drawableBackground);
- }
+ public void reloadBackground() {
+ bvPreviewBackground.reloadBackgroundImage();
+// BackgroundPictureBean bean = BackgroundPictureUtils.getInstance(getActivity()).getBackgroundPictureBean();
+// ImageView imageView = mView.findViewById(R.id.fragmentmainviewImageView1);
+// String szBackgroundFilePath = BackgroundPictureUtils.getInstance(getActivity()).getBackgroundDir() + BackgroundPictureActivity.getBackgroundFileName();
+// File fBackgroundFilePath = new File(szBackgroundFilePath);
+// LogUtils.d(TAG, "szBackgroundFilePath : " + szBackgroundFilePath);
+// LogUtils.d(TAG, String.format("fBackgroundFilePath.exists() %s", fBackgroundFilePath.exists()));
+// if (bean.isUseBackgroundFile() && fBackgroundFilePath.exists()) {
+// Drawable drawableBackground = Drawable.createFromPath(szBackgroundFilePath);
+// //drawableBackground.setAlpha(120);
+// imageView.setImageDrawable(drawableBackground);
+// } else {
+// Drawable drawableBackground = getActivity().getDrawable(R.drawable.blank10x10);
+// //drawableBackground.setAlpha(120);
+// imageView.setImageDrawable(drawableBackground);
+// }
}
Handler mHandler = new Handler(){
diff --git a/powerbell/src/main/res/layout/activity_backgroundpicture.xml b/powerbell/src/main/res/layout/activity_backgroundpicture.xml
index 2375b2ee..40ae2bea 100644
--- a/powerbell/src/main/res/layout/activity_backgroundpicture.xml
+++ b/powerbell/src/main/res/layout/activity_backgroundpicture.xml
@@ -21,13 +21,15 @@
android:layout_height="match_parent"
android:id="@+id/activitybackgroundpictureRelativeLayout1"/>
-
+ android:background="#FF7381FF"
+ android:id="@+id/activitybackgroundpictureBackgroundView1">
-
+
-
-
-
+ android:background="#FF7381FF"
+ android:id="@+id/fragmentmainviewBackgroundView1"/>