Compare commits
8 Commits
powerbell-
...
powerbell-
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b1d160dac | |||
| db87ba51e3 | |||
| fd6e852061 | |||
| 8ff4b9e1f4 | |||
| 78a2d85150 | |||
| fd2d1d17ed | |||
| 37f3091103 | |||
| 6dc5f05702 |
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Thu Dec 25 16:51:19 HKT 2025
|
||||
stageCount=33
|
||||
#Fri Dec 26 02:58:19 HKT 2025
|
||||
stageCount=35
|
||||
libraryProject=
|
||||
baseVersion=15.14
|
||||
publishVersion=15.14.32
|
||||
publishVersion=15.14.34
|
||||
buildCount=0
|
||||
baseBetaVersion=15.14.33
|
||||
baseBetaVersion=15.14.35
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:process=":main"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
@@ -65,7 +66,7 @@
|
||||
|
||||
<!-- 主活动(主进程) -->
|
||||
<activity
|
||||
android:process=".main"
|
||||
android:process=":main"
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:exported="true"
|
||||
@@ -122,19 +123,19 @@
|
||||
|
||||
<!-- 功能活动(主进程) -->
|
||||
<activity
|
||||
android:process=".main"
|
||||
android:process=":main"
|
||||
android:name=".activities.CrashActivity"
|
||||
android:exported="false"/>
|
||||
|
||||
<activity
|
||||
android:process=".main"
|
||||
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:process=":main"
|
||||
android:name=".activities.BackgroundSettingsActivity"
|
||||
android:parentActivityName="cc.winboll.studio.powerbell.MainActivity"
|
||||
android:exported="true"
|
||||
@@ -151,53 +152,53 @@
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:process=".main"
|
||||
android:process=":main"
|
||||
android:name=".activities.BatteryReporterActivity"
|
||||
android:exported="false"/>
|
||||
|
||||
<activity
|
||||
android:process=".main"
|
||||
android:process=":main"
|
||||
android:name=".activities.PixelPickerActivity"
|
||||
android:exported="false"/>
|
||||
|
||||
<activity
|
||||
android:process=".main"
|
||||
android:process=":main"
|
||||
android:name=".activities.BatteryReportActivity"
|
||||
android:exported="false"/>
|
||||
|
||||
<activity
|
||||
android:process=".main"
|
||||
android:process=":main"
|
||||
android:name=".unittest.MainUnitTestActivity"
|
||||
android:exported="false"/>
|
||||
|
||||
<activity
|
||||
android:process=".main"
|
||||
android:process=":main"
|
||||
android:name=".activities.ShortcutActionActivity"
|
||||
android:exported="false"/>
|
||||
|
||||
<activity
|
||||
android:process=".main"
|
||||
android:process=":main"
|
||||
android:name=".activities.SettingsActivity"
|
||||
android:exported="false"/>
|
||||
|
||||
<activity
|
||||
android:process=".main"
|
||||
android:process=":main"
|
||||
android:name="cc.winboll.studio.powerbell.unittest.MainUnitTest2Activity"
|
||||
android:exported="false"/>
|
||||
|
||||
<!-- 第三方活动(主进程) -->
|
||||
<activity
|
||||
android:process=".main"
|
||||
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"
|
||||
android:process=".main"
|
||||
android:directBootAware="true">
|
||||
<intent-filter android:priority="1000">
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
@@ -212,7 +213,8 @@
|
||||
android:priority="1000"
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
android:process=".main"
|
||||
android:process=":main"
|
||||
android:stopWithTask="false"
|
||||
android:foregroundServiceType="dataSync">
|
||||
<property
|
||||
android:name="android.app.PROPERTY_SPECIAL_USE_FOREGROUND_SERVICE"
|
||||
@@ -223,7 +225,8 @@
|
||||
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"
|
||||
@@ -236,7 +239,7 @@
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true"
|
||||
android:process=".main">
|
||||
android:process=":main">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_provider"/>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,默认能量风格,适配小米机型渲染)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user