Compare commits

..

8 Commits

Author SHA1 Message Date
ZhanGSKen
facf0b001d <appbase>APK 15.0.8 release Publish. 2025-03-24 08:04:27 +08:00
ZhanGSKen
df58c0355c 更新编译工具版本 2025-03-24 08:03:17 +08:00
ZhanGSKen
e657e45218 <libappbase>Library Release 15.0.7 2025-03-24 07:45:34 +08:00
ZhanGSKen
c22946f0a5 <appbase>APK 15.0.7 release Publish. 2025-03-24 07:44:12 +08:00
ZhanGSKen
1363a7dcce <appbase>APK 15.0.6 release Publish. 2025-03-24 07:43:28 +08:00
ZhanGSKen
e0ca5725f1 保持与旧版Gradle插件的兼容 2025-03-24 07:39:20 +08:00
ZhanGSKen
3c4988532f 函数命名更新 2025-03-24 07:30:59 +08:00
ZhanGSKen
b0a34579fa 命名空间重构 2025-03-24 07:17:22 +08:00
32 changed files with 147 additions and 397 deletions

View File

@@ -18,8 +18,8 @@ def genVersionName(def versionName){
} }
android { android {
compileSdkVersion 30 compileSdkVersion 32
buildToolsVersion "30.0.3" buildToolsVersion "32.0.0"
defaultConfig { defaultConfig {
applicationId "cc.winboll.studio.appbase" applicationId "cc.winboll.studio.appbase"

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Thu Mar 20 16:41:52 GMT 2025 #Mon Mar 24 08:04:27 HKT 2025
stageCount=6 stageCount=9
libraryProject=libappbase libraryProject=libappbase
baseVersion=15.0 baseVersion=15.0
publishVersion=15.0.5 publishVersion=15.0.8
buildCount=4 buildCount=0
baseBetaVersion=15.0.6 baseBetaVersion=15.0.9

View File

@@ -49,6 +49,12 @@
android:name=".services.MainService" android:name=".services.MainService"
android:exported="true"/> android:exported="true"/>
<service android:name="cc.winboll.studio.appbase.services.TestDemoBindService"
android:exported="true"/>
<service android:name="cc.winboll.studio.appbase.services.TestDemoService"
android:exported="true"/>
<service android:name=".services.AssistantService"/> <service android:name=".services.AssistantService"/>
<receiver android:name="cc.winboll.studio.appbase.receivers.MainReceiver"> <receiver android:name="cc.winboll.studio.appbase.receivers.MainReceiver">
@@ -81,13 +87,13 @@
</receiver> </receiver>
<receiver android:name=".widgets.APPNewsWidgetClickListener"> <receiver android:name=".receivers.APPNewsWidgetClickListener">
<intent-filter> <intent-filter>
<action android:name="cc.winboll.studio.appbase.widgets.APPNewsWidgetClickListener.ACTION_PRE"/> <action android:name="cc.winboll.studio.appbase.receivers.APPNewsWidgetClickListener.ACTION_PRE"/>
<action android:name="cc.winboll.studio.appbase.widgets.APPNewsWidgetClickListener.ACTION_NEXT"/> <action android:name="cc.winboll.studio.appbase.receivers.APPNewsWidgetClickListener.ACTION_NEXT"/>
</intent-filter> </intent-filter>
@@ -97,12 +103,6 @@
android:name="android.max_aspect" android:name="android.max_aspect"
android:value="4.0"/> android:value="4.0"/>
<service android:name="cc.winboll.studio.appbase.services.TestDemoBindService"
android:exported="true"/>
<service android:name="cc.winboll.studio.appbase.services.TestDemoService"
android:exported="true"/>
</application> </application>
</manifest> </manifest>

View File

@@ -89,7 +89,7 @@ public class MainActivity extends Activity {
startService(intentService); startService(intentService);
} }
public void onTestSOS(View view) { public void onTestDemoServiceSOS(View view) {
Intent intent = new Intent(this, TestDemoService.class); Intent intent = new Intent(this, TestDemoService.class);
stopService(intent); stopService(intent);
if (App.isDebuging()) { if (App.isDebuging()) {

View File

@@ -7,7 +7,7 @@ package cc.winboll.studio.appbase;
import android.content.Context; import android.content.Context;
import android.service.quicksettings.Tile; import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService; import android.service.quicksettings.TileService;
import cc.winboll.studio.appbase.beans.MainServiceBean; import cc.winboll.studio.appbase.models.MainServiceBean;
import cc.winboll.studio.appbase.services.MainService; import cc.winboll.studio.appbase.services.MainService;
public class MyTileService extends TileService { public class MyTileService extends TileService {

View File

@@ -1,4 +1,4 @@
package cc.winboll.studio.appbase.beans; package cc.winboll.studio.appbase.models;
/** /**
* @Author ZhanGSKen@AliYun.Com * @Author ZhanGSKen@AliYun.Com

View File

@@ -1,4 +1,4 @@
package cc.winboll.studio.appbase.beans; package cc.winboll.studio.appbase.models;
/** /**
* @Author ZhanGSKen@AliYun.Com * @Author ZhanGSKen@AliYun.Com

View File

@@ -1,4 +1,4 @@
package cc.winboll.studio.appbase.beans; package cc.winboll.studio.appbase.models;
/** /**
* @Author ZhanGSKen@AliYun.Com * @Author ZhanGSKen@AliYun.Com

View File

@@ -1,4 +1,4 @@
package cc.winboll.studio.appbase.beans; package cc.winboll.studio.appbase.models;
/** /**
* @Author ZhanGSKen@AliYun.Com * @Author ZhanGSKen@AliYun.Com

View File

@@ -1,13 +1,13 @@
package cc.winboll.studio.appbase.widgets; package cc.winboll.studio.appbase.receivers;
/** /**
* @Author ZhanGSKen@AliYun.Com * @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/15 17:20:46 * @Date 2025/03/24 07:11:44
* @Describe WidgetButtonClickListener
*/ */
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import cc.winboll.studio.appbase.widgets.APPNewsWidget;
import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
public class APPNewsWidgetClickListener extends BroadcastReceiver { public class APPNewsWidgetClickListener extends BroadcastReceiver {

View File

@@ -10,7 +10,7 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import cc.winboll.studio.appbase.beans.WinBollNewsBean; import cc.winboll.studio.appbase.models.WinBollNewsBean;
import cc.winboll.studio.appbase.services.MainService; import cc.winboll.studio.appbase.services.MainService;
import cc.winboll.studio.appbase.widgets.APPNewsWidget; import cc.winboll.studio.appbase.widgets.APPNewsWidget;
import cc.winboll.studio.libappbase.AppUtils; import cc.winboll.studio.libappbase.AppUtils;

View File

@@ -11,7 +11,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.os.IBinder; import android.os.IBinder;
import cc.winboll.studio.appbase.beans.MainServiceBean; import cc.winboll.studio.appbase.models.MainServiceBean;
import cc.winboll.studio.appbase.services.AssistantService; import cc.winboll.studio.appbase.services.AssistantService;
import cc.winboll.studio.appbase.services.MainService; import cc.winboll.studio.appbase.services.MainService;
import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.LogUtils;

View File

@@ -18,7 +18,7 @@ import android.content.ServiceConnection;
import android.os.Binder; import android.os.Binder;
import android.os.IBinder; import android.os.IBinder;
import cc.winboll.studio.appbase.MyTileService; import cc.winboll.studio.appbase.MyTileService;
import cc.winboll.studio.appbase.beans.MainServiceBean; import cc.winboll.studio.appbase.models.MainServiceBean;
import cc.winboll.studio.appbase.handlers.MainServiceHandler; import cc.winboll.studio.appbase.handlers.MainServiceHandler;
import cc.winboll.studio.appbase.receivers.MainReceiver; import cc.winboll.studio.appbase.receivers.MainReceiver;
import cc.winboll.studio.appbase.services.AssistantService; import cc.winboll.studio.appbase.services.AssistantService;

View File

@@ -10,7 +10,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Binder; import android.os.Binder;
import android.os.IBinder; import android.os.IBinder;
import cc.winboll.studio.appbase.beans.TestDemoBindServiceBean; import cc.winboll.studio.appbase.models.TestDemoBindServiceBean;
import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.sos.WinBoll; import cc.winboll.studio.libappbase.sos.WinBoll;
import cc.winboll.studio.appbase.App; import cc.winboll.studio.appbase.App;

View File

@@ -10,7 +10,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Binder; import android.os.Binder;
import android.os.IBinder; import android.os.IBinder;
import cc.winboll.studio.appbase.beans.TestDemoServiceBean; import cc.winboll.studio.appbase.models.TestDemoServiceBean;
import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.sos.WinBoll; import cc.winboll.studio.libappbase.sos.WinBoll;

View File

@@ -12,15 +12,16 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.widget.RemoteViews; import android.widget.RemoteViews;
import cc.winboll.studio.appbase.R; import cc.winboll.studio.appbase.R;
import cc.winboll.studio.appbase.beans.WinBollNewsBean; import cc.winboll.studio.appbase.models.WinBollNewsBean;
import cc.winboll.studio.appbase.receivers.APPNewsWidgetClickListener;
import cc.winboll.studio.libappbase.AppUtils; import cc.winboll.studio.libappbase.AppUtils;
import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.sos.APPModel;
import cc.winboll.studio.libappbase.sos.WinBoll;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import cc.winboll.studio.libappbase.sos.APPModel;
import cc.winboll.studio.libappbase.sos.WinBoll;
public class APPNewsWidget extends AppWidgetProvider { public class APPNewsWidget extends AppWidgetProvider {

View File

@@ -72,6 +72,26 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="right"> android:gravity="right">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StartCenter"
android:textAllCaps="false"
android:onClick="onStartCenter"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StopCenter"
android:textAllCaps="false"
android:onClick="onStopCenter"/>
</LinearLayout>
<HorizontalScrollView <HorizontalScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@@ -105,54 +125,41 @@
</LinearLayout> </LinearLayout>
</HorizontalScrollView> </HorizontalScrollView>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout <HorizontalScrollView
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="wrap_content">
android:layout_height="wrap_content">
<Button <LinearLayout
android:layout_width="wrap_content" android:orientation="horizontal"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:text="SartTestDemoBindService" android:layout_height="wrap_content">
android:textAllCaps="false"
android:onClick="onSartTestDemoBindService"/>
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="StopTestDemoBindService" android:text="SartTestDemoBindService"
android:textAllCaps="false" android:textAllCaps="false"
android:onClick="onStopTestDemoBindService"/> android:onClick="onSartTestDemoBindService"/>
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="StopTestDemoBindServiceNoSettings" android:text="StopTestDemoBindService"
android:textAllCaps="false" android:textAllCaps="false"
android:onClick="onStopTestDemoBindServiceNoSettings"/> android:onClick="onStopTestDemoBindService"/>
</LinearLayout> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StopTestDemoBindServiceNoSettings"
android:textAllCaps="false"
android:onClick="onStopTestDemoBindServiceNoSettings"/>
</LinearLayout>
</HorizontalScrollView> </HorizontalScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StartCenter"
android:textAllCaps="false"
android:onClick="onStartCenter"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StopCenter"
android:textAllCaps="false"
android:onClick="onStopCenter"/>
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -171,9 +178,9 @@
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="TestSOS" android:text="TestDemoServiceSOS"
android:textAllCaps="false" android:textAllCaps="false"
android:onClick="onTestSOS"/> android:onClick="onTestDemoServiceSOS"/>
</LinearLayout> </LinearLayout>
@@ -185,10 +192,10 @@
</ScrollView> </ScrollView>
<cc.winboll.studio.libappbase.LogView <cc.winboll.studio.libappbase.LogView
android:layout_height="300dp" android:layout_height="300dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:id="@+id/activitymainLogView1"/> android:id="@+id/activitymainLogView1"/>
</LinearLayout> </LinearLayout>

View File

@@ -17,3 +17,5 @@ org.gradle.jvmargs=-Xmx2048m
android.useAndroidX=false android.useAndroidX=false
# Automatically convert third-party libraries to use AndroidX # Automatically convert third-party libraries to use AndroidX
android.enableJetifier=false android.enableJetifier=false
# 保持与旧版Gradle插件的兼容
android.disableAutomaticComponentCreation=true

View File

@@ -17,3 +17,5 @@ org.gradle.jvmargs=-Xmx2048m
android.useAndroidX=true android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX # Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true android.enableJetifier=true
# 保持与旧版Gradle插件的兼容
android.disableAutomaticComponentCreation=true

View File

@@ -4,8 +4,8 @@ apply from: '../.winboll/winboll_lib_build.gradle'
apply from: '../.winboll/winboll_lint_build.gradle' apply from: '../.winboll/winboll_lint_build.gradle'
android { android {
compileSdkVersion 30 compileSdkVersion 32
buildToolsVersion "30.0.3" buildToolsVersion "32.0.0"
defaultConfig { defaultConfig {
minSdkVersion 26 minSdkVersion 26

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Thu Mar 20 16:41:52 GMT 2025 #Mon Mar 24 08:04:27 HKT 2025
stageCount=6 stageCount=9
libraryProject=libappbase libraryProject=libappbase
baseVersion=15.0 baseVersion=15.0
publishVersion=15.0.5 publishVersion=15.0.8
buildCount=4 buildCount=0
baseBetaVersion=15.0.6 baseBetaVersion=15.0.9

View File

@@ -41,6 +41,11 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
} }
dependencies { dependencies {

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Sat Mar 22 06:01:46 HKT 2025 #Thu Jan 02 11:13:45 HKT 2025
stageCount=7 stageCount=6
libraryProject= libraryProject=
baseVersion=4.0 baseVersion=4.0
publishVersion=4.0.6 publishVersion=4.0.5
buildCount=0 buildCount=0
baseBetaVersion=4.0.7 baseBetaVersion=4.0.6

View File

@@ -2,9 +2,10 @@
<manifest <manifest
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
package="cc.winboll.studio.powerbell"> package="cc.winboll.studio.powerbell">
<!-- 拍摄照片和视频 --> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.CAMERA"/> <uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<!-- 运行前台服务 --> <!-- 运行前台服务 -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
@@ -21,23 +22,6 @@
<!-- MANAGE_EXTERNAL_STORAGE --> <!-- MANAGE_EXTERNAL_STORAGE -->
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<!-- 显示通知 -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<application <application
android:name=".GlobalApplication" android:name=".GlobalApplication"
android:allowBackup="true" android:allowBackup="true"
@@ -50,8 +34,7 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:launchMode="singleTask" android:launchMode="singleTask">
android:exported="true">
<intent-filter> <intent-filter>

View File

@@ -17,7 +17,7 @@ import cc.winboll.studio.powerbell.activities.AboutActivity;
import cc.winboll.studio.powerbell.activities.BackgroundPictureActivity; import cc.winboll.studio.powerbell.activities.BackgroundPictureActivity;
import cc.winboll.studio.powerbell.activities.ClearRecordActivity; import cc.winboll.studio.powerbell.activities.ClearRecordActivity;
import cc.winboll.studio.powerbell.fragments.MainViewFragment; import cc.winboll.studio.powerbell.fragments.MainViewFragment;
import cc.winboll.studio.powerbell.utils.NotificationHelper; import cc.winboll.studio.powerbell.utils.NotificationUtils;
import cc.winboll.studio.shared.log.LogUtils; import cc.winboll.studio.shared.log.LogUtils;
import cc.winboll.studio.shared.log.LogView; import cc.winboll.studio.shared.log.LogView;
@@ -64,10 +64,8 @@ public class MainActivity extends Activity {
} }
showFragment(mMainViewFragment); showFragment(mMainViewFragment);
// NotificationHelper notificationUtils = new NotificationHelper(this); NotificationUtils notificationUtils = new NotificationUtils(this);
// notificationUtils.createNotificationChannels(); notificationUtils.createNotificationChannel();
} }
void showFragment(Fragment fragment) { void showFragment(Fragment fragment) {
@@ -115,7 +113,7 @@ public class MainActivity extends Activity {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
// 回到窗口自动取消提醒消息 // 回到窗口自动取消提醒消息
//NotificationHelper.cancelRemindNotification(this); NotificationUtils.cancelRemindNotification(this);
reloadBackground(); reloadBackground();
} }

View File

@@ -8,7 +8,7 @@ import cc.winboll.studio.powerbell.GlobalApplication;
import cc.winboll.studio.powerbell.fragments.MainViewFragment; import cc.winboll.studio.powerbell.fragments.MainViewFragment;
import cc.winboll.studio.powerbell.utils.AppConfigUtils; import cc.winboll.studio.powerbell.utils.AppConfigUtils;
import cc.winboll.studio.powerbell.utils.BatteryUtils; import cc.winboll.studio.powerbell.utils.BatteryUtils;
import cc.winboll.studio.powerbell.utils.NotificationHelper; import cc.winboll.studio.powerbell.utils.NotificationUtils;
public class GlobalApplicationReceiver extends BroadcastReceiver { public class GlobalApplicationReceiver extends BroadcastReceiver {
@@ -45,7 +45,7 @@ public class GlobalApplicationReceiver extends BroadcastReceiver {
// 新电池状态标志某一个有变化就更新显示信息 // 新电池状态标志某一个有变化就更新显示信息
if (_mIsCharging != isCharging || _mnTheQuantityOfElectricityOld != nTheQuantityOfElectricity) { if (_mIsCharging != isCharging || _mnTheQuantityOfElectricityOld != nTheQuantityOfElectricity) {
// 电池状态改变先取消旧的提醒消息 // 电池状态改变先取消旧的提醒消息
//NotificationHelper.cancelRemindNotification(context); NotificationUtils.cancelRemindNotification(context);
GlobalApplication.getAppCacheUtils(context).addChangingTime(nTheQuantityOfElectricity); GlobalApplication.getAppCacheUtils(context).addChangingTime(nTheQuantityOfElectricity);
MainViewFragment.sendMsgCurrentValueBattery(nTheQuantityOfElectricity); MainViewFragment.sendMsgCurrentValueBattery(nTheQuantityOfElectricity);

View File

@@ -8,17 +8,14 @@ package cc.winboll.studio.powerbell.services;
* Android Service之onStartCommand方法研究 * Android Service之onStartCommand方法研究
* https://blog.csdn.net/cyp331203/article/details/38920491 * https://blog.csdn.net/cyp331203/article/details/38920491
*/ */
import android.app.Notification; import cc.winboll.studio.powerbell.R;
import android.app.Service; import android.app.Service;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.os.IBinder; import android.os.IBinder;
import android.widget.RemoteViews;
import cc.winboll.studio.powerbell.GlobalApplication; import cc.winboll.studio.powerbell.GlobalApplication;
import cc.winboll.studio.powerbell.MainActivity;
import cc.winboll.studio.powerbell.R;
import cc.winboll.studio.powerbell.beans.AppConfigBean; import cc.winboll.studio.powerbell.beans.AppConfigBean;
import cc.winboll.studio.powerbell.beans.NotificationMessage; import cc.winboll.studio.powerbell.beans.NotificationMessage;
import cc.winboll.studio.powerbell.handlers.ControlCenterServiceHandler; import cc.winboll.studio.powerbell.handlers.ControlCenterServiceHandler;
@@ -27,12 +24,11 @@ import cc.winboll.studio.powerbell.services.AssistantService;
import cc.winboll.studio.powerbell.threads.RemindThread; import cc.winboll.studio.powerbell.threads.RemindThread;
import cc.winboll.studio.powerbell.utils.AppCacheUtils; import cc.winboll.studio.powerbell.utils.AppCacheUtils;
import cc.winboll.studio.powerbell.utils.AppConfigUtils; import cc.winboll.studio.powerbell.utils.AppConfigUtils;
import cc.winboll.studio.powerbell.utils.NotificationHelper; import cc.winboll.studio.powerbell.utils.NotificationUtils;
import cc.winboll.studio.powerbell.utils.ServiceUtils; import cc.winboll.studio.powerbell.utils.ServiceUtils;
import cc.winboll.studio.powerbell.utils.StringUtils; import cc.winboll.studio.powerbell.utils.StringUtils;
import cc.winboll.studio.shared.log.LogUtils; import cc.winboll.studio.shared.log.LogUtils;
import com.hjq.toast.ToastUtils; import com.hjq.toast.ToastUtils;
import android.graphics.Color;
public class ControlCenterService extends Service { public class ControlCenterService extends Service {
@@ -47,8 +43,7 @@ public class ControlCenterService extends Service {
AppConfigUtils mAppConfigUtils; AppConfigUtils mAppConfigUtils;
AppCacheUtils mAppCacheUtils; AppCacheUtils mAppCacheUtils;
// 前台服务通知工具 // 前台服务通知工具
NotificationHelper mNotificationHelper; NotificationUtils mNotificationUtils;
Notification notification;
RemindThread mRemindThread; RemindThread mRemindThread;
ControlCenterServiceHandler mControlCenterServiceHandler; ControlCenterServiceHandler mControlCenterServiceHandler;
MyServiceConnection mMyServiceConnection; MyServiceConnection mMyServiceConnection;
@@ -71,9 +66,7 @@ public class ControlCenterService extends Service {
isServiceRunning = false; isServiceRunning = false;
mAppConfigUtils = GlobalApplication.getAppConfigUtils(this); mAppConfigUtils = GlobalApplication.getAppConfigUtils(this);
mAppCacheUtils = GlobalApplication.getAppCacheUtils(this); mAppCacheUtils = GlobalApplication.getAppCacheUtils(this);
mNotificationHelper = new NotificationHelper(ControlCenterService.this); mNotificationUtils = new NotificationUtils(ControlCenterService.this);
if (mMyServiceConnection == null) { if (mMyServiceConnection == null) {
mMyServiceConnection = new MyServiceConnection(); mMyServiceConnection = new MyServiceConnection();
} }
@@ -99,16 +92,10 @@ public class ControlCenterService extends Service {
// 唤醒守护进程 // 唤醒守护进程
wakeupAndBindAssistant(); wakeupAndBindAssistant();
// 显示前台通知栏 // 显示前台通知栏
// 在Service中 NotificationMessage notificationMessage=createNotificationMessage();
NotificationHelper helper = new NotificationHelper(this); //Toast.makeText(getApplication(), "", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(this, MainActivity.class); mNotificationUtils.createForegroundNotification(this, notificationMessage);
notification = helper.showForegroundNotification(intent, getString(R.string.app_name), "Service Running, Click to open app"); mNotificationUtils.createRemindNotification(this, notificationMessage);
startForeground(NotificationHelper.FOREGROUND_NOTIFICATION_ID, notification);
// NotificationMessage notificationMessage=createNotificationMessage();
// //Toast.makeText(getApplication(), "", Toast.LENGTH_SHORT).show();
// mNotificationUtils.createForegroundNotification(this, notificationMessage);
// mNotificationUtils.createRemindNotification(this, notificationMessage);
if (mControlCenterServiceReceiver == null) { if (mControlCenterServiceReceiver == null) {
// 注册广播接收器 // 注册广播接收器
@@ -139,19 +126,19 @@ public class ControlCenterService extends Service {
// 更新前台通知 // 更新前台通知
// //
public void updateServiceNotification() { public void updateServiceNotification() {
//mNotificationUtils.updateForegroundNotification(ControlCenterService.this, createNotificationMessage()); mNotificationUtils.updateForegroundNotification(ControlCenterService.this, createNotificationMessage());
} }
// 更新前台通知 // 更新前台通知
// //
public void updateServiceNotification(NotificationMessage notificationMessage) { public void updateServiceNotification(NotificationMessage notificationMessage) {
//mNotificationUtils.updateForegroundNotification(ControlCenterService.this, notificationMessage); mNotificationUtils.updateForegroundNotification(ControlCenterService.this, notificationMessage);
} }
// 更新前台通知 // 更新前台通知
// //
public void updateRemindNotification(NotificationMessage notificationMessage) { public void updateRemindNotification(NotificationMessage notificationMessage) {
//mNotificationUtils.updateRemindNotification(ControlCenterService.this, notificationMessage); mNotificationUtils.updateRemindNotification(ControlCenterService.this, notificationMessage);
} }
// 唤醒和绑定守护进程 // 唤醒和绑定守护进程
@@ -247,32 +234,10 @@ public class ControlCenterService extends Service {
} }
public void appenRemindMSG(String szRemindMSG) { public void appenRemindMSG(String szRemindMSG) {
String msg = ""; NotificationMessage notificationMessage = createNotificationMessage();
for (int i = 0; i < 20; i++) { notificationMessage.setRemindMSG(szRemindMSG);
msg += szRemindMSG; //LogUtils.d(TAG, "notificationMessage : " + notificationMessage.getRemindMSG());
} updateRemindNotification(notificationMessage);
NotificationHelper helper = new NotificationHelper(ControlCenterService.this);
Intent intent = new Intent(ControlCenterService.this, MainActivity.class);
helper.showTemporaryNotification(intent, getString(R.string.app_name), msg);
// NotificationMessage notificationMessage = createNotificationMessage();
// notificationMessage.setRemindMSG(szRemindMSG);
// //LogUtils.d(TAG, "notificationMessage : " + notificationMessage.getRemindMSG());
// updateRemindNotification(notificationMessage);
}
// 设置颜色背景
public static RemoteViews setLinearLayoutColor(RemoteViews remoteViews, int viewId, int color) {
remoteViews.setInt(viewId, "setBackgroundColor", color);
return remoteViews;
}
// 设置Drawable背景
public static RemoteViews setLinearLayoutDrawable(RemoteViews remoteViews, int viewId, int drawableRes) {
remoteViews.setInt(viewId, "setBackgroundResource", drawableRes);
return remoteViews;
} }
// //

View File

@@ -193,7 +193,7 @@ public class AppConfigUtils {
// //
void saveConfigData() { void saveConfigData() {
// 更新配置先取消一下旧的的提醒消息 // 更新配置先取消一下旧的的提醒消息
//NotificationHelper.cancelRemindNotification(mContext); NotificationUtils.cancelRemindNotification(mContext);
AppConfigBean.saveBean(mContext, mAppConfigBean); AppConfigBean.saveBean(mContext, mAppConfigBean);
// 通知活动窗口和服务配置已更新 // 通知活动窗口和服务配置已更新

View File

@@ -1,150 +0,0 @@
package cc.winboll.studio.powerbell.utils;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/22 04:39:40
* @Describe 通知工具类
*/
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.widget.RemoteViews;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import cc.winboll.studio.powerbell.R;
public class NotificationHelper {
public static final String TAG = "NotificationHelper";
// 渠道ID和名称
private static final String CHANNEL_ID_FOREGROUND = "foreground_channel";
private static final String CHANNEL_NAME_FOREGROUND = "Foreground Service";
private static final String CHANNEL_ID_TEMPORARY = "temporary_channel";
private static final String CHANNEL_NAME_TEMPORARY = "Temporary Notifications";
// 通知ID
public static final int FOREGROUND_NOTIFICATION_ID = 1001;
public static final int TEMPORARY_NOTIFICATION_ID = 2001;
private final Context mContext;
private final NotificationManager mNotificationManager;
public NotificationHelper(Context context) {
mContext = context;
mNotificationManager = context.getSystemService(NotificationManager.class);
createNotificationChannels();
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void createNotificationChannels() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createForegroundChannel();
createTemporaryChannel();
}
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void createForegroundChannel() {
NotificationChannel channel = new NotificationChannel(
CHANNEL_ID_FOREGROUND,
CHANNEL_NAME_FOREGROUND,
NotificationManager.IMPORTANCE_LOW
);
channel.setDescription("Persistent service notifications");
channel.setSound(null, null);
channel.enableVibration(false);
mNotificationManager.createNotificationChannel(channel);
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void createTemporaryChannel() {
NotificationChannel channel = new NotificationChannel(
CHANNEL_ID_TEMPORARY,
CHANNEL_NAME_TEMPORARY,
NotificationManager.IMPORTANCE_HIGH
);
channel.setDescription("Temporary alert notifications");
channel.setSound(null, null);
channel.enableVibration(true);
channel.setVibrationPattern(new long[]{100, 200, 300, 400});
channel.setBypassDnd(true);
mNotificationManager.createNotificationChannel(channel);
}
// 显示常驻通知(通常用于前台服务)
public Notification showForegroundNotification(Intent intent, String title, String content) {
PendingIntent pendingIntent = createPendingIntent(intent);
Notification notification = new NotificationCompat.Builder(mContext, CHANNEL_ID_FOREGROUND)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_launcher))
.setContentTitle(title)
.setContentText(content)
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_LOW)
.setOngoing(true)
.build();
mNotificationManager.notify(FOREGROUND_NOTIFICATION_ID, notification);
return notification;
}
// 显示临时通知(自动消失)
public void showTemporaryNotification(Intent intent, String title, String content) {
PendingIntent pendingIntent = createPendingIntent(intent);
Notification notification = new NotificationCompat.Builder(mContext, CHANNEL_ID_TEMPORARY)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_launcher))
.setContentTitle(title)
.setContentText(content)
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setAutoCancel(true)
.setVibrate(new long[]{100, 200, 300, 400})
.build();
mNotificationManager.notify(TEMPORARY_NOTIFICATION_ID, notification);
}
// 创建自定义布局通知(可扩展)
public void showCustomNotification(Intent intent, RemoteViews contentView, RemoteViews bigContentView) {
PendingIntent pendingIntent = createPendingIntent(intent);
Notification notification = new NotificationCompat.Builder(mContext, CHANNEL_ID_TEMPORARY)
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pendingIntent)
.setContent(contentView)
.setCustomBigContentView(bigContentView)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setAutoCancel(true)
.build();
mNotificationManager.notify(TEMPORARY_NOTIFICATION_ID + 1, notification);
}
// 取消所有通知
public void cancelAllNotifications() {
mNotificationManager.cancelAll();
}
// 创建PendingIntent兼容不同API版本
private PendingIntent createPendingIntent(Intent intent) {
int flags = PendingIntent.FLAG_UPDATE_CURRENT;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// flags |= PendingIntent.FLAG_IMMUTABLE;
// }
return PendingIntent.getActivity(
mContext,
0,
intent,
flags
);
}
}

View File

@@ -18,15 +18,14 @@ import android.media.RingtoneManager;
import android.os.Build; import android.os.Build;
import android.view.View; import android.view.View;
import android.widget.RemoteViews; import android.widget.RemoteViews;
import androidx.annotation.RequiresApi;
import cc.winboll.studio.powerbell.MainActivity; import cc.winboll.studio.powerbell.MainActivity;
import cc.winboll.studio.powerbell.R; import cc.winboll.studio.powerbell.R;
import cc.winboll.studio.powerbell.beans.NotificationMessage; import cc.winboll.studio.powerbell.beans.NotificationMessage;
import cc.winboll.studio.powerbell.services.ControlCenterService; import cc.winboll.studio.powerbell.services.ControlCenterService;
public class NotificationUtils2 { public class NotificationUtils {
public static final String TAG = NotificationHelper.class.getSimpleName(); public static final String TAG = NotificationUtils.class.getSimpleName();
Context mContext; Context mContext;
NotificationManager mNotificationManager; NotificationManager mNotificationManager;
@@ -46,53 +45,19 @@ public class NotificationUtils2 {
private static String _mszChannelIDRemind = "2"; private static String _mszChannelIDRemind = "2";
private static String _mszChannelNameRemind = "Remind"; private static String _mszChannelNameRemind = "Remind";
// public NotificationUtils(Context context) { public NotificationUtils(Context context) {
// mContext = context;
// mNotificationManager = (NotificationManager) context.getSystemService(
// Context.NOTIFICATION_SERVICE);
// }
public NotificationUtils2(Context context) {
mContext = context; mContext = context;
mNotificationManager = context.getSystemService(NotificationManager.class); mNotificationManager = (NotificationManager) context.getSystemService(
//createNotificationChannels(); Context.NOTIFICATION_SERVICE);
} }
@RequiresApi(api = Build.VERSION_CODES.O) public void createNotificationChannel() {
public void createNotificationChannels() { NotificationChannel channel1 = new NotificationChannel(_mszChannelIDService, _mszChannelNameService, NotificationManager.IMPORTANCE_DEFAULT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { channel1.setSound(null, null);
createServiceChannel(); mNotificationManager.createNotificationChannel(channel1);
createRemindChannel(); NotificationChannel channel2 = new NotificationChannel(_mszChannelIDRemind, _mszChannelNameRemind, NotificationManager.IMPORTANCE_HIGH);
} channel2.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE), Notification.AUDIO_ATTRIBUTES_DEFAULT);
} mNotificationManager.createNotificationChannel(channel2);
@RequiresApi(api = Build.VERSION_CODES.O)
private void createServiceChannel() {
NotificationChannel channel = new NotificationChannel(
_mszChannelIDService,
_mszChannelNameService,
NotificationManager.IMPORTANCE_LOW
);
channel.setDescription("Background service updates");
channel.setSound(null, null);
channel.enableVibration(false);
mNotificationManager.createNotificationChannel(channel);
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void createRemindChannel() {
NotificationChannel channel = new NotificationChannel(
_mszChannelIDRemind,
_mszChannelNameRemind,
NotificationManager.IMPORTANCE_HIGH
);
channel.setDescription("Critical reminders");
channel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM), null);
channel.enableVibration(true);
channel.setVibrationPattern(new long[]{100, 200, 300, 400});
channel.setBypassDnd(true);
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
mNotificationManager.createNotificationChannel(channel);
} }
// 创建并发送服务通知 // 创建并发送服务通知

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ll_notification">
</LinearLayout>

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ll_notification">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text"
android:id="@+id/info_tv"/>
</LinearLayout>