命名空间重构
This commit is contained in:
parent
820574a4ba
commit
fb7017a857
@ -45,5 +45,23 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api project(':libappbase')
|
api project(':libappbase')
|
||||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
|
// 二维码类库
|
||||||
|
implementation 'com.google.zxing:core:3.4.1'
|
||||||
|
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||||
|
// 应用介绍页类库
|
||||||
|
implementation 'io.github.medyo:android-about-page:2.0.0'
|
||||||
|
// 吐司类库
|
||||||
|
implementation 'com.github.getActivity:ToastUtils:10.5'
|
||||||
|
// 网络连接类库
|
||||||
|
implementation 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||||
|
|
||||||
|
// Android 类库
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
|
implementation 'androidx.viewpager:viewpager:1.0.0'
|
||||||
|
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||||
|
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||||
|
implementation 'androidx.fragment:fragment:1.1.0'
|
||||||
|
implementation 'com.google.android.material:material:1.4.0'
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Tue Feb 25 16:51:17 HKT 2025
|
#Thu Feb 27 02:34:13 GMT 2025
|
||||||
stageCount=3
|
stageCount=3
|
||||||
libraryProject=libappbase
|
libraryProject=libappbase
|
||||||
baseVersion=2.0
|
baseVersion=2.0
|
||||||
publishVersion=2.0.2
|
publishVersion=2.0.2
|
||||||
buildCount=0
|
buildCount=4
|
||||||
baseBetaVersion=2.0.3
|
baseBetaVersion=2.0.3
|
||||||
|
@ -60,12 +60,12 @@
|
|||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".widgets.SOSWidget"
|
android:name=".widgets.WinBollNewsWidget"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="cc.winboll.studio.appbase.widgets.SOSWidget.ACTION_WAKEUP_SERVICE"/>
|
<action android:name="cc.winboll.studio.appbase.widgets.WinBollNewsWidget.ACTION_WAKEUP_SERVICE"/>
|
||||||
<action android:name="cc.winboll.studio.appbase.widgets.SOSWidget.ACTION_RELOAD_REPORT"/>
|
<action android:name="cc.winboll.studio.appbase.widgets.WinBollNewsWidget.ACTION_RELOAD_REPORT"/>
|
||||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
|
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
@ -75,13 +75,13 @@
|
|||||||
|
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<receiver android:name=".widgets.SOSWidgetClickListener">
|
<receiver android:name=".widgets.WinBollNewsWidgetClickListener">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
||||||
<action android:name="cc.winboll.studio.appbase.widgets.SOSWidgetClickListener.ACTION_PRE"/>
|
<action android:name="cc.winboll.studio.appbase.widgets.WinBollNewsWidgetClickListener.ACTION_PRE"/>
|
||||||
|
|
||||||
<action android:name="cc.winboll.studio.appbase.widgets.SOSWidgetClickListener.ACTION_NEXT"/>
|
<action android:name="cc.winboll.studio.appbase.widgets.WinBollNewsWidgetClickListener.ACTION_NEXT"/>
|
||||||
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ import cc.winboll.studio.appbase.services.MainService;
|
|||||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.LogView;
|
import cc.winboll.studio.libappbase.LogView;
|
||||||
import cc.winboll.studio.libappbase.SOS;
|
import cc.winboll.studio.libappbase.WinBoll;
|
||||||
import cc.winboll.studio.libappbase.SimpleOperateSignalCenterService;
|
import cc.winboll.studio.libappbase.SimpleOperateSignalCenterService;
|
||||||
import cc.winboll.studio.libappbase.bean.APPSOSBean;
|
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
||||||
import cc.winboll.studio.libappbase.services.TestService;
|
import cc.winboll.studio.libappbase.services.TestService;
|
||||||
import cc.winboll.studio.libappbase.widgets.StatusWidget;
|
import cc.winboll.studio.libappbase.widgets.StatusWidget;
|
||||||
import com.hjq.toast.ToastUtils;
|
import com.hjq.toast.ToastUtils;
|
||||||
@ -90,19 +90,19 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
public void onSOS(View view) {
|
public void onSOS(View view) {
|
||||||
Intent intent = new Intent(this, TestService.class);
|
Intent intent = new Intent(this, TestService.class);
|
||||||
stopService(intent);
|
stopService(intent);
|
||||||
SOS.sosWinBollService(this, new APPSOSBean(getPackageName(), TestService.class.getName()));
|
WinBoll.sosService(this, new APPNewsBean(getPackageName(), TestService.class.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStartTestService(View view) {
|
public void onStartTestService(View view) {
|
||||||
Intent intent = new Intent(this, TestService.class);
|
Intent intent = new Intent(this, TestService.class);
|
||||||
intent.setAction(SOS.ACTION_SERVICE_ENABLE);
|
intent.setAction(WinBoll.ACTION_SERVICE_ENABLE);
|
||||||
startService(intent);
|
startService(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStopTestService(View view) {
|
public void onStopTestService(View view) {
|
||||||
Intent intent = new Intent(this, TestService.class);
|
Intent intent = new Intent(this, TestService.class);
|
||||||
intent.setAction(SOS.ACTION_SERVICE_DISABLE);
|
intent.setAction(WinBoll.ACTION_SERVICE_DISABLE);
|
||||||
startService(intent);
|
startService(intent);
|
||||||
|
|
||||||
Intent intentStop = new Intent(this, TestService.class);
|
Intent intentStop = new Intent(this, TestService.class);
|
||||||
|
@ -10,45 +10,45 @@ import android.util.JsonWriter;
|
|||||||
import cc.winboll.studio.libappbase.BaseBean;
|
import cc.winboll.studio.libappbase.BaseBean;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class SOSReportBean extends BaseBean {
|
public class WinBollNewsBean extends BaseBean {
|
||||||
|
|
||||||
public static final String TAG = "APPSOSReportBean";
|
public static final String TAG = "APPSOSReportBean";
|
||||||
|
|
||||||
protected String sosReport;
|
protected String message;
|
||||||
|
|
||||||
public SOSReportBean() {
|
public WinBollNewsBean() {
|
||||||
this.sosReport = "";
|
this.message = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public SOSReportBean(String sosReport) {
|
public WinBollNewsBean(String message) {
|
||||||
this.sosReport = sosReport;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSosReport(String sosReport) {
|
public void setMessage(String message) {
|
||||||
this.sosReport = sosReport;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSosReport() {
|
public String getMessage() {
|
||||||
return sosReport;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return SOSReportBean.class.getName();
|
return WinBollNewsBean.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||||
super.writeThisToJsonWriter(jsonWriter);
|
super.writeThisToJsonWriter(jsonWriter);
|
||||||
jsonWriter.name("sosReport").value(getSosReport());
|
jsonWriter.name("message").value(getMessage());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||||
if (name.equals("sosReport")) {
|
if (name.equals("message")) {
|
||||||
setSosReport(jsonReader.nextString());
|
setMessage(jsonReader.nextString());
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@ -11,13 +11,13 @@ 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.SOSReportBean;
|
import cc.winboll.studio.appbase.beans.WinBollNewsBean;
|
||||||
import cc.winboll.studio.appbase.services.MainService;
|
import cc.winboll.studio.appbase.services.MainService;
|
||||||
import cc.winboll.studio.appbase.widgets.SOSWidget;
|
import cc.winboll.studio.appbase.widgets.WinBollNewsWidget;
|
||||||
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;
|
import cc.winboll.studio.libappbase.WinBoll;
|
||||||
import cc.winboll.studio.libappbase.bean.APPSOSBean;
|
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
||||||
import com.hjq.toast.ToastUtils;
|
import com.hjq.toast.ToastUtils;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
@ -43,7 +43,7 @@ public class MainReceiver extends BroadcastReceiver {
|
|||||||
String szAction = intent.getAction();
|
String szAction = intent.getAction();
|
||||||
if (szAction.equals(ACTION_BOOT_COMPLETED)) {
|
if (szAction.equals(ACTION_BOOT_COMPLETED)) {
|
||||||
ToastUtils.show("ACTION_BOOT_COMPLETED");
|
ToastUtils.show("ACTION_BOOT_COMPLETED");
|
||||||
} else if (szAction.equals(SOS.ACTION_BIND)) {
|
} else if (szAction.equals(WinBoll.ACTION_BIND)) {
|
||||||
LogUtils.d(TAG, "ACTION_BIND");
|
LogUtils.d(TAG, "ACTION_BIND");
|
||||||
LogUtils.d(TAG, String.format("context.getPackageName() %s", context.getPackageName()));
|
LogUtils.d(TAG, String.format("context.getPackageName() %s", context.getPackageName()));
|
||||||
LogUtils.d(TAG, String.format("intent.getAction() %s", intent.getAction()));
|
LogUtils.d(TAG, String.format("intent.getAction() %s", intent.getAction()));
|
||||||
@ -54,12 +54,12 @@ public class MainReceiver extends BroadcastReceiver {
|
|||||||
LogUtils.d(TAG, String.format("szAPPSOSBean %s", szAPPSOSBean));
|
LogUtils.d(TAG, String.format("szAPPSOSBean %s", szAPPSOSBean));
|
||||||
if (szAPPSOSBean != null && !szAPPSOSBean.equals("")) {
|
if (szAPPSOSBean != null && !szAPPSOSBean.equals("")) {
|
||||||
try {
|
try {
|
||||||
APPSOSBean bean = APPSOSBean.parseStringToBean(szAPPSOSBean, APPSOSBean.class);
|
APPNewsBean bean = APPNewsBean.parseStringToBean(szAPPSOSBean, APPNewsBean.class);
|
||||||
if (bean != null) {
|
if (bean != null) {
|
||||||
String sosPackage = bean.getSosPackage();
|
String szNewsPackageName = bean.getNewsPackageName();
|
||||||
LogUtils.d(TAG, String.format("sosPackage %s", sosPackage));
|
LogUtils.d(TAG, String.format("szNewsPackageName %s", szNewsPackageName));
|
||||||
String sosClassName = bean.getSosClassName();
|
String szNewsClassName = bean.getNewsClassName();
|
||||||
LogUtils.d(TAG, String.format("sosClassName %s", sosClassName));
|
LogUtils.d(TAG, String.format("szNewsClassName %s", szNewsClassName));
|
||||||
mwrService.get().bindSOSConnection(bean);
|
mwrService.get().bindSOSConnection(bean);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -67,31 +67,31 @@ public class MainReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (intent.getAction().equals(SOS.ACTION_SOS)) {
|
} else if (intent.getAction().equals(WinBoll.ACTION_SOS)) {
|
||||||
LogUtils.d(TAG, "ACTION_SOS");
|
LogUtils.d(TAG, "ACTION_SOS");
|
||||||
LogUtils.d(TAG, String.format("context.getPackageName() %s", context.getPackageName()));
|
LogUtils.d(TAG, String.format("context.getPackageName() %s", context.getPackageName()));
|
||||||
LogUtils.d(TAG, String.format("intent.getAction() %s", intent.getAction()));
|
LogUtils.d(TAG, String.format("intent.getAction() %s", intent.getAction()));
|
||||||
String SOS = intent.getStringExtra("SOS");
|
String SOS = intent.getStringExtra("SOS");
|
||||||
LogUtils.d(TAG, String.format("SOS %s", SOS));
|
LogUtils.d(TAG, String.format("SOS %s", SOS));
|
||||||
if (SOS != null && SOS.equals("Service")) {
|
if (SOS != null && SOS.equals("Service")) {
|
||||||
String szAPPSOSBean = intent.getStringExtra("APPSOSBean");
|
String szAPPNewsBean = intent.getStringExtra("APPSOSBean");
|
||||||
LogUtils.d(TAG, String.format("szAPPSOSBean %s", szAPPSOSBean));
|
LogUtils.d(TAG, String.format("szAPPNewsBean %s", szAPPNewsBean));
|
||||||
if (szAPPSOSBean != null && !szAPPSOSBean.equals("")) {
|
if (szAPPNewsBean != null && !szAPPNewsBean.equals("")) {
|
||||||
try {
|
try {
|
||||||
APPSOSBean bean = APPSOSBean.parseStringToBean(szAPPSOSBean, APPSOSBean.class);
|
APPNewsBean bean = APPNewsBean.parseStringToBean(szAPPNewsBean, APPNewsBean.class);
|
||||||
if (bean != null) {
|
if (bean != null) {
|
||||||
String sosPackage = bean.getSosPackage();
|
String szNewsPackageName = bean.getNewsPackageName();
|
||||||
LogUtils.d(TAG, String.format("sosPackage %s", sosPackage));
|
LogUtils.d(TAG, String.format("szNewsPackageName %s", szNewsPackageName));
|
||||||
String sosClassName = bean.getSosClassName();
|
String szNewsClassName = bean.getNewsClassName();
|
||||||
LogUtils.d(TAG, String.format("sosClassName %s", sosClassName));
|
LogUtils.d(TAG, String.format("szNewsClassName %s", szNewsClassName));
|
||||||
|
|
||||||
Intent intentService = new Intent();
|
Intent intentService = new Intent();
|
||||||
intentService.setComponent(new ComponentName(sosPackage, sosClassName));
|
intentService.setComponent(new ComponentName(szNewsPackageName, szNewsClassName));
|
||||||
context.startService(intentService);
|
context.startService(intentService);
|
||||||
|
|
||||||
String appName = AppUtils.getAppNameByPackageName(context, sosPackage);
|
String appName = AppUtils.getAppNameByPackageName(context, szNewsPackageName);
|
||||||
LogUtils.d(TAG, String.format("appName %s", appName));
|
LogUtils.d(TAG, String.format("appName %s", appName));
|
||||||
SOSReportBean appSOSReportBean = new SOSReportBean(appName);
|
WinBollNewsBean appWinBollNewsBean = new WinBollNewsBean(appName);
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||||
String currentTime = sdf.format(new Date());
|
String currentTime = sdf.format(new Date());
|
||||||
StringBuilder sbLine = new StringBuilder();
|
StringBuilder sbLine = new StringBuilder();
|
||||||
@ -99,12 +99,12 @@ public class MainReceiver extends BroadcastReceiver {
|
|||||||
sbLine.append(currentTime);
|
sbLine.append(currentTime);
|
||||||
sbLine.append("] Power to ");
|
sbLine.append("] Power to ");
|
||||||
sbLine.append(appName);
|
sbLine.append(appName);
|
||||||
appSOSReportBean.setSosReport(sbLine.toString());
|
appWinBollNewsBean.setMessage(sbLine.toString());
|
||||||
|
|
||||||
SOSWidget.addAPPSOSReportBean(context, appSOSReportBean);
|
WinBollNewsWidget.addWinBollNewsBean(context, appWinBollNewsBean);
|
||||||
|
|
||||||
Intent intentWidget = new Intent(context, SOSWidget.class);
|
Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
|
||||||
intentWidget.setAction(SOSWidget.ACTION_RELOAD_REPORT);
|
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
|
||||||
context.sendBroadcast(intentWidget);
|
context.sendBroadcast(intentWidget);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -122,10 +122,10 @@ public class MainReceiver extends BroadcastReceiver {
|
|||||||
public void registerAction(MainService service) {
|
public void registerAction(MainService service) {
|
||||||
IntentFilter filter=new IntentFilter();
|
IntentFilter filter=new IntentFilter();
|
||||||
filter.addAction(ACTION_BOOT_COMPLETED);
|
filter.addAction(ACTION_BOOT_COMPLETED);
|
||||||
filter.addAction(SOS.ACTION_SOS);
|
filter.addAction(WinBoll.ACTION_SOS);
|
||||||
filter.addAction(SOS.ACTION_BIND);
|
filter.addAction(WinBoll.ACTION_BIND);
|
||||||
filter.addAction(SOS.ACTION_SERVICE_ENABLE);
|
filter.addAction(WinBoll.ACTION_SERVICE_ENABLE);
|
||||||
filter.addAction(SOS.ACTION_SERVICE_DISABLE);
|
filter.addAction(WinBoll.ACTION_SERVICE_DISABLE);
|
||||||
//filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
//filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||||
service.registerReceiver(this, filter);
|
service.registerReceiver(this, filter);
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ 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;
|
||||||
import cc.winboll.studio.appbase.threads.MainServiceThread;
|
import cc.winboll.studio.appbase.threads.MainServiceThread;
|
||||||
import cc.winboll.studio.appbase.widgets.SOSWidget;
|
import cc.winboll.studio.appbase.widgets.WinBollNewsWidget;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.bean.APPSOSBean;
|
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class MainService extends Service {
|
public class MainService extends Service {
|
||||||
@ -101,8 +101,8 @@ public class MainService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 启动小部件
|
// 启动小部件
|
||||||
Intent intentTimeWidget = new Intent(this, SOSWidget.class);
|
Intent intentTimeWidget = new Intent(this, WinBollNewsWidget.class);
|
||||||
intentTimeWidget.setAction(SOSWidget.ACTION_RELOAD_REPORT);
|
intentTimeWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
|
||||||
this.sendBroadcast(intentTimeWidget);
|
this.sendBroadcast(intentTimeWidget);
|
||||||
|
|
||||||
startMainServiceThread();
|
startMainServiceThread();
|
||||||
@ -192,7 +192,7 @@ public class MainService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindSOSConnection(APPSOSBean bean) {
|
public void bindSOSConnection(APPNewsBean bean) {
|
||||||
LogUtils.d(TAG, "bindSOSConnection(...)");
|
LogUtils.d(TAG, "bindSOSConnection(...)");
|
||||||
// 清理旧的绑定链接
|
// 清理旧的绑定链接
|
||||||
for (int i = mSOSConnectionList.size() - 1; i > -1; i--) {
|
for (int i = mSOSConnectionList.size() - 1; i > -1; i--) {
|
||||||
@ -207,13 +207,13 @@ public class MainService extends Service {
|
|||||||
// 绑定服务
|
// 绑定服务
|
||||||
SOSConnection sosConnection = new SOSConnection();
|
SOSConnection sosConnection = new SOSConnection();
|
||||||
Intent intentService = new Intent();
|
Intent intentService = new Intent();
|
||||||
intentService.setComponent(new ComponentName(bean.getSosPackage(), bean.getSosClassName()));
|
intentService.setComponent(new ComponentName(bean.getNewsPackageName(), bean.getNewsClassName()));
|
||||||
bindService(intentService, sosConnection, Context.BIND_IMPORTANT);
|
bindService(intentService, sosConnection, Context.BIND_IMPORTANT);
|
||||||
mSOSConnectionList.add(sosConnection);
|
mSOSConnectionList.add(sosConnection);
|
||||||
|
|
||||||
Intent intentWidget = new Intent(this, SOSWidget.class);
|
Intent intentWidget = new Intent(this, WinBollNewsWidget.class);
|
||||||
intentWidget.setAction(SOSWidget.ACTION_WAKEUP_SERVICE);
|
intentWidget.setAction(WinBollNewsWidget.ACTION_WAKEUP_SERVICE);
|
||||||
APPSOSBean appSOSBean = new APPSOSBean(bean.getSosPackage(), bean.getSosClassName());
|
APPNewsBean appSOSBean = new APPNewsBean(bean.getNewsPackageName(), bean.getNewsClassName());
|
||||||
intentWidget.putExtra("APPSOSBean", appSOSBean.toString());
|
intentWidget.putExtra("APPSOSBean", appSOSBean.toString());
|
||||||
sendBroadcast(intentWidget);
|
sendBroadcast(intentWidget);
|
||||||
}
|
}
|
||||||
@ -222,10 +222,10 @@ public class MainService extends Service {
|
|||||||
|
|
||||||
ComponentName mComponentName;
|
ComponentName mComponentName;
|
||||||
|
|
||||||
boolean isBindToAPPSOSBean(APPSOSBean bean) {
|
boolean isBindToAPPSOSBean(APPNewsBean bean) {
|
||||||
return mComponentName != null
|
return mComponentName != null
|
||||||
&& mComponentName.getClassName().equals(bean.getSosClassName())
|
&& mComponentName.getClassName().equals(bean.getNewsClassName())
|
||||||
&& mComponentName.getPackageName().equals(bean.getSosPackage());
|
&& mComponentName.getPackageName().equals(bean.getNewsPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,31 +12,31 @@ 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.SOSReportBean;
|
import cc.winboll.studio.appbase.beans.WinBollNewsBean;
|
||||||
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.bean.APPSOSBean;
|
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
||||||
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;
|
||||||
|
|
||||||
public class SOSWidget extends AppWidgetProvider {
|
public class WinBollNewsWidget extends AppWidgetProvider {
|
||||||
|
|
||||||
public static final String TAG = "SOSWidget";
|
public static final String TAG = "WinBollNewsWidget";
|
||||||
|
|
||||||
public static final String ACTION_WAKEUP_SERVICE = "cc.winboll.studio.appbase.widgets.SOSWidget.ACTION_WAKEUP_SERVICE";
|
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.SOSWidget.ACTION_RELOAD_REPORT";
|
public static final String ACTION_RELOAD_REPORT = "cc.winboll.studio.appbase.widgets.WinBollNewsWidget.ACTION_RELOAD_REPORT";
|
||||||
|
|
||||||
|
|
||||||
volatile static ArrayList<SOSReportBean> _SOSReportBeanList;
|
volatile static ArrayList<WinBollNewsBean> _WinBollNewsBeanList;
|
||||||
final static int _MAX_PAGES = 10;
|
final static int _MAX_PAGES = 10;
|
||||||
final static int _OnePageLinesCount = 5;
|
final static int _OnePageLinesCount = 5;
|
||||||
volatile static int _CurrentPageIndex = 0;
|
volatile static int _CurrentPageIndex = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||||
initAPPSOSReportBeanList(context);
|
initWinBollNewsBeanList(context);
|
||||||
for (int appWidgetId : appWidgetIds) {
|
for (int appWidgetId : appWidgetIds) {
|
||||||
updateAppWidget(context, appWidgetManager, appWidgetId);
|
updateAppWidget(context, appWidgetManager, appWidgetId);
|
||||||
}
|
}
|
||||||
@ -45,31 +45,31 @@ public class SOSWidget extends AppWidgetProvider {
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
super.onReceive(context, intent);
|
super.onReceive(context, intent);
|
||||||
initAPPSOSReportBeanList(context);
|
initWinBollNewsBeanList(context);
|
||||||
if (intent.getAction().equals(ACTION_RELOAD_REPORT)) {
|
if (intent.getAction().equals(ACTION_RELOAD_REPORT)) {
|
||||||
LogUtils.d(TAG, "ACTION_RELOAD_REPORT");
|
LogUtils.d(TAG, "ACTION_RELOAD_REPORT");
|
||||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, SOSWidget.class));
|
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WinBollNewsWidget.class));
|
||||||
for (int appWidgetId : appWidgetIds) {
|
for (int appWidgetId : appWidgetIds) {
|
||||||
updateAppWidget(context, appWidgetManager, appWidgetId);
|
updateAppWidget(context, appWidgetManager, appWidgetId);
|
||||||
}
|
}
|
||||||
}else if (intent.getAction().equals(ACTION_WAKEUP_SERVICE)) {
|
}else if (intent.getAction().equals(ACTION_WAKEUP_SERVICE)) {
|
||||||
LogUtils.d(TAG, "ACTION_WAKEUP_SERVICE");
|
LogUtils.d(TAG, "ACTION_WAKEUP_SERVICE");
|
||||||
String szAPPSOSBean = intent.getStringExtra("APPSOSBean");
|
String szWinBollNewsBean = intent.getStringExtra("WinBollNewsBean");
|
||||||
LogUtils.d(TAG, String.format("szAPPSOSBean %s", szAPPSOSBean));
|
LogUtils.d(TAG, String.format("szWinBollNewsBean %s", szWinBollNewsBean));
|
||||||
if (szAPPSOSBean != null && !szAPPSOSBean.equals("")) {
|
if (szWinBollNewsBean != null && !szWinBollNewsBean.equals("")) {
|
||||||
try {
|
try {
|
||||||
APPSOSBean bean = APPSOSBean.parseStringToBean(szAPPSOSBean, APPSOSBean.class);
|
APPNewsBean bean = APPNewsBean.parseStringToBean(szWinBollNewsBean, APPNewsBean.class);
|
||||||
if (bean != null) {
|
if (bean != null) {
|
||||||
String sosPackage = bean.getSosPackage();
|
String szNewsPackageName = bean.getNewsPackageName();
|
||||||
LogUtils.d(TAG, String.format("sosPackage %s", sosPackage));
|
LogUtils.d(TAG, String.format("szNewsPackageName %s", szNewsPackageName));
|
||||||
String sosClassName = bean.getSosClassName();
|
String szNewsClassName = bean.getNewsClassName();
|
||||||
LogUtils.d(TAG, String.format("sosClassName %s", sosClassName));
|
LogUtils.d(TAG, String.format("szNewsClassName %s", szNewsClassName));
|
||||||
|
|
||||||
|
|
||||||
String appName = AppUtils.getAppNameByPackageName(context, sosPackage);
|
String appName = AppUtils.getAppNameByPackageName(context, szNewsPackageName);
|
||||||
LogUtils.d(TAG, String.format("appName %s", appName));
|
LogUtils.d(TAG, String.format("appName %s", appName));
|
||||||
SOSReportBean appSOSReportBean = new SOSReportBean(appName);
|
WinBollNewsBean winBollNewsBean = new WinBollNewsBean(appName);
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||||
String currentTime = sdf.format(new Date());
|
String currentTime = sdf.format(new Date());
|
||||||
StringBuilder sbLine = new StringBuilder();
|
StringBuilder sbLine = new StringBuilder();
|
||||||
@ -77,12 +77,12 @@ public class SOSWidget extends AppWidgetProvider {
|
|||||||
sbLine.append(currentTime);
|
sbLine.append(currentTime);
|
||||||
sbLine.append("] Wake up ");
|
sbLine.append("] Wake up ");
|
||||||
sbLine.append(appName);
|
sbLine.append(appName);
|
||||||
appSOSReportBean.setSosReport(sbLine.toString());
|
winBollNewsBean.setMessage(sbLine.toString());
|
||||||
|
|
||||||
addAPPSOSReportBean(context, appSOSReportBean);
|
addWinBollNewsBean(context, winBollNewsBean);
|
||||||
|
|
||||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, SOSWidget.class));
|
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WinBollNewsWidget.class));
|
||||||
for (int appWidgetId : appWidgetIds) {
|
for (int appWidgetId : appWidgetIds) {
|
||||||
updateAppWidget(context, appWidgetManager, appWidgetId);
|
updateAppWidget(context, appWidgetManager, appWidgetId);
|
||||||
}
|
}
|
||||||
@ -97,53 +97,53 @@ public class SOSWidget extends AppWidgetProvider {
|
|||||||
//
|
//
|
||||||
// 加入新报告信息
|
// 加入新报告信息
|
||||||
//
|
//
|
||||||
public synchronized static void addAPPSOSReportBean(Context context, SOSReportBean bean) {
|
public synchronized static void addWinBollNewsBean(Context context, WinBollNewsBean bean) {
|
||||||
initAPPSOSReportBeanList(context);
|
initWinBollNewsBeanList(context);
|
||||||
_SOSReportBeanList.add(0, bean);
|
_WinBollNewsBeanList.add(0, bean);
|
||||||
// 控制记录总数
|
// 控制记录总数
|
||||||
while (_SOSReportBeanList.size() > _MAX_PAGES * _OnePageLinesCount) {
|
while (_WinBollNewsBeanList.size() > _MAX_PAGES * _OnePageLinesCount) {
|
||||||
_SOSReportBeanList.remove(_SOSReportBeanList.size() - 1);
|
_WinBollNewsBeanList.remove(_WinBollNewsBeanList.size() - 1);
|
||||||
}
|
}
|
||||||
SOSReportBean.saveBeanList(context, _SOSReportBeanList, SOSReportBean.class);
|
WinBollNewsBean.saveBeanList(context, _WinBollNewsBeanList, WinBollNewsBean.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized static void initAPPSOSReportBeanList(Context context) {
|
synchronized static void initWinBollNewsBeanList(Context context) {
|
||||||
if (_SOSReportBeanList == null) {
|
if (_WinBollNewsBeanList == null) {
|
||||||
_SOSReportBeanList = new ArrayList<SOSReportBean>();
|
_WinBollNewsBeanList = new ArrayList<WinBollNewsBean>();
|
||||||
SOSReportBean.loadBeanList(context, _SOSReportBeanList, SOSReportBean.class);
|
WinBollNewsBean.loadBeanList(context, _WinBollNewsBeanList, WinBollNewsBean.class);
|
||||||
}
|
}
|
||||||
if (_SOSReportBeanList == null) {
|
if (_WinBollNewsBeanList == null) {
|
||||||
_SOSReportBeanList = new ArrayList<SOSReportBean>();
|
_WinBollNewsBeanList = new ArrayList<WinBollNewsBean>();
|
||||||
SOSReportBean.saveBeanList(context, _SOSReportBeanList, SOSReportBean.class);
|
WinBollNewsBean.saveBeanList(context, _WinBollNewsBeanList, WinBollNewsBean.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
|
private void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
|
||||||
LogUtils.d(TAG, "updateAppWidget(...)");
|
LogUtils.d(TAG, "updateAppWidget(...)");
|
||||||
|
|
||||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_sos);
|
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_news);
|
||||||
//设置按钮点击事件
|
//设置按钮点击事件
|
||||||
Intent intentPre = new Intent(context, SOSWidgetClickListener.class);
|
Intent intentPre = new Intent(context, WinBollNewsWidgetClickListener.class);
|
||||||
intentPre.setAction(SOSWidgetClickListener.ACTION_PRE);
|
intentPre.setAction(WinBollNewsWidgetClickListener.ACTION_PRE);
|
||||||
PendingIntent pendingIntentPre = PendingIntent.getBroadcast(context, 0, intentPre, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent pendingIntentPre = PendingIntent.getBroadcast(context, 0, intentPre, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
views.setOnClickPendingIntent(R.id.widget_button_pre, pendingIntentPre);
|
views.setOnClickPendingIntent(R.id.widget_button_pre, pendingIntentPre);
|
||||||
Intent intentNext = new Intent(context, SOSWidgetClickListener.class);
|
Intent intentNext = new Intent(context, WinBollNewsWidgetClickListener.class);
|
||||||
intentNext.setAction(SOSWidgetClickListener.ACTION_NEXT);
|
intentNext.setAction(WinBollNewsWidgetClickListener.ACTION_NEXT);
|
||||||
PendingIntent pendingIntentNext = PendingIntent.getBroadcast(context, 0, intentNext, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent pendingIntentNext = PendingIntent.getBroadcast(context, 0, intentNext, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
views.setOnClickPendingIntent(R.id.widget_button_next, pendingIntentNext);
|
views.setOnClickPendingIntent(R.id.widget_button_next, pendingIntentNext);
|
||||||
|
|
||||||
views.setTextViewText(R.id.infoTextView, getPageInfo());
|
views.setTextViewText(R.id.tv_msg, getPageInfo());
|
||||||
views.setTextViewText(R.id.sosReportTextView, getMessage());
|
views.setTextViewText(R.id.tv_news, getMessage());
|
||||||
appWidgetManager.updateAppWidget(appWidgetId, views);
|
appWidgetManager.updateAppWidget(appWidgetId, views);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getMessage() {
|
public static String getMessage() {
|
||||||
ArrayList<String> msgTemp = new ArrayList<String>();
|
ArrayList<String> msgTemp = new ArrayList<String>();
|
||||||
if (_SOSReportBeanList != null) {
|
if (_WinBollNewsBeanList != null) {
|
||||||
int start = _OnePageLinesCount * _CurrentPageIndex;
|
int start = _OnePageLinesCount * _CurrentPageIndex;
|
||||||
start = _SOSReportBeanList.size() > start ? start : _SOSReportBeanList.size() - 1;
|
start = _WinBollNewsBeanList.size() > start ? start : _WinBollNewsBeanList.size() - 1;
|
||||||
for (int i = start, j = 0; i < _SOSReportBeanList.size() && j < _OnePageLinesCount && start > -1; i++, j++) {
|
for (int i = start, j = 0; i < _WinBollNewsBeanList.size() && j < _OnePageLinesCount && start > -1; i++, j++) {
|
||||||
msgTemp.add(_SOSReportBeanList.get(i).getSosReport());
|
msgTemp.add(_WinBollNewsBeanList.get(i).getMessage());
|
||||||
}
|
}
|
||||||
String message = String.join("\n", msgTemp);
|
String message = String.join("\n", msgTemp);
|
||||||
return message;
|
return message;
|
||||||
@ -152,33 +152,33 @@ public class SOSWidget extends AppWidgetProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void prePage(Context context) {
|
public static void prePage(Context context) {
|
||||||
if (_SOSReportBeanList != null) {
|
if (_WinBollNewsBeanList != null) {
|
||||||
if (_CurrentPageIndex > 0) {
|
if (_CurrentPageIndex > 0) {
|
||||||
_CurrentPageIndex = _CurrentPageIndex - 1;
|
_CurrentPageIndex = _CurrentPageIndex - 1;
|
||||||
}
|
}
|
||||||
Intent intentWidget = new Intent(context, SOSWidget.class);
|
Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
|
||||||
intentWidget.setAction(SOSWidget.ACTION_RELOAD_REPORT);
|
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
|
||||||
context.sendBroadcast(intentWidget);
|
context.sendBroadcast(intentWidget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void nextPage(Context context) {
|
public static void nextPage(Context context) {
|
||||||
if (_SOSReportBeanList != null) {
|
if (_WinBollNewsBeanList != null) {
|
||||||
if ((_CurrentPageIndex + 1) * _OnePageLinesCount < _SOSReportBeanList.size()) {
|
if ((_CurrentPageIndex + 1) * _OnePageLinesCount < _WinBollNewsBeanList.size()) {
|
||||||
_CurrentPageIndex = _CurrentPageIndex + 1;
|
_CurrentPageIndex = _CurrentPageIndex + 1;
|
||||||
}
|
}
|
||||||
Intent intentWidget = new Intent(context, SOSWidget.class);
|
Intent intentWidget = new Intent(context, WinBollNewsWidget.class);
|
||||||
intentWidget.setAction(SOSWidget.ACTION_RELOAD_REPORT);
|
intentWidget.setAction(WinBollNewsWidget.ACTION_RELOAD_REPORT);
|
||||||
context.sendBroadcast(intentWidget);
|
context.sendBroadcast(intentWidget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getPageInfo() {
|
String getPageInfo() {
|
||||||
if (_SOSReportBeanList == null) {
|
if (_WinBollNewsBeanList == null) {
|
||||||
return "0/0";
|
return "0/0";
|
||||||
}
|
}
|
||||||
int leftCount = _SOSReportBeanList.size() % _OnePageLinesCount;
|
int leftCount = _WinBollNewsBeanList.size() % _OnePageLinesCount;
|
||||||
int currentPageCount = _SOSReportBeanList.size() / _OnePageLinesCount + (leftCount == 0 ?0: 1);
|
int currentPageCount = _WinBollNewsBeanList.size() / _OnePageLinesCount + (leftCount == 0 ?0: 1);
|
||||||
return String.format("%d/%d", _CurrentPageIndex + 1, currentPageCount);
|
return String.format("%d/%d", _CurrentPageIndex + 1, currentPageCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,11 +10,11 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
|
||||||
public class SOSWidgetClickListener extends BroadcastReceiver {
|
public class WinBollNewsWidgetClickListener extends BroadcastReceiver {
|
||||||
|
|
||||||
public static final String TAG = "SOSWidgetClickListener";
|
public static final String TAG = "WinBollNewsWidgetClickListener";
|
||||||
public static final String ACTION_PRE = "cc.winboll.studio.appbase.widgets.SOSWidgetClickListener.ACTION_PRE";
|
public static final String ACTION_PRE = "cc.winboll.studio.appbase.widgets.WinBollNewsWidgetClickListener.ACTION_PRE";
|
||||||
public static final String ACTION_NEXT = "cc.winboll.studio.appbase.widgets.SOSWidgetClickListener.ACTION_NEXT";
|
public static final String ACTION_NEXT = "cc.winboll.studio.appbase.widgets.WinBollNewsWidgetClickListener.ACTION_NEXT";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
@ -25,10 +25,10 @@ public class SOSWidgetClickListener extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
if (action.equals(ACTION_PRE)) {
|
if (action.equals(ACTION_PRE)) {
|
||||||
LogUtils.d(TAG, "ACTION_PRE");
|
LogUtils.d(TAG, "ACTION_PRE");
|
||||||
SOSWidget.prePage(context);
|
WinBollNewsWidget.prePage(context);
|
||||||
} else if (action.equals(ACTION_NEXT)) {
|
} else if (action.equals(ACTION_NEXT)) {
|
||||||
LogUtils.d(TAG, "ACTION_NEXT");
|
LogUtils.d(TAG, "ACTION_NEXT");
|
||||||
SOSWidget.nextPage(context);
|
WinBollNewsWidget.nextPage(context);
|
||||||
} else {
|
} else {
|
||||||
LogUtils.d(TAG, String.format("action %s", action));
|
LogUtils.d(TAG, String.format("action %s", action));
|
||||||
}
|
}
|
@ -11,31 +11,40 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="right">
|
android:gravity="right|center_vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/infoTextView"/>
|
android:id="@+id/tv_title"
|
||||||
|
android:layout_weight="1.0"
|
||||||
|
android:text="WinBollNews"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textSize="16sp"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="48dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="48dp"
|
||||||
android:text="⇦"
|
android:text="⇦"
|
||||||
android:id="@+id/widget_button_pre"/>
|
android:id="@+id/widget_button_pre"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="48dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="48dp"
|
||||||
android:text="⇨"
|
android:text="⇨"
|
||||||
android:id="@+id/widget_button_next"/>
|
android:id="@+id/widget_button_next"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/tv_msg"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:id="@+id/sosReportTextView"
|
android:id="@+id/tv_news"
|
||||||
android:layout_weight="1.0"/>
|
android:layout_weight="1.0"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -3,5 +3,5 @@
|
|||||||
android:minWidth="200dp"
|
android:minWidth="200dp"
|
||||||
android:minHeight="100dp"
|
android:minHeight="100dp"
|
||||||
android:updatePeriodMillis="1000"
|
android:updatePeriodMillis="1000"
|
||||||
android:initialLayout="@layout/widget_sos">
|
android:initialLayout="@layout/widget_news">
|
||||||
</appwidget-provider>
|
</appwidget-provider>
|
||||||
|
@ -20,13 +20,23 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api 'com.github.getActivity:ToastUtils:10.5'
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
api 'androidx.appcompat:appcompat:1.3.1'
|
// 二维码类库
|
||||||
api 'androidx.vectordrawable:vectordrawable:1.1.0'
|
implementation 'com.google.zxing:core:3.4.1'
|
||||||
api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||||
api 'androidx.fragment:fragment:1.1.0'
|
// 应用介绍页类库
|
||||||
api 'com.google.android.material:material:1.1.0'
|
implementation 'io.github.medyo:android-about-page:2.0.0'
|
||||||
|
// 吐司类库
|
||||||
|
implementation 'com.github.getActivity:ToastUtils:10.5'
|
||||||
|
// 网络连接类库
|
||||||
|
implementation 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||||
|
|
||||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
// Android 类库
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
|
implementation 'androidx.viewpager:viewpager:1.0.0'
|
||||||
|
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||||
|
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||||
|
implementation 'androidx.fragment:fragment:1.1.0'
|
||||||
|
implementation 'com.google.android.material:material:1.4.0'
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Tue Feb 25 16:51:09 HKT 2025
|
#Thu Feb 27 02:21:32 GMT 2025
|
||||||
stageCount=3
|
stageCount=3
|
||||||
libraryProject=libappbase
|
libraryProject=libappbase
|
||||||
baseVersion=2.0
|
baseVersion=2.0
|
||||||
publishVersion=2.0.2
|
publishVersion=2.0.2
|
||||||
buildCount=0
|
buildCount=4
|
||||||
baseBetaVersion=2.0.3
|
baseBetaVersion=2.0.3
|
||||||
|
@ -10,22 +10,24 @@ 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.libappbase.bean.APPSOSBean;
|
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class SOS {
|
public class WinBoll {
|
||||||
|
|
||||||
public static final String TAG = "SOS";
|
public static final String TAG = "WinBoll";
|
||||||
|
|
||||||
public static final String ACTION_SOS = SOS.class.getName() + ".ACTION_SOS";
|
public static final String ACTION_SOS = WinBoll.class.getName() + ".ACTION_SOS";
|
||||||
public static final String ACTION_BIND = SOS.class.getName() + ".ACTION_BIND";
|
public static final String ACTION_BIND = WinBoll.class.getName() + ".ACTION_BIND";
|
||||||
public static final String ACTION_SERVICE_ENABLE = SOS.class.getName() + ".ACTION_SERVICE_ENABLE";
|
public static final String ACTION_SERVICE_ENABLE = WinBoll.class.getName() + ".ACTION_SERVICE_ENABLE";
|
||||||
public static final String ACTION_SERVICE_DISABLE = SOS.class.getName() + ".ACTION_SERVICE_DISENABLE";
|
public static final String ACTION_SERVICE_DISABLE = WinBoll.class.getName() + ".ACTION_SERVICE_DISENABLE";
|
||||||
|
public static final String EXTRA_SOS = "EXTRA_SOS";
|
||||||
|
public static final String EXTRA_APPNEWSBEAN = "EXTRA_APPNEWSBEAN";
|
||||||
|
|
||||||
public static void sosWinBollService(Context context, APPSOSBean bean) {
|
public static void sosService(Context context, APPNewsBean bean) {
|
||||||
Intent intent = new Intent(ACTION_SOS);
|
Intent intent = new Intent(ACTION_SOS);
|
||||||
intent.putExtra("SOS", "Service");
|
intent.putExtra(EXTRA_SOS, "Service");
|
||||||
intent.putExtra("APPSOSBean", bean.toString());
|
intent.putExtra(EXTRA_APPNEWSBEAN, bean.toString());
|
||||||
String szToPackage = "";
|
String szToPackage = "";
|
||||||
if (GlobalApplication.isDebuging()) {
|
if (GlobalApplication.isDebuging()) {
|
||||||
szToPackage = "cc.winboll.studio.appbase.beta";
|
szToPackage = "cc.winboll.studio.appbase.beta";
|
||||||
@ -39,10 +41,10 @@ public class SOS {
|
|||||||
//ToastUtils.show("SOS Send To WinBoll");
|
//ToastUtils.show("SOS Send To WinBoll");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bindToAPPService(Context context, APPSOSBean bean) {
|
public static void bindToAPPBase(Context context, APPNewsBean bean) {
|
||||||
Intent intent = new Intent(ACTION_BIND);
|
Intent intent = new Intent(ACTION_BIND);
|
||||||
intent.putExtra("SOS", "Service");
|
intent.putExtra(EXTRA_SOS, "Service");
|
||||||
intent.putExtra("APPSOSBean", bean.toString());
|
intent.putExtra(EXTRA_APPNEWSBEAN, bean.toString());
|
||||||
String szToPackage = "";
|
String szToPackage = "";
|
||||||
if (GlobalApplication.isDebuging()) {
|
if (GlobalApplication.isDebuging()) {
|
||||||
szToPackage = "cc.winboll.studio.appbase.beta";
|
szToPackage = "cc.winboll.studio.appbase.beta";
|
@ -11,59 +11,59 @@ import cc.winboll.studio.libappbase.BaseBean;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class APPSOSBean extends BaseBean {
|
public class APPNewsBean extends BaseBean {
|
||||||
|
|
||||||
public static final String TAG = "APPSOSBean";
|
public static final String TAG = "APPNewsBean";
|
||||||
|
|
||||||
protected String sosPackage;
|
protected String newsPackageName;
|
||||||
protected String sosClassName;
|
protected String newsClassName;
|
||||||
|
|
||||||
public APPSOSBean() {
|
public APPNewsBean() {
|
||||||
this.sosPackage = "";
|
this.newsPackageName = "";
|
||||||
this.sosClassName = "";
|
this.newsClassName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public APPSOSBean(String sosPackage, String sosClassName) {
|
public APPNewsBean(String newsPackageName, String newsClassName) {
|
||||||
this.sosPackage = sosPackage;
|
this.newsPackageName = newsPackageName;
|
||||||
this.sosClassName = sosClassName;
|
this.newsClassName = newsClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSosPackage(String sosPackage) {
|
public void setNewsPackageName(String newsPackageName) {
|
||||||
this.sosPackage = sosPackage;
|
this.newsPackageName = newsPackageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSosPackage() {
|
public String getNewsPackageName() {
|
||||||
return sosPackage;
|
return newsPackageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSosClassName(String sosClassName) {
|
public void setNewsClassName(String sosClassName) {
|
||||||
this.sosClassName = sosClassName;
|
this.newsClassName = sosClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSosClassName() {
|
public String getNewsClassName() {
|
||||||
return sosClassName;
|
return newsClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return APPSOSBean.class.getName();
|
return APPNewsBean.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||||
super.writeThisToJsonWriter(jsonWriter);
|
super.writeThisToJsonWriter(jsonWriter);
|
||||||
jsonWriter.name("sosPackage").value(getSosPackage());
|
jsonWriter.name("newsPackageName").value(getNewsPackageName());
|
||||||
jsonWriter.name("sosClassName").value(getSosClassName());
|
jsonWriter.name("newsClassName").value(getNewsClassName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||||
if (name.equals("sosPackage")) {
|
if (name.equals("newsPackageName")) {
|
||||||
setSosPackage(jsonReader.nextString());
|
setNewsPackageName(jsonReader.nextString());
|
||||||
} else if (name.equals("sosClassName")) {
|
} else if (name.equals("newsClassName")) {
|
||||||
setSosClassName(jsonReader.nextString());
|
setNewsClassName(jsonReader.nextString());
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@ -11,8 +11,8 @@ import android.content.Intent;
|
|||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.SOS;
|
import cc.winboll.studio.libappbase.WinBoll;
|
||||||
import cc.winboll.studio.libappbase.bean.APPSOSBean;
|
import cc.winboll.studio.libappbase.bean.APPNewsBean;
|
||||||
import cc.winboll.studio.libappbase.bean.TestServiceBean;
|
import cc.winboll.studio.libappbase.bean.TestServiceBean;
|
||||||
|
|
||||||
public class TestService extends Service {
|
public class TestService extends Service {
|
||||||
@ -58,11 +58,11 @@ public class TestService extends Service {
|
|||||||
if (bean == null) {
|
if (bean == null) {
|
||||||
bean = new TestServiceBean();
|
bean = new TestServiceBean();
|
||||||
}
|
}
|
||||||
if (intent.getAction() != null && intent.getAction().equals(SOS.ACTION_SERVICE_ENABLE)) {
|
if (intent.getAction() != null && intent.getAction().equals(WinBoll.ACTION_SERVICE_ENABLE)) {
|
||||||
bean.setIsEnable(true);
|
bean.setIsEnable(true);
|
||||||
TestServiceBean.saveBean(this, bean);
|
TestServiceBean.saveBean(this, bean);
|
||||||
run();
|
run();
|
||||||
} else if (intent.getAction() != null && intent.getAction().equals(SOS.ACTION_SERVICE_DISABLE)) {
|
} else if (intent.getAction() != null && intent.getAction().equals(WinBoll.ACTION_SERVICE_DISABLE)) {
|
||||||
bean.setIsEnable(false);
|
bean.setIsEnable(false);
|
||||||
TestServiceBean.saveBean(this, bean);
|
TestServiceBean.saveBean(this, bean);
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ public class TestService extends Service {
|
|||||||
isStarted = true;
|
isStarted = true;
|
||||||
super.run();
|
super.run();
|
||||||
LogUtils.d(TAG, "run() start");
|
LogUtils.d(TAG, "run() start");
|
||||||
SOS.bindToAPPService(mContext, new APPSOSBean(mContext.getPackageName(), TestService.class.getName()));
|
WinBoll.bindToAPPBase(mContext, new APPNewsBean(mContext.getPackageName(), TestService.class.getName()));
|
||||||
|
|
||||||
while (!isExit()) {
|
while (!isExit()) {
|
||||||
LogUtils.d(TAG, "run()");
|
LogUtils.d(TAG, "run()");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user