Compare commits

...

12 Commits

7 changed files with 138 additions and 49 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Thu Dec 25 16:08:51 HKT 2025
stageCount=31
#Fri Dec 26 02:58:19 HKT 2025
stageCount=35
libraryProject=
baseVersion=15.14
publishVersion=15.14.30
publishVersion=15.14.34
buildCount=0
baseBetaVersion=15.14.31
baseBetaVersion=15.14.35

View File

@@ -28,9 +28,10 @@
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<!-- 外部存储权限 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<!-- 相机权限 -->
@@ -51,6 +52,7 @@
<application
android:name=".App"
android:process=":main"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
@@ -60,17 +62,17 @@
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
android:supportsRtl="true"
android:process=".main"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
<!-- 主活动 -->
<!-- 主活动(主进程) -->
<activity
android:process=":main"
android:name=".MainActivity"
android:label="@string/app_name"
android:exported="true"
android:launchMode="singleTask"/>
<!-- 活动别名(启动器) -->
<!-- 活动别名(启动器,主进程 -->
<activity-alias
android:name=".MainActivityEN1"
android:targetActivity=".MainActivity"
@@ -119,18 +121,21 @@
android:resource="@xml/shortcutsmaincn2"/>
</activity-alias>
<!-- 功能活动 -->
<!-- 功能活动(主进程) -->
<activity
android:process=":main"
android:name=".activities.CrashActivity"
android:exported="false"/>
<activity
android:process=":main"
android:name=".activities.ClearRecordActivity"
android:parentActivityName="cc.winboll.studio.powerbell.MainActivity"
android:launchMode="singleTask"
android:exported="false"/>
<activity
android:process=":main"
android:name=".activities.BackgroundSettingsActivity"
android:parentActivityName="cc.winboll.studio.powerbell.MainActivity"
android:exported="true"
@@ -147,41 +152,50 @@
</activity>
<activity
android:process=":main"
android:name=".activities.BatteryReporterActivity"
android:exported="false"/>
<activity
android:process=":main"
android:name=".activities.PixelPickerActivity"
android:exported="false"/>
<activity
android:process=":main"
android:name=".activities.BatteryReportActivity"
android:exported="false"/>
<activity
android:process=":main"
android:name=".unittest.MainUnitTestActivity"
android:exported="false"/>
<activity
android:process=":main"
android:name=".activities.ShortcutActionActivity"
android:exported="false"/>
<activity
android:process=":main"
android:name=".activities.SettingsActivity"
android:exported="false"/>
<activity
android:process=":main"
android:name="cc.winboll.studio.powerbell.unittest.MainUnitTest2Activity"
android:exported="false"/>
<!-- 第三方活动 -->
<!-- 第三方活动(主进程) -->
<activity
android:process=":main"
android:name="com.yalantis.ucrop.UCropActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:exported="true"/>
<!-- 广播接收器 -->
<!-- 广播接收器(主进程) -->
<receiver
android:process=":main"
android:name=".receivers.MainReceiver"
android:enabled="true"
android:exported="true"
@@ -193,12 +207,14 @@
</intent-filter>
</receiver>
<!-- 服务 -->
<!-- 服务ControlCenterService主进程AssistantService独立进程 -->
<service
android:name=".services.ControlCenterService"
android:priority="1000"
android:enabled="true"
android:exported="false"
android:process=":main"
android:stopWithTask="false"
android:foregroundServiceType="dataSync">
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FOREGROUND_SERVICE"
@@ -209,18 +225,21 @@
android:name=".services.AssistantService"
android:enabled="true"
android:exported="false"
android:process=".assistant">
android:process=":assistant"
android:stopWithTask="false"
android:foregroundServiceType="dataSync">
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FOREGROUND_SERVICE"
android:value="辅助核心功能运行"/>
</service>
<!-- 内容提供者 -->
<!-- 内容提供者(主进程) -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
android:grantUriPermissions="true"
android:process=":main">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider"/>

View File

@@ -40,6 +40,9 @@ public class App extends GlobalApplication {
private static final int INVALID_BATTERY_VALUE = -1;
// ===================== 静态属性区(按工具类优先级排序) =====================
// 应用单例
private static App sApp;
// 数据配置工具
public static AppConfigUtils sAppConfigUtils;
private static AppCacheUtils sAppCacheUtils;
@@ -49,25 +52,32 @@ public class App extends GlobalApplication {
public static BitmapCacheUtils sBitmapCacheUtils;
// 全局视图控件缓存工具(极致强制保持:一旦初始化,永不销毁)
// 核心修改:改为私有静态,通过实例方法获取,避免全局通用暴露
private static MemoryCachedBackgroundView sMemoryCachedBackgroundView;
// 电池状态
public static volatile int sQuantityOfElectricity = INVALID_BATTERY_VALUE;
// 通知管理工具
private static NotificationManagerUtils sNotificationManagerUtils;
// ===================== 成员属性区(按生命周期关联度排序) =====================
// 全局广播接收器
private GlobalApplicationReceiver mGlobalReceiver;
// 通知管理工具
private static NotificationManagerUtils sNotificationManagerUtils;
private static App sApp;
// ===================== 公共静态方法区(工具类实例获取/单例) =====================
/**
* 获取应用单例实例
*/
public static App getInstance() {
return sApp;
}
// ===================== 公共静态方法区(工具类实例获取) =====================
/**
* 获取应用配置工具实例
*/
public static AppConfigUtils getAppConfigUtils(Context context) {
LogUtils.d(TAG, String.format("getAppConfigUtils() 调用 | 传入Context类型=%s",
context != null ? context.getClass().getSimpleName() : "null"));
context != null ? context.getClass().getSimpleName() : "null"));
if (sAppConfigUtils == null) {
sAppConfigUtils = AppConfigUtils.getInstance(context);
LogUtils.d(TAG, "getAppConfigUtils()AppConfigUtils实例已初始化");
@@ -80,7 +90,7 @@ public class App extends GlobalApplication {
*/
public static AppCacheUtils getAppCacheUtils(Context context) {
LogUtils.d(TAG, String.format("getAppCacheUtils() 调用 | 传入Context类型=%s",
context != null ? context.getClass().getSimpleName() : "null"));
context != null ? context.getClass().getSimpleName() : "null"));
if (sAppCacheUtils == null) {
sAppCacheUtils = AppCacheUtils.getInstance(context);
LogUtils.d(TAG, "getAppCacheUtils()AppCacheUtils实例已初始化");
@@ -88,13 +98,6 @@ public class App extends GlobalApplication {
return sAppCacheUtils;
}
/**
* 获取应用单例实例
*/
public static App getInstance() {
return sApp;
}
// ===================== 公共成员方法区(业务功能) =====================
/**
* 清除电池历史数据
@@ -139,12 +142,26 @@ public class App extends GlobalApplication {
return sMemoryCachedBackgroundView;
}
/**
* 发送调试通知
*/
public static void notifyMessage(String title, String content) {
LogUtils.d(TAG, String.format("notifyMessage() 调用 | title=%s | content=%s", title, content));
if (isDebugging() && sApp != null && sNotificationManagerUtils != null) {
NotificationMessage message = new NotificationMessage(title, content, "");
sNotificationManagerUtils.showMessageNotification(sApp, message);
LogUtils.d(TAG, "notifyMessage():调试通知发送成功");
} else {
LogUtils.d(TAG, "notifyMessage():调试通知发送失败(条件不满足)");
}
}
// ===================== 生命周期方法区(按执行顺序排序) =====================
@Override
public void onCreate() {
super.onCreate();
sApp = this;
LogUtils.d(TAG, "onCreate() 应用启动,开始初始化");
sApp = this;
// 初始化调试模式
setIsDebugging(BuildConfig.DEBUG);
@@ -152,7 +169,6 @@ public class App extends GlobalApplication {
// 初始化基础工具
initBaseTools();
//App.notifyMessage(TAG, "onCreate() 应用启动中。。。");
// 初始化工具类实例(核心:极致强制缓存,永不销毁)
initUtils();
// 初始化广播接收器
@@ -185,7 +201,7 @@ public class App extends GlobalApplication {
super.onTrimMemory(level);
// 极致强制缓存:禁止任何缓存清理操作,仅记录日志
LogUtils.w(TAG, String.format("%s onTrimMemory() 调用 | 内存等级level=%d | 极致强制保持所有缓存",
CACHE_PROTECT_TAG, level));
CACHE_PROTECT_TAG, level));
// 记录详细缓存状态,不执行任何清理
logDetailedCacheStatus();
}
@@ -201,15 +217,14 @@ public class App extends GlobalApplication {
// ===================== 私有初始化方法区(按初始化顺序排序) =====================
/**
* 初始化基础工具Activity管理、Toast
* 初始化基础工具Activity管理、Toast、通知工具
*/
private void initBaseTools() {
LogUtils.d(TAG, "initBaseTools() 开始初始化基础工具");
WinBoLLActivityManager.init(this);
ToastUtils.init(this);
LogUtils.d(TAG, "initBaseTools() 基础工具初始化完成");
sNotificationManagerUtils = new NotificationManagerUtils(this);
LogUtils.d(TAG, "initBaseTools() 工具初始化完成,极致强制缓存策略已生效");
LogUtils.d(TAG, "initBaseTools() 基础工具+通知工具初始化完成,极致强制缓存策略已生效");
}
/**
@@ -217,22 +232,31 @@ public class App extends GlobalApplication {
*/
private void initUtils() {
LogUtils.d(TAG, "initUtils() 开始初始化工具类,启用极致强制缓存策略");
//App.notifyMessage(TAG, "initUtils() 开始初始化工具类,启用极致强制缓存策略");
// 初始化配置&缓存工具
sAppConfigUtils = getAppConfigUtils(this);
sAppCacheUtils = getAppCacheUtils(this);
// 初始化背景资源工具
sBackgroundSourceUtils = BackgroundSourceUtils.getInstance(this);
sBackgroundSourceUtils.loadSettings();
LogUtils.d(TAG, "initUtils() 背景资源工具已初始化");
// 极致强制初始化Bitmap缓存工具必初始化永不销毁
sBitmapCacheUtils = BitmapCacheUtils.getInstance();
LogUtils.d(TAG, "initUtils() Bitmap缓存工具已初始化极致强制保持永不销毁");
// 极致强制初始化视图控件缓存工具(必初始化,永不销毁)
// if(sMemoryCachedBackgroundView == null) {
// App.notifyMessage(TAG, "sMemoryCachedBackgroundView == null");
// }
sMemoryCachedBackgroundView = MemoryCachedBackgroundView.getLastInstance(this);
if (sMemoryCachedBackgroundView == null) {
//App.notifyMessage(TAG, "sMemoryCachedBackgroundView == null");
sMemoryCachedBackgroundView = MemoryCachedBackgroundView.getInstance(this, sBackgroundSourceUtils.getCurrentBackgroundBean(), true);
LogUtils.d(TAG, "initUtils() 视图控件缓存工具已新建实例");
//App.notifyMessage(TAG, "没有使用缓存控件");
}
//App.notifyMessage(TAG, "initUtils() 视图控件缓存工具已初始化(极致强制保持,永不销毁)");
LogUtils.d(TAG, "initUtils() 视图控件缓存工具已初始化(极致强制保持,永不销毁)");
}
@@ -290,7 +314,7 @@ public class App extends GlobalApplication {
LogUtils.d(TAG, String.format("%s Bitmap缓存数量=%d", CACHE_PROTECT_TAG, cacheCount));
} catch (Exception e) {
LogUtils.d(TAG, String.format("%s Bitmap缓存数量获取失败不影响缓存| 异常信息=%s",
CACHE_PROTECT_TAG, e.getMessage()));
CACHE_PROTECT_TAG, e.getMessage()));
}
}
// 视图控件缓存状态
@@ -302,12 +326,5 @@ public class App extends GlobalApplication {
}
LogUtils.d(TAG, "logDetailedCacheStatus() 详细缓存状态记录完成,所有缓存均极致强制保持");
}
public static void notifyMessage(String title, String content) {
if (isDebugging() && sApp != null && sNotificationManagerUtils != null) {
NotificationMessage message = new NotificationMessage(title, content, "");
sNotificationManagerUtils.showMessageNotification(sApp, message);
}
}
}

View File

@@ -48,6 +48,7 @@ public class MainActivity extends WinBoLLActivity implements MainContentView.OnV
// ======================== 静态常量(置顶统一,抽离魔法值)========================
public static final String TAG = "MainActivity";
private static final int REQUEST_BACKGROUND_SETTINGS_ACTIVITY = 1001;
public static final String EXTRA_ISRELOAD_BACKGROUNDVIEW = "EXTRA_ISRELOAD_BACKGROUNDVIEW";
private static final long DELAY_LOAD_NON_CRITICAL = 500L;
public static final int MSG_RELOAD_APPCONFIG = 0;
public static final int MSG_CURRENTVALUEBATTERY = 1;
@@ -98,14 +99,45 @@ public class MainActivity extends WinBoLLActivity implements MainContentView.OnV
initCriticalView();
initCoreUtilsAsync();
loadNonCriticalViewDelayed();
// 处理首次启动的参数
handleReloadBackgroundParam(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// 关键:将新 Intent 赋值给 Activity 的 Intent确保后续 getIntent() 获取最新值
setIntent(intent);
// 统一处理参数
handleReloadBackgroundParam(intent);
}
/**
* 统一处理刷新背景的参数
* @param intent 启动 MainActivity 的 Intent
*/
private void handleReloadBackgroundParam(Intent intent) {
if (intent == null) {
LogUtils.d(TAG, "handleReloadBackgroundParam: Intent 为空");
return;
}
// 获取传递的参数,默认值为 false
boolean isReloadBackgroundView = intent.getBooleanExtra(EXTRA_ISRELOAD_BACKGROUNDVIEW, false);
if (isReloadBackgroundView) {
LogUtils.d(TAG, "接收到刷新背景视图指令");
// 执行背景刷新逻辑
//App.notifyMessage(TAG, "reloadBackgroundView");
reloadBackgroundView();
}
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
LogUtils.d(TAG, String.format("onPostCreate() | savedInstanceState=%s", savedInstanceState));
mPermissionUtils.startPermissionRequest(this);
LogUtils.d(TAG, "onPostCreate: 发起权限申请");
}
@Override
@@ -304,6 +336,10 @@ public class MainActivity extends WinBoLLActivity implements MainContentView.OnV
LogUtils.d(TAG, "initMainContentView: 核心内容视图已初始化");
}
private void reloadBackgroundView() {
mMainContentView.reloadBackgroundView();
}
private void initCriticalView() {
LogUtils.d(TAG, "initCriticalView()");
sMainActivity = this;

View File

@@ -25,6 +25,8 @@ import androidx.core.content.FileProvider;
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.ToastUtils;
import cc.winboll.studio.powerbell.App;
import cc.winboll.studio.powerbell.MainActivity;
import cc.winboll.studio.powerbell.R;
import cc.winboll.studio.powerbell.dialogs.BackgroundPicturePreviewDialog;
import cc.winboll.studio.powerbell.dialogs.ColorPaletteDialog;
@@ -937,6 +939,10 @@ public class BackgroundSettingsActivity extends WinBoLLActivity {
mBgSourceUtils.commitPreviewSourceToCurrent();
isCommitSettings = true;
finish();
//App.notifyMessage(TAG, "startActivity");
Intent mainIntent = new Intent(BackgroundSettingsActivity.this, MainActivity.class);
mainIntent.putExtra(MainActivity.EXTRA_ISRELOAD_BACKGROUNDVIEW, true);
startActivity(mainIntent);
}
@Override

View File

@@ -9,6 +9,7 @@ import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.powerbell.App;
import cc.winboll.studio.powerbell.MainActivity;
import cc.winboll.studio.powerbell.R;
import cc.winboll.studio.powerbell.activities.BackgroundSettingsActivity;
@@ -135,6 +136,7 @@ public class BackgroundPicturePreviewDialog extends Dialog {
// 解析Uri为文件路径
String szSrcImage = UriUtils.getFilePathFromUri(mContext, mUriRecivedPicture);
//App.notifyMessage(TAG, "szSrcImage : " + szSrcImage);
if (TextUtils.isEmpty(szSrcImage)) {
LogUtils.w(TAG, "【previewRecivedPicture】解析的文件路径为空");
Toast.makeText(mContext, TOAST_MSG_EMPTY_FILE, Toast.LENGTH_SHORT).show();

View File

@@ -154,7 +154,7 @@ public class MainContentView {
mainLayout = (RelativeLayout) rootView.findViewById(R.id.activitymainRelativeLayout1);
mllBackgroundView = (LinearLayout) rootView.findViewById(R.id.ll_backgroundview);
backgroundView = App.getInstance().getMemoryCachedBackgroundView().getLastInstance(mContext);
backgroundView = App.getInstance().getMemoryCachedBackgroundView();
if (backgroundView == null) {
App.sBackgroundSourceUtils.loadSettings();
BackgroundBean backgroundBean = App.sBackgroundSourceUtils.getCurrentBackgroundBean();
@@ -197,6 +197,15 @@ public class MainContentView {
LogUtils.d(TAG, "【bindViews】视图绑定完成");
}
public void reloadBackgroundView() {
if (backgroundView != null) {
App.sBackgroundSourceUtils.loadSettings();
BackgroundBean backgroundBean = App.sBackgroundSourceUtils.getCurrentBackgroundBean();
backgroundView.loadByBackgroundBean(backgroundBean, true);
//App.notifyMessage(TAG, "reloadBackgroundView");
}
}
/**
* 初始化电池 Drawable集成 BatteryDrawable默认能量风格适配小米机型渲染
*/