Compare commits
3 Commits
aes-v15.6.
...
apputils-v
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8489ee6447 | ||
![]() |
9205af4aa9 | ||
![]() |
780e730a38 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +1,6 @@
|
||||
[submodule "winboll-x"]
|
||||
path = winboll-x
|
||||
url = https://gitea.winboll.cc/Studio/WinBollX.git
|
||||
[submodule "libjc/jcc/libs"]
|
||||
path = libjc/jcc/libs
|
||||
url = https://gitea.winboll.cc/Studio/APP_libjc_jcc_libs.git
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Mon May 12 18:07:00 HKT 2025
|
||||
stageCount=2
|
||||
#Tue Apr 29 15:14:41 HKT 2025
|
||||
stageCount=1
|
||||
libraryProject=libaes
|
||||
baseVersion=15.6
|
||||
publishVersion=15.6.1
|
||||
publishVersion=15.6.0
|
||||
buildCount=0
|
||||
baseBetaVersion=15.6.2
|
||||
baseBetaVersion=15.6.1
|
||||
|
@@ -10,14 +10,13 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libaes.winboll.APPInfo;
|
||||
import cc.winboll.studio.libaes.winboll.AboutView;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
|
||||
public class AboutActivity extends AppCompatActivity implements IWinBoLLActivity {
|
||||
public class AboutActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "AboutActivity";
|
||||
|
||||
|
60
aes/src/main/java/cc/winboll/studio/aes/WinBoLLActivity.java
Normal file
60
aes/src/main/java/cc/winboll/studio/aes/WinBoLLActivity.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package cc.winboll.studio.aes;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import cc.winboll.studio.libaes.beans.AESThemeBean;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
import android.view.MenuItem;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/30 00:34:02
|
||||
* @Describe WinBoLL 活动窗口通用基类
|
||||
*/
|
||||
public class WinBoLLActivity extends AppCompatActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "WinBoLLActivity";
|
||||
|
||||
protected volatile AESThemeBean.ThemeType mThemeType;
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mThemeType = getThemeType();
|
||||
setThemeStyle();
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
AESThemeBean.ThemeType getThemeType() {
|
||||
/*SharedPreferences sharedPreferences = getSharedPreferences(
|
||||
SHAREDPREFERENCES_NAME, MODE_PRIVATE);
|
||||
return AESThemeBean.ThemeType.values()[((sharedPreferences.getInt(DRAWER_THEME_TYPE, AESThemeBean.ThemeType.DEFAULT.ordinal())))];
|
||||
*/
|
||||
return AESThemeBean.getThemeStyleType(AESThemeUtil.getThemeTypeID(getApplicationContext()));
|
||||
}
|
||||
|
||||
void setThemeStyle() {
|
||||
//setTheme(AESThemeBean.getThemeStyle(getThemeType()));
|
||||
setTheme(AESThemeUtil.getThemeTypeID(getApplicationContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if(item.getItemId() == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sat May 03 10:32:21 GMT 2025
|
||||
#Tue Apr 29 14:47:34 HKT 2025
|
||||
stageCount=7
|
||||
libraryProject=libappbase
|
||||
baseVersion=15.7
|
||||
publishVersion=15.7.6
|
||||
buildCount=4
|
||||
buildCount=0
|
||||
baseBetaVersion=15.7.7
|
||||
|
@@ -0,0 +1,81 @@
|
||||
package cc.winboll.studio.appbase;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/28 15:34:16
|
||||
* @Describe 应用活动窗口基类
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.view.MenuItem;
|
||||
import cc.winboll.studio.appbase.App;
|
||||
import cc.winboll.studio.appbase.R;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libappbase.winboll.WinBoLLActivityManager;
|
||||
|
||||
public class WinBoLLActivityBase extends Activity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "WinBoLLActivityBase";
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
WinBoLLActivityManager getWinBoLLActivityManager() {
|
||||
return WinBoLLActivityManager.getInstance(GlobalApplication.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWinBoLLActivityManager().add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
|
||||
super.onPostCreate(savedInstanceState, persistentState);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == cc.winboll.studio.appbase.R.id.item_log) {
|
||||
GlobalApplication.getWinBoLLActivityManager().startLogActivity(this);
|
||||
return true;
|
||||
} else if(item.getItemId() == cc.winboll.studio.appbase.R.id.item_minimal) {
|
||||
//moveTaskToBack(true);
|
||||
exit();
|
||||
}
|
||||
// 在switch语句中处理每个ID,并在处理完后返回true,未处理的情况返回false。
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
void exit() {
|
||||
YesNoAlertDialog.show(this, "Exit " + getString(R.string.app_name), "Close all activity and exit?", new YesNoAlertDialog.OnDialogResultListener(){
|
||||
|
||||
@Override
|
||||
public void onYes() {
|
||||
App.getWinBoLLActivityManager().finishAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNo() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
getWinBoLLActivityManager().registeRemove(this);
|
||||
}
|
||||
}
|
@@ -1,49 +1,54 @@
|
||||
package cc.winboll.studio.autoinstaller.models;
|
||||
package cc.winboll.studio.appbase.models;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/17 10:05:09
|
||||
* @Describe APPSOSReportBean
|
||||
*/
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/04/15 09:27:39
|
||||
* @Describe MainServiceBean
|
||||
*/
|
||||
public class MainServiceBean extends BaseBean {
|
||||
|
||||
public static final String TAG = "MainServiceBean";
|
||||
|
||||
boolean isEnable;
|
||||
|
||||
public MainServiceBean() {
|
||||
this.isEnable = false;
|
||||
public class WinBoLLNewsBean extends BaseBean {
|
||||
|
||||
public static final String TAG = "WinBoLLNewsBean";
|
||||
|
||||
protected String message;
|
||||
|
||||
public WinBoLLNewsBean() {
|
||||
this.message = "";
|
||||
}
|
||||
|
||||
public void setIsEnable(boolean isEnable) {
|
||||
this.isEnable = isEnable;
|
||||
public WinBoLLNewsBean(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public boolean isEnable() {
|
||||
return isEnable;
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainServiceBean.class.getName();
|
||||
return WinBoLLNewsBean.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("isEnable").value(isEnable());
|
||||
jsonWriter.name("message").value(getMessage());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("isEnable")) {
|
||||
setIsEnable(jsonReader.nextBoolean());
|
||||
if (name.equals("message")) {
|
||||
setMessage(jsonReader.nextString());
|
||||
} else {
|
||||
return false;
|
||||
}
|
@@ -29,7 +29,7 @@ android {
|
||||
// versionName 更新后需要手动设置
|
||||
// 项目模块目录的 build.gradle 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "15.3"
|
||||
versionName "15.8"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Apr 29 15:04:17 HKT 2025
|
||||
stageCount=5
|
||||
#Tue May 13 11:09:58 HKT 2025
|
||||
stageCount=1
|
||||
libraryProject=libapputils
|
||||
baseVersion=15.3
|
||||
publishVersion=15.3.4
|
||||
baseVersion=15.8
|
||||
publishVersion=15.8.0
|
||||
buildCount=0
|
||||
baseBetaVersion=15.3.5
|
||||
baseBetaVersion=15.8.1
|
||||
|
@@ -0,0 +1,36 @@
|
||||
package cc.winboll.studio.apputils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2025/01/17 19:50:46
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toolbar;
|
||||
import cc.winboll.studio.apputils.R;
|
||||
import cc.winboll.studio.libapputils.views.StringToQrCodeView;
|
||||
|
||||
public class TestStringToQRCodeViewActivity extends Activity {
|
||||
|
||||
public static final String TAG = "TestStringToQrCodeViewActivity";
|
||||
|
||||
StringToQrCodeView mStringToQrCodeView;
|
||||
//
|
||||
// @Override
|
||||
// public Activity getActivity() {
|
||||
// return this;
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_teststringtoqrcodeview);
|
||||
|
||||
// 初始化工具栏
|
||||
Toolbar mToolbar = findViewById(R.id.toolbar);
|
||||
mToolbar.setSubtitle(TAG);
|
||||
setActionBar(mToolbar);
|
||||
|
||||
mStringToQrCodeView = findViewById(R.id.activityteststringtoqrcodeviewStringToQrCodeView1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
package cc.winboll.studio.apputils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/28 17:11:37
|
||||
* @Describe 应用活动窗口基类
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libappbase.winboll.WinBoLLActivityManager;
|
||||
|
||||
public class WinBoLLActivityBase extends Activity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "WinBoLLActivityBase";
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
WinBoLLActivityManager getWinBoLLActivityManager() {
|
||||
return WinBoLLActivityManager.getInstance(GlobalApplication.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWinBoLLActivityManager().add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
|
||||
super.onPostCreate(savedInstanceState, persistentState);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
getWinBoLLActivityManager().registeRemove(this);
|
||||
}
|
||||
}
|
@@ -19,7 +19,7 @@ def genVersionName(def versionName){
|
||||
|
||||
android {
|
||||
compileSdkVersion 32
|
||||
buildToolsVersion "32.0.0"
|
||||
buildToolsVersion "33.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "cc.winboll.studio.autoinstaller"
|
||||
@@ -29,7 +29,7 @@ android {
|
||||
// versionName 更新后需要手动设置
|
||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "15.2"
|
||||
versionName "5.0"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
@@ -41,33 +41,30 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
api 'cc.winboll.studio:libaes:15.6.0'
|
||||
api 'cc.winboll.studio:libapputils:15.3.4'
|
||||
api 'cc.winboll.studio:libappbase:15.7.6'
|
||||
|
||||
// SSH
|
||||
api 'com.jcraft:jsch:0.1.55'
|
||||
// Html 解析
|
||||
api 'org.jsoup:jsoup:1.13.1'
|
||||
// 二维码类库
|
||||
api 'com.google.zxing:core:3.4.1'
|
||||
api 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||
// 应用介绍页类库
|
||||
api 'cc.winboll.studio:winboll-shared:1.1.0'
|
||||
api 'io.github.medyo:android-about-page:2.0.0'
|
||||
// 吐司类库
|
||||
api 'com.github.getActivity:ToastUtils:10.5'
|
||||
// 网络连接类库
|
||||
api 'com.jcraft:jsch:0.1.55'
|
||||
api 'org.jsoup:jsoup:1.13.1'
|
||||
api 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
// AndroidX 类库
|
||||
api 'androidx.appcompat:appcompat:1.1.0'
|
||||
api 'com.google.android.material:material:1.4.0'
|
||||
//api 'androidx.viewpager:viewpager:1.0.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
//api 'androidx.fragment:fragment:1.1.0'
|
||||
|
||||
api 'androidx.appcompat:appcompat:1.0.0'
|
||||
api 'androidx.fragment:fragment:1.0.0'
|
||||
api 'com.google.android.material:material:1.0.0'
|
||||
|
||||
api 'androidx.vectordrawable:vectordrawable-animated:1.0.0'
|
||||
api 'androidx.lifecycle:lifecycle-livedata:1.0.0'
|
||||
|
||||
//api 'cc.winboll.studio:libaes:6.3.2'
|
||||
//api 'cc.winboll.studio:libapputils:8.3.8'
|
||||
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sun May 04 05:32:00 GMT 2025
|
||||
stageCount=1
|
||||
#Thu Jan 02 02:39:56 HKT 2025
|
||||
stageCount=4
|
||||
libraryProject=
|
||||
baseVersion=15.2
|
||||
publishVersion=15.2.0
|
||||
buildCount=74
|
||||
baseBetaVersion=15.2.1
|
||||
baseVersion=5.0
|
||||
publishVersion=5.0.3
|
||||
buildCount=0
|
||||
baseBetaVersion=5.0.4
|
||||
|
@@ -23,8 +23,6 @@
|
||||
|
||||
<!-- MANAGE_EXTERNAL_STORAGE -->
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
|
||||
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
@@ -35,7 +33,7 @@
|
||||
android:persistent="true"
|
||||
android:supportsRtl="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:theme="@style/MyAppTheme">
|
||||
android:theme="@style/Theme.Application">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
@@ -56,21 +54,6 @@
|
||||
|
||||
<service android:name=".services.AssistantService"/>
|
||||
|
||||
<service
|
||||
android:name=".AppBaseTileService"
|
||||
android:exported="true"
|
||||
android:label="@string/tileservice_name"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
</service>
|
||||
|
||||
<receiver
|
||||
android:name=".receivers.MainReceiver"
|
||||
android:enabled="true"
|
||||
|
@@ -6,23 +6,22 @@ package cc.winboll.studio.autoinstaller;
|
||||
* @Describe 全局应用类
|
||||
*/
|
||||
import android.view.Gravity;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.hjq.toast.style.WhiteToastStyle;
|
||||
import cc.winboll.studio.shared.app.WinBollApplication;
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
public class App extends WinBollApplication {
|
||||
|
||||
public static final String TAG = "App";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
setIsDebug(BuildConfig.DEBUG);
|
||||
// 初始化 Toast 框架
|
||||
ToastUtils.init(this);
|
||||
// 设置 Toast 布局样式
|
||||
//ToastUtils.setView(R.layout.view_toast);
|
||||
ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setView(R.layout.toast_custom_view);
|
||||
//ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +0,0 @@
|
||||
package cc.winboll.studio.autoinstaller;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/04/15 09:24:46
|
||||
* @Describe 磁贴工具服务类
|
||||
*/
|
||||
import android.service.quicksettings.Tile;
|
||||
import android.service.quicksettings.TileService;
|
||||
import cc.winboll.studio.autoinstaller.models.AppConfigs;
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cc.winboll.studio.autoinstaller;
|
||||
|
||||
import android.os.FileObserver;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
|
||||
public class FileListener extends FileObserver {
|
||||
public final static String TAG = "FileListener";
|
||||
|
@@ -6,24 +6,21 @@ import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextClock;
|
||||
import android.widget.Toast;
|
||||
import androidx.core.content.FileProvider;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import cc.winboll.studio.shared.log.LogView;
|
||||
import cc.winboll.studio.autoinstaller.MainActivity;
|
||||
import cc.winboll.studio.autoinstaller.models.APKModel;
|
||||
import cc.winboll.studio.autoinstaller.models.AppConfigs;
|
||||
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
|
||||
import cc.winboll.studio.autoinstaller.services.MainService;
|
||||
import cc.winboll.studio.autoinstaller.utils.NotificationUtil;
|
||||
import cc.winboll.studio.autoinstaller.utils.PackageUtil;
|
||||
import cc.winboll.studio.autoinstaller.views.ListViewForScrollView;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -33,13 +30,8 @@ import java.util.Map;
|
||||
public class MainActivity extends Activity {
|
||||
public static final String TAG = "MainActivity";
|
||||
|
||||
public static final int MSG_UPDATE_STATUS = 0;
|
||||
|
||||
private static final int INSTALL_PERMISSION_CODE = 1;
|
||||
|
||||
static MainActivity _MainActivity;
|
||||
|
||||
ArrayList<APKModel> _APKModelList = new ArrayList<APKModel>();
|
||||
LogView mLogView;
|
||||
TextClock mTextClock;
|
||||
EditText mEditText;
|
||||
@@ -68,11 +60,9 @@ public class MainActivity extends Activity {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
_MainActivity = this;
|
||||
initView();
|
||||
|
||||
String action = getIntent().getAction();
|
||||
if ((action != null) && action.equals(ACTION_NEW_INSTALLTASK)) {
|
||||
if (getIntent().getAction().equals(ACTION_NEW_INSTALLTASK)) {
|
||||
mszInstalledPackageName = getIntent().getStringExtra(EXTRA_INSTALLED_PACKAGENAME);
|
||||
mszInstalledAPKFilePath = getIntent().getStringExtra(EXTRA_INSTALLED_APKFILEPATH);
|
||||
installAPK();
|
||||
@@ -86,7 +76,11 @@ public class MainActivity extends Activity {
|
||||
mLogView = findViewById(R.id.logview);
|
||||
mLogView.start();
|
||||
|
||||
AppConfigs appConfigs = AppConfigs.getInstance(this).loadAppConfigs(this);
|
||||
AppConfigs appConfigs = AppConfigs.loadAppConfigs(this);
|
||||
if (appConfigs == null) {
|
||||
appConfigs = new AppConfigs();
|
||||
AppConfigs.saveAppConfigs(this, appConfigs);
|
||||
}
|
||||
|
||||
if (appConfigs.getSetupMode() == AppConfigs.SetupMode.WATCHOUTPUTINSTALLER) {
|
||||
((RadioButton)findViewById(R.id.activitymainRadioButton1)).setChecked(true);
|
||||
@@ -137,44 +131,23 @@ public class MainActivity extends Activity {
|
||||
|
||||
}
|
||||
|
||||
String getLastApkPackageName() {
|
||||
APKModel.loadBeanList(this, _APKModelList, APKModel.class);
|
||||
if (_APKModelList.size() > 0) {
|
||||
return _APKModelList.get(_APKModelList.size() - 1).getApkPackageName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void onOpenAPP(View view) {
|
||||
String szInstalledPackageName = getLastApkPackageName();
|
||||
LogUtils.d(TAG, "szInstalledPackageName : " + szInstalledPackageName);
|
||||
if (szInstalledPackageName.trim().equals("")) {
|
||||
if (mszInstalledPackageName.trim().equals("")) {
|
||||
ToastUtils.show("Installed APP package name is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
PackageUtil.openAPP(this, szInstalledPackageName);
|
||||
Intent intent = getPackageManager().getLaunchIntentForPackage(mszInstalledPackageName);
|
||||
if (intent != null) {
|
||||
startActivity(intent);
|
||||
} else {
|
||||
// 若没能获取到启动意图,可进行相应提示等操作,比如跳转到应用商店让用户下载该应用(示例)
|
||||
Intent marketIntent = new Intent(Intent.ACTION_VIEW);
|
||||
marketIntent.setData(Uri.parse("market://details?id=" + mszInstalledPackageName));
|
||||
startActivity(marketIntent);
|
||||
}
|
||||
}
|
||||
|
||||
// public void onOpenAPP(View view) {
|
||||
// String szInstalledPackageName = getLastApkPackageName();
|
||||
// if (szInstalledPackageName.trim().equals("")) {
|
||||
// ToastUtils.show("Installed APP package name is null.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Intent intent = getPackageManager().getLaunchIntentForPackage(mszInstalledPackageName);
|
||||
// if (intent != null) {
|
||||
// //ToastUtils.show("startActivity");
|
||||
// startActivity(intent);
|
||||
// } else {
|
||||
// // 若没能获取到启动意图,可进行相应提示等操作,比如跳转到应用商店让用户下载该应用(示例)
|
||||
// Intent marketIntent = new Intent(Intent.ACTION_VIEW);
|
||||
// marketIntent.setData(Uri.parse("market://details?id=" + mszInstalledPackageName));
|
||||
// startActivity(marketIntent);
|
||||
// }
|
||||
// }
|
||||
|
||||
public void onInstallAPK(View view) {
|
||||
installAPK();
|
||||
}
|
||||
@@ -212,22 +185,17 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
|
||||
public void onLockPath(View view) {
|
||||
AppConfigs appConfigs = AppConfigs.loadAppConfigs(this);
|
||||
|
||||
Switch sw = (Switch)view;
|
||||
setMainServiceStatus(sw.isChecked());
|
||||
}
|
||||
|
||||
public void setMainServiceStatus(boolean isEnable) {
|
||||
AppConfigs appConfigs = AppConfigs.getInstance(this).loadAppConfigs(this);
|
||||
|
||||
Switch sw = (Switch)findViewById(R.id.activitymainSwitch1);
|
||||
if (isEnable) {
|
||||
if (sw.isChecked()) {
|
||||
String szFilePath = mEditText.getText().toString();
|
||||
|
||||
// 设置空路径时退出
|
||||
//
|
||||
if (szFilePath.trim().equals("")) {
|
||||
sw.setChecked(false);
|
||||
ToastUtils.show("监控路径为空。");
|
||||
Toast.makeText(getApplication(), "监控路径为空。", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -268,7 +236,7 @@ public class MainActivity extends Activity {
|
||||
stopWatchingFile();
|
||||
|
||||
}
|
||||
AppConfigs.getInstance(this).saveAppConfigs(this, appConfigs);
|
||||
AppConfigs.saveAppConfigs(this, appConfigs);
|
||||
}
|
||||
|
||||
void stopWatchingFile() {
|
||||
@@ -283,6 +251,8 @@ public class MainActivity extends Activity {
|
||||
Intent intentService = new Intent(MainActivity.this, MainService.class);
|
||||
//intentService.putExtra(MainService.EXTRA_APKFILEPATH, szAPKFilePath);
|
||||
startService(intentService);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -328,7 +298,7 @@ public class MainActivity extends Activity {
|
||||
}*/
|
||||
|
||||
public void onChangeSetupMode(View view) {
|
||||
AppConfigs appConfigs = AppConfigs.getInstance(this).loadAppConfigs(this);
|
||||
AppConfigs appConfigs = AppConfigs.loadAppConfigs(this);
|
||||
|
||||
if (view.getId() == R.id.activitymainRadioButton1) {
|
||||
appConfigs.setSetupMode(AppConfigs.SetupMode.WATCHOUTPUTINSTALLER);
|
||||
@@ -337,42 +307,6 @@ public class MainActivity extends Activity {
|
||||
appConfigs.setSetupMode(AppConfigs.SetupMode.NEWAPKINFONEWAPKINFO);
|
||||
((RadioButton)findViewById(R.id.activitymainRadioButton1)).setChecked(false);
|
||||
}
|
||||
AppConfigs.getInstance(this).saveAppConfigs(this, appConfigs);
|
||||
}
|
||||
|
||||
// 定义Handler
|
||||
static Handler _Handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MSG_UPDATE_STATUS) {
|
||||
if (_MainActivity != null) {
|
||||
boolean isEnableMainService = (boolean)msg.obj;
|
||||
// 处理消息,这里更新 MainService 的状态
|
||||
_MainActivity.setMainServiceStatus(isEnableMainService);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static void updateMainServiceStatus(boolean isEnable) {
|
||||
if (_Handler != null) {
|
||||
Message msg = new Message();
|
||||
msg.obj = isEnable;
|
||||
msg.what = MSG_UPDATE_STATUS;
|
||||
_Handler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopMainService() {
|
||||
if (_MainActivity != null && _Handler != null) {
|
||||
updateMainServiceStatus(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void startMainService() {
|
||||
if (_MainActivity != null && _Handler != null) {
|
||||
updateMainServiceStatus(true);
|
||||
}
|
||||
AppConfigs.saveAppConfigs(this, appConfigs);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package cc.winboll.studio.autoinstaller.models;
|
||||
package cc.winboll.studio.autoinstaller.beans;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
@@ -8,14 +8,13 @@ package cc.winboll.studio.autoinstaller.models;
|
||||
import android.content.Context;
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.autoinstaller.models.AppConfigs;
|
||||
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
|
||||
import cc.winboll.studio.autoinstaller.utils.FileUtil;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
|
||||
public class AppConfigs implements Serializable {
|
||||
|
||||
@@ -27,21 +26,6 @@ public class AppConfigs implements Serializable {
|
||||
NEWAPKINFONEWAPKINFO // 调用[应用信息查看器]打开应用包
|
||||
};
|
||||
|
||||
static volatile AppConfigs _AppConfigs;
|
||||
Context mContext;
|
||||
|
||||
AppConfigs(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
}
|
||||
|
||||
public static synchronized AppConfigs getInstance(Context context) {
|
||||
if (_AppConfigs == null) {
|
||||
_AppConfigs = new AppConfigs(context);
|
||||
_AppConfigs.loadAppConfigs(_AppConfigs.mContext);
|
||||
}
|
||||
return _AppConfigs;
|
||||
}
|
||||
|
||||
// 监控文件路径
|
||||
private String watchingFilePath = "";
|
||||
|
||||
@@ -101,8 +85,8 @@ public class AppConfigs implements Serializable {
|
||||
return "";
|
||||
}
|
||||
|
||||
public AppConfigs parseAppConfigs(String szAppConfigs) {
|
||||
AppConfigs appConfigs = new AppConfigs(mContext);
|
||||
public static AppConfigs parseAppConfigs(String szAppConfigs) {
|
||||
AppConfigs appConfigs = new AppConfigs();
|
||||
// 创建 JsonWriter 对象
|
||||
StringReader stringReader = new StringReader(szAppConfigs);
|
||||
JsonReader jsonReader = new
|
||||
@@ -137,35 +121,20 @@ public class AppConfigs implements Serializable {
|
||||
static String getDataPath(Context context) {
|
||||
return context.getExternalFilesDir(TAG) + "/" + TAG + ".json";
|
||||
}
|
||||
|
||||
public AppConfigs loadAppConfigs() {
|
||||
|
||||
public static AppConfigs loadAppConfigs(Context context) {
|
||||
AppConfigs appConfigs = null;
|
||||
try {
|
||||
String szJson = FileUtil.readFile(getDataPath(mContext));
|
||||
appConfigs = AppConfigs.getInstance(mContext).parseAppConfigs(szJson);
|
||||
String szJson = FileUtil.readFile(getDataPath(context));
|
||||
appConfigs = AppConfigs.parseAppConfigs(szJson);
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
||||
}
|
||||
return appConfigs;
|
||||
}
|
||||
|
||||
public AppConfigs loadAppConfigs(Context context) {
|
||||
AppConfigs appConfigs = null;
|
||||
public static void saveAppConfigs(Context context, AppConfigs appConfigs) {
|
||||
try {
|
||||
String szJson = FileUtil.readFile(getDataPath(context.getApplicationContext()));
|
||||
appConfigs = AppConfigs.getInstance(mContext).parseAppConfigs(szJson);
|
||||
if(appConfigs != null) {
|
||||
_AppConfigs = appConfigs;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
||||
}
|
||||
return _AppConfigs;
|
||||
}
|
||||
|
||||
public void saveAppConfigs(Context context, AppConfigs appConfigs) {
|
||||
try {
|
||||
ToastUtils.show(String.format("AppConfigs set enable service to %s", appConfigs.isEnableService()));
|
||||
//LogUtils.d(TAG, "appConfigs is : " + appConfigs.toString());
|
||||
String szJson = appConfigs.toString();
|
||||
FileUtil.writeFile(getDataPath(context), szJson);
|
||||
@@ -173,8 +142,4 @@ public class AppConfigs implements Serializable {
|
||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
public void saveAppConfigs() {
|
||||
saveAppConfigs(mContext, this);
|
||||
}
|
||||
}
|
@@ -1,75 +0,0 @@
|
||||
package cc.winboll.studio.autoinstaller.models;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/04/02 20:50:29
|
||||
* @Describe 监控的 APK 安装文件对应的应用信息数据模型
|
||||
*/
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
public class APKModel extends BaseBean {
|
||||
|
||||
public static final String TAG = "APPModel";
|
||||
|
||||
// 每次更新的 APK 文件对应的应用包名称
|
||||
String apkPackageName;
|
||||
|
||||
public APKModel() {
|
||||
this.apkPackageName = "";
|
||||
}
|
||||
|
||||
public APKModel(String apkPackageName) {
|
||||
this.apkPackageName = apkPackageName;
|
||||
}
|
||||
|
||||
public void setApkPackageName(String apkPackageName) {
|
||||
this.apkPackageName = apkPackageName;
|
||||
}
|
||||
|
||||
public String getApkPackageName() {
|
||||
return apkPackageName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return APKModel.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("appPackageName").value(getApkPackageName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("appPackageName")) {
|
||||
setApkPackageName(jsonReader.nextString());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
String name = jsonReader.nextName();
|
||||
if (!initObjectsFromJsonReader(jsonReader, name)) {
|
||||
jsonReader.skipValue();
|
||||
}
|
||||
}
|
||||
// 结束 JSON 对象
|
||||
jsonReader.endObject();
|
||||
return this;
|
||||
}
|
||||
}
|
@@ -4,9 +4,9 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import cc.winboll.studio.autoinstaller.models.AppConfigs;
|
||||
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
|
||||
import cc.winboll.studio.autoinstaller.services.MainService;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
@@ -23,7 +23,7 @@ public class MainReceiver extends BroadcastReceiver {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String szAction = intent.getAction();
|
||||
if (szAction.equals(ACTION_BOOT_COMPLETED)) {
|
||||
AppConfigs appConfigs = AppConfigs.getInstance(context).loadAppConfigs(context);
|
||||
AppConfigs appConfigs = AppConfigs.loadAppConfigs(context);
|
||||
if (appConfigs.isEnableService()) {
|
||||
Intent intentService = new Intent(context, MainService.class);
|
||||
//intentService.putExtra(MainService.EXTRA_APKFILEPATH, appConfigs.getWatchingFilePath());
|
||||
|
@@ -6,7 +6,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.autoinstaller.models.AppConfigs;
|
||||
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
|
||||
import cc.winboll.studio.autoinstaller.utils.ServiceUtil;
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,7 @@ public class AssistantService extends Service {
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
//LogUtils.d(TAG, "call onStartCommand(...)");
|
||||
run();
|
||||
AppConfigs appConfigs = AppConfigs.getInstance(AssistantService.this).loadAppConfigs(AssistantService.this);
|
||||
AppConfigs appConfigs = AppConfigs.loadAppConfigs(AssistantService.this);
|
||||
return appConfigs.isEnableService() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AssistantService extends Service {
|
||||
//
|
||||
void run() {
|
||||
//LogUtils.d(TAG, "call run()");
|
||||
AppConfigs appConfigs = AppConfigs.getInstance(AssistantService.this).loadAppConfigs(AssistantService.this);
|
||||
AppConfigs appConfigs = AppConfigs.loadAppConfigs(AssistantService.this);
|
||||
if (appConfigs.isEnableService()) {
|
||||
if (mIsThreadAlive == false) {
|
||||
// 设置运行状态
|
||||
@@ -101,7 +101,7 @@ public class AssistantService extends Service {
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
//LogUtils.d(TAG, "call onServiceDisconnected(...)");
|
||||
AppConfigs appConfigs = AppConfigs.getInstance(AssistantService.this).loadAppConfigs(AssistantService.this);
|
||||
AppConfigs appConfigs = AppConfigs.loadAppConfigs(AssistantService.this);
|
||||
if (appConfigs.isEnableService()) {
|
||||
wakeupAndBindMain();
|
||||
}
|
||||
|
@@ -10,32 +10,25 @@ import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.service.quicksettings.Tile;
|
||||
import android.service.quicksettings.TileService;
|
||||
import android.widget.Toast;
|
||||
import androidx.core.content.FileProvider;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import cc.winboll.studio.autoinstaller.FileListener;
|
||||
import cc.winboll.studio.autoinstaller.MainActivity;
|
||||
import cc.winboll.studio.autoinstaller.R;
|
||||
import cc.winboll.studio.autoinstaller.models.APKModel;
|
||||
import cc.winboll.studio.autoinstaller.models.AppConfigs;
|
||||
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
|
||||
import cc.winboll.studio.autoinstaller.services.AssistantService;
|
||||
import cc.winboll.studio.autoinstaller.services.MainService;
|
||||
import cc.winboll.studio.autoinstaller.utils.NotificationUtil;
|
||||
import cc.winboll.studio.autoinstaller.utils.PackageUtil;
|
||||
import cc.winboll.studio.autoinstaller.utils.ServiceUtil;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MainService extends Service {
|
||||
|
||||
public static String TAG = "MainService";
|
||||
|
||||
Context mContext;
|
||||
|
||||
ArrayList<APKModel> _APKModelList = new ArrayList<APKModel>();
|
||||
private static boolean _mIsServiceAlive;
|
||||
//String mszAPKFilePath;
|
||||
//String mszAPKFileName;
|
||||
@@ -54,7 +47,6 @@ public class MainService extends Service {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
mContext = this;
|
||||
LogUtils.d(TAG, "onCreate()");
|
||||
_mIsServiceAlive = false;
|
||||
mHandler = new MyHandler(MainService.this);
|
||||
@@ -63,14 +55,11 @@ public class MainService extends Service {
|
||||
}
|
||||
|
||||
run();
|
||||
|
||||
// 初始化磁贴工具服务
|
||||
MainTileService mainTileService = new MainTileService(this);
|
||||
}
|
||||
|
||||
private void run() {
|
||||
|
||||
AppConfigs appConfigs = AppConfigs.getInstance(MainService.this).loadAppConfigs(MainService.this);
|
||||
AppConfigs appConfigs = AppConfigs.loadAppConfigs(MainService.this);
|
||||
if (appConfigs.isEnableService()) {
|
||||
if (_mIsServiceAlive == false) {
|
||||
// 设置运行状态
|
||||
@@ -85,8 +74,7 @@ public class MainService extends Service {
|
||||
|
||||
startWatchingFile(appConfigs.getWatchingFilePath());
|
||||
|
||||
//LogUtils.d(TAG, "running...");
|
||||
//ToastUtils.show("running...");
|
||||
LogUtils.d(TAG, "running...");
|
||||
|
||||
} else {
|
||||
LogUtils.d(TAG, "_mIsServiceAlive is " + Boolean.toString(_mIsServiceAlive));
|
||||
@@ -106,7 +94,6 @@ public class MainService extends Service {
|
||||
}
|
||||
_mIsServiceAlive = false;
|
||||
LogUtils.d(TAG, "onDestroy()");
|
||||
mContext = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,7 +101,7 @@ public class MainService extends Service {
|
||||
LogUtils.d(TAG, "onStartCommand");
|
||||
|
||||
run();
|
||||
AppConfigs appConfigs = AppConfigs.getInstance(MainService.this).loadAppConfigs(MainService.this);
|
||||
AppConfigs appConfigs = AppConfigs.loadAppConfigs(MainService.this);
|
||||
|
||||
return appConfigs.isEnableService() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
@@ -131,7 +118,7 @@ public class MainService extends Service {
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
//LogUtils.d(TAG, "call onServiceConnected(...)");
|
||||
AppConfigs appConfigs = AppConfigs.getInstance(MainService.this).loadAppConfigs(MainService.this);
|
||||
AppConfigs appConfigs = AppConfigs.loadAppConfigs(MainService.this);
|
||||
if (appConfigs.isEnableService()) {
|
||||
// 唤醒守护进程
|
||||
wakeupAndBindAssistant();
|
||||
@@ -173,7 +160,7 @@ public class MainService extends Service {
|
||||
|
||||
});
|
||||
mFileListener.startWatching();
|
||||
//ToastUtils.show("Start watching.");
|
||||
ToastUtils.show("Start watching.");
|
||||
} else {
|
||||
// 父级文件夹不存在,就提示用户
|
||||
Toast.makeText(getApplication(), fParentDir.toString() + " no exist.", Toast.LENGTH_SHORT).show();
|
||||
@@ -189,9 +176,6 @@ public class MainService extends Service {
|
||||
// 调用[应用信息查看器]打开应用包
|
||||
//
|
||||
private void installAPK(String szAPKFilePath) {
|
||||
String szAPKPackageName = PackageUtil.getPackageNameFromApk(this, szAPKFilePath);
|
||||
saveAPKInfo(szAPKPackageName);
|
||||
|
||||
long nTimeNow = System.currentTimeMillis();
|
||||
/*SimpleDateFormat dateFormat = new SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
||||
@@ -226,24 +210,15 @@ public class MainService extends Service {
|
||||
//
|
||||
void installAPK2(String szAPKFilePath) {
|
||||
LogUtils.d(TAG, "installAPK2()");
|
||||
String szAPKPackageName = PackageUtil.getPackageNameFromApk(this, szAPKFilePath);
|
||||
saveAPKInfo(szAPKPackageName);
|
||||
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
intent.setAction(MainActivity.ACTION_NEW_INSTALLTASK);
|
||||
intent.putExtra(MainActivity.EXTRA_INSTALLED_PACKAGENAME, szAPKPackageName);
|
||||
intent.putExtra(MainActivity.EXTRA_INSTALLED_PACKAGENAME, PackageUtil.getPackageNameFromApk(this, szAPKFilePath));
|
||||
intent.putExtra(MainActivity.EXTRA_INSTALLED_APKFILEPATH, szAPKFilePath);
|
||||
// Intent.ACTION_VIEW);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
}
|
||||
|
||||
void saveAPKInfo(String szApkPackageName) {
|
||||
APKModel.loadBeanList(this, _APKModelList, APKModel.class);
|
||||
_APKModelList.add(new APKModel(szApkPackageName));
|
||||
APKModel.saveBeanList(this, _APKModelList, APKModel.class);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
static class MyHandler extends Handler {
|
||||
@@ -256,7 +231,7 @@ public class MainService extends Service {
|
||||
switch (message.what) {
|
||||
case MSG_INSTALL_APK:
|
||||
{
|
||||
AppConfigs appConfigs = AppConfigs.getInstance(theActivity).loadAppConfigs(theActivity);
|
||||
AppConfigs appConfigs = AppConfigs.loadAppConfigs(theActivity);
|
||||
if (appConfigs.getSetupMode() == AppConfigs.SetupMode.WATCHOUTPUTINSTALLER) {
|
||||
theActivity.installAPK2((String)message.obj);
|
||||
} else if (appConfigs.getSetupMode() == AppConfigs.SetupMode.NEWAPKINFONEWAPKINFO) {
|
||||
@@ -270,21 +245,4 @@ public class MainService extends Service {
|
||||
super.handleMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
static class MainTileService extends TileService {
|
||||
Context mContext;
|
||||
MainTileService(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartListening() {
|
||||
super.onStartListening();
|
||||
Tile tile = getQsTile();
|
||||
tile.setIcon(android.graphics.drawable.Icon.createWithResource(this, R.drawable.ic_android));
|
||||
// 更新磁贴状态
|
||||
tile.setState((mContext == null || mContext.getApplicationContext() == null )?Tile.STATE_INACTIVE: Tile.STATE_ACTIVE);
|
||||
tile.updateTile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -55,9 +55,8 @@ public class NotificationUtil {
|
||||
|
||||
Notification mForegroundNotification = new Notification.Builder(service, szServiceChannelID)
|
||||
.setAutoCancel(true)
|
||||
//.setContentTitle(service.getString(R.string.app_name))
|
||||
.setContentTitle(service.TAG + " is started.")
|
||||
//.setContentText(service.TAG + " is started.")
|
||||
.setContentTitle(service.getString(R.string.app_name))
|
||||
.setContentText(service.TAG + " is started.")
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setSmallIcon(R.drawable.ic_launcher)
|
||||
//设置红色
|
||||
|
@@ -6,11 +6,9 @@ package cc.winboll.studio.autoinstaller.utils;
|
||||
* @Describe 一个获取安卓APK安装文件的应用包名的函数
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
|
||||
public class PackageUtil {
|
||||
|
||||
@@ -29,20 +27,4 @@ public class PackageUtil {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void openAPP(Context context, String packageName) {
|
||||
// 这里假设要打开微信,微信的包名是com.tencent.mm
|
||||
//String packageName = "com.tencent.mm";
|
||||
LogUtils.d(TAG, "packageName : " + packageName);
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
Intent intent = packageManager.getLaunchIntentForPackage(packageName);
|
||||
if (intent != null) {
|
||||
ResolveInfo resolveInfo = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (resolveInfo != null) {
|
||||
LogUtils.d(TAG, "startActivity...");
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M16.61,15.15C16.15,15.15 15.77,14.78 15.77,14.32S16.15,13.5 16.61,13.5H16.61C17.07,13.5 17.45,13.86 17.45,14.32C17.45,14.78 17.07,15.15 16.61,15.15M7.41,15.15C6.95,15.15 6.57,14.78 6.57,14.32C6.57,13.86 6.95,13.5 7.41,13.5H7.41C7.87,13.5 8.24,13.86 8.24,14.32C8.24,14.78 7.87,15.15 7.41,15.15M16.91,10.14L18.58,7.26C18.67,7.09 18.61,6.88 18.45,6.79C18.28,6.69 18.07,6.75 18,6.92L16.29,9.83C14.95,9.22 13.5,8.9 12,8.91C10.47,8.91 9,9.24 7.73,9.82L6.04,6.91C5.95,6.74 5.74,6.68 5.57,6.78C5.4,6.87 5.35,7.08 5.44,7.25L7.1,10.13C4.25,11.69 2.29,14.58 2,18H22C21.72,14.59 19.77,11.7 16.91,10.14H16.91Z"/>
|
||||
|
||||
</vector>
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="#ff000000"
|
||||
android:pathData="M6.5,20Q4.22,20 2.61,18.43 1,16.85 1,14.58 1,12.63 2.17,11.1 3.35,9.57 5.25,9.15 5.88,6.85 7.75,5.43 9.63,4 12,4 14.93,4 16.96,6.04 19,8.07 19,11 20.73,11.2 21.86,12.5 23,13.78 23,15.5 23,17.38 21.69,18.69 20.38,20 18.5,20Z"/>
|
||||
|
||||
</vector>
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="#ff000000"
|
||||
android:pathData="M6.5,20Q4.22,20 2.61,18.43 1,16.85 1,14.58 1,12.63 2.17,11.1 3.35,9.57 5.25,9.15 5.88,6.85 7.75,5.43 9.63,4 12,4 14.93,4 16.96,6.04 19,8.07 19,11 20.73,11.2 21.86,12.5 23,13.78 23,15.5 23,17.38 21.69,18.69 20.38,20 18.5,20M6.5,18H18.5Q19.55,18 20.27,17.27 21,16.55 21,15.5 21,14.45 20.27,13.73 19.55,13 18.5,13H17V11Q17,8.93 15.54,7.46 14.08,6 12,6 9.93,6 8.46,7.46 7,8.93 7,11H6.5Q5.05,11 4.03,12.03 3,13.05 3,14.5 3,15.95 4.03,17 5.05,18 6.5,18M12,12Z"/>
|
||||
|
||||
</vector>
|
@@ -132,7 +132,7 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cc.winboll.studio.libappbase.LogView
|
||||
<cc.winboll.studio.shared.log.LogView
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
|
@@ -1,4 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">AutoInstaller</string>
|
||||
<string name="tileservice_name">AutoInstaller</string>
|
||||
</resources>
|
||||
|
@@ -1,13 +0,0 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<style name="MyAppTheme" parent="APPBaseTheme">
|
||||
<item name="attrColorPrimary">@color/colorPrimary</item>
|
||||
<item name="themeGlobalCrashActivity">@style/MyGlobalCrashActivityTheme</item>
|
||||
</style>
|
||||
|
||||
<style name="MyGlobalCrashActivityTheme" parent="GlobalCrashActivityTheme">
|
||||
<item name="colorTittle">#FFFFFFFF</item>
|
||||
<item name="colorTittleBackgound">#FF00A4B3</item>
|
||||
<item name="colorText">#FFFFFFFF</item>
|
||||
<item name="colorTextBackgound">#FF000000</item>
|
||||
</style>
|
||||
</resources>
|
14
autoinstaller/src/main/res/values/themes.xml
Normal file
14
autoinstaller/src/main/res/values/themes.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Application" parent="android:Theme.Material.Light.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="android:colorPrimary">@color/purple_500</item>
|
||||
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="android:colorSecondary">@color/teal_200</item>
|
||||
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">@color/purple_700</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
28
build.gradle
28
build.gradle
@@ -1,10 +1,11 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal {
|
||||
// 设置本地Maven仓库路径
|
||||
url 'file:///sdcard/.m2/repository/'
|
||||
}
|
||||
// 本地 Maven 仓库(默认路径为 ~/.m2/repository)
|
||||
mavenLocal()
|
||||
// 或自定义本地仓库路径
|
||||
maven { url "file:///sdcard/.m2/repository" }
|
||||
|
||||
// Nexus Maven 库地址
|
||||
// "WinBoLL Release"
|
||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
||||
@@ -19,13 +20,7 @@ buildscript {
|
||||
maven { url "https://jitpack.io" }
|
||||
mavenCentral()
|
||||
google()
|
||||
//println "mavenLocal : ==========="
|
||||
//println mavenLocal().url
|
||||
//println "mavenLocal : ==========="
|
||||
//mavenLocal()
|
||||
|
||||
// WinBoLL.CC 紧急备用 Maven 仓库
|
||||
maven { url 'https://spare-maven.winboll.cc/repository/' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.2.1' // 对应 compileSdkVersion 32
|
||||
@@ -36,11 +31,6 @@ buildscript {
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal {
|
||||
// 设置本地Maven仓库路径
|
||||
url 'file:///sdcard/.m2/repository/'
|
||||
}
|
||||
|
||||
// Nexus Maven 库地址
|
||||
// "WinBoLL Release"
|
||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
||||
@@ -55,13 +45,7 @@ allprojects {
|
||||
maven { url "https://jitpack.io" }
|
||||
mavenCentral()
|
||||
google()
|
||||
//println "mavenLocal : ==========="
|
||||
//println mavenLocal().url
|
||||
//println "mavenLocal : ==========="
|
||||
//mavenLocal()
|
||||
|
||||
// WinBoLL.CC 紧急备用 Maven 仓库
|
||||
maven { url 'https://spare-maven.winboll.cc/repository/' }
|
||||
mavenLocal()
|
||||
}
|
||||
ext {
|
||||
// 定义全局变量,常用于版本管理
|
||||
|
@@ -21,9 +21,6 @@ android {
|
||||
|
||||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
//api 'cc.winboll.studio:libaes:15.6.0'
|
||||
api 'cc.winboll.studio:libapputils:15.3.4'
|
||||
api 'cc.winboll.studio:libappbase:15.7.6'
|
||||
|
||||
// 吐司类库
|
||||
api 'com.github.getActivity:ToastUtils:10.5'
|
||||
@@ -53,4 +50,7 @@ dependencies {
|
||||
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
//api 'androidx.fragment:fragment:1.1.0'
|
||||
|
||||
api 'cc.winboll.studio:libapputils:15.3.4'
|
||||
api 'cc.winboll.studio:libappbase:15.7.6'
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Mon May 12 18:07:00 HKT 2025
|
||||
stageCount=2
|
||||
#Tue Apr 29 15:14:21 HKT 2025
|
||||
stageCount=1
|
||||
libraryProject=libaes
|
||||
baseVersion=15.6
|
||||
publishVersion=15.6.1
|
||||
publishVersion=15.6.0
|
||||
buildCount=0
|
||||
baseBetaVersion=15.6.2
|
||||
baseBetaVersion=15.6.1
|
||||
|
@@ -5,34 +5,27 @@
|
||||
|
||||
<application>
|
||||
|
||||
<activity
|
||||
android:name="cc.winboll.studio.libaes.unittests.SecondaryLibraryActivity"
|
||||
<activity android:name="cc.winboll.studio.libaes.unittests.SecondaryLibraryActivity"
|
||||
android:exported="true"/>
|
||||
|
||||
<activity
|
||||
android:name="cc.winboll.studio.libaes.unittests.TestDrawerFragmentActivity"
|
||||
<activity android:name="cc.winboll.studio.libaes.unittests.TestDrawerFragmentActivity"
|
||||
android:exported="true"/>
|
||||
|
||||
<activity
|
||||
android:name="cc.winboll.studio.libaes.unittests.TestAToolbarActivity"
|
||||
<activity android:name="cc.winboll.studio.libaes.unittests.TestAToolbarActivity"
|
||||
android:exported="true"/>
|
||||
|
||||
<activity
|
||||
android:name="cc.winboll.studio.libaes.unittests.TestASupportToolbarActivity"
|
||||
<activity android:name="cc.winboll.studio.libaes.unittests.TestASupportToolbarActivity"
|
||||
android:exported="true"/>
|
||||
|
||||
<service
|
||||
android:name="cc.winboll.studio.libaes.winboll.WinBoLLClientService"
|
||||
<service android:name="cc.winboll.studio.libaes.winboll.WinBoLLClientService"
|
||||
android:exported="true"/>
|
||||
|
||||
<service
|
||||
android:name="cc.winboll.studio.libaes.winboll.AssistantService"
|
||||
<service android:name="cc.winboll.studio.libaes.winboll.AssistantService"
|
||||
android:exported="true"/>
|
||||
|
||||
<service
|
||||
android:name="cc.winboll.studio.libaes.winboll.WinBoLLMail"
|
||||
<service android:name="cc.winboll.studio.libaes.winboll.WinBoLLMail"
|
||||
android:exported="true"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
|
@@ -11,8 +11,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.libaes.beans.WinBoLLClientServiceBean;
|
||||
import cc.winboll.studio.libaes.winboll.AssistantService;
|
||||
import cc.winboll.studio.libaes.winboll.WinBoLLClientService;
|
||||
import cc.winboll.studio.libappbase.utils.ServiceUtils;
|
||||
|
||||
public class AssistantService extends Service {
|
||||
|
@@ -0,0 +1,17 @@
|
||||
package cc.winboll.studio.libaes.winboll;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/28 19:08:45
|
||||
* @Describe WinBoLLService 服务 Binder。
|
||||
*/
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public interface IWinBoLLClientServiceBinder {
|
||||
|
||||
public static final String TAG = "IWinBoLLClientServiceBinder";
|
||||
|
||||
public WinBoLLClientService getService();
|
||||
|
||||
public Drawable getCurrentStatusIconDrawable();
|
||||
}
|
@@ -1,21 +1,192 @@
|
||||
package cc.winboll.studio.libaes.winboll;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/03 19:28
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/28 19:06:54
|
||||
* @Describe WinBoLL 客户端服务
|
||||
*/
|
||||
public class WinBoLLClientService extends Service {
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.libaes.winboll.AssistantService;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.utils.ServiceUtils;
|
||||
import cc.winboll.studio.libapputils.utils.PrefUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
|
||||
public class WinBoLLClientService extends Service implements IWinBoLLClientServiceBinder {
|
||||
|
||||
public static final String TAG = "WinBoLLClientService";
|
||||
|
||||
|
||||
WinBoLLClientServiceBean mWinBoLLClientServiceBean;
|
||||
MyServiceConnection mMyServiceConnection;
|
||||
volatile boolean mIsWinBoLLClientThreadRunning;
|
||||
volatile boolean mIsEnableService;
|
||||
volatile WinBoLLClientThread mWinBoLLClientThread;
|
||||
|
||||
public boolean isWinBoLLClientThreadRunning() {
|
||||
return mIsWinBoLLClientThreadRunning;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WinBoLLClientService getService() {
|
||||
return WinBoLLClientService.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getCurrentStatusIconDrawable() {
|
||||
return mIsWinBoLLClientThreadRunning ?
|
||||
getDrawable(EWUIStatusIconDrawable.getIconDrawableId(EWUIStatusIconDrawable.NORMAL))
|
||||
: getDrawable(EWUIStatusIconDrawable.getIconDrawableId(EWUIStatusIconDrawable.NEWS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
//ToastUtils.show("onCreate");
|
||||
super.onCreate();
|
||||
mWinBoLLClientThread = null;
|
||||
mWinBoLLClientServiceBean = WinBoLLClientServiceBean.loadWinBoLLClientServiceBean(this);
|
||||
mIsEnableService = mWinBoLLClientServiceBean.isEnable();
|
||||
|
||||
if (mMyServiceConnection == null) {
|
||||
mMyServiceConnection = new MyServiceConnection();
|
||||
}
|
||||
|
||||
// 由系统启动时,应用可以通过下面函数实例化实际服务进程。
|
||||
runMainThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
//ToastUtils.show("onStartCommand");
|
||||
// 由应用 Intent 启动时,应用可以通过下面函数实例化实际服务进程。
|
||||
runMainThread();
|
||||
|
||||
// 返回运行参数持久化存储后,服务状态控制参数
|
||||
// 无论 Intent 传入如何,服务状态一直以持久化存储后的参数控制,
|
||||
// PS: 另外当然可以通过 Intent 传入的指标来修改 mWinBoLLServiceBean,
|
||||
// 不过本服务的应用方向会变得繁琐,
|
||||
// 现阶段只要满足手机端启动与停止本服务,WinBoLL 客户端实例运行在手机端就可以了。
|
||||
return mIsEnableService ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
synchronized void runMainThread() {
|
||||
if (mWinBoLLClientThread == null) {
|
||||
//ToastUtils.show("runMainThread()");
|
||||
mWinBoLLClientThread = new WinBoLLClientThread();
|
||||
mWinBoLLClientThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
void syncWinBoLLClientThreadStatus() {
|
||||
mWinBoLLClientServiceBean = WinBoLLClientServiceBean.loadWinBoLLClientServiceBean(this);
|
||||
mIsEnableService = mWinBoLLClientServiceBean.isEnable();
|
||||
LogUtils.d(TAG, String.format("mIsEnableService %s", mIsEnableService));
|
||||
}
|
||||
|
||||
|
||||
// 唤醒和绑定守护进程
|
||||
//
|
||||
void wakeupAndBindAssistant() {
|
||||
if (ServiceUtils.isServiceRunning(getApplicationContext(), AssistantService.class.getName()) == false) {
|
||||
startService(new Intent(WinBoLLClientService.this, AssistantService.class));
|
||||
//LogUtils.d(TAG, "call wakeupAndBindAssistant() : Binding... AssistantService");
|
||||
bindService(new Intent(WinBoLLClientService.this, AssistantService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
|
||||
}
|
||||
}
|
||||
|
||||
// 主进程与守护进程连接时需要用到此类
|
||||
//
|
||||
private class MyServiceConnection implements ServiceConnection {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
mWinBoLLClientServiceBean = WinBoLLClientServiceBean.loadWinBoLLClientServiceBean(WinBoLLClientService.this);
|
||||
if (mWinBoLLClientServiceBean.isEnable()) {
|
||||
// 唤醒守护进程
|
||||
wakeupAndBindAssistant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
//ToastUtils.show("onDestroy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(Intent intent, int startId) {
|
||||
super.onStart(intent, startId);
|
||||
}
|
||||
|
||||
void setWinBoLLServiceEnableStatus(boolean isEnable) {
|
||||
WinBoLLClientServiceBean bean = WinBoLLClientServiceBean.loadWinBoLLClientServiceBean(this);
|
||||
bean.setIsEnable(isEnable);
|
||||
WinBoLLClientServiceBean.saveWinBoLLServiceBean(this, bean);
|
||||
}
|
||||
|
||||
boolean getWinBoLLServiceEnableStatus(Context context) {
|
||||
mWinBoLLClientServiceBean = WinBoLLClientServiceBean.loadWinBoLLClientServiceBean(context);
|
||||
return mWinBoLLClientServiceBean.isEnable();
|
||||
}
|
||||
|
||||
/*public interface OnServiceStatusChangeListener {
|
||||
void onServerStatusChange(boolean isServiceAlive);
|
||||
}
|
||||
|
||||
public void setOnServerStatusChangeListener(OnServiceStatusChangeListener l) {
|
||||
mOnServerStatusChangeListener = l;
|
||||
}*/
|
||||
|
||||
class WinBoLLClientThread extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
LogUtils.d(TAG, "run syncWinBoLLClientThreadStatus");
|
||||
syncWinBoLLClientThreadStatus();
|
||||
if (mIsEnableService) {
|
||||
if (mIsWinBoLLClientThreadRunning == false) {
|
||||
// 设置运行状态
|
||||
mIsWinBoLLClientThreadRunning = true;
|
||||
LogUtils.d(TAG, "WinBoLLClientThread run()");
|
||||
|
||||
// 唤醒守护进程
|
||||
//wakeupAndBindAssistant();
|
||||
|
||||
while (mIsEnableService) {
|
||||
// 显示运行状态
|
||||
WinBoLLServiceStatusView.startConnection();
|
||||
LogUtils.d(TAG, String.format("while mIsEnableService is %s", mIsEnableService));
|
||||
|
||||
try {
|
||||
Thread.sleep(10 * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
syncWinBoLLClientThreadStatus();
|
||||
}
|
||||
|
||||
// 服务进程退出, 重置进程运行状态
|
||||
WinBoLLServiceStatusView.stopConnection();
|
||||
mIsWinBoLLClientThreadRunning = false;
|
||||
mWinBoLLClientThread = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package cc.winboll.studio.libaes.beans;
|
||||
package cc.winboll.studio.libaes.winboll;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/03 19:16
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/28 19:05:15
|
||||
* @Describe WinBoLLService 运行参数配置
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.util.JsonReader;
|
||||
@@ -13,16 +14,11 @@ import java.io.IOException;
|
||||
public class WinBoLLClientServiceBean extends BaseBean {
|
||||
|
||||
public static final String TAG = "WinBoLLClientServiceBean";
|
||||
|
||||
// 服务是否正在使用中
|
||||
boolean isEnable;
|
||||
|
||||
public WinBoLLClientServiceBean() {
|
||||
this.isEnable = false;
|
||||
}
|
||||
|
||||
public WinBoLLClientServiceBean(boolean isEnable) {
|
||||
this.isEnable = isEnable;
|
||||
volatile boolean isEnable;
|
||||
|
||||
public WinBoLLClientServiceBean() {
|
||||
isEnable = false;
|
||||
}
|
||||
|
||||
public void setIsEnable(boolean isEnable) {
|
||||
@@ -33,7 +29,6 @@ public class WinBoLLClientServiceBean extends BaseBean {
|
||||
return isEnable;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return WinBoLLClientServiceBean.class.getName();
|
||||
@@ -43,17 +38,17 @@ public class WinBoLLClientServiceBean extends BaseBean {
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
WinBoLLClientServiceBean bean = this;
|
||||
//jsonWriter.name("logLevel").value(bean.getLogLevel().ordinal());
|
||||
jsonWriter.name("isEnable").value(bean.isEnable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
// if (name.equals("logLevel")) {
|
||||
// setLogLevel(LogUtils.LOG_LEVEL.values()[jsonReader.nextInt()]);
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
if (name.equals("isEnable")) {
|
||||
setIsEnable(jsonReader.nextBoolean());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -73,6 +68,11 @@ public class WinBoLLClientServiceBean extends BaseBean {
|
||||
}
|
||||
|
||||
public static WinBoLLClientServiceBean loadWinBoLLClientServiceBean(Context context) {
|
||||
return new WinBoLLClientServiceBean();
|
||||
WinBoLLClientServiceBean bean = WinBoLLClientServiceBean.loadBean(context, WinBoLLClientServiceBean.class);
|
||||
return bean == null ? new WinBoLLClientServiceBean() : bean;
|
||||
}
|
||||
|
||||
public static boolean saveWinBoLLServiceBean(WinBoLLClientService service, WinBoLLClientServiceBean bean) {
|
||||
return WinBoLLClientServiceBean.saveBean(service, bean);
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package cc.winboll.studio.libaes.winboll;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/28 19:13:20
|
||||
* @Describe WinBoLL 邮件服务
|
||||
*/
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
|
||||
public class WinBoLLMail extends Service {
|
||||
|
||||
public static final String TAG = "WinBoLLMail";
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,106 @@
|
||||
package cc.winboll.studio.libaes.winboll;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/29 15:57:28
|
||||
* @Describe WinBoLL 服务器服务情况测试访问进程。
|
||||
*/
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import java.io.IOException;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Credentials;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
// 新增自定义回调接口
|
||||
interface TextCallback {
|
||||
void onSuccess(String text);
|
||||
void onFailure(Exception e);
|
||||
}
|
||||
|
||||
public class WinBoLLServerConnectionThread extends Thread {
|
||||
|
||||
public static final String TAG = "WinBoLLClientService";
|
||||
|
||||
private final String url;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final int connectTimeout;
|
||||
private final int readTimeout;
|
||||
private final int maxRetries;
|
||||
private final TextCallback callback; // 新增回调成员变量
|
||||
|
||||
// 新增带回调的构造函数
|
||||
public WinBoLLServerConnectionThread(String url, String username, String password, TextCallback callback) {
|
||||
this(url, username, password, 10000, 10000, 5, callback);
|
||||
}
|
||||
|
||||
// 修改原有构造函数,添加回调参数
|
||||
public WinBoLLServerConnectionThread(String url, String username, String password,
|
||||
int connectTimeout, int readTimeout, int maxRetries, TextCallback callback) {
|
||||
this.url = url;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.connectTimeout = connectTimeout;
|
||||
this.readTimeout = readTimeout;
|
||||
this.maxRetries = maxRetries;
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LogUtils.d(TAG, String.format("run() url %s\nusername %s\npassword %s", url, username, password));
|
||||
String credential = Credentials.basic(username, password);
|
||||
LogUtils.d(TAG, String.format("credential %s", credential));
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.header("Accept", "text/plain")
|
||||
.header("Authorization", credential)
|
||||
.build();
|
||||
|
||||
Call call = client.newCall(request);
|
||||
call.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
// 优先调用自定义回调
|
||||
if (callback != null) {
|
||||
callback.onFailure(e);
|
||||
} else {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
if (!response.isSuccessful()) {
|
||||
if (callback != null) {
|
||||
callback.onFailure(new Exception("Unexpected code " + response));
|
||||
} else {
|
||||
LogUtils.d(TAG, "Unexpected code " + response, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
String text = response.body().string();
|
||||
// 优先调用自定义回调
|
||||
if (callback != null) {
|
||||
callback.onSuccess(text);
|
||||
} else {
|
||||
LogUtils.d(TAG, text);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (callback != null) {
|
||||
callback.onFailure(e);
|
||||
} else {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,38 +1,473 @@
|
||||
package cc.winboll.studio.libaes.winboll;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/03 19:14
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/28 17:41:55
|
||||
* @Describe WinBoLL 服务主机连接状态视图
|
||||
*/
|
||||
import cc.winboll.studio.libaes.R;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.libaes.winboll.WinBoLLClientService;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libapputils.utils.PrefUtils;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
//import okhttp3.Authenticator;
|
||||
//import okhttp3.Credentials;
|
||||
//import okhttp3.OkHttpClient;
|
||||
//import okhttp3.Request;
|
||||
//import okhttp3.Response;
|
||||
//import okhttp3.Route;
|
||||
|
||||
public class WinBoLLServiceStatusView extends LinearLayout {
|
||||
|
||||
|
||||
public static final String TAG = "WinBoLLServiceStatusView";
|
||||
|
||||
|
||||
public static final int MSG_CONNECTION_INFO = 0;
|
||||
public static final int MSG_UPDATE_CONNECTION_STATUS = 1;
|
||||
|
||||
static WinBoLLServiceStatusView _WinBoLLServiceStatusView;
|
||||
Context mContext;
|
||||
//boolean mIsConnected;
|
||||
volatile ConnectionThread mConnectionThread;
|
||||
|
||||
String mszServerHost;
|
||||
WinBoLLClientService mWinBoLLService;
|
||||
ImageView mImageView;
|
||||
TextView mTextView;
|
||||
WinBoLLServiceViewHandler mWinBoLLServiceViewHandler;
|
||||
//WebView mWebView;
|
||||
static volatile ConnectionStatus mConnectionStatus;
|
||||
View.OnClickListener mViewOnClickListener;
|
||||
static String _mUserName;
|
||||
static String _mPassword;
|
||||
|
||||
static enum ConnectionStatus {
|
||||
DISCONNECTED,
|
||||
START_CONNECT,
|
||||
CONNECTING,
|
||||
CONNECTED;
|
||||
};
|
||||
|
||||
boolean isBound = false;
|
||||
ServiceConnection connection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
IWinBoLLClientServiceBinder binder = (IWinBoLLClientServiceBinder) service;
|
||||
mWinBoLLService = binder.getService();
|
||||
isBound = true;
|
||||
// 可以在这里调用Service的方法进行通信,比如获取数据
|
||||
mImageView.setBackgroundDrawable(mWinBoLLService.getCurrentStatusIconDrawable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
isBound = false;
|
||||
}
|
||||
};
|
||||
|
||||
public WinBoLLServiceStatusView(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
initView();
|
||||
}
|
||||
|
||||
public WinBoLLServiceStatusView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
initView();
|
||||
}
|
||||
|
||||
public WinBoLLServiceStatusView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
mContext = context;
|
||||
initView();
|
||||
}
|
||||
|
||||
public WinBoLLServiceStatusView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
mContext = context;
|
||||
initView();
|
||||
}
|
||||
|
||||
|
||||
void setServerHost(String szWinBoLLServerHost) {
|
||||
|
||||
ConnectionStatus getConnectionStatus() {
|
||||
return false ?
|
||||
ConnectionStatus.CONNECTED
|
||||
: ConnectionStatus.DISCONNECTED;
|
||||
}
|
||||
|
||||
void initView() {
|
||||
_WinBoLLServiceStatusView = this;
|
||||
|
||||
mImageView = new ImageView(mContext);
|
||||
setImageViewByConnection(mImageView, false);
|
||||
mConnectionStatus = getConnectionStatus();
|
||||
//mIsConnected = false;
|
||||
//mWinBoLLServerHostConnectionStatus = WinBoLLServerHostConnectionStatus.DISCONNECTED;
|
||||
//ToastUtils.show("initView()");
|
||||
|
||||
mViewOnClickListener = new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogUtils.d(TAG, "onClick()");
|
||||
if (mConnectionStatus == ConnectionStatus.CONNECTED) {
|
||||
LogUtils.d(TAG, "Click to stop service.");
|
||||
WinBoLLClientServiceBean bean = WinBoLLClientServiceBean.loadWinBoLLClientServiceBean(mContext);
|
||||
bean.setIsEnable(false);
|
||||
WinBoLLClientServiceBean.saveBean(mContext, bean);
|
||||
Intent intent = new Intent(mContext, WinBoLLClientService.class);
|
||||
mContext.stopService(intent);
|
||||
//stopConnectionThread();
|
||||
mTextView.setText("");
|
||||
setImageViewByConnection(mImageView, false);
|
||||
mConnectionStatus = ConnectionStatus.DISCONNECTED;
|
||||
} else if (mConnectionStatus == ConnectionStatus.DISCONNECTED) {
|
||||
LogUtils.d(TAG, "Click to start service.");
|
||||
WinBoLLClientServiceBean bean = WinBoLLClientServiceBean.loadWinBoLLClientServiceBean(mContext);
|
||||
bean.setIsEnable(true);
|
||||
WinBoLLClientServiceBean.saveBean(mContext, bean);
|
||||
Intent intent = new Intent(mContext, WinBoLLClientService.class);
|
||||
mContext.startService(intent);
|
||||
//startConnectionThread();
|
||||
}
|
||||
}
|
||||
};
|
||||
setOnClickListener(mViewOnClickListener);
|
||||
addView(mImageView);
|
||||
mTextView = new TextView(mContext);
|
||||
mWinBoLLServiceViewHandler = new WinBoLLServiceViewHandler(this);
|
||||
addView(mTextView);
|
||||
/*mWebView = new WebView(mContext);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
|
||||
// 弹出系统基本HTTP验证窗口
|
||||
handler.proceed("username", "password");
|
||||
}
|
||||
});
|
||||
addView(mWebView);*/
|
||||
}
|
||||
|
||||
void checkWinBoLLServerStatusAndUpdateCurrentView() {
|
||||
LogUtils.d(TAG, "checkWinBoLLServerStatusAndUpdateCurrentView()");
|
||||
/*if (getConnectionStatus() == ConnectionStatus.CONNECTED) {
|
||||
mConnectionStatus = ConnectionStatus.CONNECTED;
|
||||
} else {
|
||||
mConnectionStatus = ConnectionStatus.DISCONNECTED;
|
||||
}*/
|
||||
}
|
||||
|
||||
public void setServerHost(String szWinBoLLServerHost) {
|
||||
mszServerHost = szWinBoLLServerHost;
|
||||
}
|
||||
|
||||
public void setAuthInfo(String username, String password) {
|
||||
_mUserName = username;
|
||||
_mPassword = password;
|
||||
}
|
||||
|
||||
void setImageViewByConnection(ImageView imageView, boolean isConnected) {
|
||||
//mIsConnected = isConnected;
|
||||
// 获取vector drawable
|
||||
Drawable drawable = mContext.getDrawable(isConnected ? R.drawable.ic_dev_connected : R.drawable.ic_dev_disconnected);
|
||||
if (drawable != null) {
|
||||
imageView.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
TextCallback apiTextCallback = new TextCallback() {
|
||||
@Override
|
||||
public void onSuccess(String text) {
|
||||
// 处理成功响应
|
||||
LogUtils.d(TAG, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
// 处理失败情况
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
};
|
||||
|
||||
TextCallback cipTextCallback = new TextCallback() {
|
||||
@Override
|
||||
public void onSuccess(String text) {
|
||||
// 处理成功响应
|
||||
LogUtils.d(TAG, text);
|
||||
LogUtils.d(TAG, "Develop Host Connection IP is : " + text);
|
||||
mConnectionStatus = ConnectionStatus.CONNECTED;
|
||||
// 获取当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 定义时间格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
||||
// 按照指定格式格式化时间并输出
|
||||
String formattedDateTime = now.format(formatter);
|
||||
String msg = "ClientIP<" + formattedDateTime + ">: " + text;
|
||||
mWinBoLLServiceViewHandler.postMessageText(msg);
|
||||
mWinBoLLServiceViewHandler.postMessageConnectionStatus(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
// 处理失败情况
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
// 处理网络请求失败
|
||||
setImageViewByConnection(mImageView, false);
|
||||
mWinBoLLServiceViewHandler.postMessageText(e.getMessage());
|
||||
mWinBoLLServiceViewHandler.postMessageConnectionStatus(false);
|
||||
}
|
||||
};
|
||||
|
||||
public void requestAPIWithBasicAuth() {
|
||||
String targetUrl = "https://" + (GlobalApplication.isDebuging() ?"dev.winboll": "winboll") + ".cc/api/"; // 替换为实际测试的URL
|
||||
requestWithBasicAuth(targetUrl, apiTextCallback);
|
||||
}
|
||||
|
||||
public void requestCIPWithBasicAuth() {
|
||||
String targetUrl = mszServerHost + "/cip/?simple=true";
|
||||
requestWithBasicAuth(targetUrl, cipTextCallback);
|
||||
}
|
||||
|
||||
public void requestWithBasicAuth(String targetUrl, TextCallback callback) {
|
||||
String username = "";
|
||||
String password = "";
|
||||
if (GlobalApplication.isDebuging()) {
|
||||
username = PrefUtils.getString(mContext, "metDevUserName", "");
|
||||
password = PrefUtils.getString(mContext, "metDevUserPassword", "");
|
||||
} else {
|
||||
username = "WinBoLL";
|
||||
password = "WinBoLLPowerByZhanGSKen";
|
||||
}
|
||||
|
||||
LogUtils.d(TAG, String.format("Connection Start. targetUrl %s", targetUrl));
|
||||
WinBoLLServerConnectionThread thread = new WinBoLLServerConnectionThread(
|
||||
targetUrl,
|
||||
username,
|
||||
password,
|
||||
cipTextCallback
|
||||
);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
void setAuthInfo(String szDevUserName, String szDevUserPassword) {
|
||||
|
||||
|
||||
/*void requestWithBasicAuth(final WinBoLLServiceViewHandler textViewHandler, String targetUrl, final String username, final String password) {
|
||||
// 用户名和密码,替换为实际的认证信息
|
||||
//String username = "your_username";
|
||||
//String password = "your_password";
|
||||
LogUtils.d(TAG, "requestWithBasicAuth(...)");
|
||||
LogUtils.d(TAG, String.format("targetUrl %s", targetUrl));
|
||||
|
||||
// 构建包含认证信息的请求
|
||||
String credential = Credentials.basic(username, password);
|
||||
LogUtils.d(TAG, String.format("credential %s", credential));
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(targetUrl)
|
||||
.header("Accept", "text/plain") // 设置正确的Content-Type头
|
||||
.header("Authorization", credential)
|
||||
.build();
|
||||
|
||||
Call call = client.newCall(request);
|
||||
call.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
// 处理网络请求失败
|
||||
setImageViewByConnection(mImageView, false);
|
||||
textViewHandler.postMessageText(e.getMessage());
|
||||
textViewHandler.postMessageConnectionStatus(false);
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
//String sz = "请求失败,状态码: " + response.code();
|
||||
//setImageViewByConnection(mImageView, false);
|
||||
//LogUtils.d(TAG, sz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
if (!response.isSuccessful()) {
|
||||
setImageViewByConnection(mImageView, false);
|
||||
textViewHandler.postMessageText("Unexpected code " + response);
|
||||
textViewHandler.postMessageConnectionStatus(false);
|
||||
LogUtils.d(TAG, "Unexpected code " + response, Thread.currentThread().getStackTrace());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 读取响应体作为字符串,注意这里可能需要解码
|
||||
String text = response.body().string();
|
||||
LogUtils.d(TAG, "Develop Host Connection IP is : " + text);
|
||||
mConnectionStatus = ConnectionStatus.CONNECTED;
|
||||
// 获取当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 定义时间格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
||||
// 按照指定格式格式化时间并输出
|
||||
String formattedDateTime = now.format(formatter);
|
||||
textViewHandler.postMessageText("ClientIP<" + formattedDateTime + ">: " + text);
|
||||
textViewHandler.postMessageConnectionStatus(true);
|
||||
|
||||
//org.jsoup.nodes.Document doc = org.jsoup.Jsoup.parse(text);
|
||||
//LogUtils.d(TAG, doc.text());
|
||||
|
||||
// 使用id选择器找到具有特定id的元素
|
||||
//org.jsoup.nodes.Element elementWithId = doc.select("#LastRelease").first(); // 获取第一个匹配的元素
|
||||
|
||||
// 提取并打印元素的文本内容
|
||||
//mszNewestAppPackageName = elementWithId.text();
|
||||
//ToastUtils.delayedShow(text + "\n" + mszNewestAppPackageName, 5000);
|
||||
|
||||
//mHandler.sendMessage(mHandler.obtainMessage(MSG_APPUPDATE_CHECKED));
|
||||
//System.out.println(response.body().string());
|
||||
// mConnectionStatus = ConnectionStatus.CONNECTED;
|
||||
// // 获取当前时间
|
||||
// LocalDateTime now = LocalDateTime.now();
|
||||
//
|
||||
// // 定义时间格式
|
||||
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
||||
// // 按照指定格式格式化时间并输出
|
||||
// String formattedDateTime = now.format(formatter);
|
||||
// //System.out.println(formattedDateTime);
|
||||
// textViewHandler.postMessageText("ClientIP<" + formattedDateTime + ">: " + response.body().string());
|
||||
// textViewHandler.postMessageConnectionStatus(true);
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}*/
|
||||
|
||||
class WinBoLLServiceViewHandler extends Handler {
|
||||
WinBoLLServiceStatusView mDevelopHostConnectionStatusView;
|
||||
|
||||
public WinBoLLServiceViewHandler(WinBoLLServiceStatusView view) {
|
||||
mDevelopHostConnectionStatusView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == MSG_CONNECTION_INFO) {
|
||||
mDevelopHostConnectionStatusView.mTextView.setText((String)msg.obj);
|
||||
} else if (msg.what == MSG_UPDATE_CONNECTION_STATUS) {
|
||||
mDevelopHostConnectionStatusView.setImageViewByConnection(mImageView, (boolean)msg.obj);
|
||||
mDevelopHostConnectionStatusView.mConnectionStatus = ((boolean)msg.obj) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED;
|
||||
}
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
|
||||
void postMessageText(String szMSG) {
|
||||
Message msg = new Message();
|
||||
msg.what = MSG_CONNECTION_INFO;
|
||||
msg.obj = szMSG;
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
void postMessageConnectionStatus(boolean isConnected) {
|
||||
Message msg = new Message();
|
||||
msg.what = MSG_UPDATE_CONNECTION_STATUS;
|
||||
msg.obj = isConnected;
|
||||
sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void startConnection() {
|
||||
if (_WinBoLLServiceStatusView != null) {
|
||||
_WinBoLLServiceStatusView.startConnectionThread();
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopConnection() {
|
||||
if (_WinBoLLServiceStatusView != null) {
|
||||
_WinBoLLServiceStatusView.stopConnectionThread();
|
||||
}
|
||||
}
|
||||
|
||||
void startConnectionThread() {
|
||||
if (mConnectionStatus == ConnectionStatus.DISCONNECTED) {
|
||||
mConnectionStatus = ConnectionStatus.START_CONNECT;
|
||||
LogUtils.d(TAG, "startConnectionThread");
|
||||
if (mConnectionThread != null) {
|
||||
LogUtils.d(TAG, "mConnectionThread != null");
|
||||
mConnectionThread.mIsExist = true;
|
||||
}
|
||||
mConnectionThread = new ConnectionThread();
|
||||
mConnectionThread.start();
|
||||
} else if (mConnectionStatus == ConnectionStatus.CONNECTING) {
|
||||
//LogUtils.d(TAG, "mConnectionStatus == ConnectionStatus.CONNECTING");
|
||||
} else if (mConnectionStatus == ConnectionStatus.CONNECTED) {
|
||||
//LogUtils.d(TAG, "mConnectionStatus == ConnectionStatus.CONNECTED");
|
||||
} else {
|
||||
LogUtils.d(TAG, String.format("Unknow mConnectionStatus %s, can not start ConnectionThread.", mConnectionStatus));
|
||||
}
|
||||
}
|
||||
|
||||
void stopConnectionThread() {
|
||||
LogUtils.d(TAG, "stopConnectionThread");
|
||||
if (mConnectionThread != null) {
|
||||
LogUtils.d(TAG, "mConnectionThread != null");
|
||||
mConnectionThread.mIsExist = true;
|
||||
mConnectionThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class ConnectionThread extends Thread {
|
||||
|
||||
public volatile boolean mIsExist;
|
||||
|
||||
//DevelopHostConnectionStatusViewHandler mDevelopHostConnectionStatusViewHandler;
|
||||
|
||||
//public ConnectionThread(DevelopHostConnectionStatusViewHandler developHostConnectionStatusViewHandler) {
|
||||
//mDevelopHostConnectionStatusViewHandler = developHostConnectionStatusViewHandler;
|
||||
//}
|
||||
public ConnectionThread() {
|
||||
mIsExist = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
while (mIsExist == false) {
|
||||
if (mConnectionStatus == ConnectionStatus.START_CONNECT) {
|
||||
mConnectionStatus = ConnectionStatus.CONNECTING;
|
||||
//requestAPIWithBasicAuth();
|
||||
requestCIPWithBasicAuth();
|
||||
} else if (mConnectionStatus == ConnectionStatus.CONNECTED
|
||||
|| mConnectionStatus == ConnectionStatus.DISCONNECTED) {
|
||||
//ToastUtils.show("mWinBoLLServerHostConnectionStatus " + mConnectionStatus);
|
||||
LogUtils.d(TAG, String.format("mConnectionStatus done %s", mConnectionStatus));
|
||||
} else {
|
||||
LogUtils.d(TAG, String.format("mConnectionStatus unknow %s", mConnectionStatus));
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(5 * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
//ToastUtils.show("ConnectionThread exit.");
|
||||
LogUtils.d(TAG, "ConnectionThread exit.");
|
||||
}
|
||||
}
|
||||
|
||||
/*WinBoLLService.OnServiceStatusChangeListener mOnServerStatusChangeListener = new WinBoLLService.OnServiceStatusChangeListener(){
|
||||
@Override
|
||||
public void onServerStatusChange(boolean isServiceAlive) {
|
||||
}
|
||||
};*/
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sat May 03 10:32:21 GMT 2025
|
||||
#Tue Apr 29 14:47:16 HKT 2025
|
||||
stageCount=7
|
||||
libraryProject=libappbase
|
||||
baseVersion=15.7
|
||||
publishVersion=15.7.6
|
||||
buildCount=4
|
||||
buildCount=0
|
||||
baseBetaVersion=15.7.7
|
||||
|
@@ -0,0 +1,39 @@
|
||||
package cc.winboll.studio.libappbase.sos;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/02 09:54:28
|
||||
* @Describe WinBoLL 系列应用通用管理类
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
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_APPMODEL";
|
||||
|
||||
public static void bindToAPPBase(Context context, String appMainService) {
|
||||
LogUtils.d(TAG, "bindToAPPBase(...)");
|
||||
String toPackage = "cc.winboll.studio.appbase";
|
||||
startBind(context, toPackage, appMainService);
|
||||
}
|
||||
|
||||
public static void bindToAPPBaseBeta(Context context, String appMainService) {
|
||||
LogUtils.d(TAG, "bindToAPPBaseBeta(...)");
|
||||
String toPackage = "cc.winboll.studio.appbase.beta";
|
||||
startBind(context, toPackage, appMainService);
|
||||
}
|
||||
|
||||
static void startBind(Context context, String toPackage, String appMainService) {
|
||||
Intent intent = new Intent(ACTION_BIND);
|
||||
intent.putExtra(EXTRA_APPMODEL, (new APPModel(toPackage, appMainService)).toString());
|
||||
intent.setPackage(toPackage);
|
||||
LogUtils.d(TAG, String.format("ACTION_BIND :\nTo Package : %s\nAPP Main Service : %s", toPackage, appMainService));
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package cc.winboll.studio.libappbase.winboll;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/24 08:23:40
|
||||
* @Describe WinBoLL 活动窗口通用接口
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.widget.Toolbar;
|
||||
|
||||
public interface IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "IWinBoLLActivity";
|
||||
|
||||
// 获取活动窗口
|
||||
abstract public Activity getActivity();
|
||||
abstract public String getTag();
|
||||
}
|
@@ -0,0 +1,356 @@
|
||||
package cc.winboll.studio.libappbase.winboll;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/24 08:25:43
|
||||
* @Describe 应用活动窗口管理器
|
||||
* 参考 :
|
||||
* android 类似微信小程序多任务窗口 及 设置 TaskDescription 修改 icon 和 label
|
||||
* https://blog.csdn.net/qq_29364417/article/details/109379915?app_version=6.4.2&code=app_1562916241&csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22109379915%22%2C%22source%22%3A%22weixin_38986226%22%7D&uLinkId=usr1mkqgl919blen&utm_source=app
|
||||
*/
|
||||
import android.app.ActivityManager;
|
||||
import android.app.TaskStackBuilder;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class WinBoLLActivityManager {
|
||||
|
||||
public static final String TAG = "WinBoLLActivityManager";
|
||||
public static final String EXTRA_TAG = "EXTRA_TAG";
|
||||
|
||||
public static enum WinBoLLUI_TYPE {
|
||||
Aplication, // 退出应用后,保持最近任务栏任务记录主窗口
|
||||
Service // 退出应用后,清理所有最近任务栏任务记录窗口
|
||||
};
|
||||
|
||||
// 应用类型标志
|
||||
static volatile WinBoLLUI_TYPE _mWinBoLLUI_TYPE = WinBoLLUI_TYPE.Service;
|
||||
|
||||
GlobalApplication mGlobalApplication;
|
||||
static volatile WinBoLLActivityManager _Instance;
|
||||
static volatile Map<String, IWinBoLLActivity> _mapIWinBoLLList;
|
||||
volatile IWinBoLLActivity mFirstIWinBoLLActivity;
|
||||
|
||||
WinBoLLActivityManager(GlobalApplication application) {
|
||||
mGlobalApplication = application;
|
||||
_mapIWinBoLLList = new HashMap<String, IWinBoLLActivity>();
|
||||
}
|
||||
|
||||
public static synchronized WinBoLLActivityManager getInstance(GlobalApplication application) {
|
||||
LogUtils.d(TAG, "getInstance");
|
||||
if (_Instance == null) {
|
||||
LogUtils.d(TAG, "_Instance == null");
|
||||
_Instance = new WinBoLLActivityManager(application);
|
||||
}
|
||||
return _Instance;
|
||||
}
|
||||
|
||||
//
|
||||
// 设置 WinBoLL 应用 UI 类型
|
||||
//
|
||||
public synchronized static void setWinBoLLUI_TYPE(WinBoLLUI_TYPE mWinBoLLUI_TYPE) {
|
||||
_mWinBoLLUI_TYPE = mWinBoLLUI_TYPE;
|
||||
}
|
||||
|
||||
//
|
||||
// 获取 WinBoLL 应用 UI 类型
|
||||
//
|
||||
public synchronized static WinBoLLUI_TYPE getWinBoLLUI_TYPE() {
|
||||
return _mWinBoLLUI_TYPE;
|
||||
}
|
||||
|
||||
//
|
||||
// 把Activity添加到管理中
|
||||
//
|
||||
public <T extends IWinBoLLActivity> void add(T iWinBoLL) {
|
||||
String tag = ((IWinBoLLActivity)iWinBoLL).getTag();
|
||||
LogUtils.d(TAG, String.format("add(T iWinBoLL) tag is %s", tag));
|
||||
if (isActive(tag)) {
|
||||
LogUtils.d(TAG, String.format("isActive(tag) is true, tag : %s.", tag));
|
||||
} else {
|
||||
// 设置起始活动窗口,以便最后退出时提问
|
||||
if (mFirstIWinBoLLActivity == null && _mapIWinBoLLList.size() == 0) {
|
||||
LogUtils.d(TAG, "Set firstIWinBoLLActivity, iWinBoLL.getTag() is %s" + iWinBoLL.getTag());
|
||||
mFirstIWinBoLLActivity = iWinBoLL;
|
||||
}
|
||||
|
||||
// 添加到活动窗口列表
|
||||
_mapIWinBoLLList.put(iWinBoLL.getTag(), iWinBoLL);
|
||||
LogUtils.d(TAG, String.format("Add activity : %s\n_mapActivityList.size() : %d", iWinBoLL.getTag(), _mapIWinBoLLList.size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// activity: 为 null 时,
|
||||
// intent.putExtra 函数 EXTRA_TAG 参数为 tag
|
||||
// activity: 不为 null 时,
|
||||
// intent.putExtra 函数 "tag" 参数为 activity.getTag()
|
||||
//
|
||||
public <T extends IWinBoLLActivity> void startWinBoLLActivity(Context context, Class<T> clazz) {
|
||||
try {
|
||||
// 如果窗口已存在就重启窗口
|
||||
String tag = ((IWinBoLLActivity)clazz.newInstance()).getTag();
|
||||
LogUtils.d(TAG, String.format("startWinBoLLActivity(Context context, Class<T> clazz) tag is %s", tag));
|
||||
if (isActive(tag)) {
|
||||
resumeActivity(context, tag);
|
||||
return;
|
||||
}
|
||||
//ToastUtils.show("startWinBoLLActivity(Context context, Class<T> clazz)");
|
||||
|
||||
// 新建一个任务窗口
|
||||
Intent intent = new Intent(context, clazz);
|
||||
//打开多任务窗口 flags
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(EXTRA_TAG, tag);
|
||||
context.startActivity(intent);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends IWinBoLLActivity> void startWinBoLLActivity(Context context, Intent intent, Class<T> clazz) {
|
||||
try {
|
||||
// 如果窗口已存在就重启窗口
|
||||
String tag = ((IWinBoLLActivity)clazz.newInstance()).getTag();
|
||||
LogUtils.d(TAG, String.format("startWinBoLLActivity(Context context, Intent intent, Class<T> clazz) tag is %s", tag));
|
||||
if (isActive(tag)) {
|
||||
resumeActivity(context, tag);
|
||||
return;
|
||||
}
|
||||
|
||||
// 新建一个任务窗口
|
||||
//Intent intent = new Intent(context, clazz);
|
||||
//打开多任务窗口 flags
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(EXTRA_TAG, tag);
|
||||
context.startActivity(intent);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends IWinBoLLActivity> void startLogActivity(Context context) {
|
||||
// 如果窗口已存在就重启窗口
|
||||
String tag = LogActivity.TAG;
|
||||
if (isActive(tag)) {
|
||||
resumeActivity(context, tag);
|
||||
return;
|
||||
}
|
||||
|
||||
// 新建一个任务窗口
|
||||
Intent intent = new Intent(context, LogActivity.class);
|
||||
//打开多任务窗口 flags
|
||||
// Define the bounds.
|
||||
// Rect bounds = new Rect(0, 0, 800, 200);
|
||||
// // Set the bounds as an activity option.
|
||||
// ActivityOptions options = ActivityOptions.makeBasic();
|
||||
// options.setLaunchBounds(bounds);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
|
||||
intent.putExtra(EXTRA_TAG, tag);
|
||||
|
||||
//context.startActivity(intent, options.toBundle());
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public boolean isFirstIWinBoLLActivity(IWinBoLLActivity iWinBoLLActivity) {
|
||||
return mFirstIWinBoLLActivity != null && mFirstIWinBoLLActivity == iWinBoLLActivity;
|
||||
}
|
||||
|
||||
//
|
||||
// 判断 tag绑定的 MyActivity是否存在
|
||||
//
|
||||
public boolean isActive(String tag) {
|
||||
LogUtils.d(TAG, String.format("isActive(String tag) tag is %s", tag));
|
||||
//printIWinBoLLListInfo();
|
||||
IWinBoLLActivity iWinBoLL = getIWinBoLL(tag);
|
||||
if (iWinBoLL != null) {
|
||||
//LogUtils.d(TAG, "isActive(...) activity != null tag " + tag);
|
||||
//ToastUtils.show("activity != null tag " + tag);
|
||||
//判断是否为 BaseActivity,如果已经销毁,则移除
|
||||
if (iWinBoLL.getActivity().isFinishing() || iWinBoLL.getActivity().isDestroyed()) {
|
||||
_mapIWinBoLLList.remove(iWinBoLL.getTag());
|
||||
//_mWinBoLLActivityList.remove(activity);
|
||||
LogUtils.d(TAG, String.format("isActive(...) remove activity.\ntag : %s", tag));
|
||||
return false;
|
||||
} else {
|
||||
LogUtils.d(TAG, String.format("isActive(...) activity is exist.\ntag : %s", tag));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
LogUtils.d(TAG, String.format("isActive(...) iWinBoLL is null tag by %s", tag));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static IWinBoLLActivity getIWinBoLL(String tag) {
|
||||
LogUtils.d(TAG, String.format("getIWinBoLL(String tag) %s", tag));
|
||||
return _mapIWinBoLLList.get(tag);
|
||||
}
|
||||
|
||||
//
|
||||
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||
//
|
||||
public <T extends IWinBoLLActivity> void resumeActivity(Context context, String tag) {
|
||||
LogUtils.d(TAG, "resumeActivity(Context context, String tag)");
|
||||
T iWinBoLL = (T)getIWinBoLL(tag);
|
||||
LogUtils.d(TAG, String.format("iWinBoLL.getTag() %s", iWinBoLL.getTag()));
|
||||
//LogUtils.d(TAG, "activity " + activity.getTag());
|
||||
if (iWinBoLL != null && !iWinBoLL.getActivity().isFinishing() && !iWinBoLL.getActivity().isDestroyed()) {
|
||||
resumeActivity(context, iWinBoLL);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||
//
|
||||
public <T extends IWinBoLLActivity> void resumeActivity(Context context, T iWinBoLL) {
|
||||
LogUtils.d(TAG, "resumeActivity(Context context, T iWinBoLL)");
|
||||
ActivityManager am = (ActivityManager) mGlobalApplication.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
//返回启动它的根任务(home 或者 MainActivity)
|
||||
Intent intent = new Intent(mGlobalApplication, iWinBoLL.getClass());
|
||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mGlobalApplication);
|
||||
stackBuilder.addNextIntentWithParentStack(intent);
|
||||
stackBuilder.startActivities();
|
||||
//moveTaskToFront(YourTaskId, 0);
|
||||
//ToastUtils.show("resumeActivity am.moveTaskToFront");
|
||||
LogUtils.d(TAG, String.format("iWinBoLL.getActivity().getTaskId() %d", iWinBoLL.getActivity().getTaskId()));
|
||||
am.moveTaskToFront(iWinBoLL.getActivity().getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION);
|
||||
LogUtils.d(TAG, "am.moveTaskToFront");
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 结束所有 Activity
|
||||
//
|
||||
public void finishAll() {
|
||||
try {
|
||||
for (String key : _mapIWinBoLLList.keySet()) {
|
||||
//System.out.println("Key: " + key + ", Value: " + _mapActivityList.get(key));
|
||||
IWinBoLLActivity iWinBoLL = _mapIWinBoLLList.get(key);
|
||||
//ToastUtils.show("finishAll() activity");
|
||||
if (iWinBoLL != null && !iWinBoLL.getActivity().isFinishing() && !iWinBoLL.getActivity().isDestroyed()) {
|
||||
//ToastUtils.show("activity != null ...");
|
||||
if (getWinBoLLUI_TYPE() == WinBoLLUI_TYPE.Service) {
|
||||
// 结束窗口和最近任务栏, 建议前台服务类应用使用,可以方便用户再次调用 UI 操作。
|
||||
iWinBoLL.getActivity().finishAndRemoveTask();
|
||||
//ToastUtils.show("finishAll() activity.finishAndRemoveTask();");
|
||||
} else if (getWinBoLLUI_TYPE() == WinBoLLUI_TYPE.Aplication) {
|
||||
// 结束窗口保留最近任务栏,建议前台服务类应用使用,可以保持应用的系统自觉性。
|
||||
iWinBoLL.getActivity().finish();
|
||||
//ToastUtils.show("finishAll() activity.finish();");
|
||||
} else {
|
||||
LogUtils.d(TAG, "WinBoLLApplication.WinBoLLUI_TYPE error.");
|
||||
//ToastUtils.show("WinBoLLApplication.WinBoLLUI_TYPE error.");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 结束指定Activity
|
||||
//
|
||||
public <T extends IWinBoLLActivity> void finish(T iWinBoLL) {
|
||||
try {
|
||||
if (iWinBoLL != null && !iWinBoLL.getActivity().isFinishing() && !iWinBoLL.getActivity().isDestroyed()) {
|
||||
//根据tag 移除 MyActivity
|
||||
//String tag= activity.getTag();
|
||||
//_mWinBoLLActivityList.remove(tag);
|
||||
//ToastUtils.show("remove");
|
||||
//ToastUtils.show("_mWinBoLLActivityArrayMap.size() " + Integer.toString(_mWinBoLLActivityArrayMap.size()));
|
||||
|
||||
// 窗口回调规则:
|
||||
// [] 当前窗口位置 >> 调度出的窗口位置
|
||||
// ★:[0] 1 2 3 4 >> 1
|
||||
// ★:0 1 [2] 3 4 >> 1
|
||||
// ★:0 1 2 [3] 4 >> 2
|
||||
// ★:0 1 2 3 [4] >> 3
|
||||
// ★:[0] >> 直接关闭当前窗口
|
||||
//LogUtils.d(TAG, "finish no yet.");
|
||||
IWinBoLLActivity preIWinBoLL = getPreIWinBoLL(iWinBoLL);
|
||||
iWinBoLL.getActivity().finish();
|
||||
if (preIWinBoLL != null) {
|
||||
resumeActivity(mGlobalApplication, preIWinBoLL);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 获取窗口队列中的前一个窗口
|
||||
//
|
||||
IWinBoLLActivity getPreIWinBoLL(IWinBoLLActivity iWinBoLL) {
|
||||
try {
|
||||
boolean bingo = false;
|
||||
IWinBoLLActivity preIWinBoLL = null;
|
||||
for (Map.Entry<String, IWinBoLLActivity> entity : _mapIWinBoLLList.entrySet()) {
|
||||
if (entity.getKey().equals(iWinBoLL.getTag())) {
|
||||
bingo = true;
|
||||
//LogUtils.d(TAG, "bingo");
|
||||
break;
|
||||
}
|
||||
preIWinBoLL = entity.getValue();
|
||||
}
|
||||
|
||||
if (bingo) {
|
||||
return preIWinBoLL;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// 从管理列表中移除管理项
|
||||
//
|
||||
public <T extends IWinBoLLActivity> boolean registeRemove(T activity) {
|
||||
IWinBoLLActivity iWinBoLLTest = _mapIWinBoLLList.get(activity.getTag());
|
||||
if (iWinBoLLTest != null) {
|
||||
_mapIWinBoLLList.remove(activity.getTag());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// 打印管理列表项列表里的信息
|
||||
//
|
||||
public static void printIWinBoLLListInfo() {
|
||||
//LogUtils.d(TAG, "printAvtivityListInfo");
|
||||
if (!_mapIWinBoLLList.isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder("Map entries : " + Integer.toString(_mapIWinBoLLList.size()));
|
||||
Iterator<Map.Entry<String, IWinBoLLActivity>> iterator = _mapIWinBoLLList.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, IWinBoLLActivity> entry = iterator.next();
|
||||
sb.append("\nKey: " + entry.getKey() + ", \nValue: " + entry.getValue().getTag());
|
||||
//ToastUtils.show("\nKey: " + entry.getKey() + ", Value: " + entry.getValue().getTag());
|
||||
}
|
||||
sb.append("\nMap entries end.");
|
||||
LogUtils.d(TAG, sb.toString());
|
||||
} else {
|
||||
LogUtils.d(TAG, "The map is empty.");
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,7 +21,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
api 'cc.winboll.studio:libappbase:15.7.6'
|
||||
api 'cc.winboll.studio:libappbase:15.8.0'
|
||||
|
||||
// 二维码类库
|
||||
api 'com.google.zxing:core:3.4.1'
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Apr 29 15:03:54 HKT 2025
|
||||
stageCount=5
|
||||
#Tue May 13 11:09:58 HKT 2025
|
||||
stageCount=1
|
||||
libraryProject=libapputils
|
||||
baseVersion=15.3
|
||||
publishVersion=15.3.4
|
||||
baseVersion=15.8
|
||||
publishVersion=15.8.0
|
||||
buildCount=0
|
||||
baseBetaVersion=15.3.5
|
||||
baseBetaVersion=15.8.1
|
||||
|
@@ -19,7 +19,7 @@ def genVersionName(def versionName){
|
||||
|
||||
android {
|
||||
compileSdkVersion 32
|
||||
buildToolsVersion "32.0.0"
|
||||
buildToolsVersion "33.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "cc.winboll.studio.powerbell"
|
||||
@@ -29,7 +29,7 @@ android {
|
||||
// versionName 更新后需要手动设置
|
||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "15.3"
|
||||
versionName "4.0"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
@@ -41,39 +41,17 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
api 'cc.winboll.studio:libaes:15.6.0'
|
||||
api 'cc.winboll.studio:libapputils:15.3.4'
|
||||
api 'cc.winboll.studio:libappbase:15.7.6'
|
||||
|
||||
// 吐司提示库
|
||||
api 'cc.winboll.studio:winboll-shared:1.8.0'
|
||||
api 'io.github.medyo:android-about-page:2.0.0'
|
||||
api 'com.github.getActivity:ToastUtils:10.5'
|
||||
// 应用介绍页类库
|
||||
api 'io.github.medyo:android-about-page:2.0.0'
|
||||
// SSH
|
||||
api 'com.jcraft:jsch:0.1.55'
|
||||
// Html 解析
|
||||
api 'org.jsoup:jsoup:1.13.1'
|
||||
// 二维码类库
|
||||
api 'com.google.zxing:core:3.4.1'
|
||||
api 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||
// 网络连接类库
|
||||
api 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
|
||||
// AndroidX 类库
|
||||
api 'androidx.appcompat:appcompat:1.1.0'
|
||||
api 'com.google.android.material:material:1.4.0'
|
||||
//api 'androidx.viewpager:viewpager:1.0.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
//api 'androidx.fragment:fragment:1.1.0'
|
||||
|
||||
|
||||
/*api 'cc.winboll.studio:winboll-shared:1.8.0'
|
||||
api 'io.github.medyo:android-about-page:2.0.0'
|
||||
api 'com.jcraft:jsch:0.1.55'
|
||||
api 'org.jsoup:jsoup:1.13.1'
|
||||
api 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
@@ -89,5 +67,6 @@ dependencies {
|
||||
api 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
|
||||
api 'cc.winboll.studio:libaes:7.6.0'
|
||||
*/
|
||||
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sat May 03 06:21:11 GMT 2025
|
||||
stageCount=1
|
||||
#Thu Jan 02 11:13:45 HKT 2025
|
||||
stageCount=6
|
||||
libraryProject=
|
||||
baseVersion=15.3
|
||||
publishVersion=15.3.0
|
||||
buildCount=5
|
||||
baseBetaVersion=15.3.1
|
||||
baseVersion=4.0
|
||||
publishVersion=4.0.5
|
||||
buildCount=0
|
||||
baseBetaVersion=4.0.6
|
||||
|
@@ -6,18 +6,20 @@
|
||||
tools:replace="android:icon"
|
||||
android:icon="@drawable/ic_launcher_beta">
|
||||
|
||||
<!-- Put flavor specific code here -->
|
||||
<provider
|
||||
tools:replace="android:authorities"
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="cc.winboll.studio.powerbell.beta.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
|
||||
<meta-data
|
||||
tools:replace="android:resource"
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_provider"/>
|
||||
|
||||
</provider>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
@@ -2,9 +2,10 @@
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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"/>
|
||||
@@ -21,15 +22,8 @@
|
||||
<!-- 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"/>
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:name=".GlobalApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
@@ -40,8 +34,7 @@
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:exported="true">
|
||||
android:launchMode="singleTask">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
@@ -117,8 +110,6 @@
|
||||
android:name="android.max_aspect"
|
||||
android:value="4.0"/>
|
||||
|
||||
<activity android:name="cc.winboll.studio.powerbell.activities.BatteryReporterActivity"/>
|
||||
|
||||
<activity android:name="cc.winboll.studio.powerbell.activities.AboutActivity"/>
|
||||
|
||||
</application>
|
||||
|
@@ -2,14 +2,14 @@ package cc.winboll.studio.powerbell;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.powerbell.receivers.GlobalApplicationReceiver;
|
||||
import cc.winboll.studio.powerbell.utils.AppCacheUtils;
|
||||
import cc.winboll.studio.powerbell.utils.AppConfigUtils;
|
||||
import cc.winboll.studio.shared.app.WinBollApplication;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.io.File;
|
||||
import com.hjq.toast.style.WhiteToastStyle;
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
public class GlobalApplication extends WinBollApplication {
|
||||
|
||||
public static final String TAG = "GlobalApplication";
|
||||
|
||||
@@ -17,29 +17,16 @@ public class App extends GlobalApplication {
|
||||
static AppConfigUtils _mAppConfigUtils;
|
||||
static AppCacheUtils _mAppCacheUtils;
|
||||
GlobalApplicationReceiver mReceiver;
|
||||
static String szTempDir = "";
|
||||
|
||||
public static String getTempDirPath() {
|
||||
return szTempDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
// 初始化临时文件夹目录
|
||||
File fTempDir = new File(getExternalCacheDir(), "TempDir");
|
||||
if(!fTempDir.exists()) {
|
||||
fTempDir.mkdirs();
|
||||
}
|
||||
szTempDir = fTempDir.getAbsolutePath();
|
||||
|
||||
|
||||
// 初始化 Toast 框架
|
||||
ToastUtils.init(this);
|
||||
// 设置 Toast 布局样式
|
||||
//ToastUtils.setView(R.layout.toast_custom_view);
|
||||
//ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
|
||||
|
||||
// 设置数据配置存储工具
|
@@ -12,14 +12,14 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libaes.views.AToolbar;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import cc.winboll.studio.powerbell.MainActivity;
|
||||
import cc.winboll.studio.powerbell.activities.AboutActivity;
|
||||
import cc.winboll.studio.powerbell.activities.BackgroundPictureActivity;
|
||||
import cc.winboll.studio.powerbell.activities.BatteryReporterActivity;
|
||||
import cc.winboll.studio.powerbell.activities.ClearRecordActivity;
|
||||
import cc.winboll.studio.powerbell.fragments.MainViewFragment;
|
||||
import cc.winboll.studio.powerbell.utils.NotificationUtils;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import cc.winboll.studio.shared.log.LogView;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
public static final String TAG = "MainActivity";
|
||||
@@ -28,7 +28,7 @@ public class MainActivity extends Activity {
|
||||
public static MainActivity _mMainActivity;
|
||||
LogView mLogView;
|
||||
//ArrayList<Fragment> mlistFragment;
|
||||
App mApplication;
|
||||
GlobalApplication mApplication;
|
||||
//AppConfigUtils mAppConfigUtils;
|
||||
Menu mMenu;
|
||||
Fragment mCurrentShowFragment;
|
||||
@@ -48,13 +48,12 @@ public class MainActivity extends Activity {
|
||||
mLogView.updateLogView();
|
||||
|
||||
_mMainActivity = MainActivity.this;
|
||||
mApplication = (App) getApplication();
|
||||
mApplication = (GlobalApplication) getApplication();
|
||||
//mAppConfigUtils = AppConfigUtils.getInstance(mApplication);
|
||||
|
||||
// 初始化工具栏
|
||||
mAToolbar = (AToolbar) findViewById(R.id.toolbar);
|
||||
setActionBar(mAToolbar);
|
||||
//mAToolbar.setSubtitle("Main");
|
||||
mAToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
|
||||
|
||||
if (mMainViewFragment == null) {
|
||||
@@ -65,10 +64,8 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
showFragment(mMainViewFragment);
|
||||
|
||||
// NotificationHelper notificationUtils = new NotificationHelper(this);
|
||||
// notificationUtils.createNotificationChannels();
|
||||
|
||||
|
||||
NotificationUtils notificationUtils = new NotificationUtils(this);
|
||||
notificationUtils.createNotificationChannel();
|
||||
}
|
||||
|
||||
void showFragment(Fragment fragment) {
|
||||
@@ -116,7 +113,7 @@ public class MainActivity extends Activity {
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
// 回到窗口自动取消提醒消息
|
||||
//NotificationHelper.cancelRemindNotification(this);
|
||||
NotificationUtils.cancelRemindNotification(this);
|
||||
|
||||
reloadBackground();
|
||||
}
|
||||
@@ -143,11 +140,8 @@ public class MainActivity extends Activity {
|
||||
super.onOptionsItemSelected(item);
|
||||
int menuItemId = item.getItemId();
|
||||
if (menuItemId == R.id.action_about) {
|
||||
Intent intent = new Intent(this, AboutActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (menuItemId == R.id.action_battery_reporter) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(this, BatteryReporterActivity.class);
|
||||
intent.setClass(this, AboutActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (menuItemId == R.id.action_clearrecord) {
|
||||
Intent intent = new Intent();
|
||||
|
@@ -1,65 +1,42 @@
|
||||
package cc.winboll.studio.powerbell.activities;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/25 01:16:32
|
||||
* @Describe 应用介绍窗口
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/07/12 13:33:59
|
||||
* @Describe AboutActivity
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.view.View;
|
||||
import cc.winboll.studio.libaes.views.AToolbar;
|
||||
import cc.winboll.studio.libaes.winboll.APPInfo;
|
||||
import cc.winboll.studio.libaes.winboll.AboutView;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
|
||||
public class AboutActivity extends Activity {
|
||||
|
||||
Context mContext;
|
||||
|
||||
public static final String TAG = "AboutActivity";
|
||||
|
||||
AToolbar mAToolbar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
mContext = this;
|
||||
|
||||
// 初始化工具栏
|
||||
AToolbar mAToolbar = (AToolbar) findViewById(R.id.toolbar);
|
||||
mAToolbar = (AToolbar) findViewById(R.id.toolbar);
|
||||
setActionBar(mAToolbar);
|
||||
//mAToolbar.setTitle(getTitle() + "-" + getString(R.string.subtitle_activity_backgroundpicture));
|
||||
mAToolbar.setSubtitle(R.string.subtitle_activity_about);
|
||||
mAToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
|
||||
mAToolbar.setSubtitleTextAppearance(this, R.style.Toolbar_SubTitleText);
|
||||
//mAToolbar.setBackgroundColor(getColor(R.color.colorPrimary));
|
||||
setActionBar(mAToolbar);
|
||||
mAToolbar.setSubtitle(getString(R.string.text_about));
|
||||
//mAToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
AboutView aboutView = CreateAboutView();
|
||||
// 在 Activity 的 onCreate 或其他生命周期方法中调用
|
||||
LinearLayout llRoot = findViewById(R.id.root_ll);
|
||||
//layout.setOrientation(LinearLayout.VERTICAL);
|
||||
// 创建布局参数(宽度和高度)
|
||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
);
|
||||
llRoot.addView(aboutView, params);
|
||||
|
||||
}
|
||||
|
||||
public AboutView CreateAboutView() {
|
||||
String szBranchName = "powerbell";
|
||||
APPInfo appInfo = new APPInfo();
|
||||
appInfo.setAppName(getString(R.string.app_name));
|
||||
appInfo.setAppIcon(R.drawable.ic_launcher);
|
||||
appInfo.setAppDescription(getString(R.string.app_description));
|
||||
appInfo.setAppGitName("APP");
|
||||
appInfo.setAppGitOwner("Studio");
|
||||
appInfo.setAppGitAPPBranch(szBranchName);
|
||||
appInfo.setAppGitAPPSubProjectFolder(szBranchName);
|
||||
appInfo.setAppHomePage("https://www.winboll.cc/studio/details.php?app=PowerBell");
|
||||
appInfo.setAppAPKName("PowerBell");
|
||||
appInfo.setAppAPKFolderName("PowerBell");
|
||||
return new AboutView(mContext, appInfo);
|
||||
mAToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -7,14 +7,12 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libaes.views.AToolbar;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
|
||||
import cc.winboll.studio.powerbell.App;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import cc.winboll.studio.powerbell.activities.BackgroundPictureActivity;
|
||||
import cc.winboll.studio.powerbell.beans.BackgroundPictureBean;
|
||||
@@ -22,6 +20,8 @@ import cc.winboll.studio.powerbell.dialogs.BackgroundPicturePreviewDialog;
|
||||
import cc.winboll.studio.powerbell.utils.BackgroundPictureUtils;
|
||||
import cc.winboll.studio.powerbell.utils.FileUtils;
|
||||
import cc.winboll.studio.powerbell.utils.UriUtil;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -59,21 +59,18 @@ implements BackgroundPicturePreviewDialog.IOnRecivedPictureListener {
|
||||
static String _mszCommonFileType = "jpeg";
|
||||
// 背景图片的压缩比
|
||||
int mnPictureCompress = 100;
|
||||
static String _RecivedPictureFileName;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_backgroundpicture);
|
||||
initEnv();
|
||||
|
||||
mBackgroundPictureUtils = BackgroundPictureUtils.getInstance(this);
|
||||
mfBackgroundDir = new File(mBackgroundPictureUtils.getBackgroundDir());
|
||||
if (!mfBackgroundDir.exists()) {
|
||||
mfBackgroundDir.mkdirs();
|
||||
}
|
||||
//mfPictureDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), getString(R.string.app_projectname));
|
||||
mfPictureDir = new File(App.getTempDirPath());
|
||||
mfPictureDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), getString(R.string.app_projectname));
|
||||
if (!mfPictureDir.exists()) {
|
||||
mfPictureDir.mkdirs();
|
||||
}
|
||||
@@ -87,8 +84,8 @@ implements BackgroundPicturePreviewDialog.IOnRecivedPictureListener {
|
||||
setActionBar(mAToolbar);
|
||||
//mAToolbar.setTitle(getTitle() + "-" + getString(R.string.subtitle_activity_backgroundpicture));
|
||||
mAToolbar.setSubtitle(R.string.subtitle_activity_backgroundpicture);
|
||||
//mAToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
|
||||
//mAToolbar.setSubtitleTextAppearance(this, R.style.Toolbar_SubTitleText);
|
||||
mAToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
|
||||
mAToolbar.setSubtitleTextAppearance(this, R.style.Toolbar_SubTitleText);
|
||||
//mAToolbar.setBackgroundColor(getColor(R.color.colorPrimary));
|
||||
setActionBar(mAToolbar);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
@@ -133,11 +130,6 @@ implements BackgroundPicturePreviewDialog.IOnRecivedPictureListener {
|
||||
}
|
||||
}
|
||||
|
||||
void initEnv() {
|
||||
LogUtils.d(TAG, "initEnv()");
|
||||
_RecivedPictureFileName = "Recived.data";
|
||||
}
|
||||
|
||||
public static String getBackgroundFileName() {
|
||||
return _mszRecivedCropPicture;
|
||||
}
|
||||
@@ -153,7 +145,7 @@ implements BackgroundPicturePreviewDialog.IOnRecivedPictureListener {
|
||||
// 加载背景
|
||||
startCropImageActivity(false);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 更新预览背景
|
||||
//
|
||||
@@ -338,9 +330,10 @@ implements BackgroundPicturePreviewDialog.IOnRecivedPictureListener {
|
||||
}
|
||||
|
||||
public static File getRecivedPictureFile(Context context) {
|
||||
String szRecivedPictureFileName = "Recived.data";
|
||||
BackgroundPictureUtils utils = BackgroundPictureUtils.getInstance(context);
|
||||
utils.loadBackgroundPictureBean();
|
||||
return new File(utils.getBackgroundDir(), _RecivedPictureFileName);
|
||||
return new File(utils.getBackgroundDir(), szRecivedPictureFileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,51 +0,0 @@
|
||||
package cc.winboll.studio.powerbell.activities;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/22 14:20:15
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import cc.winboll.studio.powerbell.adapters.BatteryAdapter;
|
||||
import cc.winboll.studio.powerbell.beans.BatteryData;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BatteryReporterActivity extends Activity {
|
||||
public static final String TAG = "BatteryReporterActivity";
|
||||
|
||||
private RecyclerView rvBatteryReport;
|
||||
private BatteryAdapter adapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_battery_reporter);
|
||||
|
||||
rvBatteryReport = findViewById(R.id.rvBatteryReport);
|
||||
setupRecyclerView();
|
||||
loadSampleData();
|
||||
}
|
||||
|
||||
private void setupRecyclerView() {
|
||||
adapter = new BatteryAdapter();
|
||||
rvBatteryReport.setLayoutManager(new LinearLayoutManager(this));
|
||||
rvBatteryReport.setAdapter(adapter);
|
||||
rvBatteryReport.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
|
||||
}
|
||||
|
||||
private void loadSampleData() {
|
||||
List<BatteryData> dataList = Arrays.asList(
|
||||
new BatteryData(95, "01:23:45", "00:05:12"),
|
||||
new BatteryData(80, "02:15:30", "00:10:00"),
|
||||
new BatteryData(65, "03:45:15", "00:15:30"),
|
||||
new BatteryData(50, "05:00:00", "00:20:45")
|
||||
);
|
||||
adapter.updateData(dataList);
|
||||
}
|
||||
}
|
||||
|
@@ -7,14 +7,14 @@ import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
|
||||
import cc.winboll.studio.libaes.views.AToolbar;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
|
||||
import cc.winboll.studio.powerbell.App;
|
||||
import cc.winboll.studio.powerbell.GlobalApplication;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import cc.winboll.studio.powerbell.beans.BatteryInfoBean;
|
||||
import cc.winboll.studio.powerbell.receivers.ControlCenterServiceReceiver;
|
||||
import cc.winboll.studio.powerbell.utils.AppCacheUtils;
|
||||
import cc.winboll.studio.powerbell.utils.StringUtils;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ClearRecordActivity extends Activity {
|
||||
@@ -23,21 +23,21 @@ public class ClearRecordActivity extends Activity {
|
||||
|
||||
AToolbar mAToolbar;
|
||||
TextView mtvRecordText;
|
||||
App mApplication;
|
||||
GlobalApplication mApplication;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_clearrecord);
|
||||
mApplication = (App) getApplication();
|
||||
mApplication = (GlobalApplication) getApplication();
|
||||
|
||||
// 初始化工具栏
|
||||
mAToolbar = (AToolbar) findViewById(R.id.toolbar);
|
||||
setActionBar(mAToolbar);
|
||||
//mAToolbar.setTitle(getTitle() + " - " + getString(R.string.subtitle_activity_clearrecord));
|
||||
mAToolbar.setSubtitle(R.string.subtitle_activity_clearrecord);
|
||||
//mAToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
|
||||
//mAToolbar.setSubtitleTextAppearance(this, R.style.Toolbar_SubTitleText);
|
||||
mAToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
|
||||
mAToolbar.setSubtitleTextAppearance(this, R.style.Toolbar_SubTitleText);
|
||||
//mAToolbar.setBackgroundColor(getColor(R.color.colorPrimary));
|
||||
setActionBar(mAToolbar);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
@@ -1,61 +0,0 @@
|
||||
package cc.winboll.studio.powerbell.adapters;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/22 14:38:55
|
||||
* @Describe 电池报告数据适配器
|
||||
*/
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import cc.winboll.studio.powerbell.adapters.BatteryAdapter;
|
||||
import cc.winboll.studio.powerbell.beans.BatteryData;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BatteryAdapter extends RecyclerView.Adapter<BatteryAdapter.ViewHolder> {
|
||||
public static final String TAG = "BatteryAdapter";
|
||||
private List<BatteryData> dataList = new ArrayList<>();
|
||||
|
||||
public void updateData(List<BatteryData> newData) {
|
||||
dataList = newData;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_battery_report, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
BatteryData item = dataList.get(position);
|
||||
holder.tvLevel.setText(String.format("%d%%", item.getCurrentLevel()));
|
||||
holder.tvDischargeTime.setText("使用时间: " + item.getDischargeTime());
|
||||
holder.tvChargeTime.setText("充电时间: " + item.getChargeTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataList.size();
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvLevel;
|
||||
TextView tvDischargeTime;
|
||||
TextView tvChargeTime;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
tvLevel = itemView.findViewById(R.id.tvLevel);
|
||||
tvDischargeTime = itemView.findViewById(R.id.tvDischargeTime);
|
||||
tvChargeTime = itemView.findViewById(R.id.tvChargeTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ package cc.winboll.studio.powerbell.beans;
|
||||
*/
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import cc.winboll.studio.shared.app.BaseBean;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@@ -7,7 +7,7 @@ package cc.winboll.studio.powerbell.beans;
|
||||
*/
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import cc.winboll.studio.shared.app.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
public class BackgroundPictureBean extends BaseBean {
|
||||
|
@@ -1,26 +0,0 @@
|
||||
package cc.winboll.studio.powerbell.beans;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/22 14:30:51
|
||||
* @Describe 电池报告数据模型
|
||||
*/
|
||||
public class BatteryData {
|
||||
|
||||
public static final String TAG = "BatteryData";
|
||||
|
||||
private int currentLevel;
|
||||
private String dischargeTime;
|
||||
private String chargeTime;
|
||||
|
||||
public BatteryData(int currentLevel, String dischargeTime, String chargeTime) {
|
||||
this.currentLevel = currentLevel;
|
||||
this.dischargeTime = dischargeTime;
|
||||
this.chargeTime = chargeTime;
|
||||
}
|
||||
|
||||
public int getCurrentLevel() { return currentLevel; }
|
||||
public String getDischargeTime() { return dischargeTime; }
|
||||
public String getChargeTime() { return chargeTime; }
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package cc.winboll.studio.powerbell.beans;
|
||||
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import cc.winboll.studio.shared.app.BaseBean;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@@ -7,7 +7,7 @@ package cc.winboll.studio.powerbell.beans;
|
||||
*/
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import cc.winboll.studio.shared.app.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ControlCenterServiceBean extends BaseBean {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
package cc.winboll.studio.powerbell.dialogs;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -9,13 +10,12 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.powerbell.MainActivity;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import cc.winboll.studio.powerbell.activities.BackgroundPictureActivity;
|
||||
import cc.winboll.studio.powerbell.utils.BackgroundPictureUtils;
|
||||
import cc.winboll.studio.powerbell.utils.FileUtils;
|
||||
import cc.winboll.studio.powerbell.utils.UriUtil;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -37,8 +37,6 @@ public class BackgroundPicturePreviewDialog extends Dialog {
|
||||
public BackgroundPicturePreviewDialog(Context context) {
|
||||
super(context);
|
||||
setContentView(R.layout.dialog_backgroundpicturepreview);
|
||||
initEnv();
|
||||
|
||||
mContext = context;
|
||||
mBackgroundPictureUtils = ((BackgroundPictureActivity)context).mBackgroundPictureUtils;
|
||||
|
||||
@@ -70,11 +68,6 @@ public class BackgroundPicturePreviewDialog extends Dialog {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void initEnv() {
|
||||
LogUtils.d(TAG, "initEnv()");
|
||||
mszPreReceivedFileName = "PreReceived.data";
|
||||
}
|
||||
|
||||
void copyAndViewRecivePicture(ImageView imageView) {
|
||||
//AppConfigUtils appConfigUtils = AppConfigUtils.getInstance((GlobalApplication)mContext.getApplicationContext());
|
||||
@@ -94,6 +87,7 @@ public class BackgroundPicturePreviewDialog extends Dialog {
|
||||
}
|
||||
|
||||
File fSrcImage = new File(szSrcImage);
|
||||
mszPreReceivedFileName = "PreReceived.data";
|
||||
//mszPreReceivedFileName = DateUtils.getDateNowString() + "-" + fSrcImage.getName();
|
||||
File mfPreReceivedPhoto = new File(activity.mBackgroundPictureUtils.getBackgroundDir(), mszPreReceivedFileName);
|
||||
// 复制源图片到剪裁文件
|
||||
@@ -102,7 +96,7 @@ public class BackgroundPicturePreviewDialog extends Dialog {
|
||||
LogUtils.d(TAG, "copyFileUsingFileChannels");
|
||||
Drawable drawable = Drawable.createFromPath(mfPreReceivedPhoto.getPath());
|
||||
imageView.setBackground(drawable);
|
||||
//LogUtils.d(TAG, "mszPreReceivedFileName : " + mszPreReceivedFileName);
|
||||
LogUtils.d(TAG, "mszPreReceivedFileName : " + mszPreReceivedFileName);
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
|
@@ -17,8 +17,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.powerbell.App;
|
||||
import cc.winboll.studio.powerbell.GlobalApplication;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import cc.winboll.studio.powerbell.activities.BackgroundPictureActivity;
|
||||
import cc.winboll.studio.powerbell.beans.BackgroundPictureBean;
|
||||
@@ -28,11 +27,12 @@ import cc.winboll.studio.powerbell.utils.BackgroundPictureUtils;
|
||||
import cc.winboll.studio.powerbell.utils.ServiceUtils;
|
||||
import cc.winboll.studio.powerbell.views.BatteryDrawable;
|
||||
import cc.winboll.studio.powerbell.views.VerticalSeekBar;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import java.io.File;
|
||||
|
||||
public class MainViewFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "MainViewFragment";
|
||||
public static final String TAG = MainViewFragment.class.getSimpleName();
|
||||
|
||||
public static final int MSG_RELOAD_APPCONFIG = 0;
|
||||
public static final int MSG_CURRENTVALUEBATTERY = 1;
|
||||
@@ -78,7 +78,7 @@ public class MainViewFragment extends Fragment {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
mView = inflater.inflate(R.layout.fragment_mainview, container, false);
|
||||
_mMainViewFragment = MainViewFragment.this;
|
||||
mAppConfigUtils = App.getAppConfigUtils(getActivity());
|
||||
mAppConfigUtils = GlobalApplication.getAppConfigUtils(getActivity());
|
||||
|
||||
// 获取指定ID的View实例
|
||||
final View mainImageView = mView.findViewById(R.id.fragmentmainviewImageView1);
|
||||
@@ -308,7 +308,6 @@ public class MainViewFragment extends Fragment {
|
||||
String szBackgroundFilePath = BackgroundPictureUtils.getInstance(getActivity()).getBackgroundDir() + BackgroundPictureActivity.getBackgroundFileName();
|
||||
File fBackgroundFilePath = new File(szBackgroundFilePath);
|
||||
LogUtils.d(TAG, "szBackgroundFilePath : " + szBackgroundFilePath);
|
||||
LogUtils.d(TAG, String.format("fBackgroundFilePath.exists() %s", fBackgroundFilePath.exists()));
|
||||
if (bean.isUseBackgroundFile() && fBackgroundFilePath.exists()) {
|
||||
Drawable drawableBackground = Drawable.createFromPath(szBackgroundFilePath);
|
||||
drawableBackground.setAlpha(120);
|
||||
|
@@ -4,11 +4,11 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.powerbell.beans.AppConfigBean;
|
||||
import cc.winboll.studio.powerbell.services.ControlCenterService;
|
||||
import cc.winboll.studio.powerbell.utils.AppConfigUtils;
|
||||
import cc.winboll.studio.powerbell.utils.BatteryUtils;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class ControlCenterServiceReceiver extends BroadcastReceiver {
|
||||
@@ -52,13 +52,6 @@ public class ControlCenterServiceReceiver extends BroadcastReceiver {
|
||||
appConfigBean.setCurrentValue(nTheQuantityOfElectricity);
|
||||
appConfigBean.setIsCharging(isCharging);
|
||||
mwrService.get().startRemindThread(appConfigBean);
|
||||
|
||||
// 保存电池报告
|
||||
// 示例数据更新逻辑
|
||||
// List<BatteryData> newData = new ArrayList<>(adapter.getDataList());
|
||||
// newData.add(0, new BatteryData(percentage, "00:00:00", "00:00:00"));
|
||||
// adapter.updateData(newData);
|
||||
|
||||
// 保存好新的电池状态标志
|
||||
_mIsCharging = isCharging;
|
||||
_mnTheQuantityOfElectricityOld = nTheQuantityOfElectricity;
|
||||
|
@@ -4,18 +4,18 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import cc.winboll.studio.powerbell.App;
|
||||
import cc.winboll.studio.powerbell.GlobalApplication;
|
||||
import cc.winboll.studio.powerbell.fragments.MainViewFragment;
|
||||
import cc.winboll.studio.powerbell.utils.AppConfigUtils;
|
||||
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 static final String TAG = "GlobalApplicationReceiver";
|
||||
|
||||
AppConfigUtils mAppConfigUtils;
|
||||
App mGlobalApplication;
|
||||
GlobalApplication mGlobalApplication;
|
||||
// 存储电量指示值,
|
||||
// 用于校验电量消息时的电量变化
|
||||
static volatile int _mnTheQuantityOfElectricityOld = -1;
|
||||
@@ -24,10 +24,10 @@ public class GlobalApplicationReceiver extends BroadcastReceiver {
|
||||
// 便利封装 registerAction() 函数
|
||||
GlobalApplicationReceiver mReceiver;
|
||||
|
||||
public GlobalApplicationReceiver(App globalApplication) {
|
||||
public GlobalApplicationReceiver(GlobalApplication globalApplication) {
|
||||
mReceiver = this;
|
||||
mGlobalApplication = globalApplication;
|
||||
mAppConfigUtils = App.getAppConfigUtils(mGlobalApplication);
|
||||
mAppConfigUtils = GlobalApplication.getAppConfigUtils(mGlobalApplication);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,9 +45,9 @@ public class GlobalApplicationReceiver extends BroadcastReceiver {
|
||||
// 新电池状态标志某一个有变化就更新显示信息
|
||||
if (_mIsCharging != isCharging || _mnTheQuantityOfElectricityOld != nTheQuantityOfElectricity) {
|
||||
// 电池状态改变先取消旧的提醒消息
|
||||
//NotificationHelper.cancelRemindNotification(context);
|
||||
NotificationUtils.cancelRemindNotification(context);
|
||||
|
||||
App.getAppCacheUtils(context).addChangingTime(nTheQuantityOfElectricity);
|
||||
GlobalApplication.getAppCacheUtils(context).addChangingTime(nTheQuantityOfElectricity);
|
||||
MainViewFragment.sendMsgCurrentValueBattery(nTheQuantityOfElectricity);
|
||||
// 保存好新的电池状态标志
|
||||
_mIsCharging = isCharging;
|
||||
|
@@ -9,10 +9,10 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.powerbell.App;
|
||||
import cc.winboll.studio.powerbell.GlobalApplication;
|
||||
import cc.winboll.studio.powerbell.services.ControlCenterService;
|
||||
import cc.winboll.studio.powerbell.utils.ServiceUtils;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
|
||||
public class MainReceiver extends BroadcastReceiver {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class MainReceiver extends BroadcastReceiver {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String szAction = intent.getAction();
|
||||
if (szAction.equals(ACTION_BOOT_COMPLETED)) {
|
||||
boolean isEnableService = App.getAppConfigUtils(context).getIsEnableService();
|
||||
boolean isEnableService = GlobalApplication.getAppConfigUtils(context).getIsEnableService();
|
||||
if (isEnableService) {
|
||||
if (ServiceUtils.isServiceAlive(context.getApplicationContext(), ControlCenterService.class.getName()) == false) {
|
||||
LogUtils.d(TAG, "wakeupAndBindMain() Wakeup... ControlCenterService");
|
||||
|
@@ -6,7 +6,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.powerbell.App;
|
||||
import cc.winboll.studio.powerbell.GlobalApplication;
|
||||
import cc.winboll.studio.powerbell.services.ControlCenterService;
|
||||
import cc.winboll.studio.powerbell.utils.AppConfigUtils;
|
||||
import cc.winboll.studio.powerbell.utils.ServiceUtils;
|
||||
@@ -29,7 +29,7 @@ public class AssistantService extends Service {
|
||||
public void onCreate() {
|
||||
//LogUtils.d(TAG, "onCreate");
|
||||
super.onCreate();
|
||||
mAppConfigUtils = App.getAppConfigUtils(this);
|
||||
mAppConfigUtils = GlobalApplication.getAppConfigUtils(this);
|
||||
|
||||
//mMyBinder = new MyBinder();
|
||||
if (mMyServiceConnection == null) {
|
||||
|
@@ -8,19 +8,14 @@ package cc.winboll.studio.powerbell.services;
|
||||
* Android Service之onStartCommand方法研究
|
||||
* https://blog.csdn.net/cyp331203/article/details/38920491
|
||||
*/
|
||||
import android.app.Notification;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.widget.RemoteViews;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
|
||||
import cc.winboll.studio.powerbell.App;
|
||||
import cc.winboll.studio.powerbell.MainActivity;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import cc.winboll.studio.powerbell.GlobalApplication;
|
||||
import cc.winboll.studio.powerbell.beans.AppConfigBean;
|
||||
import cc.winboll.studio.powerbell.beans.NotificationMessage;
|
||||
import cc.winboll.studio.powerbell.handlers.ControlCenterServiceHandler;
|
||||
@@ -29,11 +24,11 @@ import cc.winboll.studio.powerbell.services.AssistantService;
|
||||
import cc.winboll.studio.powerbell.threads.RemindThread;
|
||||
import cc.winboll.studio.powerbell.utils.AppCacheUtils;
|
||||
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.StringUtils;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
|
||||
public class ControlCenterService extends Service {
|
||||
|
||||
@@ -48,8 +43,7 @@ public class ControlCenterService extends Service {
|
||||
AppConfigUtils mAppConfigUtils;
|
||||
AppCacheUtils mAppCacheUtils;
|
||||
// 前台服务通知工具
|
||||
NotificationHelper mNotificationHelper;
|
||||
Notification notification;
|
||||
NotificationUtils mNotificationUtils;
|
||||
RemindThread mRemindThread;
|
||||
ControlCenterServiceHandler mControlCenterServiceHandler;
|
||||
MyServiceConnection mMyServiceConnection;
|
||||
@@ -70,11 +64,9 @@ public class ControlCenterService extends Service {
|
||||
super.onCreate();
|
||||
_mControlCenterService = ControlCenterService.this;
|
||||
isServiceRunning = false;
|
||||
mAppConfigUtils = App.getAppConfigUtils(this);
|
||||
mAppCacheUtils = App.getAppCacheUtils(this);
|
||||
mNotificationHelper = new NotificationHelper(ControlCenterService.this);
|
||||
|
||||
|
||||
mAppConfigUtils = GlobalApplication.getAppConfigUtils(this);
|
||||
mAppCacheUtils = GlobalApplication.getAppCacheUtils(this);
|
||||
mNotificationUtils = new NotificationUtils(ControlCenterService.this);
|
||||
if (mMyServiceConnection == null) {
|
||||
mMyServiceConnection = new MyServiceConnection();
|
||||
}
|
||||
@@ -100,33 +92,19 @@ public class ControlCenterService extends Service {
|
||||
// 唤醒守护进程
|
||||
wakeupAndBindAssistant();
|
||||
// 显示前台通知栏
|
||||
// 在Service中
|
||||
NotificationHelper helper = new NotificationHelper(this);
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
notification = helper.showForegroundNotification(intent, getString(R.string.app_name), "Service Running, Click to open app");
|
||||
startForeground(NotificationHelper.FOREGROUND_NOTIFICATION_ID, notification);
|
||||
|
||||
// NotificationMessage notificationMessage=createNotificationMessage();
|
||||
// //Toast.makeText(getApplication(), "", Toast.LENGTH_SHORT).show();
|
||||
// mNotificationUtils.createForegroundNotification(this, notificationMessage);
|
||||
// mNotificationUtils.createRemindNotification(this, notificationMessage);
|
||||
NotificationMessage notificationMessage=createNotificationMessage();
|
||||
//Toast.makeText(getApplication(), "", Toast.LENGTH_SHORT).show();
|
||||
mNotificationUtils.createForegroundNotification(this, notificationMessage);
|
||||
mNotificationUtils.createRemindNotification(this, notificationMessage);
|
||||
|
||||
if (mControlCenterServiceReceiver == null) {
|
||||
// 注册广播接收器
|
||||
mControlCenterServiceReceiver = new ControlCenterServiceReceiver(this);
|
||||
mControlCenterServiceReceiver.registerAction(this);
|
||||
}
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
startRemindThread(mAppConfigUtils.mAppConfigBean);
|
||||
ToastUtils.show("Service Is Start.");
|
||||
LogUtils.i(TAG, "Service Is Start.");
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
startRemindThread(mAppConfigUtils.mAppConfigBean);
|
||||
ToastUtils.show("Service Is Start.");
|
||||
LogUtils.i(TAG, "Service Is Start.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +118,7 @@ public class ControlCenterService extends Service {
|
||||
}
|
||||
|
||||
NotificationMessage createNotificationMessage() {
|
||||
String szTitle = ((App)getApplication()).getString(R.string.app_name);
|
||||
String szTitle = ((GlobalApplication)getApplication()).getString(R.string.app_name);
|
||||
String szContent = getValuesString() + " {?} " + StringUtils.formatPCMListString(mAppCacheUtils.getArrayListBatteryInfo());
|
||||
return new NotificationMessage(szTitle, szContent);
|
||||
}
|
||||
@@ -148,19 +126,19 @@ public class ControlCenterService extends Service {
|
||||
// 更新前台通知
|
||||
//
|
||||
public void updateServiceNotification() {
|
||||
//mNotificationUtils.updateForegroundNotification(ControlCenterService.this, createNotificationMessage());
|
||||
mNotificationUtils.updateForegroundNotification(ControlCenterService.this, createNotificationMessage());
|
||||
}
|
||||
|
||||
// 更新前台通知
|
||||
//
|
||||
public void updateServiceNotification(NotificationMessage notificationMessage) {
|
||||
//mNotificationUtils.updateForegroundNotification(ControlCenterService.this, notificationMessage);
|
||||
mNotificationUtils.updateForegroundNotification(ControlCenterService.this, notificationMessage);
|
||||
}
|
||||
|
||||
// 更新前台通知
|
||||
//
|
||||
public void updateRemindNotification(NotificationMessage notificationMessage) {
|
||||
//mNotificationUtils.updateRemindNotification(ControlCenterService.this, notificationMessage);
|
||||
mNotificationUtils.updateRemindNotification(ControlCenterService.this, notificationMessage);
|
||||
}
|
||||
|
||||
// 唤醒和绑定守护进程
|
||||
@@ -256,32 +234,10 @@ public class ControlCenterService extends Service {
|
||||
}
|
||||
|
||||
public void appenRemindMSG(String szRemindMSG) {
|
||||
String msg = "";
|
||||
for (int i = 0; i < 20; i++) {
|
||||
msg += szRemindMSG;
|
||||
}
|
||||
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;
|
||||
NotificationMessage notificationMessage = createNotificationMessage();
|
||||
notificationMessage.setRemindMSG(szRemindMSG);
|
||||
//LogUtils.d(TAG, "notificationMessage : " + notificationMessage.getRemindMSG());
|
||||
updateRemindNotification(notificationMessage);
|
||||
}
|
||||
|
||||
//
|
||||
|
@@ -2,8 +2,8 @@ package cc.winboll.studio.powerbell.threads;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Message;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.powerbell.handlers.ControlCenterServiceHandler;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class RemindThread extends Thread {
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package cc.winboll.studio.powerbell.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.powerbell.beans.BatteryInfoBean;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AppCacheUtils {
|
||||
|
@@ -2,14 +2,14 @@ package cc.winboll.studio.powerbell.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.powerbell.App;
|
||||
import cc.winboll.studio.powerbell.GlobalApplication;
|
||||
import cc.winboll.studio.powerbell.MainActivity;
|
||||
import cc.winboll.studio.powerbell.beans.AppConfigBean;
|
||||
import cc.winboll.studio.powerbell.beans.ControlCenterServiceBean;
|
||||
import cc.winboll.studio.powerbell.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.powerbell.fragments.MainViewFragment;
|
||||
import cc.winboll.studio.powerbell.services.ControlCenterService;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import java.io.File;
|
||||
|
||||
// 应用配置工具类
|
||||
@@ -42,7 +42,7 @@ public class AppConfigUtils {
|
||||
volatile String mszBackgroundFileName = "";
|
||||
|
||||
// 保存应用实例
|
||||
App mApplication;
|
||||
GlobalApplication mApplication;
|
||||
|
||||
AppConfigUtils(Context context) {
|
||||
mContext = context;
|
||||
@@ -193,7 +193,7 @@ public class AppConfigUtils {
|
||||
//
|
||||
void saveConfigData() {
|
||||
// 更新配置先取消一下旧的的提醒消息
|
||||
//NotificationHelper.cancelRemindNotification(mContext);
|
||||
NotificationUtils.cancelRemindNotification(mContext);
|
||||
|
||||
AppConfigBean.saveBean(mContext, mAppConfigBean);
|
||||
// 通知活动窗口和服务配置已更新
|
||||
|
@@ -2,7 +2,7 @@ package cc.winboll.studio.powerbell.utils;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
|
@@ -3,7 +3,7 @@ package cc.winboll.studio.powerbell.utils;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
|
@@ -1,151 +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 + "\n" + content)
|
||||
.setContentTitle(content)
|
||||
//.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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -18,15 +18,14 @@ import android.media.RingtoneManager;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.widget.RemoteViews;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import cc.winboll.studio.powerbell.MainActivity;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import cc.winboll.studio.powerbell.beans.NotificationMessage;
|
||||
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;
|
||||
NotificationManager mNotificationManager;
|
||||
@@ -46,53 +45,19 @@ public class NotificationUtils2 {
|
||||
private static String _mszChannelIDRemind = "2";
|
||||
private static String _mszChannelNameRemind = "Remind";
|
||||
|
||||
// public NotificationUtils(Context context) {
|
||||
// mContext = context;
|
||||
// mNotificationManager = (NotificationManager) context.getSystemService(
|
||||
// Context.NOTIFICATION_SERVICE);
|
||||
// }
|
||||
|
||||
public NotificationUtils2(Context context) {
|
||||
public NotificationUtils(Context context) {
|
||||
mContext = context;
|
||||
mNotificationManager = context.getSystemService(NotificationManager.class);
|
||||
//createNotificationChannels();
|
||||
mNotificationManager = (NotificationManager) context.getSystemService(
|
||||
Context.NOTIFICATION_SERVICE);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public void createNotificationChannels() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
createServiceChannel();
|
||||
createRemindChannel();
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
public void createNotificationChannel() {
|
||||
NotificationChannel channel1 = new NotificationChannel(_mszChannelIDService, _mszChannelNameService, NotificationManager.IMPORTANCE_DEFAULT);
|
||||
channel1.setSound(null, null);
|
||||
mNotificationManager.createNotificationChannel(channel1);
|
||||
NotificationChannel channel2 = new NotificationChannel(_mszChannelIDRemind, _mszChannelNameRemind, NotificationManager.IMPORTANCE_HIGH);
|
||||
channel2.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE), Notification.AUDIO_ATTRIBUTES_DEFAULT);
|
||||
mNotificationManager.createNotificationChannel(channel2);
|
||||
}
|
||||
|
||||
// 创建并发送服务通知
|
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="line">
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#E0E0E0"/>
|
||||
</shape>
|
@@ -6,26 +6,20 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
<cc.winboll.studio.libaes.views.AToolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/DefaultAToolbar"/>
|
||||
|
||||
<cc.winboll.studio.libaes.views.AToolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:id="@+id/toolbar"
|
||||
android:gravity="center_vertical"
|
||||
style="@style/DefaultAToolbar"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0"
|
||||
android:id="@+id/root_ll"/>
|
||||
<cc.winboll.studio.shared.view.AboutView
|
||||
app:appname="PowerBell"
|
||||
app:appprojectname="PowerBell"
|
||||
app:appdescription="@string/app_description"
|
||||
app:appicon="@drawable/ic_launcher"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/activityaboutAboutView1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@@ -26,27 +26,29 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/toolbar">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right">
|
||||
|
||||
<cc.winboll.studio.libaes.views.AButton
|
||||
android:layout_width="160dp"
|
||||
android:layout_width="180dp"
|
||||
android:layout_height="36dp"
|
||||
android:text="Origin BG"
|
||||
android:id="@+id/activitybackgroundpictureAButton5"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_margin="5dp"/>
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_margin="10dp"
|
||||
android:id="@+id/activitybackgroundpictureAButton5"/>
|
||||
|
||||
<cc.winboll.studio.libaes.views.AButton
|
||||
android:layout_width="160dp"
|
||||
android:layout_width="180dp"
|
||||
android:layout_height="36dp"
|
||||
android:text="Received BG"
|
||||
android:id="@+id/activitybackgroundpictureAButton4"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_margin="5dp"/>
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_margin="10dp"
|
||||
android:id="@+id/activitybackgroundpictureAButton4"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
|
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="电池使用报告"
|
||||
android:textSize="24sp"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rvBatteryReport"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:divider="@drawable/divider_line"
|
||||
android:dividerHeight="1dp"/>
|
||||
|
||||
</LinearLayout>
|
@@ -33,10 +33,10 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cc.winboll.studio.libappbase.LogView
|
||||
<cc.winboll.studio.shared.log.LogView
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
android:layout_height="100dp"
|
||||
android:id="@+id/logview"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="12dp"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@android:color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLevel"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:fontFamily="sans-serif-medium"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDischargeTime"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="16sp"
|
||||
android:paddingStart="16dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvChargeTime"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="16sp"
|
||||
android:paddingStart="16dp"/>
|
||||
|
||||
</LinearLayout>
|
@@ -1,8 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_battery_reporter"
|
||||
android:title="@string/item_battery_reporter"/>
|
||||
<item
|
||||
android:id="@+id/action_clearrecord"
|
||||
android:title="@string/item_clearrecord"/>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">能源钟</string>
|
||||
<string name="app_description">一个接收手机电量信息的应用,当电量值达到设定范围时会提醒用户。</string>
|
||||
<string name="app_description">手机电量变化铃声提醒应用。</string>
|
||||
<string name="about_crashed">本应用崩溃了,作者水平有限,敬请谅解!</string>
|
||||
<string name="item_mainview">Main View</string>
|
||||
<string name="item_aboutview">About</string>
|
||||
|
@@ -1,3 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<attr name="appTheme" format="reference"/>
|
||||
<declare-styleable name="AToolbar">
|
||||
<attr name="attrAToolbarStartColor" format="color" />
|
||||
<attr name="attrAToolbarCenterColor" format="color" />
|
||||
<attr name="attrAToolbarEndColor" format="color" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
@@ -25,7 +25,7 @@
|
||||
<color name="colorShuiDark">#FF0072A4</color>
|
||||
<color name="colorShuiAccent">#FF33C1FF</color>
|
||||
<color name="colorXinling">#FFFCC500</color>
|
||||
<color name="colorPrimary">@color/colorShuiDark</color>
|
||||
<color name="colorPrimary">@color/colorShui</color>
|
||||
<color name="colorPrimaryDark">@color/colorFeng</color>
|
||||
<color name="colorAccent">@color/colorShui</color>
|
||||
<color name="colorYellow">#FFFFFF00</color>
|
||||
|
@@ -2,11 +2,10 @@
|
||||
<resources>
|
||||
<string name="app_name">PowerBell</string>
|
||||
<string name="app_projectname">PowerBell</string>
|
||||
<string name="app_description">A mobile app that receives battery level information from a phone and alerts the user when the battery level reaches a predefined range.</string>
|
||||
<string name="app_description">Mobile phone power change ringtone alert app.</string>
|
||||
<string name="about_crashed">This application has crashed, the author level is limited, please understand!</string>
|
||||
<string name="item_mainview">Main View</string>
|
||||
<string name="item_aboutview">About</string>
|
||||
<string name="item_battery_reporter">Battery Reporter</string>
|
||||
<string name="item_clearrecord">Clear Record</string>
|
||||
<string name="item_changepicture">Change Picture</string>
|
||||
<string name="item_devoloperoptionsview">Developer View</string>
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="AppTheme_Base" parent="AESTheme">
|
||||
<style name="AppTheme_Base" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
<style name="AppTheme_Default" parent="AESTheme">
|
||||
<style name="AppTheme_Default" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
@@ -12,7 +12,6 @@
|
||||
</style>
|
||||
|
||||
<style name="DefaultAToolbar">
|
||||
<item name="attrAToolbarTitleTextColor">#FF000000</item>
|
||||
<item name="attrAToolbarStartColor">@color/colorShuiDark</item>
|
||||
<item name="attrAToolbarCenterColor">@color/colorShui</item>
|
||||
<item name="attrAToolbarEndColor">@color/colorShuiAccent</item>
|
||||
|
@@ -4,18 +4,20 @@
|
||||
|
||||
<application>
|
||||
|
||||
<!-- Put flavor specific code here -->
|
||||
<provider
|
||||
tools:replace="android:authorities"
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="cc.winboll.studio.powerbell.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
|
||||
<meta-data
|
||||
tools:replace="android:resource"
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_provider"/>
|
||||
|
||||
</provider>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
@@ -37,10 +37,6 @@
|
||||
//include ':mymessagemanager'
|
||||
//rootProject.name = "mymessagemanager"
|
||||
|
||||
// TimeStamp 项目编译设置
|
||||
//include ':timestamp'
|
||||
//rootProject.name = "timestamp"
|
||||
|
||||
// AndroidDemo 项目编译设置
|
||||
//include ':androiddemo'
|
||||
//rootProject.name = "androiddemo"
|
||||
|
1
timestamp/.gitignore
vendored
1
timestamp/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/build
|
@@ -1,6 +0,0 @@
|
||||
## TimpStamp
|
||||
## 时间戳工具集
|
||||
|
||||
## 使用要点:
|
||||
1。常驻通知栏按钮的正常使用,
|
||||
需要设置允许应用[写入剪贴板]的[始终允许]权限。
|
@@ -1 +0,0 @@
|
||||
|
@@ -1,72 +0,0 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply from: '../.winboll/winboll_app_build.gradle'
|
||||
apply from: '../.winboll/winboll_lint_build.gradle'
|
||||
|
||||
def genVersionName(def versionName){
|
||||
// 检查编译标志位配置
|
||||
assert (winbollBuildProps['stageCount'] != null)
|
||||
assert (winbollBuildProps['baseVersion'] != null)
|
||||
// 保存基础版本号
|
||||
winbollBuildProps.setProperty("baseVersion", "${versionName}");
|
||||
//保存编译标志配置
|
||||
FileOutputStream fos = new FileOutputStream(winbollBuildPropsFile)
|
||||
winbollBuildProps.store(fos, "${winbollBuildPropsDesc}");
|
||||
fos.close();
|
||||
|
||||
// 返回编译版本号
|
||||
return "${versionName}." + winbollBuildProps['stageCount']
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 32
|
||||
buildToolsVersion "32.0.0"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "cc.winboll.studio.timestamp"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
// versionName 更新后需要手动设置
|
||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "15.1"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
api 'cc.winboll.studio:libaes:15.6.0'
|
||||
api 'cc.winboll.studio:libapputils:15.3.4'
|
||||
api 'cc.winboll.studio:libappbase:15.7.6'
|
||||
|
||||
// SSH
|
||||
api 'com.jcraft:jsch:0.1.55'
|
||||
// Html 解析
|
||||
api 'org.jsoup:jsoup:1.13.1'
|
||||
// 二维码类库
|
||||
api 'com.google.zxing:core:3.4.1'
|
||||
api 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||
// 应用介绍页类库
|
||||
api 'io.github.medyo:android-about-page:2.0.0'
|
||||
// 吐司类库
|
||||
api 'com.github.getActivity:ToastUtils:10.5'
|
||||
// 网络连接类库
|
||||
api 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
// AndroidX 类库
|
||||
api 'androidx.appcompat:appcompat:1.1.0'
|
||||
api 'com.google.android.material:material:1.4.0'
|
||||
//api 'androidx.viewpager:viewpager:1.0.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
//api 'androidx.fragment:fragment:1.1.0'
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Wed May 07 15:07:02 HKT 2025
|
||||
stageCount=2
|
||||
libraryProject=
|
||||
baseVersion=15.1
|
||||
publishVersion=15.1.1
|
||||
buildCount=0
|
||||
baseBetaVersion=15.1.2
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user