Compare commits

...

8 Commits

11 changed files with 88 additions and 44 deletions

View File

@@ -83,11 +83,11 @@ dependencies {
//api 'androidx.fragment:fragment:1.1.0'
// WinBoLL库 nexus.winboll.cc 地址
api 'cc.winboll.studio:libaes:15.12.6'
//api 'cc.winboll.studio:libaes:15.12.7'
//api 'cc.winboll.studio:libappbase:15.12.2'
// WinBoLL备用库 jitpack.io 地址
//api 'com.github.ZhanGSKen:AES:aes-v15.12.3'
api 'com.github.ZhanGSKen:AES:aes-v15.12.7'
api 'com.github.ZhanGSKen:APPBase:appbase-v15.14.1'
//api fileTree(dir: 'libs', include: ['*.aar'])

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Dec 23 15:23:07 HKT 2025
stageCount=26
#Wed Dec 24 12:22:06 HKT 2025
stageCount=29
libraryProject=
baseVersion=15.14
publishVersion=15.14.25
publishVersion=15.14.28
buildCount=0
baseBetaVersion=15.14.26
baseBetaVersion=15.14.29

View File

@@ -1,8 +1,6 @@
package cc.winboll.studio.powerbell;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.LogUtils;
@@ -13,7 +11,6 @@ import cc.winboll.studio.powerbell.utils.AppConfigUtils;
import cc.winboll.studio.powerbell.utils.BitmapCacheUtils;
import cc.winboll.studio.powerbell.utils.NotificationManagerUtils;
import cc.winboll.studio.powerbell.views.MemoryCachedBackgroundView;
import java.io.File;
/**
* 应用全局入口类适配Android API 30基于Java 7编写

View File

@@ -12,7 +12,6 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewStub;
import android.widget.LinearLayout;
import androidx.appcompat.widget.Toolbar;
import cc.winboll.studio.libaes.activitys.AboutActivity;
import cc.winboll.studio.libaes.models.APPInfo;
@@ -46,7 +45,7 @@ public class MainActivity extends WinBoLLActivity implements MainContentView.OnV
// ======================== 静态常量(置顶统一,抽离魔法值)========================
public static final String TAG = "MainActivity";
private static final int REQUEST_READ_MEDIA_IMAGES = 1001;
private static final int REQUEST_BACKGROUND_SETTINGS_ACTIVITY = 1001;
private static final long DELAY_LOAD_NON_CRITICAL = 500L;
public static final int MSG_RELOAD_APPCONFIG = 0;
public static final int MSG_CURRENTVALUEBATTERY = 1;
@@ -111,10 +110,7 @@ public class MainActivity extends WinBoLLActivity implements MainContentView.OnV
protected void onResume() {
super.onResume();
LogUtils.d(TAG, "onResume()");
if (sGlobalHandler != null) {
sGlobalHandler.sendEmptyMessage(MSG_LOAD_BACKGROUND);
sGlobalHandler.sendEmptyMessage(MSG_UPDATE_SERVICE_SWITCH);
}
if (mADsBannerView != null) {
mADsBannerView.resumeADs(this);
}
@@ -168,7 +164,7 @@ public class MainActivity extends WinBoLLActivity implements MainContentView.OnV
super.onActivityResult(requestCode, resultCode, data);
LogUtils.d(TAG, "onActivityResult() | requestCode=" + requestCode + " | resultCode=" + resultCode + " | data=" + data);
mPermissionUtils.handlePermissionRequest(this, requestCode, resultCode, data);
if (requestCode == REQUEST_READ_MEDIA_IMAGES && sGlobalHandler != null) {
if (requestCode == REQUEST_BACKGROUND_SETTINGS_ACTIVITY && sGlobalHandler != null) {
sGlobalHandler.sendEmptyMessage(MSG_LOAD_BACKGROUND);
}
}
@@ -208,7 +204,7 @@ public class MainActivity extends WinBoLLActivity implements MainContentView.OnV
startActivity(new Intent(this, ClearRecordActivity.class));
break;
case R.id.action_changepicture:
startActivityForResult(new Intent(this, BackgroundSettingsActivity.class), REQUEST_READ_MEDIA_IMAGES);
startActivityForResult(new Intent(this, BackgroundSettingsActivity.class), REQUEST_BACKGROUND_SETTINGS_ACTIVITY);
break;
case R.id.action_unittestactivity:
startActivity(new Intent(this, MainUnitTestActivity.class));
@@ -275,7 +271,7 @@ public class MainActivity extends WinBoLLActivity implements MainContentView.OnV
break;
case MSG_LOAD_BACKGROUND:
sMainActivity.reloadBackground();
sMainActivity.setMainLayoutBackgroundColor();
//sMainActivity.setMainLayoutBackgroundColor();
break;
case MSG_UPDATE_SERVICE_SWITCH:
sMainActivity.updateServiceSwitchUI();
@@ -407,24 +403,24 @@ public class MainActivity extends WinBoLLActivity implements MainContentView.OnV
}
BackgroundBean currentBgBean = mBgSourceUtils.getCurrentBackgroundBean();
if (currentBgBean != null) {
mMainContentView.backgroundView.loadByBackgroundBean(currentBgBean);
mMainContentView.backgroundView.loadByBackgroundBean(currentBgBean, true);
} else {
mMainContentView.backgroundView.setBackgroundResource(R.drawable.default_background);
}
}
private void setMainLayoutBackgroundColor() {
LogUtils.d(TAG, "setMainLayoutBackgroundColor()");
if (isFinishing() || isDestroyed() || mMainContentView == null || mBgSourceUtils == null) {
LogUtils.e(TAG, "setMainLayoutBackgroundColor: 上下文无效,设置失败");
return;
}
BackgroundBean currentBgBean = mBgSourceUtils.getCurrentBackgroundBean();
if (currentBgBean != null) {
mMainContentView.mainLayout.setBackgroundColor(currentBgBean.getPixelColor());
LogUtils.d(TAG, "setMainLayoutBackgroundColor: 主布局背景色设置完成 | color=" + currentBgBean.getPixelColor());
}
}
// private void setMainLayoutBackgroundColor() {
// LogUtils.d(TAG, "setMainLayoutBackgroundColor()");
// if (isFinishing() || isDestroyed() || mMainContentView == null || mBgSourceUtils == null) {
// LogUtils.e(TAG, "setMainLayoutBackgroundColor: 上下文无效,设置失败");
// return;
// }
// BackgroundBean currentBgBean = mBgSourceUtils.getCurrentBackgroundBean();
// if (currentBgBean != null) {
// mMainContentView.mainLayout.setBackgroundColor(currentBgBean.getPixelColor());
// LogUtils.d(TAG, "setMainLayoutBackgroundColor: 主布局背景色设置完成 | color=" + currentBgBean.getPixelColor2());
// }
// }
private void updateServiceSwitchUI() {
LogUtils.d(TAG, "updateServiceSwitchUI()");

View File

@@ -33,6 +33,7 @@ import cc.winboll.studio.powerbell.utils.BackgroundSourceUtils;
import cc.winboll.studio.powerbell.utils.BitmapCacheUtils;
import cc.winboll.studio.powerbell.utils.FileUtils;
import cc.winboll.studio.powerbell.utils.ImageCropUtils;
import cc.winboll.studio.powerbell.utils.ImageUtils;
import cc.winboll.studio.powerbell.utils.UriUtils;
import cc.winboll.studio.powerbell.views.BackgroundView;
import java.io.File;
@@ -317,7 +318,7 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
return;
}
int oldColor = previewBean.getPixelColor();
previewBean.setPixelColor(0xFF000000);
previewBean.setPixelColor(ImageUtils.getColorAccent(BackgroundSettingsActivity.this));
mBgSourceUtils.saveSettings();
doubleRefreshPreview();
isPreviewBackgroundChanged = true;
@@ -403,7 +404,7 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
mBgSourceUtils.loadSettings();
BackgroundBean previewBean = mBgSourceUtils.getPreviewBackgroundBean();
mBackgroundView.loadByBackgroundBean(previewBean, true);
mBackgroundView.setBackgroundColor(previewBean.getPixelColor());
//mBackgroundView.setBackgroundColor(previewBean.getPixelColor());
LogUtils.d(TAG, "【双重刷新】第一重完成");
} catch (Exception e) {
LogUtils.e(TAG, "【双重刷新】第一重异常:" + e.getMessage());
@@ -419,7 +420,7 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
mBgSourceUtils.loadSettings();
BackgroundBean previewBean = mBgSourceUtils.getPreviewBackgroundBean();
mBackgroundView.loadByBackgroundBean(previewBean, true);
mBackgroundView.setBackgroundColor(previewBean.getPixelColor());
//mBackgroundView.setBackgroundColor(previewBean.getPixelColor());
LogUtils.d(TAG, "【双重刷新】第二重完成");
} catch (Exception e) {
LogUtils.e(TAG, "【双重刷新】第二重异常:" + e.getMessage());

View File

@@ -39,7 +39,7 @@ public class BackgroundBean extends BaseBean implements Serializable {
private int backgroundWidth = DEFAULT_DIMENSION; // 背景图宽度
private int backgroundHeight = DEFAULT_DIMENSION; // 背景图高度
// 像素颜色
private int pixelColor = 0; // 拾取的像素颜色(纯色背景用)
private int pixelColor = 0xFFFFFFFF; // 拾取的像素颜色(纯色背景用)
// ====================== 构造方法无参构造JSON反序列化必备 ======================
/**

View File

@@ -16,6 +16,7 @@ import cc.winboll.studio.powerbell.R;
import cc.winboll.studio.powerbell.models.BackgroundBean;
import cc.winboll.studio.powerbell.utils.FileUtils;
import cc.winboll.studio.powerbell.utils.ImageCropUtils;
import cc.winboll.studio.powerbell.utils.ImageUtils;
import cc.winboll.studio.powerbell.views.MemoryCachedBackgroundView;
import java.io.File;
import java.io.IOException;
@@ -141,6 +142,7 @@ public class MainUnitTest2Activity extends AppCompatActivity {
private void initBackgroundBean() {
LogUtils.d(TAG, "initBackgroundBean初始化背景Bean");
mPreviewBackgroundBean = new BackgroundBean();
mPreviewBackgroundBean.setPixelColor(ImageUtils.getColorAccent(this));
mPreviewBackgroundBean.setBackgroundFileName(mPrivateTestImageFile.getName());
mPreviewBackgroundBean.setBackgroundFilePath(mPrivateTestImageFile.getAbsolutePath());
mPreviewBackgroundBean.setBackgroundScaledCompressFileName(mPrivateCropImageFile.getName());
@@ -241,7 +243,7 @@ public class MainUnitTest2Activity extends AppCompatActivity {
// 第一重刷新
try {
mMemoryCachedBackgroundView.loadByBackgroundBean(mPreviewBackgroundBean, true);
mMemoryCachedBackgroundView.setBackgroundColor(mPreviewBackgroundBean.getPixelColor());
//mMemoryCachedBackgroundView.setBackgroundColor(mPreviewBackgroundBean.getPixelColor());
LogUtils.d(TAG, "doubleRefreshPreview【双重刷新】第一重完成");
} catch (Exception e) {
LogUtils.e(TAG, String.format("doubleRefreshPreview【双重刷新】第一重异常 | %s", e.getMessage()));
@@ -255,7 +257,7 @@ public class MainUnitTest2Activity extends AppCompatActivity {
if (mMemoryCachedBackgroundView != null && !isFinishing()) {
try {
mMemoryCachedBackgroundView.loadByBackgroundBean(mPreviewBackgroundBean, true);
mMemoryCachedBackgroundView.setBackgroundColor(mPreviewBackgroundBean.getPixelColor());
//mMemoryCachedBackgroundView.setBackgroundColor(mPreviewBackgroundBean.getPixelColor());
LogUtils.d(TAG, "doubleRefreshPreview【双重刷新】第二重完成");
} catch (Exception e) {
LogUtils.e(TAG, String.format("doubleRefreshPreview【双重刷新】第二重异常 | %s", e.getMessage()));

View File

@@ -15,6 +15,7 @@ import cc.winboll.studio.powerbell.R;
import cc.winboll.studio.powerbell.models.BackgroundBean;
import cc.winboll.studio.powerbell.utils.FileUtils;
import cc.winboll.studio.powerbell.utils.ImageCropUtils;
import cc.winboll.studio.powerbell.utils.ImageUtils;
import cc.winboll.studio.powerbell.views.BackgroundView;
import java.io.File;
import java.io.IOException;
@@ -134,6 +135,7 @@ public class MainUnitTestActivity extends AppCompatActivity {
private void initBackgroundBean() {
LogUtils.d(TAG, "initBackgroundBean初始化背景Bean");
mPreviewBackgroundBean = new BackgroundBean();
mPreviewBackgroundBean.setPixelColor(ImageUtils.getColorAccent(this));
mPreviewBackgroundBean.setBackgroundFileName(mPrivateTestImageFile.getName());
mPreviewBackgroundBean.setBackgroundFilePath(mPrivateTestImageFile.getAbsolutePath());
mPreviewBackgroundBean.setBackgroundScaledCompressFileName(mPrivateCropImageFile.getName());

View File

@@ -156,6 +156,7 @@ public class BackgroundSourceUtils {
currentBackgroundBean = BackgroundBean.loadBeanFromFile(currentBackgroundBeanFile.getAbsolutePath(), BackgroundBean.class);
if (currentBackgroundBean == null) {
currentBackgroundBean = new BackgroundBean();
currentBackgroundBean.setPixelColor(ImageUtils.getColorAccent(mContext));
BackgroundBean.saveBeanToFile(currentBackgroundBeanFile.getAbsolutePath(), currentBackgroundBean);
LogUtils.d(TAG, "【配置加载】正式背景Bean不存在已创建新实例");
}
@@ -163,6 +164,7 @@ public class BackgroundSourceUtils {
previewBackgroundBean = BackgroundBean.loadBeanFromFile(previewBackgroundBeanFile.getAbsolutePath(), BackgroundBean.class);
if (previewBackgroundBean == null) {
previewBackgroundBean = new BackgroundBean();
previewBackgroundBean.setPixelColor(ImageUtils.getColorAccent(mContext));
BackgroundBean.saveBeanToFile(previewBackgroundBeanFile.getAbsolutePath(), previewBackgroundBean);
LogUtils.d(TAG, "【配置加载】预览背景Bean不存在已创建新实例");
}
@@ -542,6 +544,7 @@ public class BackgroundSourceUtils {
LogUtils.d(TAG, "【背景提交】开始深拷贝预览Bean到正式Bean");
// 深拷贝Bean属性
currentBackgroundBean = new BackgroundBean();
currentBackgroundBean.setPixelColor(ImageUtils.getColorAccent(mContext));
copyBackgroundBeanProperties(previewBackgroundBean, currentBackgroundBean);
// 复制文件
@@ -570,6 +573,7 @@ public class BackgroundSourceUtils {
LogUtils.d(TAG, "【背景同步】开始深拷贝正式Bean到预览Bean");
// 深拷贝Bean属性
previewBackgroundBean = new BackgroundBean();
previewBackgroundBean.setPixelColor(ImageUtils.getColorAccent(mContext));
copyBackgroundBeanProperties(currentBackgroundBean, previewBackgroundBean);
saveSettings();

View File

@@ -1,9 +1,12 @@
package cc.winboll.studio.powerbell.utils;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.powerbell.R;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -12,9 +15,10 @@ import java.io.OutputStream;
/**
* 图片处理工具类(质量压缩专用)
* 功能对图片进行JPEG质量压缩并将压缩结果覆盖源文件
* 功能对图片进行JPEG质量压缩并将压缩结果覆盖源文件获取主题colorPrimary颜色值
* 适配Java 7 + Android API 30
* 核心逻辑Bitmap.compress 质量压缩 + FileChannel 高效文件复制
* 核心逻辑Bitmap.compress 质量压缩 + FileChannel 高效文件复制;主题属性解析
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
*/
public class ImageUtils {
// ================================== 静态常量区(置顶归类,消除魔法值)=================================
@@ -22,6 +26,39 @@ public class ImageUtils {
private static final Bitmap.CompressFormat COMPRESS_FORMAT = Bitmap.CompressFormat.JPEG;
private static final int MIN_COMPRESS_QUALITY = 0;
private static final int MAX_COMPRESS_QUALITY = 100;
private static final int[] COLOR_ACCENT_ATTR = new int[]{R.attr.colorAccent}; // colorPrimary属性数组
// ================================== 新增Accent 颜色获取方法 =================================
/**
* 从当前应用主题中获取 colorAccent 颜色值
* @param context 上下文,用于获取主题与资源
* @return 解析到的 colorAccent 颜色值,解析失败返回默认白色#FFFFFFFF
*/
public static int getColorAccent(Context context) {
LogUtils.d(TAG, "【getColorAccent】方法调用");
if (context == null) {
LogUtils.e(TAG, "【getColorAccent】参数异常Context为空返回默认颜色");
return Color.parseColor("#FFFFFFFF");
}
TypedArray typedArray = null;
try {
// 从当前主题中解析 colorAccent 属性
typedArray = context.obtainStyledAttributes(COLOR_ACCENT_ATTR);
int colorAccent = typedArray.getColor(0, Color.parseColor("#FFFFFFFF"));
LogUtils.d(TAG, String.format("【getColorAccent】解析成功 | colorAccent=0x%08X", colorAccent));
return colorAccent;
} catch (Exception e) {
LogUtils.e(TAG, "【getColorAccent】解析失败返回默认颜色", e);
return Color.parseColor("#FFFFFFFF");
} finally {
// 回收TypedArray资源避免内存泄漏
if (typedArray != null) {
typedArray.recycle();
LogUtils.d(TAG, "【getColorAccent】TypedArray资源已回收");
}
}
}
// ================================== 核心工具方法(图片质量压缩)=================================
/**
@@ -32,7 +69,8 @@ public class ImageUtils {
* @param compressQuality 压缩质量0-100数值越小压缩率越高
*/
public static void bitmapCompress(Context context, String srcImagePath, String dstImagePath, int compressQuality) {
LogUtils.d(TAG, "【bitmapCompress】调用开始 | 源路径=" + srcImagePath + " | 临时路径=" + dstImagePath + " | 压缩质量=" + compressQuality);
LogUtils.d(TAG, String.format("【bitmapCompress】调用开始 | 源路径=%s | 临时路径=%s | 压缩质量=%d",
srcImagePath, dstImagePath, compressQuality));
// 1. 前置参数校验
if (srcImagePath == null || srcImagePath.isEmpty()) {
LogUtils.e(TAG, "【bitmapCompress】参数异常源文件路径为空");
@@ -43,7 +81,7 @@ public class ImageUtils {
return;
}
if (compressQuality < MIN_COMPRESS_QUALITY || compressQuality > MAX_COMPRESS_QUALITY) {
LogUtils.e(TAG, "【bitmapCompress】参数异常压缩质量超出范围0-100当前值=" + compressQuality);
LogUtils.e(TAG, String.format("【bitmapCompress】参数异常压缩质量超出范围0-100当前值=%d", compressQuality));
return;
}
@@ -62,14 +100,16 @@ public class ImageUtils {
LogUtils.e(TAG, "【bitmapCompress】Bitmap解码失败无法读取源图片 " + srcImagePath);
return;
}
LogUtils.d(TAG, "【bitmapCompress】Bitmap解码成功 | 尺寸=" + compressBitmap.getWidth() + "x" + compressBitmap.getHeight());
LogUtils.d(TAG, String.format("【bitmapCompress】Bitmap解码成功 | 尺寸=%dx%d",
compressBitmap.getWidth(), compressBitmap.getHeight()));
// 3. 创建临时压缩文件
File dstFile = new File(dstImagePath);
File dstParentDir = dstFile.getParentFile();
if (dstParentDir != null && !dstParentDir.exists()) {
boolean isDirCreated = dstParentDir.mkdirs();
LogUtils.d(TAG, "【bitmapCompress】临时目录创建" + (isDirCreated ? "成功" : "失败") + "" + dstParentDir.getAbsolutePath());
LogUtils.d(TAG, String.format("【bitmapCompress】临时目录创建%s%s",
isDirCreated ? "成功" : "失败", dstParentDir.getAbsolutePath()));
}
// 4. 写入压缩数据
@@ -83,7 +123,8 @@ public class ImageUtils {
// 5. 复制压缩文件覆盖源文件
FileUtils.copyFileUsingFileChannels(dstFile, srcFile);
LogUtils.d(TAG, "【bitmapCompress】" + compressQuality + "%压缩结束:已覆盖源文件 " + srcImagePath);
LogUtils.d(TAG, String.format("【bitmapCompress】%d%%压缩结束:已覆盖源文件 %s",
compressQuality, srcImagePath));
} catch (FileNotFoundException e) {
LogUtils.e(TAG, "【bitmapCompress】文件未找到异常", e);

View File

@@ -149,6 +149,7 @@ public class BackgroundView extends RelativeLayout {
}
// 加载图片
loadImage(targetPath);
setBackgroundColor(bean.getPixelColor());
LogUtils.d(TAG, "=== loadByBackgroundBean 完成 ===");
}