Compare commits
106 Commits
appbase-v1
...
timestamp-
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1cdad9ac7d | ||
![]() |
986922c1fa | ||
![]() |
bff40d2a64 | ||
![]() |
13e0ad3f03 | ||
![]() |
be85ef923e | ||
![]() |
9a3383a43b | ||
![]() |
d875b6965d | ||
![]() |
bc873852c2 | ||
![]() |
b032de55dc | ||
![]() |
8fa20b56ec | ||
![]() |
1ca93a610e | ||
![]() |
6555346618 | ||
![]() |
df6633046c | ||
![]() |
7d35d5a9b8 | ||
![]() |
ddce5646bd | ||
![]() |
3607a99053 | ||
![]() |
6a101d8843 | ||
![]() |
c5e5e76bbf | ||
![]() |
6d05808a2a | ||
![]() |
2625ffe6a6 | ||
![]() |
9c4c1320aa | ||
![]() |
551b424960 | ||
![]() |
1062c7d2ee | ||
![]() |
e958556073 | ||
![]() |
466e061aa8 | ||
![]() |
2f2512cd76 | ||
![]() |
d26de8f2f7 | ||
![]() |
2e9b6ae263 | ||
![]() |
f0a29dc7a9 | ||
![]() |
125c2b4431 | ||
![]() |
03ceaf3e2a | ||
![]() |
7ff2cab615 | ||
![]() |
954139f0c9 | ||
![]() |
027dc23060 | ||
![]() |
9816167e87 | ||
![]() |
512c321b76 | ||
![]() |
482c007481 | ||
![]() |
609182f909 | ||
![]() |
eb69a473a3 | ||
![]() |
e772563fc0 | ||
![]() |
55ce968053 | ||
![]() |
502d3ad23d | ||
![]() |
103c1101ce | ||
![]() |
03d4cf2efe | ||
![]() |
15fa0ad506 | ||
![]() |
0dfc7df4b5 | ||
![]() |
f33956c872 | ||
![]() |
9283ad709f | ||
![]() |
459fff1531 | ||
![]() |
b4fb680b8c | ||
![]() |
cf933da3aa | ||
![]() |
2bd8947af1 | ||
![]() |
28f2ada31a | ||
![]() |
81669f03b3 | ||
![]() |
5a1f1f2d73 | ||
![]() |
0e4dc85dfa | ||
![]() |
204642a5cd | ||
![]() |
daf10dd727 | ||
![]() |
2005ba6aee | ||
![]() |
6adc96449b | ||
![]() |
4d8675f1f7 | ||
![]() |
2467f3b5a8 | ||
![]() |
b8834627ae | ||
![]() |
164c00ee0d | ||
![]() |
b34d777c9f | ||
![]() |
2ce07bbcf3 | ||
![]() |
7932e25def | ||
![]() |
191de5c511 | ||
![]() |
d520c9ae06 | ||
![]() |
933abbc261 | ||
![]() |
14a161ab3f | ||
![]() |
248b8084dc | ||
![]() |
006cefea2a | ||
![]() |
ad1b6ca3e9 | ||
![]() |
37c93658b3 | ||
![]() |
65aae2146e | ||
![]() |
58eba26eb5 | ||
![]() |
a32b10cdec | ||
![]() |
4612593d88 | ||
![]() |
0460613aea | ||
![]() |
e1dadfa41c | ||
![]() |
6a0510e76c | ||
![]() |
8dd41a0c3a | ||
![]() |
ca4814744f | ||
![]() |
5a9ee81c30 | ||
![]() |
841d526b0d | ||
![]() |
11d2db6bf9 | ||
![]() |
93d8fa15db | ||
![]() |
99ff741a22 | ||
![]() |
5bc7581db1 | ||
![]() |
fde0712439 | ||
![]() |
4ff54c785e | ||
![]() |
b961468e1e | ||
![]() |
575ef9aac0 | ||
![]() |
16b118f83b | ||
![]() |
1eeba4e4c6 | ||
![]() |
66eb8e06ea | ||
![]() |
51775620db | ||
![]() |
deaa9caadd | ||
![]() |
58af5ba074 | ||
![]() |
19743d30ef | ||
![]() |
3c2b720e20 | ||
![]() |
5a052e4b22 | ||
![]() |
4ccf6824a6 | ||
![]() |
508c8b0b97 | ||
![]() |
0d21994291 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,6 +1,3 @@
|
||||
[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
|
||||
|
@@ -24,12 +24,12 @@ android {
|
||||
defaultConfig {
|
||||
applicationId "cc.winboll.studio.aes"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 29
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
// versionName 更新后需要手动设置
|
||||
// 项目模块目录的 build.gradle 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "15.2"
|
||||
versionName "15.6"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Thu Apr 03 11:14:05 HKT 2025
|
||||
stageCount=7
|
||||
#Sun May 04 06:42:28 GMT 2025
|
||||
stageCount=1
|
||||
libraryProject=libaes
|
||||
baseVersion=15.2
|
||||
publishVersion=15.2.6
|
||||
buildCount=0
|
||||
baseBetaVersion=15.2.7
|
||||
baseVersion=15.6
|
||||
publishVersion=15.6.0
|
||||
buildCount=10
|
||||
baseBetaVersion=15.6.1
|
||||
|
@@ -15,9 +15,9 @@ 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;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
|
||||
public class AboutActivity extends WinBollActivity implements IWinBollActivity {
|
||||
public class AboutActivity extends AppCompatActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "AboutActivity";
|
||||
|
||||
@@ -64,13 +64,13 @@ public class AboutActivity extends WinBollActivity implements IWinBollActivity {
|
||||
);
|
||||
layout.addView(aboutView, params);
|
||||
|
||||
GlobalApplication.getWinBollActivityManager().add(this);
|
||||
GlobalApplication.getWinBoLLActivityManager().add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
GlobalApplication.getWinBollActivityManager().registeRemove(this);
|
||||
GlobalApplication.getWinBoLLActivityManager().registeRemove(this);
|
||||
}
|
||||
|
||||
public AboutView CreateAboutView() {
|
||||
|
@@ -8,6 +8,7 @@ package cc.winboll.studio.aes;
|
||||
import android.view.Gravity;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.hjq.toast.style.WhiteToastStyle;
|
||||
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
@@ -21,8 +22,8 @@ public class App extends GlobalApplication {
|
||||
// 初始化 Toast 框架
|
||||
ToastUtils.init(this);
|
||||
// 设置 Toast 布局样式
|
||||
ToastUtils.setView(R.layout.view_toast);
|
||||
//ToastUtils.setStyle(new WhiteToastStyle());
|
||||
//ToastUtils.setView(R.layout.view_toast);
|
||||
ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
|
||||
|
||||
}
|
||||
|
@@ -25,12 +25,12 @@ import cc.winboll.studio.libaes.unittests.TestAToolbarActivity;
|
||||
import cc.winboll.studio.libaes.unittests.TestDrawerFragmentActivity;
|
||||
import cc.winboll.studio.libaes.unittests.TestViewPageFragment;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
import com.a4455jkjh.colorpicker.ColorPickerDialog;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MainActivity extends DrawerFragmentActivity implements IWinBollActivity {
|
||||
public class MainActivity extends DrawerFragmentActivity implements IWinBoLLActivity {
|
||||
|
||||
|
||||
public static final String TAG = "MainActivity";
|
||||
@@ -123,7 +123,7 @@ public class MainActivity extends DrawerFragmentActivity implements IWinBollActi
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int nItemId = item.getItemId();
|
||||
// if (item.getItemId() == R.id.item_log) {
|
||||
// WinBollActivityManager.getInstance(this).startWinBollActivity(getApplicationContext(), LogActivity.class);
|
||||
// WinBoLLActivityManager.getInstance(this).startWinBoLLActivity(getApplicationContext(), LogActivity.class);
|
||||
// } else
|
||||
if (nItemId == R.id.item_atoast) {
|
||||
Toast.makeText(getApplication(), "item_testatoast", Toast.LENGTH_SHORT).show();
|
||||
|
@@ -1,60 +0,0 @@
|
||||
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
|
||||
#Tue Apr 29 14:47:16 HKT 2025
|
||||
#Sat May 03 10:32:21 GMT 2025
|
||||
stageCount=7
|
||||
libraryProject=libappbase
|
||||
baseVersion=15.7
|
||||
publishVersion=15.7.6
|
||||
buildCount=0
|
||||
buildCount=4
|
||||
baseBetaVersion=15.7.7
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Apr 29 14:08:11 HKT 2025
|
||||
stageCount=4
|
||||
#Tue Apr 29 15:04:17 HKT 2025
|
||||
stageCount=5
|
||||
libraryProject=libapputils
|
||||
baseVersion=15.3
|
||||
publishVersion=15.3.3
|
||||
publishVersion=15.3.4
|
||||
buildCount=0
|
||||
baseBetaVersion=15.3.4
|
||||
baseBetaVersion=15.3.5
|
||||
|
@@ -15,12 +15,12 @@ import android.view.MenuItem;
|
||||
import android.widget.Toolbar;
|
||||
import cc.winboll.studio.apputils.R;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libapputils.views.SimpleWebView;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class AssetsHtmlActivity extends WinBollActivityBase implements IWinBollActivity {
|
||||
public class AssetsHtmlActivity extends WinBoLLActivityBase implements IWinBoLLActivity {
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
@@ -57,7 +57,7 @@ public class AssetsHtmlActivity extends WinBollActivityBase implements IWinBollA
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// if (item.getItemId() == android.R.id.home) {
|
||||
// WinBollActivityManager.getInstance(this).finish(this);
|
||||
// WinBoLLActivityManager.getInstance(this).finish(this);
|
||||
// }
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@@ -60,9 +60,9 @@ final public class MainActivity extends Activity {
|
||||
//if (prosessIntents(getIntent())) return;
|
||||
// 以下正常创建主窗口
|
||||
|
||||
// // 设置 WinBoll 应用 UI 类型
|
||||
// WinBollApplication.setWinBollUI_TYPE(WinBollApplication.WinBollUI_TYPE.Aplication);
|
||||
// //ToastUtils.show("WinBollUI_TYPE " + WinBollApplication.getWinBollUI_TYPE());
|
||||
// // 设置 WinBoLL 应用 UI 类型
|
||||
// WinBoLLApplication.setWinBoLLUI_TYPE(WinBoLLApplication.WinBoLLUI_TYPE.Aplication);
|
||||
// //ToastUtils.show("WinBoLLUI_TYPE " + WinBoLLApplication.getWinBoLLUI_TYPE());
|
||||
// LogUtils.d(TAG, "BuildConfig.DEBUG : " + Boolean.toString(BuildConfig.DEBUG));
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ final public class MainActivity extends Activity {
|
||||
if (intent.getAction() != null) {
|
||||
// if (intent.getAction().equals(cc.winboll.studio.libapputils.intent.action.DEBUGVIEW)) {
|
||||
// App.setIsDebug(true);
|
||||
// //ToastUtils.show!("WinBollApplication.setIsDebug(true) by action : " + intent.getAction());
|
||||
// //ToastUtils.show!("WinBoLLApplication.setIsDebug(true) by action : " + intent.getAction());
|
||||
//
|
||||
// }
|
||||
}
|
||||
@@ -130,12 +130,12 @@ final public class MainActivity extends Activity {
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
// 缓存当前 activity
|
||||
//WinBollActivityManager.getInstance(this).add(this);
|
||||
//WinBoLLActivityManager.getInstance(this).add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
//WinBollActivityManager.getInstance(this).registeRemove(this);
|
||||
//WinBoLLActivityManager.getInstance(this).registeRemove(this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -150,8 +150,8 @@ final public class MainActivity extends Activity {
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
// startActivity(intent);
|
||||
|
||||
//WinBollActivityManager.getInstance().printAvtivityListInfo();
|
||||
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, LogActivity.class);
|
||||
//WinBoLLActivityManager.getInstance().printAvtivityListInfo();
|
||||
//WinBoLLActivityManager.getInstance(this).startWinBoLLActivity(this, LogActivity.class);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -165,7 +165,7 @@ final public class MainActivity extends Activity {
|
||||
|
||||
// if (intent.getAction().equals(StringToQrCodeView.ACTION_UNITTEST_QRCODE)) {
|
||||
// try {
|
||||
// WinBollActivity clazzActivity = UnitTestActivity.class.newInstance();
|
||||
// WinBoLLActivity clazzActivity = UnitTestActivity.class.newInstance();
|
||||
// String tag = clazzActivity.getTag();
|
||||
// LogUtils.d(TAG, "String tag = clazzActivity.getTag(); tag " + tag);
|
||||
// Intent subIntent = new Intent(this, UnitTestActivity.class);
|
||||
@@ -183,8 +183,8 @@ final public class MainActivity extends Activity {
|
||||
// }
|
||||
//
|
||||
// Files.copy(Paths.get(szSrcPath), Paths.get(file.getPath()));
|
||||
// //startWinBollActivity(subIntent, tag);
|
||||
// WinBollActivityManager.getInstance(this).startWinBollActivity(this, subIntent, UnitTestActivity.class);
|
||||
// //startWinBoLLActivity(subIntent, tag);
|
||||
// WinBoLLActivityManager.getInstance(this).startWinBoLLActivity(this, subIntent, UnitTestActivity.class);
|
||||
// } catch (IllegalAccessException | InstantiationException | IOException e) {
|
||||
// LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
// // 函数处理异常返回失败
|
||||
@@ -201,8 +201,8 @@ final public class MainActivity extends Activity {
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
//ToastUtils.show("onCreateOptionsMenu");
|
||||
getMenuInflater().inflate(R.menu.toolbar_main, menu);
|
||||
// if (isAddWinBollToolBar()) {
|
||||
// //ToastUtils.show("mIWinBoll.isAddWinBollToolBar()");
|
||||
// if (isAddWinBoLLToolBar()) {
|
||||
// //ToastUtils.show("mIWinBoLL.isAddWinBoLLToolBar()");
|
||||
// getMenuInflater().inflate(R.menu.toolbar_winboll_shared_main, menu);
|
||||
// }
|
||||
if (App.isDebuging()) {
|
||||
@@ -220,7 +220,7 @@ final public class MainActivity extends Activity {
|
||||
} else if (item.getItemId() == R.id.item_teststringtoqrcodeview) {
|
||||
Intent intent = new Intent(this, TestStringToQRCodeViewActivity.class);
|
||||
startActivityForResult(intent, REQUEST_QRCODEDECODE_ACTIVITY);
|
||||
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, TestStringToQrCodeViewActivity.class);
|
||||
//WinBoLLActivityManager.getInstance(this).startWinBoLLActivity(this, TestStringToQrCodeViewActivity.class);
|
||||
} else if (item.getItemId() == R.id.item_testqrcodedecodeactivity) {
|
||||
Intent intent = new Intent(this, QRCodeDecodeActivity.class);
|
||||
startActivityForResult(intent, REQUEST_QRCODEDECODE_ACTIVITY);
|
||||
@@ -230,13 +230,13 @@ final public class MainActivity extends Activity {
|
||||
}
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.item_log) {
|
||||
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, LogActivity.class);
|
||||
//WinBoLLActivityManager.getInstance(this).startWinBoLLActivity(this, LogActivity.class);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.item_exitdebug) {
|
||||
//AboutView.setApp2NormalMode(this);
|
||||
return true;
|
||||
} else if (item.getItemId() == android.R.id.home) {
|
||||
//WinBollActivityManager.getInstance(this).finish(this);
|
||||
//WinBoLLActivityManager.getInstance(this).finish(this);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
@@ -247,7 +247,7 @@ final public class MainActivity extends Activity {
|
||||
//
|
||||
// @Override
|
||||
// public void onYes() {
|
||||
// //WinBollActivityManager.getInstance(getApplicationContext()).finishAll();
|
||||
// //WinBoLLActivityManager.getInstance(getApplicationContext()).finishAll();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
@@ -260,10 +260,10 @@ final public class MainActivity extends Activity {
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// if (WinBollActivityManager.getInstance(getApplicationContext()).isFirstIWinBollActivity(this)) {
|
||||
// if (WinBoLLActivityManager.getInstance(getApplicationContext()).isFirstIWinBoLLActivity(this)) {
|
||||
// exit();
|
||||
// } else {
|
||||
// WinBollActivityManager.getInstance(this).finish(this);
|
||||
// WinBoLLActivityManager.getInstance(this).finish(this);
|
||||
// super.onBackPressed();
|
||||
// }
|
||||
}
|
||||
@@ -275,7 +275,7 @@ final public class MainActivity extends Activity {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
startActivity(intent);
|
||||
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, intent, AssetsHtmlActivity.class);
|
||||
//WinBoLLActivityManager.getInstance(this).startWinBoLLActivity(this, intent, AssetsHtmlActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,51 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- WinBoll 默认方案 -->
|
||||
<!-- WinBoLL 默认方案 -->
|
||||
<color name="colorPrimary">#FF196ABC</color>
|
||||
<color name="colorPrimaryDark">#FF002B57</color>
|
||||
<color name="colorAccent">#FF80BFFF</color>
|
||||
|
@@ -1,11 +1,6 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
repositories {
|
||||
// 本地 Maven 仓库(默认路径为 ~/.m2/repository)
|
||||
mavenLocal()
|
||||
// 或自定义本地仓库路径
|
||||
maven { url "file:///sdcard/.m2/repository" }
|
||||
|
||||
// Nexus Maven 库地址
|
||||
// "WinBoLL Release"
|
||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
||||
|
@@ -9,7 +9,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 29
|
||||
targetSdkVersion 30
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
@@ -21,6 +21,9 @@ 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'
|
||||
@@ -45,12 +48,9 @@ dependencies {
|
||||
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 '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:libapputils:15.2.2'
|
||||
api 'cc.winboll.studio:libappbase:15.2.2'
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Thu Apr 03 11:13:53 HKT 2025
|
||||
stageCount=7
|
||||
#Sun May 04 06:42:28 GMT 2025
|
||||
stageCount=1
|
||||
libraryProject=libaes
|
||||
baseVersion=15.2
|
||||
publishVersion=15.2.6
|
||||
buildCount=0
|
||||
baseBetaVersion=15.2.7
|
||||
baseVersion=15.6
|
||||
publishVersion=15.6.0
|
||||
buildCount=10
|
||||
baseBetaVersion=15.6.1
|
||||
|
@@ -5,27 +5,34 @@
|
||||
|
||||
<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>
|
@@ -29,11 +29,11 @@ import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libaes.views.ADrawerMenuListView;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
import com.baoyz.widget.PullRefreshLayout;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class DrawerFragmentActivity extends AppCompatActivity implements IWinBollActivity,AdapterView.OnItemClickListener {
|
||||
public abstract class DrawerFragmentActivity extends AppCompatActivity implements IWinBoLLActivity,AdapterView.OnItemClickListener {
|
||||
|
||||
public static final String TAG = "DrawerFragmentActivity";
|
||||
|
||||
@@ -177,7 +177,7 @@ public abstract class DrawerFragmentActivity extends AppCompatActivity implement
|
||||
getString(i);
|
||||
}
|
||||
} else if (R.id.item_log == item.getItemId()) {
|
||||
GlobalApplication.getWinBollActivityManager().startLogActivity(this);
|
||||
GlobalApplication.getWinBoLLActivityManager().startLogActivity(this);
|
||||
} else if (R.id.item_about == item.getItemId()) {
|
||||
LogUtils.d(TAG, "onAbout");
|
||||
} else if (android.R.id.home == item.getItemId()) {
|
||||
|
@@ -1,9 +1,8 @@
|
||||
package cc.winboll.studio.libaes.winboll;
|
||||
package cc.winboll.studio.libaes.beans;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/28 19:05:15
|
||||
* @Describe WinBollService 运行参数配置
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/03 19:16
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.util.JsonReader;
|
||||
@@ -11,14 +10,19 @@ import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
public class WinBollClientServiceBean extends BaseBean {
|
||||
public class WinBoLLClientServiceBean extends BaseBean {
|
||||
|
||||
public static final String TAG = "WinBollClientServiceBean";
|
||||
public static final String TAG = "WinBoLLClientServiceBean";
|
||||
|
||||
// 服务是否正在使用中
|
||||
boolean isEnable;
|
||||
|
||||
public WinBoLLClientServiceBean() {
|
||||
this.isEnable = false;
|
||||
}
|
||||
|
||||
volatile boolean isEnable;
|
||||
|
||||
public WinBollClientServiceBean() {
|
||||
isEnable = false;
|
||||
public WinBoLLClientServiceBean(boolean isEnable) {
|
||||
this.isEnable = isEnable;
|
||||
}
|
||||
|
||||
public void setIsEnable(boolean isEnable) {
|
||||
@@ -29,26 +33,27 @@ public class WinBollClientServiceBean extends BaseBean {
|
||||
return isEnable;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return WinBollClientServiceBean.class.getName();
|
||||
return WinBoLLClientServiceBean.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
WinBollClientServiceBean bean = this;
|
||||
jsonWriter.name("isEnable").value(bean.isEnable());
|
||||
WinBoLLClientServiceBean bean = this;
|
||||
//jsonWriter.name("logLevel").value(bean.getLogLevel().ordinal());
|
||||
}
|
||||
|
||||
@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());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// if (name.equals("logLevel")) {
|
||||
// setLogLevel(LogUtils.LOG_LEVEL.values()[jsonReader.nextInt()]);
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -67,12 +72,7 @@ public class WinBollClientServiceBean extends BaseBean {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static WinBollClientServiceBean loadWinBollClientServiceBean(Context context) {
|
||||
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);
|
||||
public static WinBoLLClientServiceBean loadWinBoLLClientServiceBean(Context context) {
|
||||
return new WinBoLLClientServiceBean();
|
||||
}
|
||||
}
|
@@ -7,14 +7,14 @@ import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libaes.R;
|
||||
import cc.winboll.studio.libaes.activitys.DrawerFragmentActivity;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/06/15 00:58:10
|
||||
* @Describe 第二级窗口
|
||||
*/
|
||||
public class SecondaryLibraryActivity extends DrawerFragmentActivity implements IWinBollActivity {
|
||||
public class SecondaryLibraryActivity extends DrawerFragmentActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "SecondaryLibraryActivity";
|
||||
|
||||
|
@@ -11,9 +11,9 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libaes.R;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
|
||||
public class TestASupportToolbarActivity extends AppCompatActivity implements IWinBollActivity {
|
||||
public class TestASupportToolbarActivity extends AppCompatActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "TestASupportToolbarActivity";
|
||||
|
||||
|
@@ -10,9 +10,9 @@ import android.os.Bundle;
|
||||
import android.widget.Toolbar;
|
||||
import cc.winboll.studio.libaes.R;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
|
||||
public class TestAToolbarActivity extends Activity implements IWinBollActivity {
|
||||
public class TestAToolbarActivity extends Activity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "TestAToolbarActivity";
|
||||
|
||||
|
@@ -11,16 +11,15 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cc.winboll.studio.libaes.R;
|
||||
import cc.winboll.studio.libaes.activitys.DrawerFragmentActivity;
|
||||
import cc.winboll.studio.libaes.beans.DrawerMenuBean;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TestDrawerFragmentActivity extends DrawerFragmentActivity implements IWinBollActivity {
|
||||
public class TestDrawerFragmentActivity extends DrawerFragmentActivity implements IWinBoLLActivity {
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
|
@@ -41,7 +41,7 @@ public class AESThemeUtil {
|
||||
activity.setTheme(getThemeTypeID(activity));
|
||||
}
|
||||
|
||||
/*public static <T extends WinBollActivity> void applyWinBollTheme(T activity) {
|
||||
/*public static <T extends WinBoLLActivity> void applyWinBoLLTheme(T activity) {
|
||||
activity.setTheme(getThemeTypeID(activity.getApplicationContext()));
|
||||
}*/
|
||||
|
||||
@@ -53,7 +53,7 @@ public class AESThemeUtil {
|
||||
activity.setTheme(AESThemeBean.getThemeStyleID(themeType));
|
||||
}
|
||||
|
||||
/*public static <T extends WinBollActivity> void applyWinBollTheme(Activity activity, AESThemeBean.ThemeType themeType) {
|
||||
/*public static <T extends WinBoLLActivity> void applyWinBoLLTheme(Activity activity, AESThemeBean.ThemeType themeType) {
|
||||
activity.setTheme(AESThemeBean.getThemeStyleID(themeType));
|
||||
}*/
|
||||
|
||||
@@ -65,7 +65,7 @@ public class AESThemeUtil {
|
||||
activity.getMenuInflater().inflate(R.menu.toolbar_apptheme, menu);
|
||||
}
|
||||
|
||||
/*public static <T extends WinBollActivity> void inflateWinBollMenu(T activity, Menu menu) {
|
||||
/*public static <T extends WinBoLLActivity> void inflateWinBoLLMenu(T activity, Menu menu) {
|
||||
activity.getMenuInflater().inflate(R.menu.toolbar_apptheme, menu);
|
||||
}*/
|
||||
|
||||
@@ -131,7 +131,7 @@ public class AESThemeUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static <T extends AppCompatActivity> boolean onWinBollThemeItemSelected(T activity, MenuItem item) {
|
||||
public static <T extends AppCompatActivity> boolean onWinBoLLThemeItemSelected(T activity, MenuItem item) {
|
||||
int nThemeStyleID;
|
||||
if (R.id.item_depththeme == item.getItemId()) {
|
||||
nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.DEPTH);
|
||||
@@ -162,7 +162,7 @@ public class AESThemeUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static <T extends DrawerFragmentActivity> boolean onWinBollThemeItemSelected(T activity, MenuItem item) {
|
||||
public static <T extends DrawerFragmentActivity> boolean onWinBoLLThemeItemSelected(T activity, MenuItem item) {
|
||||
int nThemeStyleID;
|
||||
if (R.id.item_depththeme == item.getItemId()) {
|
||||
nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.DEPTH);
|
||||
|
@@ -3,7 +3,7 @@ package cc.winboll.studio.libaes.winboll;
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/24 15:08:52
|
||||
* @Describe WinBoll应用介绍视图
|
||||
* @Describe WinBoLL应用介绍视图
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -43,7 +43,7 @@ public class AboutView extends LinearLayout {
|
||||
Context mContext;
|
||||
APPInfo mAPPInfo;
|
||||
|
||||
WinBollServiceStatusView mWinBollServiceStatusView;
|
||||
WinBoLLServiceStatusView mWinBoLLServiceStatusView;
|
||||
OnRequestDevUserInfoAutofillListener mOnRequestDevUserInfoAutofillListener;
|
||||
String mszAppName = "";
|
||||
String mszAppAPKFolderName = "";
|
||||
@@ -57,7 +57,7 @@ public class AboutView extends LinearLayout {
|
||||
String mszHomePage = "";
|
||||
String mszGitea = "";
|
||||
int mnAppIcon = 0;
|
||||
String mszWinBollServerHost;
|
||||
String mszWinBoLLServerHost;
|
||||
String mszReleaseAPKName;
|
||||
EditText metDevUserName;
|
||||
EditText metDevUserPassword;
|
||||
@@ -107,7 +107,7 @@ public class AboutView extends LinearLayout {
|
||||
mszAppDescription = mAPPInfo.getAppDescription();
|
||||
mnAppIcon = mAPPInfo.getAppIcon();
|
||||
|
||||
mszWinBollServerHost = GlobalApplication.isDebuging() ? "https://dev.winboll.cc": "https://www.winboll.cc";
|
||||
mszWinBoLLServerHost = GlobalApplication.isDebuging() ? "https://dev.winboll.cc": "https://www.winboll.cc";
|
||||
|
||||
try {
|
||||
mszAppVersionName = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionName;
|
||||
@@ -115,7 +115,7 @@ public class AboutView extends LinearLayout {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
mszCurrentAppPackageName = mszAppAPKName + "_" + mszAppVersionName + ".apk";
|
||||
mszHomePage = mszWinBollServerHost + "/studio/details.php?app=" + mszAppAPKFolderName;
|
||||
mszHomePage = mszWinBoLLServerHost + "/studio/details.php?app=" + mszAppAPKFolderName;
|
||||
if (mAPPInfo.getAppGitAPPBranch().equals("")) {
|
||||
mszGitea = "https://gitea.winboll.cc/" + mAPPInfo.getAppGitOwner() + "/" + mszAppGitName;
|
||||
} else {
|
||||
@@ -132,9 +132,9 @@ public class AboutView extends LinearLayout {
|
||||
metDevUserName.setText(PrefUtils.getString(mContext, "metDevUserName", ""));
|
||||
metDevUserPassword.setText(PrefUtils.getString(mContext, "metDevUserPassword", ""));
|
||||
//mDevelopHostConnectionStatusView = new DevelopHostConnectionStatusView(context);
|
||||
mWinBollServiceStatusView = addedView.findViewById(R.id.viewaboutdevWinBollServiceStatusView1);
|
||||
mWinBollServiceStatusView.setServerHost(mszWinBollServerHost);
|
||||
mWinBollServiceStatusView.setAuthInfo(metDevUserName.getText().toString(), metDevUserPassword.getText().toString());
|
||||
mWinBoLLServiceStatusView = addedView.findViewById(R.id.viewaboutdevWinBoLLServiceStatusView1);
|
||||
mWinBoLLServiceStatusView.setServerHost(mszWinBoLLServerHost);
|
||||
mWinBoLLServiceStatusView.setAuthInfo(metDevUserName.getText().toString(), metDevUserPassword.getText().toString());
|
||||
//llMain.addView(mDevelopHostConnectionStatusView);
|
||||
llMain.addView(createAboutPage());
|
||||
addView(addedView);
|
||||
@@ -143,9 +143,9 @@ public class AboutView extends LinearLayout {
|
||||
View addedView = inflater.inflate(R.layout.view_about_www, this, false);
|
||||
LinearLayout llMain = addedView.findViewById(R.id.viewaboutwwwLinearLayout1);
|
||||
//mDevelopHostConnectionStatusView = new DevelopHostConnectionStatusView(context);
|
||||
mWinBollServiceStatusView = addedView.findViewById(R.id.viewaboutwwwWinBollServiceStatusView1);
|
||||
mWinBollServiceStatusView.setServerHost(mszWinBollServerHost);
|
||||
mWinBollServiceStatusView.setAuthInfo("", "");
|
||||
mWinBoLLServiceStatusView = addedView.findViewById(R.id.viewaboutwwwWinBoLLServiceStatusView1);
|
||||
mWinBoLLServiceStatusView.setServerHost(mszWinBoLLServerHost);
|
||||
mWinBoLLServiceStatusView.setAuthInfo("", "");
|
||||
//llMain.addView(mDevelopHostConnectionStatusView);
|
||||
llMain.addView(createAboutPage());
|
||||
addView(addedView);
|
||||
@@ -291,7 +291,7 @@ public class AboutView extends LinearLayout {
|
||||
GlobalApplication.setIsDebuging(true);
|
||||
GlobalApplication.saveDebugStatus();
|
||||
|
||||
GlobalApplication.getWinBollActivityManager().finishAll();
|
||||
GlobalApplication.getWinBoLLActivityManager().finishAll();
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
@@ -303,7 +303,7 @@ public class AboutView extends LinearLayout {
|
||||
GlobalApplication.setIsDebuging(false);
|
||||
GlobalApplication.saveDebugStatus();
|
||||
|
||||
GlobalApplication.getWinBollActivityManager().finishAll();
|
||||
GlobalApplication.getWinBoLLActivityManager().finishAll();
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
@@ -323,7 +323,7 @@ public class AboutView extends LinearLayout {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String szUrl = mszWinBollServerHost + "/studio/details.php?app=" + mszAppAPKFolderName;
|
||||
String szUrl = mszWinBoLLServerHost + "/studio/details.php?app=" + mszAppAPKFolderName;
|
||||
// 构建包含认证信息的请求
|
||||
String credential = "";
|
||||
if (GlobalApplication.isDebuging()) {
|
||||
@@ -331,8 +331,8 @@ public class AboutView extends LinearLayout {
|
||||
PrefUtils.saveString(mContext, "metDevUserName", metDevUserName.getText().toString());
|
||||
PrefUtils.saveString(mContext, "metDevUserPassword", metDevUserPassword.getText().toString());
|
||||
} else {
|
||||
String username = "WinBoll";
|
||||
String password = "WinBollPowerByZhanGSKen";
|
||||
String username = "WinBoLL";
|
||||
String password = "WinBoLLPowerByZhanGSKen";
|
||||
credential = Credentials.basic(username, password);
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ public class AboutView extends LinearLayout {
|
||||
YesNoAlertDialog.OnDialogResultListener mIsDownlaodUpdateListener = new YesNoAlertDialog.OnDialogResultListener() {
|
||||
@Override
|
||||
public void onYes() {
|
||||
String szUrl = mszWinBollServerHost + "/studio/download.php?appname=" + mszAppAPKFolderName + "&apkname=" + mszNewestAppPackageName;
|
||||
String szUrl = mszWinBoLLServerHost + "/studio/download.php?appname=" + mszAppAPKFolderName + "&apkname=" + mszNewestAppPackageName;
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(szUrl));
|
||||
mContext.startActivity(browserIntent);
|
||||
}
|
||||
|
@@ -11,14 +11,15 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.libaes.winboll.WinBollClientService;
|
||||
import cc.winboll.studio.libaes.beans.WinBoLLClientServiceBean;
|
||||
import cc.winboll.studio.libaes.winboll.AssistantService;
|
||||
import cc.winboll.studio.libappbase.utils.ServiceUtils;
|
||||
|
||||
public class AssistantService extends Service {
|
||||
|
||||
public final static String TAG = "AssistantService";
|
||||
|
||||
WinBollClientServiceBean mWinBollServiceBean;
|
||||
WinBoLLClientServiceBean mWinBoLLServiceBean;
|
||||
MyServiceConnection mMyServiceConnection;
|
||||
volatile boolean mIsServiceRunning;
|
||||
|
||||
@@ -30,7 +31,7 @@ public class AssistantService extends Service {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
mWinBollServiceBean = WinBollClientServiceBean.loadWinBollClientServiceBean(this);
|
||||
mWinBoLLServiceBean = WinBoLLClientServiceBean.loadWinBoLLClientServiceBean(this);
|
||||
if (mMyServiceConnection == null) {
|
||||
mMyServiceConnection = new MyServiceConnection();
|
||||
}
|
||||
@@ -55,8 +56,8 @@ public class AssistantService extends Service {
|
||||
// 运行服务内容
|
||||
//
|
||||
void run() {
|
||||
mWinBollServiceBean = WinBollClientServiceBean.loadWinBollClientServiceBean(this);
|
||||
if (mWinBollServiceBean.isEnable()) {
|
||||
mWinBoLLServiceBean = WinBoLLClientServiceBean.loadWinBoLLClientServiceBean(this);
|
||||
if (mWinBoLLServiceBean.isEnable()) {
|
||||
if (mIsServiceRunning == false) {
|
||||
// 设置运行状态
|
||||
mIsServiceRunning = true;
|
||||
@@ -70,11 +71,11 @@ public class AssistantService extends Service {
|
||||
// 唤醒和绑定主进程
|
||||
//
|
||||
void wakeupAndBindMain() {
|
||||
if (ServiceUtils.isServiceRunning(getApplicationContext(), WinBollClientService.class.getName()) == false) {
|
||||
startForegroundService(new Intent(AssistantService.this, WinBollClientService.class));
|
||||
if (ServiceUtils.isServiceRunning(getApplicationContext(), WinBoLLClientService.class.getName()) == false) {
|
||||
startForegroundService(new Intent(AssistantService.this, WinBoLLClientService.class));
|
||||
}
|
||||
|
||||
bindService(new Intent(AssistantService.this, WinBollClientService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
|
||||
bindService(new Intent(AssistantService.this, WinBoLLClientService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -87,8 +88,8 @@ public class AssistantService extends Service {
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
mWinBollServiceBean = WinBollClientServiceBean.loadWinBollClientServiceBean(AssistantService.this);
|
||||
if (mWinBollServiceBean.isEnable()) {
|
||||
mWinBoLLServiceBean = WinBoLLClientServiceBean.loadWinBoLLClientServiceBean(AssistantService.this);
|
||||
if (mWinBoLLServiceBean.isEnable()) {
|
||||
wakeupAndBindMain();
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package cc.winboll.studio.libaes.winboll;
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/28 19:11:27
|
||||
* @Describe WinBoll UI 状态图标枚举
|
||||
* @Describe WinBoLL UI 状态图标枚举
|
||||
*/
|
||||
import cc.winboll.studio.libaes.R;
|
||||
|
||||
|
@@ -1,17 +0,0 @@
|
||||
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,22 +1,21 @@
|
||||
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";
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen
|
||||
* @Date 2025/05/03 19:28
|
||||
*/
|
||||
public class WinBoLLClientService extends Service {
|
||||
|
||||
public static final String TAG = "WinBoLLClientService";
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
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
|
||||
*/
|
||||
public class WinBoLLServiceStatusView extends LinearLayout {
|
||||
|
||||
public static final String TAG = "WinBoLLServiceStatusView";
|
||||
|
||||
public WinBoLLServiceStatusView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public WinBoLLServiceStatusView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public WinBoLLServiceStatusView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public WinBoLLServiceStatusView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
|
||||
void setServerHost(String szWinBoLLServerHost) {
|
||||
|
||||
}
|
||||
|
||||
void setAuthInfo(String szDevUserName, String szDevUserPassword) {
|
||||
|
||||
}
|
||||
}
|
@@ -1,192 +0,0 @@
|
||||
package cc.winboll.studio.libaes.winboll;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/28 19:06:54
|
||||
* @Describe WinBoll 客户端服务
|
||||
*/
|
||||
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,106 +0,0 @@
|
||||
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,473 +0,0 @@
|
||||
package cc.winboll.studio.libaes.winboll;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/28 17:41:55
|
||||
* @Describe WinBoll 服务主机连接状态视图
|
||||
*/
|
||||
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.R;
|
||||
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();
|
||||
}
|
||||
|
||||
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 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) {
|
||||
}
|
||||
};*/
|
||||
}
|
@@ -53,10 +53,10 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<cc.winboll.studio.libaes.winboll.WinBollServiceStatusView
|
||||
<cc.winboll.studio.libaes.winboll.WinBoLLServiceStatusView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/viewaboutdevWinBollServiceStatusView1"/>
|
||||
android:id="@+id/viewaboutdevWinBoLLServiceStatusView1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@@ -12,10 +12,10 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<cc.winboll.studio.libaes.winboll.WinBollServiceStatusView
|
||||
<cc.winboll.studio.libaes.winboll.WinBoLLServiceStatusView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/viewaboutwwwWinBollServiceStatusView1"/>
|
||||
android:id="@+id/viewaboutwwwWinBoLLServiceStatusView1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:background="@drawable/toast_frame"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#FFFFFFFF"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:src="@drawable/ic_launcher"/>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:textColor="#FFFFFFFF"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<resources>
|
||||
|
||||
<string name="lib_name">libaes</string>
|
||||
<string name="lib_description">云宝APP应用安卓元素类库示例。源码仅供调试参考,请勿直接引用。(WinBoll APP application Android element class library example. The source is just for demo debug test, Do not quote directly.)</string>
|
||||
<string name="lib_description">云宝APP应用安卓元素类库示例。源码仅供调试参考,请勿直接引用。(WinBoLL APP application Android element class library example. The source is just for demo debug test, Do not quote directly.)</string>
|
||||
<string name="lib_home">https://winboll.cc/aes</string>
|
||||
<string name="text_about">关于</string>
|
||||
<string name="text_AppTheme">应用主题</string>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<resources>
|
||||
|
||||
<string name="lib_name">libaes</string>
|
||||
<string name="lib_description">云宝APP应用安卓元素类库示例。源码仅供调试参考,请勿直接引用。(WinBoll APP application Android element class library example. The source is just for demo debug test, Do not quote directly.)</string>
|
||||
<string name="lib_description">云宝APP应用安卓元素类库示例。源码仅供调试参考,请勿直接引用。(WinBoLL APP application Android element class library example. The source is just for demo debug test, Do not quote directly.)</string>
|
||||
<string name="lib_home">https://winboll.cc/libaes</string>
|
||||
<string name="text_about">About</string>
|
||||
<string name="text_AppTheme">AppTheme</string>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Apr 29 14:47:16 HKT 2025
|
||||
#Sat May 03 10:32:21 GMT 2025
|
||||
stageCount=7
|
||||
libraryProject=libappbase
|
||||
baseVersion=15.7
|
||||
publishVersion=15.7.6
|
||||
buildCount=0
|
||||
buildCount=4
|
||||
baseBetaVersion=15.7.7
|
||||
|
@@ -21,7 +21,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
api 'cc.winboll.studio:libappbase:15.7.5'
|
||||
api 'cc.winboll.studio:libappbase:15.7.6'
|
||||
|
||||
// 二维码类库
|
||||
api 'com.google.zxing:core:3.4.1'
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Apr 29 14:07:52 HKT 2025
|
||||
stageCount=4
|
||||
#Tue Apr 29 15:03:54 HKT 2025
|
||||
stageCount=5
|
||||
libraryProject=libapputils
|
||||
baseVersion=15.3
|
||||
publishVersion=15.3.3
|
||||
publishVersion=15.3.4
|
||||
buildCount=0
|
||||
baseBetaVersion=15.3.4
|
||||
baseBetaVersion=15.3.5
|
||||
|
@@ -3,10 +3,10 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device - width, initial - scale = 1.0">
|
||||
<title>WinBoll-APP</title>
|
||||
<title>WinBoLL-APP</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2><a href="https://www.winboll.cc">访问 WWW.WinBoll.CC</a></h2>
|
||||
<h2><a href="https://www.winboll.cc">访问 WWW.WinBoLL.CC</a></h2>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@@ -7,10 +7,10 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device - width, initial - scale = 1.0">
|
||||
<title>WinBoll</title>
|
||||
<title>WinBoLL</title>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="ChangeText">WinBoll Studio</canvas>
|
||||
<canvas id="ChangeText">WinBoLL Studio</canvas>
|
||||
|
||||
<script type="text/javascript">
|
||||
const COLOR = "#39BC54"; // 设定粒子特效颜色
|
||||
|
@@ -29,7 +29,7 @@ public interface IAPPFiles {
|
||||
static String _mFilesRoot = "";
|
||||
|
||||
HashFile(Context context) {
|
||||
_mapFiles.put(UUID_WINBOLLCLIENTSERVICEBEAN_JSON, "/BaseBean/cc.winboll.studio.shared.service.WinBollClientServiceBean.json");
|
||||
_mapFiles.put(UUID_WINBOLLCLIENTSERVICEBEAN_JSON, "/BaseBean/cc.winboll.studio.shared.service.WinBoLLClientServiceBean.json");
|
||||
_mapFiles.put(UUID_LOGUTILS_JSON, "/LogUtils/LogUtils.json");
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ def genVersionName(def versionName){
|
||||
|
||||
android {
|
||||
compileSdkVersion 32
|
||||
buildToolsVersion "33.0.3"
|
||||
buildToolsVersion "32.0.0"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "cc.winboll.studio.powerbell"
|
||||
@@ -29,7 +29,7 @@ android {
|
||||
// versionName 更新后需要手动设置
|
||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "4.0"
|
||||
versionName "15.3"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
@@ -41,17 +41,39 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api 'cc.winboll.studio:winboll-shared:1.8.0'
|
||||
api 'io.github.medyo:android-about-page:2.0.0'
|
||||
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'
|
||||
// 应用介绍页类库
|
||||
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'
|
||||
@@ -67,6 +89,5 @@ 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
|
||||
#Thu Jan 02 11:13:45 HKT 2025
|
||||
stageCount=6
|
||||
#Sat May 03 06:21:11 GMT 2025
|
||||
stageCount=1
|
||||
libraryProject=
|
||||
baseVersion=4.0
|
||||
publishVersion=4.0.5
|
||||
buildCount=0
|
||||
baseBetaVersion=4.0.6
|
||||
baseVersion=15.3
|
||||
publishVersion=15.3.0
|
||||
buildCount=5
|
||||
baseBetaVersion=15.3.1
|
||||
|
@@ -6,20 +6,18 @@
|
||||
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,10 +2,9 @@
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="cc.winboll.studio.powerbell">
|
||||
|
||||
<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.CAMERA"/>
|
||||
|
||||
<!-- 运行前台服务 -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
@@ -22,8 +21,15 @@
|
||||
<!-- 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=".GlobalApplication"
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
@@ -34,7 +40,8 @@
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:launchMode="singleTask">
|
||||
android:launchMode="singleTask"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
@@ -110,6 +117,8 @@
|
||||
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 com.hjq.toast.style.WhiteToastStyle;
|
||||
import java.io.File;
|
||||
|
||||
public class GlobalApplication extends WinBollApplication {
|
||||
public class App extends GlobalApplication {
|
||||
|
||||
public static final String TAG = "GlobalApplication";
|
||||
|
||||
@@ -17,16 +17,29 @@ public class GlobalApplication extends WinBollApplication {
|
||||
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;
|
||||
GlobalApplication mApplication;
|
||||
App mApplication;
|
||||
//AppConfigUtils mAppConfigUtils;
|
||||
Menu mMenu;
|
||||
Fragment mCurrentShowFragment;
|
||||
@@ -48,12 +48,13 @@ public class MainActivity extends Activity {
|
||||
mLogView.updateLogView();
|
||||
|
||||
_mMainActivity = MainActivity.this;
|
||||
mApplication = (GlobalApplication) getApplication();
|
||||
mApplication = (App) 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) {
|
||||
@@ -64,8 +65,10 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
showFragment(mMainViewFragment);
|
||||
|
||||
NotificationUtils notificationUtils = new NotificationUtils(this);
|
||||
notificationUtils.createNotificationChannel();
|
||||
// NotificationHelper notificationUtils = new NotificationHelper(this);
|
||||
// notificationUtils.createNotificationChannels();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void showFragment(Fragment fragment) {
|
||||
@@ -113,7 +116,7 @@ public class MainActivity extends Activity {
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
// 回到窗口自动取消提醒消息
|
||||
NotificationUtils.cancelRemindNotification(this);
|
||||
//NotificationHelper.cancelRemindNotification(this);
|
||||
|
||||
reloadBackground();
|
||||
}
|
||||
@@ -140,8 +143,11 @@ 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, AboutActivity.class);
|
||||
intent.setClass(this, BatteryReporterActivity.class);
|
||||
startActivity(intent);
|
||||
} else if (menuItemId == R.id.action_clearrecord) {
|
||||
Intent intent = new Intent();
|
||||
|
@@ -1,42 +1,65 @@
|
||||
package cc.winboll.studio.powerbell.activities;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/07/12 13:33:59
|
||||
* @Describe AboutActivity
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/25 01:16:32
|
||||
* @Describe 应用介绍窗口
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
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 {
|
||||
|
||||
public static final String TAG = "AboutActivity";
|
||||
Context mContext;
|
||||
|
||||
AToolbar mAToolbar;
|
||||
public static final String TAG = "AboutActivity";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
mContext = this;
|
||||
|
||||
// 初始化工具栏
|
||||
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));
|
||||
AToolbar mAToolbar = (AToolbar) findViewById(R.id.toolbar);
|
||||
setActionBar(mAToolbar);
|
||||
mAToolbar.setSubtitle(getString(R.string.text_about));
|
||||
//mAToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
mAToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -7,12 +7,14 @@ 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;
|
||||
@@ -20,8 +22,6 @@ 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,18 +59,21 @@ 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(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), getString(R.string.app_projectname));
|
||||
mfPictureDir = new File(App.getTempDirPath());
|
||||
if (!mfPictureDir.exists()) {
|
||||
mfPictureDir.mkdirs();
|
||||
}
|
||||
@@ -84,8 +87,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);
|
||||
@@ -130,6 +133,11 @@ implements BackgroundPicturePreviewDialog.IOnRecivedPictureListener {
|
||||
}
|
||||
}
|
||||
|
||||
void initEnv() {
|
||||
LogUtils.d(TAG, "initEnv()");
|
||||
_RecivedPictureFileName = "Recived.data";
|
||||
}
|
||||
|
||||
public static String getBackgroundFileName() {
|
||||
return _mszRecivedCropPicture;
|
||||
}
|
||||
@@ -145,7 +153,7 @@ implements BackgroundPicturePreviewDialog.IOnRecivedPictureListener {
|
||||
// 加载背景
|
||||
startCropImageActivity(false);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 更新预览背景
|
||||
//
|
||||
@@ -330,10 +338,9 @@ 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(), szRecivedPictureFileName);
|
||||
return new File(utils.getBackgroundDir(), _RecivedPictureFileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -0,0 +1,51 @@
|
||||
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.powerbell.GlobalApplication;
|
||||
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.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;
|
||||
GlobalApplication mApplication;
|
||||
App mApplication;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_clearrecord);
|
||||
mApplication = (GlobalApplication) getApplication();
|
||||
mApplication = (App) 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);
|
||||
|
@@ -0,0 +1,61 @@
|
||||
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.shared.app.BaseBean;
|
||||
import cc.winboll.studio.libappbase.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.shared.app.BaseBean;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
public class BackgroundPictureBean extends BaseBean {
|
||||
|
@@ -0,0 +1,26 @@
|
||||
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.shared.app.BaseBean;
|
||||
import cc.winboll.studio.libappbase.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.shared.app.BaseBean;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ControlCenterServiceBean extends BaseBean {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
package cc.winboll.studio.powerbell.dialogs;
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -10,12 +9,13 @@ 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,6 +37,8 @@ public class BackgroundPicturePreviewDialog extends Dialog {
|
||||
public BackgroundPicturePreviewDialog(Context context) {
|
||||
super(context);
|
||||
setContentView(R.layout.dialog_backgroundpicturepreview);
|
||||
initEnv();
|
||||
|
||||
mContext = context;
|
||||
mBackgroundPictureUtils = ((BackgroundPictureActivity)context).mBackgroundPictureUtils;
|
||||
|
||||
@@ -68,6 +70,11 @@ 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());
|
||||
@@ -87,7 +94,6 @@ 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);
|
||||
// 复制源图片到剪裁文件
|
||||
@@ -96,7 +102,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,7 +17,8 @@ import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.powerbell.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
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;
|
||||
@@ -27,12 +28,11 @@ 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.class.getSimpleName();
|
||||
public static final String TAG = "MainViewFragment";
|
||||
|
||||
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 = GlobalApplication.getAppConfigUtils(getActivity());
|
||||
mAppConfigUtils = App.getAppConfigUtils(getActivity());
|
||||
|
||||
// 获取指定ID的View实例
|
||||
final View mainImageView = mView.findViewById(R.id.fragmentmainviewImageView1);
|
||||
@@ -308,6 +308,7 @@ 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,6 +52,13 @@ 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.GlobalApplication;
|
||||
import cc.winboll.studio.powerbell.App;
|
||||
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.NotificationUtils;
|
||||
import cc.winboll.studio.powerbell.utils.NotificationHelper;
|
||||
|
||||
public class GlobalApplicationReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String TAG = "GlobalApplicationReceiver";
|
||||
|
||||
AppConfigUtils mAppConfigUtils;
|
||||
GlobalApplication mGlobalApplication;
|
||||
App mGlobalApplication;
|
||||
// 存储电量指示值,
|
||||
// 用于校验电量消息时的电量变化
|
||||
static volatile int _mnTheQuantityOfElectricityOld = -1;
|
||||
@@ -24,10 +24,10 @@ public class GlobalApplicationReceiver extends BroadcastReceiver {
|
||||
// 便利封装 registerAction() 函数
|
||||
GlobalApplicationReceiver mReceiver;
|
||||
|
||||
public GlobalApplicationReceiver(GlobalApplication globalApplication) {
|
||||
public GlobalApplicationReceiver(App globalApplication) {
|
||||
mReceiver = this;
|
||||
mGlobalApplication = globalApplication;
|
||||
mAppConfigUtils = GlobalApplication.getAppConfigUtils(mGlobalApplication);
|
||||
mAppConfigUtils = App.getAppConfigUtils(mGlobalApplication);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,9 +45,9 @@ public class GlobalApplicationReceiver extends BroadcastReceiver {
|
||||
// 新电池状态标志某一个有变化就更新显示信息
|
||||
if (_mIsCharging != isCharging || _mnTheQuantityOfElectricityOld != nTheQuantityOfElectricity) {
|
||||
// 电池状态改变先取消旧的提醒消息
|
||||
NotificationUtils.cancelRemindNotification(context);
|
||||
//NotificationHelper.cancelRemindNotification(context);
|
||||
|
||||
GlobalApplication.getAppCacheUtils(context).addChangingTime(nTheQuantityOfElectricity);
|
||||
App.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.powerbell.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.powerbell.App;
|
||||
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 = GlobalApplication.getAppConfigUtils(context).getIsEnableService();
|
||||
boolean isEnableService = App.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.GlobalApplication;
|
||||
import cc.winboll.studio.powerbell.App;
|
||||
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 = GlobalApplication.getAppConfigUtils(this);
|
||||
mAppConfigUtils = App.getAppConfigUtils(this);
|
||||
|
||||
//mMyBinder = new MyBinder();
|
||||
if (mMyServiceConnection == null) {
|
||||
|
@@ -8,14 +8,19 @@ package cc.winboll.studio.powerbell.services;
|
||||
* Android Service之onStartCommand方法研究
|
||||
* https://blog.csdn.net/cyp331203/article/details/38920491
|
||||
*/
|
||||
import cc.winboll.studio.powerbell.R;
|
||||
import android.app.Notification;
|
||||
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 cc.winboll.studio.powerbell.GlobalApplication;
|
||||
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.beans.AppConfigBean;
|
||||
import cc.winboll.studio.powerbell.beans.NotificationMessage;
|
||||
import cc.winboll.studio.powerbell.handlers.ControlCenterServiceHandler;
|
||||
@@ -24,11 +29,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.NotificationUtils;
|
||||
import cc.winboll.studio.powerbell.utils.NotificationHelper;
|
||||
import cc.winboll.studio.powerbell.utils.ServiceUtils;
|
||||
import cc.winboll.studio.powerbell.utils.StringUtils;
|
||||
import cc.winboll.studio.shared.log.LogUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
public class ControlCenterService extends Service {
|
||||
|
||||
@@ -43,7 +48,8 @@ public class ControlCenterService extends Service {
|
||||
AppConfigUtils mAppConfigUtils;
|
||||
AppCacheUtils mAppCacheUtils;
|
||||
// 前台服务通知工具
|
||||
NotificationUtils mNotificationUtils;
|
||||
NotificationHelper mNotificationHelper;
|
||||
Notification notification;
|
||||
RemindThread mRemindThread;
|
||||
ControlCenterServiceHandler mControlCenterServiceHandler;
|
||||
MyServiceConnection mMyServiceConnection;
|
||||
@@ -64,9 +70,11 @@ public class ControlCenterService extends Service {
|
||||
super.onCreate();
|
||||
_mControlCenterService = ControlCenterService.this;
|
||||
isServiceRunning = false;
|
||||
mAppConfigUtils = GlobalApplication.getAppConfigUtils(this);
|
||||
mAppCacheUtils = GlobalApplication.getAppCacheUtils(this);
|
||||
mNotificationUtils = new NotificationUtils(ControlCenterService.this);
|
||||
mAppConfigUtils = App.getAppConfigUtils(this);
|
||||
mAppCacheUtils = App.getAppCacheUtils(this);
|
||||
mNotificationHelper = new NotificationHelper(ControlCenterService.this);
|
||||
|
||||
|
||||
if (mMyServiceConnection == null) {
|
||||
mMyServiceConnection = new MyServiceConnection();
|
||||
}
|
||||
@@ -92,19 +100,33 @@ public class ControlCenterService extends Service {
|
||||
// 唤醒守护进程
|
||||
wakeupAndBindAssistant();
|
||||
// 显示前台通知栏
|
||||
NotificationMessage notificationMessage=createNotificationMessage();
|
||||
//Toast.makeText(getApplication(), "", Toast.LENGTH_SHORT).show();
|
||||
mNotificationUtils.createForegroundNotification(this, notificationMessage);
|
||||
mNotificationUtils.createRemindNotification(this, notificationMessage);
|
||||
// 在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);
|
||||
|
||||
if (mControlCenterServiceReceiver == null) {
|
||||
// 注册广播接收器
|
||||
mControlCenterServiceReceiver = new ControlCenterServiceReceiver(this);
|
||||
mControlCenterServiceReceiver.registerAction(this);
|
||||
}
|
||||
startRemindThread(mAppConfigUtils.mAppConfigBean);
|
||||
ToastUtils.show("Service Is Start.");
|
||||
LogUtils.i(TAG, "Service Is Start.");
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +140,7 @@ public class ControlCenterService extends Service {
|
||||
}
|
||||
|
||||
NotificationMessage createNotificationMessage() {
|
||||
String szTitle = ((GlobalApplication)getApplication()).getString(R.string.app_name);
|
||||
String szTitle = ((App)getApplication()).getString(R.string.app_name);
|
||||
String szContent = getValuesString() + " {?} " + StringUtils.formatPCMListString(mAppCacheUtils.getArrayListBatteryInfo());
|
||||
return new NotificationMessage(szTitle, szContent);
|
||||
}
|
||||
@@ -126,19 +148,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);
|
||||
}
|
||||
|
||||
// 唤醒和绑定守护进程
|
||||
@@ -234,10 +256,32 @@ public class ControlCenterService extends Service {
|
||||
}
|
||||
|
||||
public void appenRemindMSG(String szRemindMSG) {
|
||||
NotificationMessage notificationMessage = createNotificationMessage();
|
||||
notificationMessage.setRemindMSG(szRemindMSG);
|
||||
//LogUtils.d(TAG, "notificationMessage : " + notificationMessage.getRemindMSG());
|
||||
updateRemindNotification(notificationMessage);
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
|
@@ -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.powerbell.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.powerbell.App;
|
||||
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 = "";
|
||||
|
||||
// 保存应用实例
|
||||
GlobalApplication mApplication;
|
||||
App mApplication;
|
||||
|
||||
AppConfigUtils(Context context) {
|
||||
mContext = context;
|
||||
@@ -193,7 +193,7 @@ public class AppConfigUtils {
|
||||
//
|
||||
void saveConfigData() {
|
||||
// 更新配置先取消一下旧的的提醒消息
|
||||
NotificationUtils.cancelRemindNotification(mContext);
|
||||
//NotificationHelper.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.shared.log.LogUtils;
|
||||
import cc.winboll.studio.libappbase.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.shared.log.LogUtils;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
|
@@ -0,0 +1,151 @@
|
||||
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,14 +18,15 @@ 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 NotificationUtils {
|
||||
public class NotificationUtils2 {
|
||||
|
||||
public static final String TAG = NotificationUtils.class.getSimpleName();
|
||||
public static final String TAG = NotificationHelper.class.getSimpleName();
|
||||
|
||||
Context mContext;
|
||||
NotificationManager mNotificationManager;
|
||||
@@ -45,19 +46,53 @@ public class NotificationUtils {
|
||||
private static String _mszChannelIDRemind = "2";
|
||||
private static String _mszChannelNameRemind = "Remind";
|
||||
|
||||
public NotificationUtils(Context context) {
|
||||
// public NotificationUtils(Context context) {
|
||||
// mContext = context;
|
||||
// mNotificationManager = (NotificationManager) context.getSystemService(
|
||||
// Context.NOTIFICATION_SERVICE);
|
||||
// }
|
||||
|
||||
public NotificationUtils2(Context context) {
|
||||
mContext = context;
|
||||
mNotificationManager = (NotificationManager) context.getSystemService(
|
||||
Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager = context.getSystemService(NotificationManager.class);
|
||||
//createNotificationChannels();
|
||||
}
|
||||
|
||||
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);
|
||||
@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);
|
||||
}
|
||||
|
||||
// 创建并发送服务通知
|
7
powerbell/src/main/res/drawable/divider_line.xml
Normal file
7
powerbell/src/main/res/drawable/divider_line.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?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,20 +6,26 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<cc.winboll.studio.libaes.views.AToolbar
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/DefaultAToolbar"/>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<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"/>
|
||||
<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"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@@ -26,29 +26,27 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/toolbar">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right">
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<cc.winboll.studio.libaes.views.AButton
|
||||
android:layout_width="180dp"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="36dp"
|
||||
android:text="Origin BG"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_margin="10dp"
|
||||
android:id="@+id/activitybackgroundpictureAButton5"/>
|
||||
android:id="@+id/activitybackgroundpictureAButton5"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_margin="5dp"/>
|
||||
|
||||
<cc.winboll.studio.libaes.views.AButton
|
||||
android:layout_width="180dp"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="36dp"
|
||||
android:text="Received BG"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_margin="10dp"
|
||||
android:id="@+id/activitybackgroundpictureAButton4"/>
|
||||
android:id="@+id/activitybackgroundpictureAButton4"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_margin="5dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
|
24
powerbell/src/main/res/layout/activity_battery_reporter.xml
Normal file
24
powerbell/src/main/res/layout/activity_battery_reporter.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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.shared.log.LogView
|
||||
<cc.winboll.studio.libappbase.LogView
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:layout_height="200dp"
|
||||
android:id="@+id/logview"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
11
powerbell/src/main/res/layout/custom_notification.xml
Normal file
11
powerbell/src/main/res/layout/custom_notification.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?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>
|
||||
|
@@ -0,0 +1,17 @@
|
||||
<?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>
|
||||
|
34
powerbell/src/main/res/layout/item_battery_report.xml
Normal file
34
powerbell/src/main/res/layout/item_battery_report.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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,5 +1,8 @@
|
||||
<?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,9 +1,3 @@
|
||||
<?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/colorShui</color>
|
||||
<color name="colorPrimary">@color/colorShuiDark</color>
|
||||
<color name="colorPrimaryDark">@color/colorFeng</color>
|
||||
<color name="colorAccent">@color/colorShui</color>
|
||||
<color name="colorYellow">#FFFFFF00</color>
|
||||
|
@@ -2,10 +2,11 @@
|
||||
<resources>
|
||||
<string name="app_name">PowerBell</string>
|
||||
<string name="app_projectname">PowerBell</string>
|
||||
<string name="app_description">Mobile phone power change ringtone alert app.</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="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="@android:style/Theme.DeviceDefault.Light.NoActionBar">
|
||||
<style name="AppTheme_Base" parent="AESTheme">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
<style name="AppTheme_Default" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
|
||||
<style name="AppTheme_Default" parent="AESTheme">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
@@ -12,6 +12,7 @@
|
||||
</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,20 +4,18 @@
|
||||
|
||||
<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,6 +37,10 @@
|
||||
//include ':mymessagemanager'
|
||||
//rootProject.name = "mymessagemanager"
|
||||
|
||||
// TimeStamp 项目编译设置
|
||||
//include ':timestamp'
|
||||
//rootProject.name = "timestamp"
|
||||
|
||||
// AndroidDemo 项目编译设置
|
||||
//include ':androiddemo'
|
||||
//rootProject.name = "androiddemo"
|
||||
|
1
timestamp/.gitignore
vendored
Normal file
1
timestamp/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
6
timestamp/README.md
Normal file
6
timestamp/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
## TimpStamp
|
||||
## 时间戳工具集
|
||||
|
||||
## 使用要点:
|
||||
1。常驻通知栏按钮的正常使用,
|
||||
需要设置允许应用[写入剪贴板]的[始终允许]权限。
|
1
timestamp/app_update_description.txt
Normal file
1
timestamp/app_update_description.txt
Normal file
@@ -0,0 +1 @@
|
||||
|
72
timestamp/build.gradle
Normal file
72
timestamp/build.gradle
Normal file
@@ -0,0 +1,72 @@
|
||||
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.0"
|
||||
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'
|
||||
}
|
8
timestamp/build.properties
Normal file
8
timestamp/build.properties
Normal file
@@ -0,0 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Wed May 07 02:58:13 HKT 2025
|
||||
stageCount=8
|
||||
libraryProject=
|
||||
baseVersion=15.0
|
||||
publishVersion=15.0.7
|
||||
buildCount=0
|
||||
baseBetaVersion=15.0.8
|
21
timestamp/proguard-rules.pro
vendored
Normal file
21
timestamp/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
12
timestamp/src/beta/AndroidManifest.xml
Normal file
12
timestamp/src/beta/AndroidManifest.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" >
|
||||
|
||||
<application>
|
||||
|
||||
<!-- Put flavor specific code here -->
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
6
timestamp/src/beta/res/values/strings.xml
Normal file
6
timestamp/src/beta/res/values/strings.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">TimeStamp +</string>
|
||||
|
||||
</resources>
|
50
timestamp/src/main/AndroidManifest.xml
Normal file
50
timestamp/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="cc.winboll.studio.timestamp">
|
||||
|
||||
<!-- 运行前台服务 -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
|
||||
<!-- READ_CLIPBOARD -->
|
||||
<uses-permission android:name="android.permission.READ_CLIPBOARD"/>
|
||||
|
||||
<!-- WRITE_CLIPBOARD -->
|
||||
<uses-permission android:name="android.permission.WRITE_CLIPBOARD"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:roundIcon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/MyAppTheme"
|
||||
android:resizeableActivity="true"
|
||||
android:name=".App">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<meta-data
|
||||
android:name="android.max_aspect"
|
||||
android:value="4.0"/>
|
||||
|
||||
<activity android:name=".GlobalApplication$CrashActivity"/>
|
||||
|
||||
<service android:name=".MainService"/>
|
||||
|
||||
<service android:name=".AssistantService"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
345
timestamp/src/main/java/cc/winboll/studio/timestamp/App.java
Normal file
345
timestamp/src/main/java/cc/winboll/studio/timestamp/App.java
Normal file
@@ -0,0 +1,345 @@
|
||||
package cc.winboll.studio.timestamp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.timestamp.R;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
|
||||
private static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
// 初始化 Toast 框架
|
||||
ToastUtils.init(this);
|
||||
// 设置 Toast 布局样式
|
||||
//ToastUtils.setView(R.layout.view_toast);
|
||||
//ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
|
||||
|
||||
//CrashHandler.getInstance().registerGlobal(this);
|
||||
//CrashHandler.getInstance().registerPart(this);
|
||||
}
|
||||
|
||||
public static void write(InputStream input, OutputStream output) throws IOException {
|
||||
byte[] buf = new byte[1024 * 8];
|
||||
int len;
|
||||
while ((len = input.read(buf)) != -1) {
|
||||
output.write(buf, 0, len);
|
||||
}
|
||||
}
|
||||
|
||||
public static void write(File file, byte[] data) throws IOException {
|
||||
File parent = file.getParentFile();
|
||||
if (parent != null && !parent.exists()) parent.mkdirs();
|
||||
|
||||
ByteArrayInputStream input = new ByteArrayInputStream(data);
|
||||
FileOutputStream output = new FileOutputStream(file);
|
||||
try {
|
||||
write(input, output);
|
||||
} finally {
|
||||
closeIO(input, output);
|
||||
}
|
||||
}
|
||||
|
||||
public static String toString(InputStream input) throws IOException {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
write(input, output);
|
||||
try {
|
||||
return output.toString("UTF-8");
|
||||
} finally {
|
||||
closeIO(input, output);
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeIO(Closeable... closeables) {
|
||||
for (Closeable closeable : closeables) {
|
||||
try {
|
||||
if (closeable != null) closeable.close();
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CrashHandler {
|
||||
|
||||
public static final UncaughtExceptionHandler DEFAULT_UNCAUGHT_EXCEPTION_HANDLER = Thread.getDefaultUncaughtExceptionHandler();
|
||||
|
||||
private static CrashHandler sInstance;
|
||||
|
||||
private PartCrashHandler mPartCrashHandler;
|
||||
|
||||
public static CrashHandler getInstance() {
|
||||
if (sInstance == null) {
|
||||
sInstance = new CrashHandler();
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void registerGlobal(Context context) {
|
||||
registerGlobal(context, null);
|
||||
}
|
||||
|
||||
public void registerGlobal(Context context, String crashDir) {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandlerImpl(context.getApplicationContext(), crashDir));
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
Thread.setDefaultUncaughtExceptionHandler(DEFAULT_UNCAUGHT_EXCEPTION_HANDLER);
|
||||
}
|
||||
|
||||
public void registerPart(Context context) {
|
||||
unregisterPart(context);
|
||||
mPartCrashHandler = new PartCrashHandler(context.getApplicationContext());
|
||||
MAIN_HANDLER.postAtFrontOfQueue(mPartCrashHandler);
|
||||
}
|
||||
|
||||
public void unregisterPart(Context context) {
|
||||
if (mPartCrashHandler != null) {
|
||||
mPartCrashHandler.isRunning.set(false);
|
||||
mPartCrashHandler = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class PartCrashHandler implements Runnable {
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
public AtomicBoolean isRunning = new AtomicBoolean(true);
|
||||
|
||||
public PartCrashHandler(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (isRunning.get()) {
|
||||
try {
|
||||
Looper.loop();
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
if (isRunning.get()) {
|
||||
MAIN_HANDLER.post(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(mContext, e.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (e instanceof RuntimeException) {
|
||||
throw (RuntimeException)e;
|
||||
} else {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class UncaughtExceptionHandlerImpl implements UncaughtExceptionHandler {
|
||||
|
||||
private static DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss");
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
private final File mCrashDir;
|
||||
|
||||
public UncaughtExceptionHandlerImpl(Context context, String crashDir) {
|
||||
this.mContext = context;
|
||||
this.mCrashDir = TextUtils.isEmpty(crashDir) ? new File(mContext.getExternalCacheDir(), "crash") : new File(crashDir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
||||
try {
|
||||
|
||||
String log = buildLog(throwable);
|
||||
writeLog(log);
|
||||
|
||||
try {
|
||||
Intent intent = new Intent(mContext, CrashActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, log);
|
||||
mContext.startActivity(intent);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
writeLog(e.toString());
|
||||
}
|
||||
|
||||
throwable.printStackTrace();
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(0);
|
||||
|
||||
} catch (Throwable e) {
|
||||
if (DEFAULT_UNCAUGHT_EXCEPTION_HANDLER != null) DEFAULT_UNCAUGHT_EXCEPTION_HANDLER.uncaughtException(thread, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
private String buildLog(Throwable throwable) {
|
||||
String time = DATE_FORMAT.format(new Date());
|
||||
|
||||
String versionName = "unknown";
|
||||
long versionCode = 0;
|
||||
try {
|
||||
PackageInfo packageInfo = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
|
||||
versionName = packageInfo.versionName;
|
||||
versionCode = Build.VERSION.SDK_INT >= 28 ? packageInfo.getLongVersionCode() : packageInfo.versionCode;
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
LinkedHashMap<String, String> head = new LinkedHashMap<String, String>();
|
||||
head.put("Time Of Crash", time);
|
||||
head.put("Device", String.format("%s, %s", Build.MANUFACTURER, Build.MODEL));
|
||||
head.put("Android Version", String.format("%s (%d)", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
|
||||
head.put("App Version", String.format("%s (%d)", versionName, versionCode));
|
||||
head.put("Kernel", getKernel());
|
||||
head.put("Support Abis", Build.VERSION.SDK_INT >= 21 && Build.SUPPORTED_ABIS != null ? Arrays.toString(Build.SUPPORTED_ABIS): "unknown");
|
||||
head.put("Fingerprint", Build.FINGERPRINT);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (String key : head.keySet()) {
|
||||
if (builder.length() != 0) builder.append("\n");
|
||||
builder.append(key);
|
||||
builder.append(" : ");
|
||||
builder.append(head.get(key));
|
||||
}
|
||||
|
||||
builder.append("\n\n");
|
||||
builder.append(Log.getStackTraceString(throwable));
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private void writeLog(String log) {
|
||||
String time = DATE_FORMAT.format(new Date());
|
||||
File file = new File(mCrashDir, "crash_" + time + ".txt");
|
||||
try {
|
||||
write(file, log.getBytes("UTF-8"));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getKernel() {
|
||||
try {
|
||||
return App.toString(new FileInputStream("/proc/version")).trim();
|
||||
} catch (Throwable e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final class CrashActivity extends Activity {
|
||||
|
||||
private String mLog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setTheme(android.R.style.Theme_DeviceDefault);
|
||||
setTitle("App Crash");
|
||||
|
||||
mLog = getIntent().getStringExtra(Intent.EXTRA_TEXT);
|
||||
|
||||
ScrollView contentView = new ScrollView(this);
|
||||
contentView.setFillViewport(true);
|
||||
|
||||
HorizontalScrollView horizontalScrollView = new HorizontalScrollView(this);
|
||||
|
||||
TextView textView = new TextView(this);
|
||||
int padding = dp2px(16);
|
||||
textView.setPadding(padding, padding, padding, padding);
|
||||
textView.setText(mLog);
|
||||
textView.setTextIsSelectable(true);
|
||||
textView.setTypeface(Typeface.DEFAULT);
|
||||
textView.setLinksClickable(true);
|
||||
|
||||
horizontalScrollView.addView(textView);
|
||||
contentView.addView(horizontalScrollView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
|
||||
setContentView(contentView);
|
||||
}
|
||||
|
||||
private void restart() {
|
||||
Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName());
|
||||
if (intent != null) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
finish();
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
private static int dp2px(float dpValue) {
|
||||
final float scale = Resources.getSystem().getDisplayMetrics().density;
|
||||
return (int) (dpValue * scale + 0.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu.add(0, android.R.id.copy, 0, android.R.string.copy)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.copy:
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cm.setPrimaryClip(ClipData.newPlainText(getPackageName(), mLog));
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
restart();
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user