更新UI视图

This commit is contained in:
ZhanGSKen 2025-03-07 12:37:13 +08:00
parent bc252041d3
commit 00d0871809
8 changed files with 144 additions and 132 deletions

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Fri Mar 07 03:14:48 GMT 2025
#Fri Mar 07 04:36:05 GMT 2025
stageCount=3
libraryProject=libappbase
baseVersion=2.0
publishVersion=2.0.2
buildCount=5
buildCount=7
baseBetaVersion=2.0.3

View File

@ -13,7 +13,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import cc.winboll.studio.appbase.beans.WinBollNewsBean;
import cc.winboll.studio.appbase.services.MainService;
import cc.winboll.studio.appbase.widgets.WinBollNewsWidget;
import cc.winboll.studio.appbase.widgets.APPNewsWidget;
import cc.winboll.studio.libappbase.AppUtils;
import cc.winboll.studio.libappbase.LogUtils;
import com.hjq.toast.ToastUtils;
@ -95,10 +95,10 @@ public class MainReceiver extends BroadcastReceiver {
sbLine.append(appName);
appWinBollNewsBean.setMessage(sbLine.toString());
WinBollNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean);
APPNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean);
Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
Intent intentWidget = new Intent(context, APPNewsWidget.class);
intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
context.sendBroadcast(intentWidget);
}

View File

@ -23,7 +23,7 @@ import cc.winboll.studio.appbase.handlers.MainServiceHandler;
import cc.winboll.studio.appbase.receivers.MainReceiver;
import cc.winboll.studio.appbase.services.AssistantService;
import cc.winboll.studio.appbase.threads.MainServiceThread;
import cc.winboll.studio.appbase.widgets.WinBollNewsWidget;
import cc.winboll.studio.appbase.widgets.APPNewsWidget;
import cc.winboll.studio.libappbase.LogUtils;
import java.util.ArrayList;
import cc.winboll.studio.libappbase.sos.APPModel;
@ -101,8 +101,8 @@ public class MainService extends Service {
}
// 启动小部件
Intent intentTimeWidget = new Intent(this, WinBollNewsWidget.class);
intentTimeWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
Intent intentTimeWidget = new Intent(this, APPNewsWidget.class);
intentTimeWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
this.sendBroadcast(intentTimeWidget);
startMainServiceThread();
@ -211,8 +211,8 @@ public class MainService extends Service {
bindService(intentService, sosConnection, Context.BIND_IMPORTANT);
mSOSConnectionList.add(sosConnection);
Intent intentWidget = new Intent(this, WinBollNewsWidget.class);
intentWidget.setAction(WinBollNewsWidget.ACTION_WAKEUP_SERVICE);
Intent intentWidget = new Intent(this, APPNewsWidget.class);
intentWidget.setAction(APPNewsWidget.ACTION_WAKEUP_SERVICE);
APPModel appSOSBean = new APPModel(bean.getAppPackageName(), bean.getAppMainServiveName());
intentWidget.putExtra("APPSOSBean", appSOSBean.toString());
sendBroadcast(intentWidget);

View File

@ -20,10 +20,11 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import cc.winboll.studio.libappbase.sos.APPModel;
import cc.winboll.studio.libappbase.sos.WinBoll;
public class WinBollNewsWidget extends AppWidgetProvider {
public class APPNewsWidget extends AppWidgetProvider {
public static final String TAG = "WinBollNewsWidget";
public static final String TAG = "APPNewsWidget";
public static final String ACTION_WAKEUP_SERVICE = "cc.winboll.studio.appbase.widgets.WinBollNewsWidget.ACTION_WAKEUP_SERVICE";
public static final String ACTION_RELOAD_REPORT = "cc.winboll.studio.appbase.widgets.WinBollNewsWidget.ACTION_RELOAD_REPORT";
@ -49,25 +50,25 @@ public class WinBollNewsWidget extends AppWidgetProvider {
if (intent.getAction().equals(ACTION_RELOAD_REPORT)) {
LogUtils.d(TAG, "ACTION_RELOAD_REPORT");
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WinBollNewsWidget.class));
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, APPNewsWidget.class));
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
}else if (intent.getAction().equals(ACTION_WAKEUP_SERVICE)) {
LogUtils.d(TAG, "ACTION_WAKEUP_SERVICE");
String szWinBollNewsBean = intent.getStringExtra("WinBollNewsBean");
LogUtils.d(TAG, String.format("szWinBollNewsBean %s", szWinBollNewsBean));
if (szWinBollNewsBean != null && !szWinBollNewsBean.equals("")) {
String szAPPModel = intent.getStringExtra(WinBoll.EXTRA_APPMODEL);
LogUtils.d(TAG, String.format("szAPPModel %s", szAPPModel));
if (szAPPModel != null && !szAPPModel.equals("")) {
try {
APPModel bean = APPModel.parseStringToBean(szWinBollNewsBean, APPModel.class);
APPModel bean = APPModel.parseStringToBean(szAPPModel, APPModel.class);
if (bean != null) {
String szNewsPackageName = bean.getAppPackageName();
LogUtils.d(TAG, String.format("szNewsPackageName %s", szNewsPackageName));
String szNewsClassName = bean.getAppMainServiveName();
LogUtils.d(TAG, String.format("szNewsClassName %s", szNewsClassName));
String szAppPackageName = bean.getAppPackageName();
LogUtils.d(TAG, String.format("szAppPackageName %s", szAppPackageName));
String szAppMainServiveName = bean.getAppMainServiveName();
LogUtils.d(TAG, String.format("szAppMainServiveName %s", szAppMainServiveName));
String appName = AppUtils.getAppNameByPackageName(context, szNewsPackageName);
String appName = AppUtils.getAppNameByPackageName(context, szAppPackageName);
LogUtils.d(TAG, String.format("appName %s", appName));
WinBollNewsBean winBollNewsBean = new WinBollNewsBean(appName);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
@ -82,7 +83,7 @@ public class WinBollNewsWidget extends AppWidgetProvider {
addWinBollNewsBean(context, winBollNewsBean);
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WinBollNewsWidget.class));
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, APPNewsWidget.class));
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
}
@ -156,8 +157,8 @@ public class WinBollNewsWidget extends AppWidgetProvider {
if (_CurrentPageIndex > 0) {
_CurrentPageIndex = _CurrentPageIndex - 1;
}
Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
Intent intentWidget = new Intent(context, APPNewsWidget.class);
intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
context.sendBroadcast(intentWidget);
}
}
@ -167,8 +168,8 @@ public class WinBollNewsWidget extends AppWidgetProvider {
if ((_CurrentPageIndex + 1) * _OnePageLinesCount < _WinBollNewsBeanList.size()) {
_CurrentPageIndex = _CurrentPageIndex + 1;
}
Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
Intent intentWidget = new Intent(context, APPNewsWidget.class);
intentWidget.setAction(APPNewsWidget.ACTION_RELOAD_REPORT);
context.sendBroadcast(intentWidget);
}
}

View File

@ -25,10 +25,10 @@ public class WinBollNewsWidgetClickListener extends BroadcastReceiver {
}
if (action.equals(ACTION_PRE)) {
LogUtils.d(TAG, "ACTION_PRE");
WinBollNewsWidget.prePage(context);
APPNewsWidget.prePage(context);
} else if (action.equals(ACTION_NEXT)) {
LogUtils.d(TAG, "ACTION_NEXT");
WinBollNewsWidget.nextPage(context);
APPNewsWidget.nextPage(context);
} else {
LogUtils.d(TAG, String.format("action %s", action));
}

View File

@ -1,149 +1,160 @@
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/activitymainToolbar1"/>
<LinearLayout
android:orientation="vertical"
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, WinBoll!"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android版本10的代号是“Q”API级别是29。 Android 10开始谷歌不再公开使用甜品作为版本代号但内部仍保留了大量与“Q”相关的元素。Android 10本身并没有严格对应某个特定的Java版本但在开发Android 10应用时通常可以使用Java 8或更高版本。
Java 8为Android开发带来了诸如Lambda表达式、方法引用等新特性能提高开发效率和代码可读性与Android 10开发适配良好。Java 9及更高版本也可用于Android 10开发能使用一些新的语言特性和API但可能需要注意兼容性和配置问题。"/>
android:layout_weight="1.0">
<LinearLayout
android:orientation="horizontal"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right|center_vertical">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Debug Mode"
android:layout_weight="1.0"
android:onClick="onSwitchDebugMode"
android:id="@+id/activitymainCheckBox1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test Application CrashReport"
android:textAllCaps="false"
android:onClick="onTestApplicationCrashReport"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="400dp">
android:orientation="vertical"
android:gravity="center">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
android:layout_height="0dp"
android:layout_weight="1.0"
android:gravity="center_horizontal">
<HorizontalScrollView
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, WinBoll!"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android版本10的代号是“Q”API级别是29。 Android 10开始谷歌不再公开使用甜品作为版本代号但内部仍保留了大量与“Q”相关的元素。Android 10本身并没有严格对应某个特定的Java版本但在开发Android 10应用时通常可以使用Java 8或更高版本。 Java 8为Android开发带来了诸如Lambda表达式、方法引用等新特性能提高开发效率和代码可读性与Android 10开发适配良好。Java 9及更高版本也可用于Android 10开发能使用一些新的语言特性和API但可能需要注意兼容性和配置问题。"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:gravity="right|center_vertical">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Debug Mode"
android:layout_weight="1.0"
android:onClick="onSwitchDebugMode"
android:id="@+id/activitymainCheckBox1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test Application CrashReport"
android:textAllCaps="false"
android:onClick="onTestApplicationCrashReport"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="400dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<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="StartTestService"
android:textAllCaps="false"
android:onClick="onStartTestService"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StopTestService"
android:textAllCaps="false"
android:onClick="onStopTestService"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StopTestServiceNoSettings"
android:textAllCaps="false"
android:onClick="onStopTestServiceNoSettings"/>
</LinearLayout>
</HorizontalScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StartTestService"
android:text="StartCenter"
android:textAllCaps="false"
android:onClick="onStartTestService"/>
android:onClick="onStartCenter"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StopTestService"
android:text="StopCenter"
android:textAllCaps="false"
android:onClick="onStopTestService"/>
android:onClick="onStopCenter"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="StopTestServiceNoSettings"
android:text="TestStopWithoutSettingEnable"
android:textAllCaps="false"
android:onClick="onStopTestServiceNoSettings"/>
android:onClick="onTestStopWithoutSettingEnable"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TestStartWithString"
android:textAllCaps="false"
android:onClick="onTestStartWithString"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SOS"
android:textAllCaps="false"
android:onClick="onSOS"/>
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
<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
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TestStopWithoutSettingEnable"
android:textAllCaps="false"
android:onClick="onTestStopWithoutSettingEnable"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TestStartWithString"
android:textAllCaps="false"
android:onClick="onTestStartWithString"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SOS"
android:textAllCaps="false"
android:onClick="onSOS"/>
<cc.winboll.studio.libappbase.LogView
android:layout_height="500dp"
android:layout_width="match_parent"
android:id="@+id/activitymainLogView1"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
<cc.winboll.studio.libappbase.LogView
android:layout_weight="1.0"
android:layout_height="0dp"
android:layout_width="match_parent"
android:id="@+id/activitymainLogView1"/>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Fri Mar 07 03:14:48 GMT 2025
#Fri Mar 07 04:36:05 GMT 2025
stageCount=3
libraryProject=libappbase
baseVersion=2.0
publishVersion=2.0.2
buildCount=5
buildCount=7
baseBetaVersion=2.0.3

View File

@ -14,7 +14,7 @@ public class WinBoll {
public static final String TAG = "WinBoll";
public static final String ACTION_BIND = WinBoll.class.getName() + ".ACTION_BIND";
public static final String EXTRA_APPMODEL = "EXTRA_APP";
public static final String EXTRA_APPMODEL = "EXTRA_APPMODEL";
public static void bindToAPPBase(Context context, String appMainService) {
String toPackage = "cc.winboll.studio.appbase";