Compare commits

...

103 Commits

Author SHA1 Message Date
ZhanGSKen
16f45aabe4 <aes>APK 15.6.3 release Publish. 2025-05-12 18:10:35 +08:00
ZhanGSKen
8190f4818f <aes>APK 15.6.2 release Publish. 2025-05-12 18:10:02 +08:00
ZhanGSKen
f339733d4b <aes>APK 15.6.1 release Publish. 2025-05-12 18:07:00 +08:00
ZhanGSKen
0a993ccb9b 设置 Gradle 编译时的本地 Maven 库路径 2025-05-12 18:03:14 +08:00
ZhanGSKen
9bd4c41b75 添加 Maven 库紧急备用通道 2025-05-12 15:19:02 +08:00
ZhanGSKen
42256fd0e4 更新 Maven 库引用方案 2025-05-12 03:34:18 +08:00
ZhanGSKen
2a11205468 添加 gradle 调试码 2025-05-07 20:00:44 +08:00
ZhanGSKen
bb9f46373a Merge remote-tracking branch 'origin/timestamp' into appbase 2025-05-07 19:23:19 +08:00
ZhanGSKen
af797743d4 <timestamp>APK 15.1.1 release Publish. 2025-05-07 15:07:02 +08:00
ZhanGSKen
1b37f1bd11 修改图标资源 2025-05-07 15:06:16 +08:00
ZhanGSKen
00177284c1 <timestamp>APK 15.1.0 release Publish. 2025-05-07 14:54:01 +08:00
ZhanGSKen
178e00f8b4 更新版本号 2025-05-07 14:53:32 +08:00
ZhanGSKen
743a5d5299 <timestamp>Start New Stage Version. 2025-05-07 14:51:24 +08:00
ZhanGSKen
30f75f2394 <timestamp>Start New Stage Version. 2025-05-07 14:51:14 +08:00
ZhanGSKen
9d66934694 图标资源修改 2025-05-07 14:48:50 +08:00
ZhanGSKen
c7177f5fa5 <timestamp>APK 15.0.16 release Publish. 2025-05-07 14:44:06 +08:00
ZhanGSKen
9e8263ae8f 分开应用图标和调试图标 2025-05-07 14:43:20 +08:00
ZhanGSKen
5ee9da1982 <timestamp>APK 15.0.15 release Publish. 2025-05-07 14:05:50 +08:00
ZhanGSKen
f59f7676b7 调整通知栏显示信息 2025-05-07 14:05:12 +08:00
ZhanGSKen
19b8251182 <timestamp>APK 15.0.14 release Publish. 2025-05-07 13:59:51 +08:00
ZhanGSKen
4dadb15c0c <timestamp>APK 15.0.13 release Publish. 2025-05-07 13:59:38 +08:00
ZhanGSKen
21b5487513 设置时间戳初始数据 2025-05-07 13:58:56 +08:00
ZhanGSKen
f49c8141a8 <timestamp>APK 15.0.12 release Publish. 2025-05-07 13:48:06 +08:00
ZhanGSKen
6f3ce092ca 调整调试版与阶段版的消息发送 2025-05-07 13:47:26 +08:00
ZhanGSKen
29785be88d 修复信息显示 2025-05-07 13:46:21 +08:00
ZhanGSKen
bf0a70e056 Merge remote-tracking branch 'origin/timestamp' into appbase 2025-05-07 13:34:00 +08:00
ZhanGSKen
3f809e4c7a <timestamp>APK 15.0.11 release Publish. 2025-05-07 13:33:12 +08:00
ZhanGSKen
9c3c485ecd 更新Maven库地址 2025-05-07 13:32:10 +08:00
ZhanGSKen
336511931d <timestamp>APK 15.0.10 release Publish. 2025-05-07 12:09:48 +08:00
ZhanGSKen
d3da3304ee 统一时间戳数据生成方法 2025-05-07 11:58:48 +08:00
ZhanGSKen
a5295a0744 更新Maven库地址 2025-05-07 11:58:14 +08:00
ZhanGSKen
9b761b35ce <timestamp>APK 15.0.9 release Publish. 2025-05-07 10:56:24 +08:00
ZhanGSKen
5206f8781e 初始数据 BugFix. 2025-05-07 10:55:46 +08:00
ZhanGSKen
2c0a5bfe65 更新默认时间戳显示格式 2025-05-07 10:51:48 +08:00
ZhanGSKen
49bce0f773 <timestamp>APK 15.0.8 release Publish. 2025-05-07 10:48:11 +08:00
ZhanGSKen
07c6778212 优化UI显示 2025-05-07 10:47:19 +08:00
ZhanGSKen
1cdad9ac7d <timestamp>APK 15.0.7 release Publish. 2025-05-07 02:58:13 +08:00
ZhanGSKen
986922c1fa 添加自定义应用内铃声 2025-05-07 02:57:08 +08:00
ZhanGSKen
bff40d2a64 重构通知栏消息,添加铃声。 2025-05-07 02:35:51 +08:00
ZhanGSKen
13e0ad3f03 <timestamp>APK 15.0.6 release Publish. 2025-05-06 20:37:48 +08:00
ZhanGSKen
be85ef923e 更新应用图标,优化状态栏UI。 2025-05-06 20:36:51 +08:00
ZhanGSKen
9a3383a43b <timestamp>APK 15.0.5 release Publish. 2025-05-06 18:33:59 +08:00
ZhanGSKen
d875b6965d <timestamp>APK 15.0.4 release Publish. 2025-05-06 18:33:32 +08:00
ZhanGSKen
bc873852c2 修复时间戳复制格式设置未保存问题 2025-05-06 18:32:51 +08:00
ZhanGSKen
b032de55dc 添加说明书 2025-05-06 18:14:34 +08:00
ZhanGSKen
8fa20b56ec <timestamp>APK 15.0.3 release Publish. 2025-05-06 18:01:46 +08:00
ZhanGSKen
1ca93a610e 优化常驻通知电量消耗 2025-05-06 17:59:57 +08:00
ZhanGSKen
6555346618 重构通知栏模块 2025-05-06 17:04:14 +08:00
ZhanGSKen
df6633046c <timestamp>APK 15.0.2 release Publish. 2025-05-06 11:34:02 +08:00
ZhanGSKen
7d35d5a9b8 添加通知栏打开主窗口功能 2025-05-06 11:33:28 +08:00
ZhanGSKen
ddce5646bd <timestamp>APK 15.0.1 release Publish. 2025-05-06 11:27:46 +08:00
ZhanGSKen
3607a99053 添加通知栏清理功能 2025-05-06 11:27:09 +08:00
ZhanGSKen
b44e5575b3 Merge remote-tracking branch 'origin/timestamp' into appbase 2025-05-06 11:18:33 +08:00
ZhanGSKen
6a101d8843 <timestamp>Start New Stage Version. 2025-05-06 11:17:47 +08:00
ZhanGSKen
c5e5e76bbf <timestamp>APK 15.0.0 release Publish. 2025-05-06 11:17:44 +08:00
ZhanGSKen
6d05808a2a 设置目标版本 2025-05-06 11:13:35 +08:00
ZhanGSKen
2625ffe6a6 通知栏优先级设置调试 2025-05-06 11:11:45 +08:00
ZhanGSKen
9c4c1320aa 添加拷贝时间戳到剪贴板功能 2025-05-06 11:07:28 +08:00
ZhanGSKen
551b424960 添加时间戳拷贝与显示的格式设置功能 2025-05-06 10:48:53 +08:00
ZhanGSKen
1062c7d2ee 重构常驻通知栏 2025-05-06 10:09:34 +08:00
ZhanGSKen
e958556073 0937 2025-05-05 21:37:22 +08:00
ZhanGSKen
466e061aa8 0343 2025-05-05 15:43:41 +08:00
ZhanGSKen
2f2512cd76 修复时间戳复制按钮响应 2025-05-05 12:39:45 +08:00
ZhanGSKen
d26de8f2f7 1153 2025-05-05 11:53:48 +08:00
ZhanGSKen
2e9b6ae263 添加通知栏时间戳显示 2025-05-05 11:30:41 +08:00
ZhanGSKen
f0a29dc7a9 添加常驻通知栏 2025-05-05 10:45:25 +08:00
ZhanGSKen
125c2b4431 初始化 TimeStamp 时间戳应用。 2025-05-04 22:03:06 +08:00
ZhanGSKen
4a4e20a6bd 常驻通知栏点击BugFix. 2025-05-04 13:33:15 +08:00
ZhanGSKen
4c0d825d7b Merge remote-tracking branch 'origin/appbase' into autoinstaller 2025-05-04 13:29:22 +08:00
ZhanGSKen
ae111b3a99 2025-05-04 13:27:55 +08:00
ZhanGSKen
03ceaf3e2a Merge remote-tracking branch 'origin/powerbell' into appbase 2025-05-04 13:23:10 +08:00
ZhanGSKen
7ff2cab615 源码整理 2025-05-03 19:36:03 +08:00
ZhanGSKen
954139f0c9 Merge remote-tracking branch 'origin/appbase' into aes 2025-05-03 18:34:10 +08:00
ZhanGSKen
027dc23060 更新Maven库地址设置 2025-05-03 18:33:41 +08:00
ZhanGSKen
640f0c39e9 常驻通知栏UI优化。 2025-05-03 16:44:32 +08:00
ZhanGSKen
9816167e87 优化通知栏显示文字 2025-05-03 14:22:27 +08:00
ZhanGSKen
512c321b76 优化常驻通知栏显示UI 2025-05-03 14:19:32 +08:00
ZhanGSKen
482c007481 应用服务启动后延迟2秒执行提醒任务 2025-05-03 14:01:56 +08:00
ZhanGSKen
609182f909 编译测试 2025-05-03 13:53:48 +08:00
ZhanGSKen
eb69a473a3 调整类库引用顺序 2025-05-03 13:53:32 +08:00
ZhanGSKen
38e4deb425 修复应用不能打开的Bug. 2025-05-03 13:46:46 +08:00
ZhanGSKen
d06023d023 (打开应用)的按钮修复 2025-05-03 13:21:32 +08:00
ZhanGSKen
cb486bb90c 更新类库,BugFix。 2025-05-03 11:52:00 +08:00
ZhanGSKen
2cbf9e5669 Merge remote-tracking branch 'origin/appbase' into autoinstaller 2025-05-03 10:09:42 +08:00
ZhanGSKen
e772563fc0 模块清理 2025-05-02 06:16:08 +08:00
ZhanGSKen
1a7134711e 实现磁贴工具静态挂载... 2025-04-15 18:22:17 +08:00
ZhanGSKen
dabd1271fd 重构磁贴状态更新方法 2025-04-15 17:23:19 +08:00
ZhanGSKen
0d3d691d8a 添加应用图标文件 2025-04-15 17:10:01 +08:00
ZhanGSKen
f3198de003 源码整理 2025-04-15 16:18:26 +08:00
ZhanGSKen
df179242f0 清理冗余注释 2025-04-15 16:09:39 +08:00
ZhanGSKen
1ae3fdf2b7 取消磁贴状态更新 2025-04-15 16:07:49 +08:00
ZhanGSKen
7edc341f15 整理代码 2025-04-15 16:03:45 +08:00
ZhanGSKen
f1669f9e41 更新应用实例参数上下文 2025-04-15 16:00:42 +08:00
ZhanGSKen
63b1d2dece 添加磁贴工具... 2025-04-15 10:57:19 +08:00
ZhanGSKen
c302179960 <autoinstaller>APK 15.2.0 release Publish. 2025-04-02 21:25:51 +08:00
ZhanGSKen
df55608eb3 更新应用打开按钮的启动数据。 2025-04-02 21:23:49 +08:00
ZhanGSKen
b64a229ab1 数据模型命名空间重构 2025-04-02 20:48:37 +08:00
ZhanGSKen
d507d4ac06 调整全局吐司风格 2025-04-02 20:45:25 +08:00
ZhanGSKen
e815c08970 更新类库,去掉主窗口启动时的吐司提示。 2025-04-02 20:41:05 +08:00
ZhanGSKen
d780116031 Merge remote-tracking branch 'origin/appbase' into autoinstaller 2025-04-02 20:31:31 +08:00
ZhanGSKen
5714aed761 <autoinstaller>APK 15.0.0 release Publish. 2025-03-15 15:38:45 +08:00
ZhanGSKen
f04f5cf77c 更新安卓适配版本 2025-03-15 15:33:36 +08:00
ZhanGSKen
6ccbaf8c32 更新类库 2025-03-15 15:21:41 +08:00
85 changed files with 2751 additions and 1614 deletions

3
.gitmodules vendored
View File

@@ -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

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Apr 29 15:14:41 HKT 2025
stageCount=1
#Mon May 12 18:10:35 HKT 2025
stageCount=4
libraryProject=libaes
baseVersion=15.6
publishVersion=15.6.0
publishVersion=15.6.3
buildCount=0
baseBetaVersion=15.6.1
baseBetaVersion=15.6.4

View File

@@ -10,13 +10,14 @@ import android.content.Context;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import cc.winboll.studio.libaes.winboll.APPInfo;
import cc.winboll.studio.libaes.winboll.AboutView;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
public class AboutActivity extends WinBoLLActivity implements IWinBoLLActivity {
public class AboutActivity extends AppCompatActivity implements IWinBoLLActivity {
public static final String TAG = "AboutActivity";

View File

@@ -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);
}
}

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Apr 29 14:47:34 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

View File

@@ -1,81 +0,0 @@
package cc.winboll.studio.appbase;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/28 15:34:16
* @Describe 应用活动窗口基类
*/
import android.app.Activity;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.MenuItem;
import cc.winboll.studio.appbase.App;
import cc.winboll.studio.appbase.R;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog;
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
import cc.winboll.studio.libappbase.winboll.WinBoLLActivityManager;
public class WinBoLLActivityBase extends Activity implements IWinBoLLActivity {
public static final String TAG = "WinBoLLActivityBase";
@Override
public Activity getActivity() {
return this;
}
@Override
public String getTag() {
return TAG;
}
WinBoLLActivityManager getWinBoLLActivityManager() {
return WinBoLLActivityManager.getInstance(GlobalApplication.getInstance());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWinBoLLActivityManager().add(this);
}
@Override
public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onPostCreate(savedInstanceState, persistentState);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == cc.winboll.studio.appbase.R.id.item_log) {
GlobalApplication.getWinBoLLActivityManager().startLogActivity(this);
return true;
} else if(item.getItemId() == cc.winboll.studio.appbase.R.id.item_minimal) {
//moveTaskToBack(true);
exit();
}
// 在switch语句中处理每个ID并在处理完后返回true未处理的情况返回false。
return super.onOptionsItemSelected(item);
}
void exit() {
YesNoAlertDialog.show(this, "Exit " + getString(R.string.app_name), "Close all activity and exit?", new YesNoAlertDialog.OnDialogResultListener(){
@Override
public void onYes() {
App.getWinBoLLActivityManager().finishAll();
}
@Override
public void onNo() {
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
getWinBoLLActivityManager().registeRemove(this);
}
}

View File

@@ -1,36 +0,0 @@
package cc.winboll.studio.apputils;
/**
* @Author ZhanGSKen@QQ.COM
* @Date 2025/01/17 19:50:46
*/
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toolbar;
import cc.winboll.studio.apputils.R;
import cc.winboll.studio.libapputils.views.StringToQrCodeView;
public class TestStringToQRCodeViewActivity extends Activity {
public static final String TAG = "TestStringToQrCodeViewActivity";
StringToQrCodeView mStringToQrCodeView;
//
// @Override
// public Activity getActivity() {
// return this;
// }
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_teststringtoqrcodeview);
// 初始化工具栏
Toolbar mToolbar = findViewById(R.id.toolbar);
mToolbar.setSubtitle(TAG);
setActionBar(mToolbar);
mStringToQrCodeView = findViewById(R.id.activityteststringtoqrcodeviewStringToQrCodeView1);
}
}

View File

@@ -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);
}
}

View File

@@ -19,7 +19,7 @@ def genVersionName(def versionName){
android {
compileSdkVersion 32
buildToolsVersion "33.0.3"
buildToolsVersion "32.0.0"
defaultConfig {
applicationId "cc.winboll.studio.autoinstaller"
@@ -29,7 +29,7 @@ android {
// versionName 更新后需要手动设置
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
versionName "5.0"
versionName "15.2"
if(true) {
versionName = genVersionName("${versionName}")
}
@@ -41,30 +41,33 @@ 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.1.0'
api 'io.github.medyo:android-about-page:2.0.0'
api 'com.github.getActivity:ToastUtils:10.5'
api 'com.jcraft:jsch:0.1.55'
api 'org.jsoup:jsoup:1.13.1'
api 'com.squareup.okhttp3:okhttp:4.4.1'
api 'androidx.appcompat:appcompat:1.0.0'
api 'androidx.fragment:fragment:1.0.0'
api 'com.google.android.material:material:1.0.0'
api 'androidx.vectordrawable:vectordrawable-animated:1.0.0'
api 'androidx.lifecycle:lifecycle-livedata:1.0.0'
//api 'cc.winboll.studio:libaes:6.3.2'
//api 'cc.winboll.studio:libapputils:8.3.8'
api fileTree(dir: 'libs', include: ['*.jar'])
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'
}

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Thu Jan 02 02:39:56 HKT 2025
stageCount=4
#Sun May 04 05:32:00 GMT 2025
stageCount=1
libraryProject=
baseVersion=5.0
publishVersion=5.0.3
buildCount=0
baseBetaVersion=5.0.4
baseVersion=15.2
publishVersion=15.2.0
buildCount=74
baseBetaVersion=15.2.1

View File

@@ -23,6 +23,8 @@
<!-- MANAGE_EXTERNAL_STORAGE -->
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<application
android:name=".App"
@@ -33,7 +35,7 @@
android:persistent="true"
android:supportsRtl="true"
android:requestLegacyExternalStorage="true"
android:theme="@style/Theme.Application">
android:theme="@style/MyAppTheme">
<activity
android:name=".MainActivity"
@@ -54,6 +56,21 @@
<service android:name=".services.AssistantService"/>
<service
android:name=".AppBaseTileService"
android:exported="true"
android:label="@string/tileservice_name"
android:icon="@drawable/ic_launcher"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE"/>
</intent-filter>
</service>
<receiver
android:name=".receivers.MainReceiver"
android:enabled="true"

View File

@@ -6,22 +6,23 @@ package cc.winboll.studio.autoinstaller;
* @Describe 全局应用类
*/
import android.view.Gravity;
import cc.winboll.studio.libappbase.GlobalApplication;
import com.hjq.toast.ToastUtils;
import cc.winboll.studio.shared.app.WinBollApplication;
import com.hjq.toast.style.WhiteToastStyle;
public class App extends WinBollApplication {
public class App extends GlobalApplication {
public static final String TAG = "App";
@Override
public void onCreate() {
super.onCreate();
setIsDebug(BuildConfig.DEBUG);
// 初始化 Toast 框架
ToastUtils.init(this);
// 设置 Toast 布局样式
ToastUtils.setView(R.layout.toast_custom_view);
//ToastUtils.setStyle(new WhiteToastStyle());
//ToastUtils.setView(R.layout.view_toast);
ToastUtils.setStyle(new WhiteToastStyle());
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
}
}

View File

@@ -0,0 +1,12 @@
package cc.winboll.studio.autoinstaller;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/04/15 09:24:46
* @Describe 磁贴工具服务类
*/
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import cc.winboll.studio.autoinstaller.models.AppConfigs;

View File

@@ -1,7 +1,7 @@
package cc.winboll.studio.autoinstaller;
import android.os.FileObserver;
import cc.winboll.studio.shared.log.LogUtils;
import cc.winboll.studio.libappbase.LogUtils;
public class FileListener extends FileObserver {
public final static String TAG = "FileListener";

View File

@@ -6,21 +6,24 @@ import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.SimpleAdapter;
import android.widget.Switch;
import android.widget.TextClock;
import android.widget.Toast;
import androidx.core.content.FileProvider;
import cc.winboll.studio.shared.log.LogUtils;
import cc.winboll.studio.shared.log.LogView;
import cc.winboll.studio.autoinstaller.MainActivity;
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
import cc.winboll.studio.autoinstaller.models.APKModel;
import cc.winboll.studio.autoinstaller.models.AppConfigs;
import cc.winboll.studio.autoinstaller.services.MainService;
import cc.winboll.studio.autoinstaller.utils.NotificationUtil;
import cc.winboll.studio.autoinstaller.utils.PackageUtil;
import cc.winboll.studio.autoinstaller.views.ListViewForScrollView;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.LogView;
import com.hjq.toast.ToastUtils;
import java.io.File;
import java.util.ArrayList;
@@ -30,8 +33,13 @@ import java.util.Map;
public class MainActivity extends Activity {
public static final String TAG = "MainActivity";
public static final int MSG_UPDATE_STATUS = 0;
private static final int INSTALL_PERMISSION_CODE = 1;
static MainActivity _MainActivity;
ArrayList<APKModel> _APKModelList = new ArrayList<APKModel>();
LogView mLogView;
TextClock mTextClock;
EditText mEditText;
@@ -60,9 +68,11 @@ public class MainActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
_MainActivity = this;
initView();
if (getIntent().getAction().equals(ACTION_NEW_INSTALLTASK)) {
String action = getIntent().getAction();
if ((action != null) && action.equals(ACTION_NEW_INSTALLTASK)) {
mszInstalledPackageName = getIntent().getStringExtra(EXTRA_INSTALLED_PACKAGENAME);
mszInstalledAPKFilePath = getIntent().getStringExtra(EXTRA_INSTALLED_APKFILEPATH);
installAPK();
@@ -76,11 +86,7 @@ public class MainActivity extends Activity {
mLogView = findViewById(R.id.logview);
mLogView.start();
AppConfigs appConfigs = AppConfigs.loadAppConfigs(this);
if (appConfigs == null) {
appConfigs = new AppConfigs();
AppConfigs.saveAppConfigs(this, appConfigs);
}
AppConfigs appConfigs = AppConfigs.getInstance(this).loadAppConfigs(this);
if (appConfigs.getSetupMode() == AppConfigs.SetupMode.WATCHOUTPUTINSTALLER) {
((RadioButton)findViewById(R.id.activitymainRadioButton1)).setChecked(true);
@@ -131,23 +137,44 @@ public class MainActivity extends Activity {
}
String getLastApkPackageName() {
APKModel.loadBeanList(this, _APKModelList, APKModel.class);
if (_APKModelList.size() > 0) {
return _APKModelList.get(_APKModelList.size() - 1).getApkPackageName();
}
return "";
}
public void onOpenAPP(View view) {
if (mszInstalledPackageName.trim().equals("")) {
String szInstalledPackageName = getLastApkPackageName();
LogUtils.d(TAG, "szInstalledPackageName : " + szInstalledPackageName);
if (szInstalledPackageName.trim().equals("")) {
ToastUtils.show("Installed APP package name is null.");
return;
}
Intent intent = getPackageManager().getLaunchIntentForPackage(mszInstalledPackageName);
if (intent != null) {
startActivity(intent);
} else {
// 若没能获取到启动意图,可进行相应提示等操作,比如跳转到应用商店让用户下载该应用(示例)
Intent marketIntent = new Intent(Intent.ACTION_VIEW);
marketIntent.setData(Uri.parse("market://details?id=" + mszInstalledPackageName));
startActivity(marketIntent);
}
PackageUtil.openAPP(this, szInstalledPackageName);
}
// public void onOpenAPP(View view) {
// String szInstalledPackageName = getLastApkPackageName();
// if (szInstalledPackageName.trim().equals("")) {
// ToastUtils.show("Installed APP package name is null.");
// return;
// }
//
// Intent intent = getPackageManager().getLaunchIntentForPackage(mszInstalledPackageName);
// if (intent != null) {
// //ToastUtils.show("startActivity");
// startActivity(intent);
// } else {
// // 若没能获取到启动意图,可进行相应提示等操作,比如跳转到应用商店让用户下载该应用(示例)
// Intent marketIntent = new Intent(Intent.ACTION_VIEW);
// marketIntent.setData(Uri.parse("market://details?id=" + mszInstalledPackageName));
// startActivity(marketIntent);
// }
// }
public void onInstallAPK(View view) {
installAPK();
}
@@ -185,17 +212,22 @@ public class MainActivity extends Activity {
}
public void onLockPath(View view) {
AppConfigs appConfigs = AppConfigs.loadAppConfigs(this);
Switch sw = (Switch)view;
if (sw.isChecked()) {
setMainServiceStatus(sw.isChecked());
}
public void setMainServiceStatus(boolean isEnable) {
AppConfigs appConfigs = AppConfigs.getInstance(this).loadAppConfigs(this);
Switch sw = (Switch)findViewById(R.id.activitymainSwitch1);
if (isEnable) {
String szFilePath = mEditText.getText().toString();
// 设置空路径时退出
//
if (szFilePath.trim().equals("")) {
sw.setChecked(false);
Toast.makeText(getApplication(), "监控路径为空。", Toast.LENGTH_SHORT).show();
ToastUtils.show("监控路径为空。");
return;
}
@@ -236,7 +268,7 @@ public class MainActivity extends Activity {
stopWatchingFile();
}
AppConfigs.saveAppConfigs(this, appConfigs);
AppConfigs.getInstance(this).saveAppConfigs(this, appConfigs);
}
void stopWatchingFile() {
@@ -251,8 +283,6 @@ public class MainActivity extends Activity {
Intent intentService = new Intent(MainActivity.this, MainService.class);
//intentService.putExtra(MainService.EXTRA_APKFILEPATH, szAPKFilePath);
startService(intentService);
}
/*
@@ -298,7 +328,7 @@ public class MainActivity extends Activity {
}*/
public void onChangeSetupMode(View view) {
AppConfigs appConfigs = AppConfigs.loadAppConfigs(this);
AppConfigs appConfigs = AppConfigs.getInstance(this).loadAppConfigs(this);
if (view.getId() == R.id.activitymainRadioButton1) {
appConfigs.setSetupMode(AppConfigs.SetupMode.WATCHOUTPUTINSTALLER);
@@ -307,6 +337,42 @@ public class MainActivity extends Activity {
appConfigs.setSetupMode(AppConfigs.SetupMode.NEWAPKINFONEWAPKINFO);
((RadioButton)findViewById(R.id.activitymainRadioButton1)).setChecked(false);
}
AppConfigs.saveAppConfigs(this, appConfigs);
AppConfigs.getInstance(this).saveAppConfigs(this, appConfigs);
}
// 定义Handler
static Handler _Handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == MSG_UPDATE_STATUS) {
if (_MainActivity != null) {
boolean isEnableMainService = (boolean)msg.obj;
// 处理消息,这里更新 MainService 的状态
_MainActivity.setMainServiceStatus(isEnableMainService);
}
}
}
};
static void updateMainServiceStatus(boolean isEnable) {
if (_Handler != null) {
Message msg = new Message();
msg.obj = isEnable;
msg.what = MSG_UPDATE_STATUS;
_Handler.sendMessage(msg);
}
}
public static void stopMainService() {
if (_MainActivity != null && _Handler != null) {
updateMainServiceStatus(false);
}
}
public static void startMainService() {
if (_MainActivity != null && _Handler != null) {
updateMainServiceStatus(true);
}
}
}

View File

@@ -0,0 +1,75 @@
package cc.winboll.studio.autoinstaller.models;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/04/02 20:50:29
* @Describe 监控的 APK 安装文件对应的应用信息数据模型
*/
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class APKModel extends BaseBean {
public static final String TAG = "APPModel";
// 每次更新的 APK 文件对应的应用包名称
String apkPackageName;
public APKModel() {
this.apkPackageName = "";
}
public APKModel(String apkPackageName) {
this.apkPackageName = apkPackageName;
}
public void setApkPackageName(String apkPackageName) {
this.apkPackageName = apkPackageName;
}
public String getApkPackageName() {
return apkPackageName;
}
@Override
public String getName() {
return APKModel.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
jsonWriter.name("appPackageName").value(getApkPackageName());
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
if (name.equals("appPackageName")) {
setApkPackageName(jsonReader.nextString());
} else {
return false;
}
}
return true;
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (!initObjectsFromJsonReader(jsonReader, name)) {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return this;
}
}

View File

@@ -1,4 +1,4 @@
package cc.winboll.studio.autoinstaller.beans;
package cc.winboll.studio.autoinstaller.models;
/**
* @Author ZhanGSKen@QQ.COM
@@ -8,13 +8,14 @@ package cc.winboll.studio.autoinstaller.beans;
import android.content.Context;
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
import cc.winboll.studio.autoinstaller.models.AppConfigs;
import cc.winboll.studio.autoinstaller.utils.FileUtil;
import cc.winboll.studio.libappbase.LogUtils;
import com.hjq.toast.ToastUtils;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringReader;
import java.io.StringWriter;
import cc.winboll.studio.shared.log.LogUtils;
public class AppConfigs implements Serializable {
@@ -26,6 +27,21 @@ public class AppConfigs implements Serializable {
NEWAPKINFONEWAPKINFO // 调用[应用信息查看器]打开应用包
};
static volatile AppConfigs _AppConfigs;
Context mContext;
AppConfigs(Context context) {
mContext = context.getApplicationContext();
}
public static synchronized AppConfigs getInstance(Context context) {
if (_AppConfigs == null) {
_AppConfigs = new AppConfigs(context);
_AppConfigs.loadAppConfigs(_AppConfigs.mContext);
}
return _AppConfigs;
}
// 监控文件路径
private String watchingFilePath = "";
@@ -85,8 +101,8 @@ public class AppConfigs implements Serializable {
return "";
}
public static AppConfigs parseAppConfigs(String szAppConfigs) {
AppConfigs appConfigs = new AppConfigs();
public AppConfigs parseAppConfigs(String szAppConfigs) {
AppConfigs appConfigs = new AppConfigs(mContext);
// 创建 JsonWriter 对象
StringReader stringReader = new StringReader(szAppConfigs);
JsonReader jsonReader = new
@@ -121,20 +137,35 @@ public class AppConfigs implements Serializable {
static String getDataPath(Context context) {
return context.getExternalFilesDir(TAG) + "/" + TAG + ".json";
}
public static AppConfigs loadAppConfigs(Context context) {
public AppConfigs loadAppConfigs() {
AppConfigs appConfigs = null;
try {
String szJson = FileUtil.readFile(getDataPath(context));
appConfigs = AppConfigs.parseAppConfigs(szJson);
String szJson = FileUtil.readFile(getDataPath(mContext));
appConfigs = AppConfigs.getInstance(mContext).parseAppConfigs(szJson);
} catch (IOException e) {
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
}
return appConfigs;
}
public static void saveAppConfigs(Context context, AppConfigs appConfigs) {
public AppConfigs loadAppConfigs(Context context) {
AppConfigs appConfigs = null;
try {
String szJson = FileUtil.readFile(getDataPath(context.getApplicationContext()));
appConfigs = AppConfigs.getInstance(mContext).parseAppConfigs(szJson);
if(appConfigs != null) {
_AppConfigs = appConfigs;
}
} catch (IOException e) {
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
}
return _AppConfigs;
}
public void saveAppConfigs(Context context, AppConfigs appConfigs) {
try {
ToastUtils.show(String.format("AppConfigs set enable service to %s", appConfigs.isEnableService()));
//LogUtils.d(TAG, "appConfigs is : " + appConfigs.toString());
String szJson = appConfigs.toString();
FileUtil.writeFile(getDataPath(context), szJson);
@@ -142,4 +173,8 @@ public class AppConfigs implements Serializable {
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
}
}
public void saveAppConfigs() {
saveAppConfigs(mContext, this);
}
}

View File

@@ -1,54 +1,49 @@
package cc.winboll.studio.appbase.models;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/02/17 10:05:09
* @Describe APPSOSReportBean
*/
package cc.winboll.studio.autoinstaller.models;
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
public class WinBoLLNewsBean extends BaseBean {
public static final String TAG = "WinBoLLNewsBean";
protected String message;
public WinBoLLNewsBean() {
this.message = "";
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/04/15 09:27:39
* @Describe MainServiceBean
*/
public class MainServiceBean extends BaseBean {
public static final String TAG = "MainServiceBean";
boolean isEnable;
public MainServiceBean() {
this.isEnable = false;
}
public WinBoLLNewsBean(String message) {
this.message = message;
public void setIsEnable(boolean isEnable) {
this.isEnable = isEnable;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
public boolean isEnable() {
return isEnable;
}
@Override
public String getName() {
return WinBoLLNewsBean.class.getName();
return MainServiceBean.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
jsonWriter.name("message").value(getMessage());
jsonWriter.name("isEnable").value(isEnable());
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
if (name.equals("message")) {
setMessage(jsonReader.nextString());
if (name.equals("isEnable")) {
setIsEnable(jsonReader.nextBoolean());
} else {
return false;
}

View File

@@ -4,9 +4,9 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
import cc.winboll.studio.autoinstaller.models.AppConfigs;
import cc.winboll.studio.autoinstaller.services.MainService;
import cc.winboll.studio.shared.log.LogUtils;
import cc.winboll.studio.libappbase.LogUtils;
/**
* @Author ZhanGSKen@QQ.COM
@@ -23,7 +23,7 @@ public class MainReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
String szAction = intent.getAction();
if (szAction.equals(ACTION_BOOT_COMPLETED)) {
AppConfigs appConfigs = AppConfigs.loadAppConfigs(context);
AppConfigs appConfigs = AppConfigs.getInstance(context).loadAppConfigs(context);
if (appConfigs.isEnableService()) {
Intent intentService = new Intent(context, MainService.class);
//intentService.putExtra(MainService.EXTRA_APKFILEPATH, appConfigs.getWatchingFilePath());

View File

@@ -6,7 +6,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
import cc.winboll.studio.autoinstaller.models.AppConfigs;
import cc.winboll.studio.autoinstaller.utils.ServiceUtil;
/**
@@ -46,7 +46,7 @@ public class AssistantService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) {
//LogUtils.d(TAG, "call onStartCommand(...)");
run();
AppConfigs appConfigs = AppConfigs.loadAppConfigs(AssistantService.this);
AppConfigs appConfigs = AppConfigs.getInstance(AssistantService.this).loadAppConfigs(AssistantService.this);
return appConfigs.isEnableService() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
}
@@ -68,7 +68,7 @@ public class AssistantService extends Service {
//
void run() {
//LogUtils.d(TAG, "call run()");
AppConfigs appConfigs = AppConfigs.loadAppConfigs(AssistantService.this);
AppConfigs appConfigs = AppConfigs.getInstance(AssistantService.this).loadAppConfigs(AssistantService.this);
if (appConfigs.isEnableService()) {
if (mIsThreadAlive == false) {
// 设置运行状态
@@ -101,7 +101,7 @@ public class AssistantService extends Service {
@Override
public void onServiceDisconnected(ComponentName name) {
//LogUtils.d(TAG, "call onServiceDisconnected(...)");
AppConfigs appConfigs = AppConfigs.loadAppConfigs(AssistantService.this);
AppConfigs appConfigs = AppConfigs.getInstance(AssistantService.this).loadAppConfigs(AssistantService.this);
if (appConfigs.isEnableService()) {
wakeupAndBindMain();
}

View File

@@ -10,25 +10,32 @@ import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.widget.Toast;
import androidx.core.content.FileProvider;
import cc.winboll.studio.shared.log.LogUtils;
import cc.winboll.studio.autoinstaller.FileListener;
import cc.winboll.studio.autoinstaller.MainActivity;
import cc.winboll.studio.autoinstaller.beans.AppConfigs;
import cc.winboll.studio.autoinstaller.R;
import cc.winboll.studio.autoinstaller.models.APKModel;
import cc.winboll.studio.autoinstaller.models.AppConfigs;
import cc.winboll.studio.autoinstaller.services.AssistantService;
import cc.winboll.studio.autoinstaller.services.MainService;
import cc.winboll.studio.autoinstaller.utils.NotificationUtil;
import cc.winboll.studio.autoinstaller.utils.PackageUtil;
import cc.winboll.studio.autoinstaller.utils.ServiceUtil;
import com.hjq.toast.ToastUtils;
import cc.winboll.studio.libappbase.LogUtils;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
public class MainService extends Service {
public static String TAG = "MainService";
Context mContext;
ArrayList<APKModel> _APKModelList = new ArrayList<APKModel>();
private static boolean _mIsServiceAlive;
//String mszAPKFilePath;
//String mszAPKFileName;
@@ -47,6 +54,7 @@ public class MainService extends Service {
@Override
public void onCreate() {
super.onCreate();
mContext = this;
LogUtils.d(TAG, "onCreate()");
_mIsServiceAlive = false;
mHandler = new MyHandler(MainService.this);
@@ -55,11 +63,14 @@ public class MainService extends Service {
}
run();
// 初始化磁贴工具服务
MainTileService mainTileService = new MainTileService(this);
}
private void run() {
AppConfigs appConfigs = AppConfigs.loadAppConfigs(MainService.this);
AppConfigs appConfigs = AppConfigs.getInstance(MainService.this).loadAppConfigs(MainService.this);
if (appConfigs.isEnableService()) {
if (_mIsServiceAlive == false) {
// 设置运行状态
@@ -74,7 +85,8 @@ public class MainService extends Service {
startWatchingFile(appConfigs.getWatchingFilePath());
LogUtils.d(TAG, "running...");
//LogUtils.d(TAG, "running...");
//ToastUtils.show("running...");
} else {
LogUtils.d(TAG, "_mIsServiceAlive is " + Boolean.toString(_mIsServiceAlive));
@@ -94,6 +106,7 @@ public class MainService extends Service {
}
_mIsServiceAlive = false;
LogUtils.d(TAG, "onDestroy()");
mContext = null;
}
@Override
@@ -101,7 +114,7 @@ public class MainService extends Service {
LogUtils.d(TAG, "onStartCommand");
run();
AppConfigs appConfigs = AppConfigs.loadAppConfigs(MainService.this);
AppConfigs appConfigs = AppConfigs.getInstance(MainService.this).loadAppConfigs(MainService.this);
return appConfigs.isEnableService() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
}
@@ -118,7 +131,7 @@ public class MainService extends Service {
@Override
public void onServiceDisconnected(ComponentName name) {
//LogUtils.d(TAG, "call onServiceConnected(...)");
AppConfigs appConfigs = AppConfigs.loadAppConfigs(MainService.this);
AppConfigs appConfigs = AppConfigs.getInstance(MainService.this).loadAppConfigs(MainService.this);
if (appConfigs.isEnableService()) {
// 唤醒守护进程
wakeupAndBindAssistant();
@@ -160,7 +173,7 @@ public class MainService extends Service {
});
mFileListener.startWatching();
ToastUtils.show("Start watching.");
//ToastUtils.show("Start watching.");
} else {
// 父级文件夹不存在,就提示用户
Toast.makeText(getApplication(), fParentDir.toString() + " no exist.", Toast.LENGTH_SHORT).show();
@@ -176,6 +189,9 @@ public class MainService extends Service {
// 调用[应用信息查看器]打开应用包
//
private void installAPK(String szAPKFilePath) {
String szAPKPackageName = PackageUtil.getPackageNameFromApk(this, szAPKFilePath);
saveAPKInfo(szAPKPackageName);
long nTimeNow = System.currentTimeMillis();
/*SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss", Locale.getDefault());
@@ -210,15 +226,24 @@ public class MainService extends Service {
//
void installAPK2(String szAPKFilePath) {
LogUtils.d(TAG, "installAPK2()");
String szAPKPackageName = PackageUtil.getPackageNameFromApk(this, szAPKFilePath);
saveAPKInfo(szAPKPackageName);
Intent intent = new Intent(this, MainActivity.class);
intent.setAction(MainActivity.ACTION_NEW_INSTALLTASK);
intent.putExtra(MainActivity.EXTRA_INSTALLED_PACKAGENAME, PackageUtil.getPackageNameFromApk(this, szAPKFilePath));
intent.putExtra(MainActivity.EXTRA_INSTALLED_PACKAGENAME, szAPKPackageName);
intent.putExtra(MainActivity.EXTRA_INSTALLED_APKFILEPATH, szAPKFilePath);
// Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
}
void saveAPKInfo(String szApkPackageName) {
APKModel.loadBeanList(this, _APKModelList, APKModel.class);
_APKModelList.add(new APKModel(szApkPackageName));
APKModel.saveBeanList(this, _APKModelList, APKModel.class);
}
//
//
static class MyHandler extends Handler {
@@ -231,7 +256,7 @@ public class MainService extends Service {
switch (message.what) {
case MSG_INSTALL_APK:
{
AppConfigs appConfigs = AppConfigs.loadAppConfigs(theActivity);
AppConfigs appConfigs = AppConfigs.getInstance(theActivity).loadAppConfigs(theActivity);
if (appConfigs.getSetupMode() == AppConfigs.SetupMode.WATCHOUTPUTINSTALLER) {
theActivity.installAPK2((String)message.obj);
} else if (appConfigs.getSetupMode() == AppConfigs.SetupMode.NEWAPKINFONEWAPKINFO) {
@@ -245,4 +270,21 @@ public class MainService extends Service {
super.handleMessage(message);
}
}
static class MainTileService extends TileService {
Context mContext;
MainTileService(Context context) {
mContext = context;
}
@Override
public void onStartListening() {
super.onStartListening();
Tile tile = getQsTile();
tile.setIcon(android.graphics.drawable.Icon.createWithResource(this, R.drawable.ic_android));
// 更新磁贴状态
tile.setState((mContext == null || mContext.getApplicationContext() == null )?Tile.STATE_INACTIVE: Tile.STATE_ACTIVE);
tile.updateTile();
}
}
}

View File

@@ -55,8 +55,9 @@ public class NotificationUtil {
Notification mForegroundNotification = new Notification.Builder(service, szServiceChannelID)
.setAutoCancel(true)
.setContentTitle(service.getString(R.string.app_name))
.setContentText(service.TAG + " is started.")
//.setContentTitle(service.getString(R.string.app_name))
.setContentTitle(service.TAG + " is started.")
//.setContentText(service.TAG + " is started.")
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher)
//设置红色

View File

@@ -6,9 +6,11 @@ package cc.winboll.studio.autoinstaller.utils;
* @Describe 一个获取安卓APK安装文件的应用包名的函数
*/
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import cc.winboll.studio.shared.log.LogUtils;
import android.content.pm.ResolveInfo;
import cc.winboll.studio.libappbase.LogUtils;
public class PackageUtil {
@@ -27,4 +29,20 @@ public class PackageUtil {
}
return "";
}
public static void openAPP(Context context, String packageName) {
// 这里假设要打开微信微信的包名是com.tencent.mm
//String packageName = "com.tencent.mm";
LogUtils.d(TAG, "packageName : " + packageName);
PackageManager packageManager = context.getPackageManager();
Intent intent = packageManager.getLaunchIntentForPackage(packageName);
if (intent != null) {
ResolveInfo resolveInfo = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (resolveInfo != null) {
LogUtils.d(TAG, "startActivity...");
context.startActivity(intent);
}
}
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#FF000000"
android:pathData="M16.61,15.15C16.15,15.15 15.77,14.78 15.77,14.32S16.15,13.5 16.61,13.5H16.61C17.07,13.5 17.45,13.86 17.45,14.32C17.45,14.78 17.07,15.15 16.61,15.15M7.41,15.15C6.95,15.15 6.57,14.78 6.57,14.32C6.57,13.86 6.95,13.5 7.41,13.5H7.41C7.87,13.5 8.24,13.86 8.24,14.32C8.24,14.78 7.87,15.15 7.41,15.15M16.91,10.14L18.58,7.26C18.67,7.09 18.61,6.88 18.45,6.79C18.28,6.69 18.07,6.75 18,6.92L16.29,9.83C14.95,9.22 13.5,8.9 12,8.91C10.47,8.91 9,9.24 7.73,9.82L6.04,6.91C5.95,6.74 5.74,6.68 5.57,6.78C5.4,6.87 5.35,7.08 5.44,7.25L7.1,10.13C4.25,11.69 2.29,14.58 2,18H22C21.72,14.59 19.77,11.7 16.91,10.14H16.91Z"/>
</vector>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#ff000000"
android:pathData="M6.5,20Q4.22,20 2.61,18.43 1,16.85 1,14.58 1,12.63 2.17,11.1 3.35,9.57 5.25,9.15 5.88,6.85 7.75,5.43 9.63,4 12,4 14.93,4 16.96,6.04 19,8.07 19,11 20.73,11.2 21.86,12.5 23,13.78 23,15.5 23,17.38 21.69,18.69 20.38,20 18.5,20Z"/>
</vector>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#ff000000"
android:pathData="M6.5,20Q4.22,20 2.61,18.43 1,16.85 1,14.58 1,12.63 2.17,11.1 3.35,9.57 5.25,9.15 5.88,6.85 7.75,5.43 9.63,4 12,4 14.93,4 16.96,6.04 19,8.07 19,11 20.73,11.2 21.86,12.5 23,13.78 23,15.5 23,17.38 21.69,18.69 20.38,20 18.5,20M6.5,18H18.5Q19.55,18 20.27,17.27 21,16.55 21,15.5 21,14.45 20.27,13.73 19.55,13 18.5,13H17V11Q17,8.93 15.54,7.46 14.08,6 12,6 9.93,6 8.46,7.46 7,8.93 7,11H6.5Q5.05,11 4.03,12.03 3,13.05 3,14.5 3,15.95 4.03,17 5.05,18 6.5,18M12,12Z"/>
</vector>

View File

@@ -132,7 +132,7 @@
</LinearLayout>
<cc.winboll.studio.shared.log.LogView
<cc.winboll.studio.libappbase.LogView
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="200dp"

View File

@@ -1,3 +1,4 @@
<resources>
<string name="app_name">AutoInstaller</string>
<string name="tileservice_name">AutoInstaller</string>
</resources>

View File

@@ -0,0 +1,13 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="MyAppTheme" parent="APPBaseTheme">
<item name="attrColorPrimary">@color/colorPrimary</item>
<item name="themeGlobalCrashActivity">@style/MyGlobalCrashActivityTheme</item>
</style>
<style name="MyGlobalCrashActivityTheme" parent="GlobalCrashActivityTheme">
<item name="colorTittle">#FFFFFFFF</item>
<item name="colorTittleBackgound">#FF00A4B3</item>
<item name="colorText">#FFFFFFFF</item>
<item name="colorTextBackgound">#FF000000</item>
</style>
</resources>

View File

@@ -1,14 +0,0 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Application" parent="android:Theme.Material.Light.DarkActionBar">
<!-- Primary brand color. -->
<item name="android:colorPrimary">@color/purple_500</item>
<!-- Secondary brand color. -->
<item name="android:colorSecondary">@color/teal_200</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">@color/purple_700</item>
<!-- Customize your theme here. -->
</style>
</resources>

View File

@@ -1,11 +1,10 @@
// 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" }
mavenLocal {
// 设置本地Maven仓库路径
url 'file:///sdcard/.m2/repository/'
}
// Nexus Maven 库地址
// "WinBoLL Release"
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
@@ -20,7 +19,13 @@ buildscript {
maven { url "https://jitpack.io" }
mavenCentral()
google()
//println "mavenLocal : ==========="
//println mavenLocal().url
//println "mavenLocal : ==========="
//mavenLocal()
// WinBoLL.CC 紧急备用 Maven 仓库
maven { url 'https://spare-maven.winboll.cc/repository/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1' // 对应 compileSdkVersion 32
@@ -31,6 +36,11 @@ buildscript {
allprojects {
repositories {
mavenLocal {
// 设置本地Maven仓库路径
url 'file:///sdcard/.m2/repository/'
}
// Nexus Maven 库地址
// "WinBoLL Release"
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
@@ -45,7 +55,13 @@ allprojects {
maven { url "https://jitpack.io" }
mavenCentral()
google()
mavenLocal()
//println "mavenLocal : ==========="
//println mavenLocal().url
//println "mavenLocal : ==========="
//mavenLocal()
// WinBoLL.CC 紧急备用 Maven 仓库
maven { url 'https://spare-maven.winboll.cc/repository/' }
}
ext {
// 定义全局变量,常用于版本管理

View File

@@ -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'
@@ -50,7 +53,4 @@ dependencies {
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
//api 'androidx.fragment:fragment:1.1.0'
api 'cc.winboll.studio:libapputils:15.3.4'
api 'cc.winboll.studio:libappbase:15.7.6'
}

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Apr 29 15:14:21 HKT 2025
stageCount=1
#Mon May 12 18:10:35 HKT 2025
stageCount=4
libraryProject=libaes
baseVersion=15.6
publishVersion=15.6.0
publishVersion=15.6.3
buildCount=0
baseBetaVersion=15.6.1
baseBetaVersion=15.6.4

View File

@@ -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>

View File

@@ -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;
@@ -14,11 +13,16 @@ import java.io.IOException;
public class WinBoLLClientServiceBean extends BaseBean {
public static final String TAG = "WinBoLLClientServiceBean";
volatile boolean isEnable;
// 服务是否正在使用中
boolean isEnable;
public WinBoLLClientServiceBean() {
isEnable = false;
this.isEnable = false;
}
public WinBoLLClientServiceBean(boolean isEnable) {
this.isEnable = isEnable;
}
public void setIsEnable(boolean isEnable) {
@@ -29,6 +33,7 @@ public class WinBoLLClientServiceBean extends BaseBean {
return isEnable;
}
@Override
public String getName() {
return WinBoLLClientServiceBean.class.getName();
@@ -38,17 +43,17 @@ public class WinBoLLClientServiceBean extends BaseBean {
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
WinBoLLClientServiceBean bean = this;
jsonWriter.name("isEnable").value(bean.isEnable());
//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;
}
@@ -68,11 +73,6 @@ public class WinBoLLClientServiceBean extends BaseBean {
}
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);
return new WinBoLLClientServiceBean();
}
}

View File

@@ -11,7 +11,8 @@ 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 {

View File

@@ -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();
}

View File

@@ -1,192 +1,21 @@
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 {
/**
* @Author ZhanGSKen
* @Date 2025/05/03 19:28
*/
public class WinBoLLClientService extends Service {
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;
}
}
}
}
}
}

View File

@@ -1,22 +0,0 @@
package cc.winboll.studio.libaes.winboll;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/28 19:13:20
* @Describe WinBoLL 邮件服务
*/
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
public class WinBoLLMail extends Service {
public static final String TAG = "WinBoLLMail";
@Override
public IBinder onBind(Intent intent) {
return null;
}
}

View File

@@ -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());
}
}
}
});
}
}

View File

@@ -1,473 +1,38 @@
package cc.winboll.studio.libaes.winboll;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/28 17:41:55
* @Describe WinBoLL 服务主机连接状态视图
* @Author ZhanGSKen
* @Date 2025/05/03 19:14
*/
import cc.winboll.studio.libaes.R;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import cc.winboll.studio.libaes.winboll.WinBoLLClientService;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libapputils.utils.PrefUtils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
//import okhttp3.Authenticator;
//import okhttp3.Credentials;
//import okhttp3.OkHttpClient;
//import okhttp3.Request;
//import okhttp3.Response;
//import okhttp3.Route;
public class WinBoLLServiceStatusView extends LinearLayout {
public static final String TAG = "WinBoLLServiceStatusView";
public static final int MSG_CONNECTION_INFO = 0;
public static final int MSG_UPDATE_CONNECTION_STATUS = 1;
static WinBoLLServiceStatusView _WinBoLLServiceStatusView;
Context mContext;
//boolean mIsConnected;
volatile ConnectionThread mConnectionThread;
String mszServerHost;
WinBoLLClientService mWinBoLLService;
ImageView mImageView;
TextView mTextView;
WinBoLLServiceViewHandler mWinBoLLServiceViewHandler;
//WebView mWebView;
static volatile ConnectionStatus mConnectionStatus;
View.OnClickListener mViewOnClickListener;
static String _mUserName;
static String _mPassword;
static enum ConnectionStatus {
DISCONNECTED,
START_CONNECT,
CONNECTING,
CONNECTED;
};
boolean isBound = false;
ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
IWinBoLLClientServiceBinder binder = (IWinBoLLClientServiceBinder) service;
mWinBoLLService = binder.getService();
isBound = true;
// 可以在这里调用Service的方法进行通信比如获取数据
mImageView.setBackgroundDrawable(mWinBoLLService.getCurrentStatusIconDrawable());
}
@Override
public void onServiceDisconnected(ComponentName name) {
isBound = false;
}
};
public WinBoLLServiceStatusView(Context context) {
super(context);
mContext = context;
initView();
}
public WinBoLLServiceStatusView(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
initView();
}
public WinBoLLServiceStatusView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mContext = context;
initView();
}
public WinBoLLServiceStatusView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mContext = context;
initView();
}
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";
}
void setServerHost(String szWinBoLLServerHost) {
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);
}
void setAuthInfo(String szDevUserName, String szDevUserPassword) {
}
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) {
}
};*/
}

View File

@@ -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

View File

@@ -1,39 +0,0 @@
package cc.winboll.studio.libappbase.sos;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/02 09:54:28
* @Describe WinBoLL 系列应用通用管理类
*/
import android.content.Context;
import android.content.Intent;
import cc.winboll.studio.libappbase.LogUtils;
public class WinBoLL {
public static final String TAG = "WinBoLL";
public static final String ACTION_BIND = WinBoLL.class.getName() + ".ACTION_BIND";
public static final String EXTRA_APPMODEL = "EXTRA_APPMODEL";
public static void bindToAPPBase(Context context, String appMainService) {
LogUtils.d(TAG, "bindToAPPBase(...)");
String toPackage = "cc.winboll.studio.appbase";
startBind(context, toPackage, appMainService);
}
public static void bindToAPPBaseBeta(Context context, String appMainService) {
LogUtils.d(TAG, "bindToAPPBaseBeta(...)");
String toPackage = "cc.winboll.studio.appbase.beta";
startBind(context, toPackage, appMainService);
}
static void startBind(Context context, String toPackage, String appMainService) {
Intent intent = new Intent(ACTION_BIND);
intent.putExtra(EXTRA_APPMODEL, (new APPModel(toPackage, appMainService)).toString());
intent.setPackage(toPackage);
LogUtils.d(TAG, String.format("ACTION_BIND :\nTo Package : %s\nAPP Main Service : %s", toPackage, appMainService));
context.sendBroadcast(intent);
}
}

View File

@@ -1,18 +0,0 @@
package cc.winboll.studio.libappbase.winboll;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/24 08:23:40
* @Describe WinBoLL 活动窗口通用接口
*/
import android.app.Activity;
import android.widget.Toolbar;
public interface IWinBoLLActivity {
public static final String TAG = "IWinBoLLActivity";
// 获取活动窗口
abstract public Activity getActivity();
abstract public String getTag();
}

View File

@@ -1,356 +0,0 @@
package cc.winboll.studio.libappbase.winboll;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/03/24 08:25:43
* @Describe 应用活动窗口管理器
* 参考
* android 类似微信小程序多任务窗口 及 设置 TaskDescription 修改 icon 和 label
* https://blog.csdn.net/qq_29364417/article/details/109379915?app_version=6.4.2&code=app_1562916241&csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22109379915%22%2C%22source%22%3A%22weixin_38986226%22%7D&uLinkId=usr1mkqgl919blen&utm_source=app
*/
import android.app.ActivityManager;
import android.app.TaskStackBuilder;
import android.content.Context;
import android.content.Intent;
import cc.winboll.studio.libappbase.GlobalApplication;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.utils.ToastUtils;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class WinBoLLActivityManager {
public static final String TAG = "WinBoLLActivityManager";
public static final String EXTRA_TAG = "EXTRA_TAG";
public static enum WinBoLLUI_TYPE {
Aplication, // 退出应用后,保持最近任务栏任务记录主窗口
Service // 退出应用后,清理所有最近任务栏任务记录窗口
};
// 应用类型标志
static volatile WinBoLLUI_TYPE _mWinBoLLUI_TYPE = WinBoLLUI_TYPE.Service;
GlobalApplication mGlobalApplication;
static volatile WinBoLLActivityManager _Instance;
static volatile Map<String, IWinBoLLActivity> _mapIWinBoLLList;
volatile IWinBoLLActivity mFirstIWinBoLLActivity;
WinBoLLActivityManager(GlobalApplication application) {
mGlobalApplication = application;
_mapIWinBoLLList = new HashMap<String, IWinBoLLActivity>();
}
public static synchronized WinBoLLActivityManager getInstance(GlobalApplication application) {
LogUtils.d(TAG, "getInstance");
if (_Instance == null) {
LogUtils.d(TAG, "_Instance == null");
_Instance = new WinBoLLActivityManager(application);
}
return _Instance;
}
//
// 设置 WinBoLL 应用 UI 类型
//
public synchronized static void setWinBoLLUI_TYPE(WinBoLLUI_TYPE mWinBoLLUI_TYPE) {
_mWinBoLLUI_TYPE = mWinBoLLUI_TYPE;
}
//
// 获取 WinBoLL 应用 UI 类型
//
public synchronized static WinBoLLUI_TYPE getWinBoLLUI_TYPE() {
return _mWinBoLLUI_TYPE;
}
//
// 把Activity添加到管理中
//
public <T extends IWinBoLLActivity> void add(T iWinBoLL) {
String tag = ((IWinBoLLActivity)iWinBoLL).getTag();
LogUtils.d(TAG, String.format("add(T iWinBoLL) tag is %s", tag));
if (isActive(tag)) {
LogUtils.d(TAG, String.format("isActive(tag) is true, tag : %s.", tag));
} else {
// 设置起始活动窗口,以便最后退出时提问
if (mFirstIWinBoLLActivity == null && _mapIWinBoLLList.size() == 0) {
LogUtils.d(TAG, "Set firstIWinBoLLActivity, iWinBoLL.getTag() is %s" + iWinBoLL.getTag());
mFirstIWinBoLLActivity = iWinBoLL;
}
// 添加到活动窗口列表
_mapIWinBoLLList.put(iWinBoLL.getTag(), iWinBoLL);
LogUtils.d(TAG, String.format("Add activity : %s\n_mapActivityList.size() : %d", iWinBoLL.getTag(), _mapIWinBoLLList.size()));
}
}
//
// activity: 为 null 时,
// intent.putExtra 函数 EXTRA_TAG 参数为 tag
// activity: 不为 null 时,
// intent.putExtra 函数 "tag" 参数为 activity.getTag()
//
public <T extends IWinBoLLActivity> void startWinBoLLActivity(Context context, Class<T> clazz) {
try {
// 如果窗口已存在就重启窗口
String tag = ((IWinBoLLActivity)clazz.newInstance()).getTag();
LogUtils.d(TAG, String.format("startWinBoLLActivity(Context context, Class<T> clazz) tag is %s", tag));
if (isActive(tag)) {
resumeActivity(context, tag);
return;
}
//ToastUtils.show("startWinBoLLActivity(Context context, Class<T> clazz)");
// 新建一个任务窗口
Intent intent = new Intent(context, clazz);
//打开多任务窗口 flags
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(EXTRA_TAG, tag);
context.startActivity(intent);
} catch (InstantiationException | IllegalAccessException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
public <T extends IWinBoLLActivity> void startWinBoLLActivity(Context context, Intent intent, Class<T> clazz) {
try {
// 如果窗口已存在就重启窗口
String tag = ((IWinBoLLActivity)clazz.newInstance()).getTag();
LogUtils.d(TAG, String.format("startWinBoLLActivity(Context context, Intent intent, Class<T> clazz) tag is %s", tag));
if (isActive(tag)) {
resumeActivity(context, tag);
return;
}
// 新建一个任务窗口
//Intent intent = new Intent(context, clazz);
//打开多任务窗口 flags
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(EXTRA_TAG, tag);
context.startActivity(intent);
} catch (InstantiationException | IllegalAccessException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
public <T extends IWinBoLLActivity> void startLogActivity(Context context) {
// 如果窗口已存在就重启窗口
String tag = LogActivity.TAG;
if (isActive(tag)) {
resumeActivity(context, tag);
return;
}
// 新建一个任务窗口
Intent intent = new Intent(context, LogActivity.class);
//打开多任务窗口 flags
// Define the bounds.
// Rect bounds = new Rect(0, 0, 800, 200);
// // Set the bounds as an activity option.
// ActivityOptions options = ActivityOptions.makeBasic();
// options.setLaunchBounds(bounds);
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.putExtra(EXTRA_TAG, tag);
//context.startActivity(intent, options.toBundle());
context.startActivity(intent);
}
public boolean isFirstIWinBoLLActivity(IWinBoLLActivity iWinBoLLActivity) {
return mFirstIWinBoLLActivity != null && mFirstIWinBoLLActivity == iWinBoLLActivity;
}
//
// 判断 tag绑定的 MyActivity是否存在
//
public boolean isActive(String tag) {
LogUtils.d(TAG, String.format("isActive(String tag) tag is %s", tag));
//printIWinBoLLListInfo();
IWinBoLLActivity iWinBoLL = getIWinBoLL(tag);
if (iWinBoLL != null) {
//LogUtils.d(TAG, "isActive(...) activity != null tag " + tag);
//ToastUtils.show("activity != null tag " + tag);
//判断是否为 BaseActivity,如果已经销毁,则移除
if (iWinBoLL.getActivity().isFinishing() || iWinBoLL.getActivity().isDestroyed()) {
_mapIWinBoLLList.remove(iWinBoLL.getTag());
//_mWinBoLLActivityList.remove(activity);
LogUtils.d(TAG, String.format("isActive(...) remove activity.\ntag : %s", tag));
return false;
} else {
LogUtils.d(TAG, String.format("isActive(...) activity is exist.\ntag : %s", tag));
return true;
}
} else {
LogUtils.d(TAG, String.format("isActive(...) iWinBoLL is null tag by %s", tag));
return false;
}
}
static IWinBoLLActivity getIWinBoLL(String tag) {
LogUtils.d(TAG, String.format("getIWinBoLL(String tag) %s", tag));
return _mapIWinBoLLList.get(tag);
}
//
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
//
public <T extends IWinBoLLActivity> void resumeActivity(Context context, String tag) {
LogUtils.d(TAG, "resumeActivity(Context context, String tag)");
T iWinBoLL = (T)getIWinBoLL(tag);
LogUtils.d(TAG, String.format("iWinBoLL.getTag() %s", iWinBoLL.getTag()));
//LogUtils.d(TAG, "activity " + activity.getTag());
if (iWinBoLL != null && !iWinBoLL.getActivity().isFinishing() && !iWinBoLL.getActivity().isDestroyed()) {
resumeActivity(context, iWinBoLL);
}
}
//
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
//
public <T extends IWinBoLLActivity> void resumeActivity(Context context, T iWinBoLL) {
LogUtils.d(TAG, "resumeActivity(Context context, T iWinBoLL)");
ActivityManager am = (ActivityManager) mGlobalApplication.getSystemService(Context.ACTIVITY_SERVICE);
//返回启动它的根任务home 或者 MainActivity
Intent intent = new Intent(mGlobalApplication, iWinBoLL.getClass());
TaskStackBuilder stackBuilder = TaskStackBuilder.create(mGlobalApplication);
stackBuilder.addNextIntentWithParentStack(intent);
stackBuilder.startActivities();
//moveTaskToFront(YourTaskId, 0);
//ToastUtils.show("resumeActivity am.moveTaskToFront");
LogUtils.d(TAG, String.format("iWinBoLL.getActivity().getTaskId() %d", iWinBoLL.getActivity().getTaskId()));
am.moveTaskToFront(iWinBoLL.getActivity().getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION);
LogUtils.d(TAG, "am.moveTaskToFront");
}
//
// 结束所有 Activity
//
public void finishAll() {
try {
for (String key : _mapIWinBoLLList.keySet()) {
//System.out.println("Key: " + key + ", Value: " + _mapActivityList.get(key));
IWinBoLLActivity iWinBoLL = _mapIWinBoLLList.get(key);
//ToastUtils.show("finishAll() activity");
if (iWinBoLL != null && !iWinBoLL.getActivity().isFinishing() && !iWinBoLL.getActivity().isDestroyed()) {
//ToastUtils.show("activity != null ...");
if (getWinBoLLUI_TYPE() == WinBoLLUI_TYPE.Service) {
// 结束窗口和最近任务栏, 建议前台服务类应用使用,可以方便用户再次调用 UI 操作。
iWinBoLL.getActivity().finishAndRemoveTask();
//ToastUtils.show("finishAll() activity.finishAndRemoveTask();");
} else if (getWinBoLLUI_TYPE() == WinBoLLUI_TYPE.Aplication) {
// 结束窗口保留最近任务栏,建议前台服务类应用使用,可以保持应用的系统自觉性。
iWinBoLL.getActivity().finish();
//ToastUtils.show("finishAll() activity.finish();");
} else {
LogUtils.d(TAG, "WinBoLLApplication.WinBoLLUI_TYPE error.");
//ToastUtils.show("WinBoLLApplication.WinBoLLUI_TYPE error.");
}
}
}
} catch (Exception e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
//
// 结束指定Activity
//
public <T extends IWinBoLLActivity> void finish(T iWinBoLL) {
try {
if (iWinBoLL != null && !iWinBoLL.getActivity().isFinishing() && !iWinBoLL.getActivity().isDestroyed()) {
//根据tag 移除 MyActivity
//String tag= activity.getTag();
//_mWinBoLLActivityList.remove(tag);
//ToastUtils.show("remove");
//ToastUtils.show("_mWinBoLLActivityArrayMap.size() " + Integer.toString(_mWinBoLLActivityArrayMap.size()));
// 窗口回调规则:
// [] 当前窗口位置 >> 调度出的窗口位置
// ★:[0] 1 2 3 4 >> 1
// ★0 1 [2] 3 4 >> 1
// ★0 1 2 [3] 4 >> 2
// ★0 1 2 3 [4] >> 3
// ★:[0] >> 直接关闭当前窗口
//LogUtils.d(TAG, "finish no yet.");
IWinBoLLActivity preIWinBoLL = getPreIWinBoLL(iWinBoLL);
iWinBoLL.getActivity().finish();
if (preIWinBoLL != null) {
resumeActivity(mGlobalApplication, preIWinBoLL);
}
}
} catch (Exception e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
}
//
// 获取窗口队列中的前一个窗口
//
IWinBoLLActivity getPreIWinBoLL(IWinBoLLActivity iWinBoLL) {
try {
boolean bingo = false;
IWinBoLLActivity preIWinBoLL = null;
for (Map.Entry<String, IWinBoLLActivity> entity : _mapIWinBoLLList.entrySet()) {
if (entity.getKey().equals(iWinBoLL.getTag())) {
bingo = true;
//LogUtils.d(TAG, "bingo");
break;
}
preIWinBoLL = entity.getValue();
}
if (bingo) {
return preIWinBoLL;
}
} catch (Exception e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
return null;
}
//
// 从管理列表中移除管理项
//
public <T extends IWinBoLLActivity> boolean registeRemove(T activity) {
IWinBoLLActivity iWinBoLLTest = _mapIWinBoLLList.get(activity.getTag());
if (iWinBoLLTest != null) {
_mapIWinBoLLList.remove(activity.getTag());
return true;
}
return false;
}
//
// 打印管理列表项列表里的信息
//
public static void printIWinBoLLListInfo() {
//LogUtils.d(TAG, "printAvtivityListInfo");
if (!_mapIWinBoLLList.isEmpty()) {
StringBuilder sb = new StringBuilder("Map entries : " + Integer.toString(_mapIWinBoLLList.size()));
Iterator<Map.Entry<String, IWinBoLLActivity>> iterator = _mapIWinBoLLList.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, IWinBoLLActivity> entry = iterator.next();
sb.append("\nKey: " + entry.getKey() + ", \nValue: " + entry.getValue().getTag());
//ToastUtils.show("\nKey: " + entry.getKey() + ", Value: " + entry.getValue().getTag());
}
sb.append("\nMap entries end.");
LogUtils.d(TAG, sb.toString());
} else {
LogUtils.d(TAG, "The map is empty.");
}
}
}

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Apr 29 21:00:39 HKT 2025
#Sat May 03 06:21:11 GMT 2025
stageCount=1
libraryProject=
baseVersion=15.3
publishVersion=15.3.0
buildCount=0
buildCount=5
baseBetaVersion=15.3.1

View File

@@ -32,6 +32,8 @@ import cc.winboll.studio.powerbell.utils.AppConfigUtils;
import cc.winboll.studio.powerbell.utils.NotificationHelper;
import cc.winboll.studio.powerbell.utils.ServiceUtils;
import cc.winboll.studio.powerbell.utils.StringUtils;
import android.os.Handler;
import android.os.Looper;
public class ControlCenterService extends Service {
@@ -114,9 +116,17 @@ public class ControlCenterService extends Service {
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);
}
}

View File

@@ -83,8 +83,9 @@ public class NotificationHelper {
Notification notification = new NotificationCompat.Builder(mContext, CHANNEL_ID_FOREGROUND)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_launcher))
.setContentTitle(title)
.setContentText(content)
//.setContentTitle(title + "\n" + content)
.setContentTitle(content)
//.setContentText(content)
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_LOW)
.setOngoing(true)

View File

@@ -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
View File

@@ -0,0 +1 @@
/build

6
timestamp/README.md Normal file
View File

@@ -0,0 +1,6 @@
## TimpStamp
## 时间戳工具集
## 使用要点:
1。常驻通知栏按钮的正常使用
需要设置允许应用[写入剪贴板]的[始终允许]权限。

View File

@@ -0,0 +1 @@

72
timestamp/build.gradle Normal file
View 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.1"
if(true) {
versionName = genVersionName("${versionName}")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
api 'cc.winboll.studio:libaes:15.6.0'
api 'cc.winboll.studio:libapputils:15.3.4'
api 'cc.winboll.studio:libappbase:15.7.6'
// SSH
api 'com.jcraft:jsch:0.1.55'
// Html 解析
api 'org.jsoup:jsoup:1.13.1'
// 二维码类库
api 'com.google.zxing:core:3.4.1'
api 'com.journeyapps:zxing-android-embedded:3.6.0'
// 应用介绍页类库
api 'io.github.medyo:android-about-page:2.0.0'
// 吐司类库
api 'com.github.getActivity:ToastUtils:10.5'
// 网络连接类库
api 'com.squareup.okhttp3:okhttp:4.4.1'
// AndroidX 类库
api 'androidx.appcompat:appcompat:1.1.0'
api 'com.google.android.material:material:1.4.0'
//api 'androidx.viewpager:viewpager:1.0.0'
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
//api 'androidx.fragment:fragment:1.1.0'
}

View File

@@ -0,0 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Wed May 07 15:07:02 HKT 2025
stageCount=2
libraryProject=
baseVersion=15.1
publishVersion=15.1.1
buildCount=0
baseBetaVersion=15.1.2

21
timestamp/proguard-rules.pro vendored Normal file
View 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

View File

@@ -0,0 +1,15 @@
<?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
tools:replace="android:icon,android:roundIcon"
android:icon="@drawable/ic_launcher_beta"
android:roundIcon="@drawable/ic_launcher_beta">
<!-- Put flavor specific code here -->
</application>
</manifest>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TimeStamp +</string>
</resources>

View 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_stage"
android:roundIcon="@drawable/ic_launcher_stage"
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>

View File

@@ -0,0 +1,349 @@
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 int getAPPIcon() {
return BuildConfig.DEBUG?R.drawable.ic_launcher_beta:R.drawable.ic_launcher_stage;
}
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();
}
}
}

View File

@@ -0,0 +1,113 @@
package cc.winboll.studio.timestamp;
/**
* @Author ZhanGSKen
* @Date 2025/05/05 09:49
* @Describe MainService 守护进程服务
*/
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.timestamp.AssistantService;
import cc.winboll.studio.timestamp.MainService;
import cc.winboll.studio.timestamp.models.AppConfigsModel;
import cc.winboll.studio.timestamp.utils.AppConfigsUtil;
import cc.winboll.studio.timestamp.utils.ServiceUtil;
public class AssistantService extends Service {
public static final String TAG = "AssistantService";
//MyBinder mMyBinder;
MyServiceConnection mMyServiceConnection;
volatile boolean mIsThreadAlive;
@Override
public IBinder onBind(Intent intent) {
//return mMyBinder;
return null;
}
@Override
public void onCreate() {
//LogUtils.d(TAG, "call onCreate()");
super.onCreate();
//mMyBinder = new MyBinder();
if (mMyServiceConnection == null) {
mMyServiceConnection = new MyServiceConnection();
}
// 设置运行参数
mIsThreadAlive = false;
run();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
//LogUtils.d(TAG, "call onStartCommand(...)");
run();
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(AssistantService.this).loadAppConfigs();
return appConfigs.isEnableService() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
}
/*class MyBinder extends IMyAidlInterface.Stub {
@Override
public String getServiceName() {
return AssistantService.class.getSimpleName();
}
}*/
@Override
public void onDestroy() {
//LogUtils.d(TAG, "call onDestroy()");
mIsThreadAlive = false;
super.onDestroy();
}
// 运行服务内容
//
void run() {
//LogUtils.d(TAG, "call run()");
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(AssistantService.this).loadAppConfigs();
if (appConfigs.isEnableService()) {
if (mIsThreadAlive == false) {
// 设置运行状态
mIsThreadAlive = true;
// 唤醒和绑定主进程
wakeupAndBindMain();
}
}
}
// 唤醒和绑定主进程
//
void wakeupAndBindMain() {
if (ServiceUtil.isServiceAlive(getApplicationContext(), MainService.class.getName()) == false) {
//LogUtils.d(TAG, "wakeupAndBindMain() Wakeup... ControlCenterService");
startForegroundService(new Intent(AssistantService.this, MainService.class));
}
//LogUtils.d(TAG, "wakeupAndBindMain() Bind... ControlCenterService");
bindService(new Intent(AssistantService.this, MainService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
}
// 主进程与守护进程连接时需要用到此类
//
class MyServiceConnection implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
//LogUtils.d(TAG, "call onServiceConnected(...)");
}
@Override
public void onServiceDisconnected(ComponentName name) {
//LogUtils.d(TAG, "call onServiceDisconnected(...)");
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(AssistantService.this).loadAppConfigs();
if (appConfigs.isEnableService()) {
wakeupAndBindMain();
}
}
}
}

View File

@@ -0,0 +1,100 @@
package cc.winboll.studio.timestamp;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.LogView;
import cc.winboll.studio.timestamp.MainService;
import cc.winboll.studio.timestamp.R;
import cc.winboll.studio.timestamp.utils.AppConfigsUtil;
import com.hjq.toast.ToastUtils;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
public class MainActivity extends AppCompatActivity {
public static final String TAG = "MainActivity";
EditText metTimeStampFormatString;
TextView mtvTimeStampFormatString;
EditText metTimeStampCopyFormatString;
TextView mtvTimeStampCopyFormatString;
LogView mLogView;
Switch mswEnableMainService;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
metTimeStampFormatString = findViewById(R.id.et_timestampformatstring);
mtvTimeStampFormatString = findViewById(R.id.tv_timestampformatstring);
metTimeStampCopyFormatString = findViewById(R.id.et_timestampcopyformatstring);
mtvTimeStampCopyFormatString = findViewById(R.id.tv_timestampcopyformatstring);
metTimeStampFormatString.setText(AppConfigsUtil.getInstance(this).getAppConfigsModel().getTimeStampFormatString());
showPreViewResult(metTimeStampFormatString, mtvTimeStampFormatString);
metTimeStampCopyFormatString.setText(AppConfigsUtil.getInstance(this).getAppConfigsModel().getTimeStampCopyFormatString());
showPreViewResult(metTimeStampCopyFormatString, mtvTimeStampCopyFormatString);
mswEnableMainService = findViewById(R.id.activitymainSwitch1);
mswEnableMainService.setChecked(AppConfigsUtil.getInstance(this).loadAppConfigs().isEnableService());
mLogView = findViewById(R.id.logview);
ToastUtils.show("onCreate");
}
@Override
protected void onResume() {
super.onResume();
mLogView.start();
}
public void onSetMainServiceStatus(View view) {
MainService.setMainServiceStatus(this, mswEnableMainService.isChecked());
}
public void onSaveFormatString(View view) {
if(showPreViewResult(metTimeStampFormatString, mtvTimeStampFormatString)) {
AppConfigsUtil.getInstance(this).getAppConfigsModel().setTimeStampFormatString(metTimeStampFormatString.getText().toString());
AppConfigsUtil.getInstance(this).saveAppConfigs();
}
}
public void onSaveCopyFormatString(View view) {
if(showPreViewResult(metTimeStampCopyFormatString, mtvTimeStampCopyFormatString)) {
AppConfigsUtil.getInstance(this).getAppConfigsModel().setTimeStampCopyFormatString(metTimeStampCopyFormatString.getText().toString());
AppConfigsUtil.getInstance(this).saveAppConfigs();
}
}
boolean showPreViewResult(EditText etFormat, TextView tvShow) {
try {
long currentMillis = System.currentTimeMillis();
Instant instant = Instant.ofEpochMilli(currentMillis);
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
String szTimeStampFormatString = etFormat.getText().toString();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(szTimeStampFormatString);
String formattedDateTime = ldt.format(formatter);
tvShow.setText(formattedDateTime);
return true;
} catch (Exception e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
}
return false;
}
}

View File

@@ -0,0 +1,229 @@
package cc.winboll.studio.timestamp;
/**
* @Author ZhanGSKen
* @Date 2025/05/05 09:47
* @Describe 主要服务
*/
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.widget.RemoteViews;
import android.widget.TextView;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.timestamp.AssistantService;
import cc.winboll.studio.timestamp.MainService;
import cc.winboll.studio.timestamp.models.AppConfigsModel;
import cc.winboll.studio.timestamp.receivers.ButtonClickReceiver;
import cc.winboll.studio.timestamp.utils.AppConfigsUtil;
import cc.winboll.studio.timestamp.utils.NotificationHelper;
import cc.winboll.studio.timestamp.utils.ServiceUtil;
import cc.winboll.studio.timestamp.utils.TimeStampUtil;
public class MainService extends Service {
public static String TAG = "MainService";
public static final int MSG_UPDATE_TIMESTAMP = 0;
ButtonClickReceiver mButtonClickReceiver;
NotificationHelper mNotificationHelper;
Notification mNotification;
RemoteViews mRemoteViews;
TextView mtvTimeStamp;
//Timer mTimer;
private static boolean _mIsServiceAlive;
public static final String EXTRA_APKFILEPATH = "EXTRA_APKFILEPATH";
final static int MSG_INSTALL_APK = 0;
static MyHandler _MyHandler;
MyServiceConnection mMyServiceConnection;
MainActivity mInstallCompletedFollowUpActivity;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
mNotificationHelper = new NotificationHelper();
mNotificationHelper.createServiceNotificationChannel(this);
// 创建广播接收器实例
mButtonClickReceiver = new ButtonClickReceiver();
// 创建 IntentFilter 并设置要接收的广播动作
IntentFilter filter = new IntentFilter(ButtonClickReceiver.BUTTON_COPYTIMESTAMP_ACTION);
// 注册广播接收器
registerReceiver(mButtonClickReceiver, filter);
LogUtils.d(TAG, "onCreate()");
_mIsServiceAlive = false;
_MyHandler = new MyHandler();
if (mMyServiceConnection == null) {
mMyServiceConnection = new MyServiceConnection();
}
run();
}
private void run() {
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(MainService.this).loadAppConfigs();
if (appConfigs.isEnableService()) {
if (_mIsServiceAlive == false) {
// 设置运行状态
_mIsServiceAlive = true;
// 显示前台通知栏
// mNotificationHelper = new NotificationHelper(this);
// //notification = helper.showForegroundNotification(intent, getString(R.string.app_name), getString(R.string.text_aboutservernotification));
// mNotification = mNotificationHelper.showCustomForegroundNotification(new Intent(this, MainActivity.class), mRemoteViews, mRemoteViews);
// startForeground(NotificationHelper.FOREGROUND_NOTIFICATION_ID, mNotification);
// 唤醒守护进程
wakeupAndBindAssistant();
LogUtils.d(TAG, "running...");
_MyHandler.sendEmptyMessage(MSG_UPDATE_TIMESTAMP);
// mTimer = new Timer();
// TimerTask task = new TimerTask() {
// @Override
// public void run() {
// //System.out.println("定时任务执行了");
// mMyHandler.sendEmptyMessage(MSG_UPDATE_TIMESTAMP);
// }
// };
// // 延迟1秒后开始执行之后每隔100毫秒执行一次
// mTimer.schedule(task, 1000, 100);
} else {
LogUtils.d(TAG, "_mIsServiceAlive is " + Boolean.toString(_mIsServiceAlive));
}
}
}
@Override
public void onDestroy() {
super.onDestroy();
// if (mTimer != null) {
// mTimer.cancel();
// }
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.cancelAll();
_mIsServiceAlive = false;
_MyHandler = null;
LogUtils.d(TAG, "onDestroy()");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
LogUtils.d(TAG, "onStartCommand");
run();
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(MainService.this).loadAppConfigs();
return appConfigs.isEnableService() ? Service.START_STICKY: super.onStartCommand(intent, flags, startId);
}
public static void setMainServiceStatus(Context context, boolean isEnable) {
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(context).loadAppConfigs();
appConfigs.setIsEnableService(isEnable);
AppConfigsUtil.getInstance(context).saveAppConfigs();
Intent intent = new Intent(context, MainService.class);
if (isEnable) {
context.startService(intent);
} else {
context.stopService(intent);
}
}
// 主进程与守护进程连接时需要用到此类
//
private class MyServiceConnection implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
//LogUtils.d(TAG, "call onServiceConnected(...)");
}
@Override
public void onServiceDisconnected(ComponentName name) {
//LogUtils.d(TAG, "call onServiceConnected(...)");
AppConfigsModel appConfigs = AppConfigsUtil.getInstance(MainService.this).loadAppConfigs();
if (appConfigs.isEnableService()) {
// 唤醒守护进程
wakeupAndBindAssistant();
}
}
}
// 唤醒和绑定守护进程
//
void wakeupAndBindAssistant() {
if (ServiceUtil.isServiceAlive(getApplicationContext(), AssistantService.class.getName()) == false) {
startService(new Intent(MainService.this, AssistantService.class));
//LogUtils.d(TAG, "call wakeupAndBindAssistant() : Binding... AssistantService");
bindService(new Intent(MainService.this, AssistantService.class), mMyServiceConnection, Context.BIND_IMPORTANT);
}
}
// void updateTimeStamp() {
// long currentMillis = System.currentTimeMillis();
// Instant instant = Instant.ofEpochMilli(currentMillis);
// LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
// String szTimeStampFormatString = AppConfigs.getInstance(this).getTimeStampFormatString();
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern(szTimeStampFormatString);
// String formattedDateTime = ldt.format(formatter);
// //System.out.println(formattedDateTime);
// mRemoteViews.setTextViewText(R.id.tv_timestamp, formattedDateTime);
// notification = mNotificationHelper.showCustomForegroundNotification(intentMainService, mRemoteViews, mRemoteViews);
// //startForeground(NotificationHelper.FOREGROUND_NOTIFICATION_ID, notification);
// }
//
//
// 服务事务处理类
//
class MyHandler extends Handler {
public void handleMessage(Message message) {
switch (message.what) {
case MSG_UPDATE_TIMESTAMP:
{
String szTimeStampShowString = TimeStampUtil.getInstance(MainService.this).getTimeStampShowString();
mNotificationHelper.sendForegroundNotification(MainService.this, "时间戳:\n" + szTimeStampShowString + "\n已截取。");
LogUtils.d(TAG, "Hello, World! " + szTimeStampShowString);
break;
}
default:
break;
}
super.handleMessage(message);
}
}
public static void updateCopiedTimeStamp() {
if (_MyHandler != null) {
_MyHandler.sendEmptyMessage(MSG_UPDATE_TIMESTAMP);
}
}
}

View File

@@ -0,0 +1,98 @@
package cc.winboll.studio.timestamp.models;
/**
* @Author ZhanGSKen
* @Date 2025/05/05 09:51
* @Describe 应用配置数据模型
*/
import android.content.Context;
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import cc.winboll.studio.timestamp.models.AppConfigsModel;
import java.io.IOException;
public class AppConfigsModel extends BaseBean {
public static final String TAG = "AppConfigs";
// 是否启动服务
boolean isEnableService;
// 时间戳显示格式
String timeStampFormatString;
// 时间戳拷贝格式
String timeStampCopyFormatString;
public AppConfigsModel() {
this.isEnableService = false;
this.timeStampFormatString = "yyyy-MM-dd HH:mm:ss SSS";
this.timeStampCopyFormatString = "yyyy_MM_dd-HH_mm_ss-SSS";
}
public void setTimeStampCopyFormatString(String timeStampCopyFormatString) {
this.timeStampCopyFormatString = timeStampCopyFormatString;
}
public String getTimeStampCopyFormatString() {
return timeStampCopyFormatString;
}
public void setTimeStampFormatString(String timeStampFormatString) {
this.timeStampFormatString = timeStampFormatString;
}
public String getTimeStampFormatString() {
return timeStampFormatString;
}
public void setIsEnableService(boolean isEnableService) {
this.isEnableService = isEnableService;
}
public boolean isEnableService() {
return isEnableService;
}
@Override
public String getName() {
return AppConfigsModel.class.getName();
}
@Override
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
super.writeThisToJsonWriter(jsonWriter);
jsonWriter.name("isEnableService").value(isEnableService());
jsonWriter.name("timeStampFormatString").value(getTimeStampFormatString());
jsonWriter.name("timeStampCopyFormatString").value(getTimeStampCopyFormatString());
}
@Override
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
if (name.equals("isEnableService")) {
setIsEnableService(jsonReader.nextBoolean());
} else if (name.equals("timeStampFormatString")) {
setTimeStampFormatString(jsonReader.nextString());
} else if (name.equals("timeStampCopyFormatString")) {
setTimeStampCopyFormatString(jsonReader.nextString());
} else {
return false;
}
}
return true;
}
@Override
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (!initObjectsFromJsonReader(jsonReader, name)) {
jsonReader.skipValue();
}
}
// 结束 JSON 对象
jsonReader.endObject();
return this;
}
}

View File

@@ -0,0 +1,38 @@
package cc.winboll.studio.timestamp.receivers;
/**
* @Author ZhanGSKen
* @Date 2025/05/05 11:35
* @Describe ButtonClickReceiver
*/
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.timestamp.BuildConfig;
import cc.winboll.studio.timestamp.MainService;
import cc.winboll.studio.timestamp.utils.ClipboardUtil;
import cc.winboll.studio.timestamp.utils.TimeStampUtil;
public class ButtonClickReceiver extends BroadcastReceiver {
public static final String TAG = "ButtonClickReceiver";
public static final String BUTTON_COPYTIMESTAMP_ACTION = ButtonClickReceiver.class.getName() + (BuildConfig.DEBUG ?".DEBUG_": ".") + "BUTTON_COPYTIMESTAMP_ACTION";
@Override
public void onReceive(Context context, Intent intent) {
LogUtils.d(TAG, "onReceive");
if (intent.getAction().equals(BUTTON_COPYTIMESTAMP_ACTION)) {
// 在这里编写按钮点击后要执行的代码
TimeStampUtil.getInstance(context).genTimeStamp();
ClipboardUtil.copyTextToClipboard(context, TimeStampUtil.getInstance(context).getTimeStampCopyString());
// 比如显示一个Toast
Toast.makeText(context, "时间戳:\n" + TimeStampUtil.getInstance(context).getTimeStampCopyString() + "\n已拷贝到剪贴板。", Toast.LENGTH_SHORT).show();
MainService.updateCopiedTimeStamp();
}
}
}

View File

@@ -0,0 +1,58 @@
package cc.winboll.studio.timestamp.utils;
/**
* @Author ZhanGSKen
* @Date 2025/05/05 14:00
* @Describe AppConfigsUtil
*/
import android.content.Context;
import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import cc.winboll.studio.timestamp.models.AppConfigsModel;
import java.io.IOException;
public class AppConfigsUtil {
public static final String TAG = "AppConfigsUtil";
volatile static AppConfigsUtil _AppConfigsUtil;
Context mContext;
AppConfigsModel mAppConfigsModel;
AppConfigsUtil(Context context) {
this.mContext = context;
loadAppConfigs();
}
public synchronized static AppConfigsUtil getInstance(Context context){
if(_AppConfigsUtil == null) {
_AppConfigsUtil = new AppConfigsUtil(context);
}
return _AppConfigsUtil;
}
public AppConfigsModel getAppConfigsModel() {
return mAppConfigsModel;
}
public AppConfigsModel loadAppConfigs() {
AppConfigsModel appConfigsModel = null;
appConfigsModel = AppConfigsModel.loadBean(mContext, AppConfigsModel.class);
if (appConfigsModel != null) {
mAppConfigsModel = appConfigsModel;
} else {
mAppConfigsModel = new AppConfigsModel();
saveAppConfigs(mAppConfigsModel);
}
return mAppConfigsModel;
}
public void saveAppConfigs(AppConfigsModel appConfigsModel) {
AppConfigsModel.saveBean(mContext, appConfigsModel);
}
public void saveAppConfigs() {
AppConfigsModel.saveBean(mContext, mAppConfigsModel);
}
}

View File

@@ -0,0 +1,71 @@
package cc.winboll.studio.timestamp.utils;
/**
* @Author ZhanGSKen
* @Date 2025/05/07 02:38
* @Describe AudioPlayer
*/
import android.content.Context;
import android.media.MediaPlayer;
import android.net.Uri;
import android.util.Log;
public class AudioPlayerMP3Util {
public static final String TAG = "AudioPlayer";
private static MediaPlayer mediaPlayer;
/**
* 播放指定的 MP3 文件
*
* @param context 上下文
* @param mp3FilePath MP3 文件的路径,例如:"/storage/emulated/0/Music/song.mp3"
*/
public static void playMp3(Context context, String mp3FilePath) {
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
mediaPlayer.stop();
mediaPlayer.release();
mediaPlayer = null;
}
try {
mediaPlayer = new MediaPlayer();
Uri uri = Uri.parse(mp3FilePath);
mediaPlayer.setDataSource(context, uri);
mediaPlayer.prepare();
mediaPlayer.start();
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
releaseMediaPlayer();
}
});
mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
Log.e("AudioPlayer", "播放音频时出错: what=" + what + ", extra=" + extra);
releaseMediaPlayer();
return true;
}
});
} catch (Exception e) {
e.printStackTrace();
releaseMediaPlayer();
}
}
/**
* 释放 MediaPlayer 资源
*/
private static void releaseMediaPlayer() {
if (mediaPlayer != null) {
mediaPlayer.stop();
mediaPlayer.release();
mediaPlayer = null;
}
}
}

View File

@@ -0,0 +1,69 @@
package cc.winboll.studio.timestamp.utils;
/**
* @Author ZhanGSKen
* @Date 2025/05/07 02:31
* @Describe AudioPlayerUtil
*/
import android.content.Context;
import android.media.MediaPlayer;
import android.net.Uri;
import android.util.Log;
public class AudioPlayerUriUtil {
public static final String TAG = "AudioPlayerUtil";
private static MediaPlayer mediaPlayer;
/**
* 播放指定Uri的音频
* @param context 上下文
* @param audioUri 音频的Uri
*/
public static void playAudio(Context context, Uri audioUri) {
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
mediaPlayer.stop();
mediaPlayer.release();
mediaPlayer = null;
}
try {
mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(context, audioUri);
mediaPlayer.prepare();
mediaPlayer.start();
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
releaseMediaPlayer();
}
});
mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
Log.e("AudioPlayer", "播放音频时出错: what=" + what + ", extra=" + extra);
releaseMediaPlayer();
return true;
}
});
} catch (Exception e) {
e.printStackTrace();
releaseMediaPlayer();
}
}
/**
* 释放MediaPlayer资源
*/
private static void releaseMediaPlayer() {
if (mediaPlayer != null) {
mediaPlayer.stop();
mediaPlayer.release();
mediaPlayer = null;
}
}
}

View File

@@ -0,0 +1,37 @@
package cc.winboll.studio.timestamp.utils;
/**
* @Author ZhanGSKen
* @Date 2025/05/06 10:53
* @Describe 剪贴板工具集
*/
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Handler;
public class ClipboardUtil {
public static final String TAG = "ClipboardUtil";
private static final long COPY_DELAY = 500; // 延迟 500 毫秒
private static Handler handler = new Handler();
/**
* 拷贝文本到剪贴板
* @param context 上下文
* @param text 要拷贝的文本
*/
public static void copyTextToClipboard(final Context context, final String text) {
handler.postDelayed(new Runnable() {
@Override
public void run() {
ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboardManager != null) {
ClipData clipData = ClipData.newPlainText("label", text);
clipboardManager.setPrimaryClip(clipData);
}
}
}, COPY_DELAY);
}
}

View File

@@ -0,0 +1,47 @@
package cc.winboll.studio.timestamp.utils;
/**
* @Author ZhanGSKen
* @Date 2025/05/05 09:52
* @Describe 文件管理工具类
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
public class FileUtil {
public static final String TAG = "FileUtil";
//
// 把字符串写入文件,指定 UTF-8 编码
//
public static void writeFile(String filePath, String content) throws IOException {
File file = new File(filePath);
FileOutputStream outputStream = new FileOutputStream(file);
OutputStreamWriter writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
writer.write(content);
writer.close();
}
//
// 读取文件到字符串,指定 UTF-8 编码
//
public static String readFile(String filePath) throws IOException {
File file = new File(filePath);
FileInputStream inputStream = new FileInputStream(file);
InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
StringBuilder content = new StringBuilder();
int character;
while ((character = reader.read()) != -1) {
content.append((char) character);
}
reader.close();
return content.toString();
}
}

View File

@@ -0,0 +1,206 @@
package cc.winboll.studio.timestamp.utils;
/**
* @Author ZhanGSKen
* @Date 2025/05/05 10:36
* @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.graphics.Color;
import android.media.RingtoneManager;
import android.net.Uri;
import android.widget.RemoteViews;
import cc.winboll.studio.timestamp.App;
import cc.winboll.studio.timestamp.MainActivity;
import cc.winboll.studio.timestamp.MainService;
import cc.winboll.studio.timestamp.R;
import cc.winboll.studio.timestamp.receivers.ButtonClickReceiver;
public class NotificationHelper {
public static final String TAG = "NotificationUtil";
public static final int ID_MSG_SERVICE = 10000;
static final String szSMSChannelID = "1";
static final String szServiceChannelID = "0";
//static int mNumSendForegroundNotification = 10000;
//static int mNumSendSMSNotification = 20000;
Context mContext;
public NotificationManager createServiceNotificationChannel(Context context) {
mContext = context;
//创建通知渠道ID
String channelId = szServiceChannelID;
//创建通知渠道名称
String channelName = "Service Message";
//创建通知渠道重要性
int importance = NotificationManager.IMPORTANCE_MIN;
NotificationChannel channel = new NotificationChannel(channelId, channelName, importance);
channel.setSound(null, null);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(
Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
return notificationManager;
}
public NotificationManager createSMSNotificationChannel(Context context) {
//创建通知渠道ID
String channelId = szSMSChannelID;
//创建通知渠道名称
String channelName = "SMS Message";
//创建通知渠道重要性
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel channel = new NotificationChannel(channelId, channelName, importance);
channel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE), Notification.AUDIO_ATTRIBUTES_DEFAULT);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(
Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
return notificationManager;
}
// 创建通知
//
public void sendForegroundNotification(MainService service, String message) {
//创建Notification传入Context和channelId
Intent intent = new Intent();//这个intent会传给目标,可以使用getIntent来获取
intent.setClass(mContext, MainActivity.class);
//这里放一个count用来区分每一个通知
//intent.putExtra("intent", "intent--->" + count);//这里设置一个数据,带过去
//参数1:context 上下文对象
//参数2:发送者私有的请求码(Private request code for the sender)
//参数3:intent 意图对象
//参数4:必须为FLAG_ONE_SHOT,FLAG_NO_CREATE,FLAG_CANCEL_CURRENT,FLAG_UPDATE_CURRENT,中的一个
PendingIntent mForegroundPendingIntent = PendingIntent.getActivity(service, ID_MSG_SERVICE, intent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT);
Notification mForegroundNotification = new Notification.Builder(service, szServiceChannelID)
.setAutoCancel(true)
//.setContentTitle(nessageNotificationBean.getTitle())
//.setContentText(nessageNotificationBean.getContent())
//.setContent(remoteviews)
.setWhen(System.currentTimeMillis())
.setSmallIcon(App.getAPPIcon())
//设置红色
.setColor(Color.parseColor("#F00606"))
.setLargeIcon(BitmapFactory.decodeResource(service.getResources(), App.getAPPIcon()))
.setContentIntent(mForegroundPendingIntent)
.build();
// 创建 RemoteViews 对象,加载布局
RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(), R.layout.custom_notification_layout);
// 自定义 TextView 的文本
remoteViews.setTextViewText(R.id.tv_timestamp, message);
// 自定义 TextView 的文本颜色
remoteViews.setTextColor(R.id.tv_timestamp, mContext.getResources().getColor(R.color.colorAccent, null));
// 这里虽然不能直接设置字体大小,但可以通过反射等方式尝试(不推荐,且有兼容性问题)
// 设置按钮图片
remoteViews.setImageViewResource(R.id.iv_copytimestamp, App.getAPPIcon());
// 创建点击通知后的意图
Intent intentMain = new Intent(mContext, MainActivity.class);
PendingIntent pendingMainIntent = PendingIntent.getActivity(mContext, 0, intentMain, PendingIntent.FLAG_UPDATE_CURRENT);
// 设置通知的点击事件
remoteViews.setOnClickPendingIntent(R.id.tv_timestamp, pendingMainIntent);
// 创建点击按钮后要发送的广播 Intent
Intent broadcastIntent = new Intent(ButtonClickReceiver.BUTTON_COPYTIMESTAMP_ACTION);
android.app.PendingIntent pendingIntent = android.app.PendingIntent.getBroadcast(
mContext,
0,
broadcastIntent,
android.app.PendingIntent.FLAG_UPDATE_CURRENT
);
// 为按钮设置点击事件
remoteViews.setOnClickPendingIntent(R.id.iv_copytimestamp, pendingIntent);
mForegroundNotification.contentView = remoteViews;
mForegroundNotification.bigContentView = remoteViews;
service.startForeground(ID_MSG_SERVICE, mForegroundNotification);
// 播放默认短信铃声
Uri defaultSmsRingtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
AudioPlayerUriUtil.playAudio(service, defaultSmsRingtoneUri);
// 播放应用铃声
// 获取MP3文件的Uri
Uri soundUri = Uri.parse("android.resource://" + service.getPackageName() + "/" + R.raw.diweiyi);
AudioPlayerUriUtil.playAudio(service, soundUri);
}
// public void sendSMSNotification(Context context, MessageNotificationBean messageNotificationBean) {
// NotificationManager notificationManager = (NotificationManager) context.getSystemService(
// Context.NOTIFICATION_SERVICE);
// /*NotificationManager notificationManager = createSMSNotificationChannel(context);
// if (notificationManager == null) {
// LogUtils.d(TAG, "createSMSNotificationChannel failed.");
// return;
// }*/
//
// //创建Notification传入Context和channelId
// Intent intent = new Intent(context, SMSActivity.class);
// intent.putExtra(SMSActivity.EXTRA_PHONE, messageNotificationBean.getPhone());
// LogUtils.d(TAG, "sendSMSNotification(...) message.getPhone() is : " + messageNotificationBean.getPhone());
// //Intent intent = new Intent();//这个intent会传给目标,可以使用getIntent来获取
// //intent.setClass(context, MainActivity.class);
// //这里放一个count用来区分每一个通知
// //intent.putExtra("intent", "intent--->" + count);//这里设置一个数据,带过去
//
// //参数1:context 上下文对象
// //参数2:发送者私有的请求码(Private request code for the sender)
// //参数3:intent 意图对象
// //参数4:必须为FLAG_ONE_SHOT,FLAG_NO_CREATE,FLAG_CANCEL_CURRENT,FLAG_UPDATE_CURRENT,中的一个
// PendingIntent mRemindPendingIntent = PendingIntent.getActivity(context, messageNotificationBean.getMessageId(), intent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT);
// Notification mSMSNotification = new Notification.Builder(context, szSMSChannelID)
// .setAutoCancel(true)
// .setContentTitle(messageNotificationBean.getTitle())
// .setContentText(messageNotificationBean.getContent())
// .setWhen(System.currentTimeMillis())
// .setSmallIcon(R.drawable.ic_launcher)
// //设置红色
// .setColor(Color.parseColor("#F00606"))
// .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher))
// .setContentIntent(mRemindPendingIntent)
// .build();
//
// RemoteViews mrvSMSNotificationView = new RemoteViews(context.getPackageName(), R.layout.remoteview);
// mrvSMSNotificationView.setTextViewText(R.id.remoteviewTextView1, messageNotificationBean.getTitle());
// mrvSMSNotificationView.setTextViewText(R.id.remoteviewTextView2, messageNotificationBean.getContent());
// mrvSMSNotificationView.setImageViewResource(R.id.remoteviewImageView1, R.drawable.ic_launcher);
// mSMSNotification.contentView = mrvSMSNotificationView;
// mSMSNotification.bigContentView = mrvSMSNotificationView;
// notificationManager.notify(messageNotificationBean.getMessageId(), mSMSNotification);
// LogUtils.d(TAG, "getMessageId is : " + Integer.toString(messageNotificationBean.getMessageId()));
//
// }
// public void sendSMSReceivedMessage(Context context, int nMessageId, String szPhone, String szBody) {
// String szTitle = context.getString(R.string.text_smsfrom) + "<" + szPhone + ">";
// String szContent = "[ " + szBody + " ]";
// sendSMSNotification(context, new MessageNotificationBean(nMessageId, szPhone, szTitle, szContent));
// }
// public static void cancelNotification(Context context, int notificationId) {
// // 获取 NotificationManager 实例
// NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// // 撤回指定 ID 的通知栏消息
// notificationManager.cancel(notificationId);
// }
}

View File

@@ -0,0 +1,35 @@
package cc.winboll.studio.timestamp.utils;
/**
* @Author ZhanGSKen
* @Date 2025/05/05 09:58
* @Describe 应用服务管理类
*/
import android.app.ActivityManager;
import android.content.Context;
import java.util.List;
public class ServiceUtil {
public final static String TAG = "ServiceUtil";
public static boolean isServiceAlive(Context context, String szServiceName) {
// 获取Activity管理者对象
ActivityManager manager = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
// 获取正在运行的服务此处设置最多取1000个
List<ActivityManager.RunningServiceInfo> runningServices = manager
.getRunningServices(1000);
if (runningServices.size() <= 0) {
return false;
}
// 遍历若存在名字和传入的serviceName的一致则说明存在
for (ActivityManager.RunningServiceInfo runningServiceInfo : runningServices) {
if (runningServiceInfo.service.getClassName().equals(szServiceName)) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,58 @@
package cc.winboll.studio.timestamp.utils;
/**
* @Author ZhanGSKen
* @Date 2025/05/07 11:03
* @Describe TimeStampUtil
*/
import android.content.Context;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
public class TimeStampUtil {
public static final String TAG = "TimeStampUtil";
volatile static TimeStampUtil _TimeStampUtil;
Context mContext;
long mTimeStamp;
TimeStampUtil(Context context) {
mContext = context;
mTimeStamp = System.currentTimeMillis();
}
public synchronized static TimeStampUtil getInstance(Context context) {
if (_TimeStampUtil == null) {
_TimeStampUtil = new TimeStampUtil(context);
}
return _TimeStampUtil;
}
public void genTimeStamp() {
mTimeStamp = System.currentTimeMillis();
}
public String getTimeStampShowString() {
long currentMillis = mTimeStamp;
Instant instant = Instant.ofEpochMilli(currentMillis);
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
String szTimeStampFormatString = AppConfigsUtil.getInstance(mContext).getAppConfigsModel().getTimeStampFormatString();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(szTimeStampFormatString);
String formattedDateTime = ldt.format(formatter);
return formattedDateTime;
}
public String getTimeStampCopyString() {
long currentMillis = mTimeStamp;
Instant instant = Instant.ofEpochMilli(currentMillis);
LocalDateTime ldt = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
String szTimeStampFormatString = AppConfigsUtil.getInstance(mContext).getAppConfigsModel().getTimeStampCopyFormatString();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(szTimeStampFormatString);
String formattedDateTime = ldt.format(formatter);
return formattedDateTime;
}
}

View File

@@ -0,0 +1,99 @@
package cc.winboll.studio.timestamp.views;
/**
* @Author ZhanGSKen
* @Date 2025/05/05 12:53
* @Describe TimeStampView
*/
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;
public class TimeStampView extends View {
public static final String TAG = "TimeStampView";
public static final int MSG_UPDATE_TIMESTAMP = 0;
//private Paint circlePaint;
//private Paint textPaint;
// Context mContext;
// Timer mTimer;
// TextView mtvTimeStamp;
// MyHandler mMyHandler;
public TimeStampView(Context context) {
super(context);
//initView(context);
init();
}
public TimeStampView(Context context, AttributeSet attrs) {
super(context, attrs);
//initView(context);
init();
}
public TimeStampView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
//initView(context);
init();
}
public TimeStampView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
//initView(context);
init();
}
private void init() {
// circlePaint = new Paint();
// circlePaint.setColor(Color.BLUE);
// circlePaint.setStyle(Paint.Style.FILL);
//
// textPaint = new Paint();
// textPaint.setColor(Color.WHITE);
// textPaint.setTextSize(40);
// textPaint.setTextAlign(Paint.Align.CENTER);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//int width = getWidth();
//int height = getHeight();
// int width = 50;
// int height = 50;
// float radius = Math.min(width, height) / 2;
// canvas.drawCircle(width / 2, height / 2, radius, circlePaint);
// String text = "自定义";
// RectF rect = new RectF(0, 0, width, height);
// Paint.FontMetricsInt fontMetrics = textPaint.getFontMetricsInt();
// int baseline =(int)((rect.bottom + rect.top - fontMetrics.bottom - fontMetrics.top) / 2);
// canvas.drawText(text, width / 2, baseline, textPaint);
}
// void initView(Context context) {
// View viewMain = inflate(context, R.layout.view_timestamp, null);
// this.mContext = context;
// mtvTimeStamp = viewMain.findViewById(R.id.tv_timestamp);
// addView(viewMain);
//
// mMyHandler = new MyHandler();
//
// }
// public void updateTimeStamp() {
// try {
//
// } catch (Exception e) {
// LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
// ToastUtils.show(e);
// }
// }
}

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"
android:drawable="@drawable/ic_launcher_background"/>
<item
android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"
android:drawable="@drawable/ic_timestamp"/>
</layer-list>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--<item android:drawable="@drawable/ic_launcher_background"/>-->
<item
android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"
android:drawable="@drawable/ic_timestamp"/>
</layer-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<Switch
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="启用时间戳常驻通知栏"
android:id="@+id/activitymainSwitch1"
android:onClick="onSetMainServiceStatus"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Format Preview:"
android:paddingRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text"
android:id="@+id/tv_timestampformatstring"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<EditText
android:layout_width="0dp"
android:ems="10"
android:layout_height="wrap_content"
android:id="@+id/et_timestampformatstring"
android:layout_weight="1.0"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ApplyShow"
android:id="@+id/btn_saveformatstring"
android:textAllCaps="false"
android:onClick="onSaveFormatString"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Copy Format Preview:"
android:paddingRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text"
android:id="@+id/tv_timestampcopyformatstring"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<EditText
android:layout_width="0dp"
android:ems="10"
android:layout_height="wrap_content"
android:id="@+id/et_timestampcopyformatstring"
android:layout_weight="1.0"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ApplyCopy"
android:id="@+id/btn_savecopyformatstring"
android:textAllCaps="false"
android:onClick="onSaveCopyFormatString"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:gravity="center_vertical|center_horizontal">
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0">
<cc.winboll.studio.libappbase.LogView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/logview"/>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,25 @@
<?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="horizontal"
android:padding="16dp"
android:gravity="center_vertical">
<TextView
android:id="@+id/tv_timestamp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Text"
android:textColor="#000000"
android:textSize="14sp"
android:layout_weight="1.0"/>
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/iv_copytimestamp"/>
</LinearLayout>

Binary file not shown.

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#009688</color>
<color name="colorPrimaryDark">#00796B</color>
<color name="colorAccent">#FF9800</color>
</resources>

View File

@@ -0,0 +1,5 @@
<resources>
<string name="app_name">TimeStamp</string>
<string name="text_aboutservernotification">This is the prompt window when the SMS service runs, which you can set to hide this class notification in the notification message settings.</string>
<string name="accessibility_service_description">Accessibility service description.</string>
</resources>

View File

@@ -0,0 +1,11 @@
<resources>
<!-- Base application theme. -->
<style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>

View File

@@ -0,0 +1,15 @@
<?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
tools:replace="android:icon,android:roundIcon"
android:icon="@drawable/ic_launcher_stage"
android:roundIcon="@drawable/ic_launcher_stage">
<!-- Put flavor specific code here -->
</application>
</manifest>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Put flavor specific strings here -->
</resources>