Compare commits
44 Commits
a16d98cad0
...
appbase-v1
| Author | SHA1 | Date | |
|---|---|---|---|
| 9db3b3b703 | |||
| 744fb23291 | |||
| bd01220892 | |||
| 4b2b5acc99 | |||
| 1274bc7c05 | |||
| f67c57108a | |||
| 6d694992b7 | |||
| 6f5aa807c0 | |||
| f897f6e9ab | |||
| e2c73fdec0 | |||
| 4fcc5f9689 | |||
| 4208cda32f | |||
| 7c83b903f3 | |||
| 54b040285c | |||
| e8667bb26f | |||
| 05259e5ca9 | |||
| a5a5b37121 | |||
| 29726828b0 | |||
| 436e92702f | |||
| 3669a96768 | |||
| 37c3d1563c | |||
| 6741c41c83 | |||
| 4708dd4426 | |||
| 36e2ed0b48 | |||
| 3cfee1c4a8 | |||
| 24af31d51d | |||
| 54f77a8d87 | |||
| 69b18343c9 | |||
| e1bd959842 | |||
| bad38e37ae | |||
| 08eb360dbd | |||
| 819018b149 | |||
| 6e6b262e86 | |||
| 9665856b1b | |||
| 052bbce839 | |||
| 90102f4eea | |||
| 759a08cec9 | |||
| 42cc7a2822 | |||
| c9c95d6ab0 | |||
| bc9bd47daa | |||
| 4bec8c3e9e | |||
| e726c9d435 | |||
| 5277913606 | |||
| c1bd31df2f |
@@ -24,13 +24,13 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "cc.winboll.studio.appbase"
|
applicationId "cc.winboll.studio.appbase"
|
||||||
minSdkVersion 21
|
minSdkVersion 26
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 1
|
versionCode 1
|
||||||
// versionName 更新后需要手动设置
|
// versionName 更新后需要手动设置
|
||||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||||
versionName "15.15"
|
versionName "15.20"
|
||||||
if(true) {
|
if(true) {
|
||||||
versionName = genVersionName("${versionName}")
|
versionName = genVersionName("${versionName}")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Tue Apr 28 17:08:30 HKT 2026
|
#Mon May 11 16:56:19 HKT 2026
|
||||||
stageCount=22
|
stageCount=7
|
||||||
libraryProject=libappbase
|
libraryProject=libappbase
|
||||||
baseVersion=15.15
|
baseVersion=15.20
|
||||||
publishVersion=15.15.21
|
publishVersion=15.20.6
|
||||||
buildCount=0
|
buildCount=0
|
||||||
baseBetaVersion=15.15.22
|
baseBetaVersion=15.20.7
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/MyAPPBaseTheme"
|
android:theme="@style/MyAPPBaseTheme"
|
||||||
android:resizeableActivity="true"
|
android:resizeableActivity="true"
|
||||||
android:process=":App">
|
android:process=":App"
|
||||||
|
android:sharedUserId="@string/shared_user_id"
|
||||||
|
android:sharedUserLabel="@string/shared_user_label">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
@@ -19,28 +21,16 @@
|
|||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
|
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
|
||||||
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".MainActivityAlias"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
android:exported="true"
|
|
||||||
android:resizeableActivity="true"
|
|
||||||
android:launchMode="singleTop"
|
|
||||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
|
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".Main2Activity"
|
android:name=".Main2Activity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ public class App extends GlobalApplication {
|
|||||||
if (isDebugging() != true) {
|
if (isDebugging() != true) {
|
||||||
setIsDebugging(BuildConfig.DEBUG);
|
setIsDebugging(BuildConfig.DEBUG);
|
||||||
}
|
}
|
||||||
|
// release 版调试码
|
||||||
|
//setIsDebugging(!BuildConfig.DEBUG);
|
||||||
|
|
||||||
// 初始化 Toast 工具类(传入应用全局上下文,确保 Toast 可在任意地方调用)
|
// 初始化 Toast 工具类(传入应用全局上下文,确保 Toast 可在任意地方调用)
|
||||||
ToastUtils.init(getApplicationContext());
|
ToastUtils.init(getApplicationContext());
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package cc.winboll.studio.appbase;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
import cc.winboll.studio.libappbase.ToastUtils;
|
||||||
|
|
||||||
|
public class CrashTestActivity extends Activity {
|
||||||
|
|
||||||
|
public static final String TAG = "CrashTestActivity";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_crash_test);
|
||||||
|
LogUtils.d(TAG, "CrashTestActivity onCreate()");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBack(View view) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTestCrash(View view) {
|
||||||
|
LogUtils.d(TAG, "onTestCrash()");
|
||||||
|
ToastUtils.show("测试布局崩溃...");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -162,25 +162,7 @@ public class MainActivity extends Activity {
|
|||||||
startActivity(aboutIntent);
|
startActivity(aboutIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSplitScreenMode(View view) {
|
|
||||||
LogUtils.d(TAG, "onSplitScreenMode() 分屏测试按钮已点击");
|
|
||||||
ToastUtils.show("分屏测试:已启动新窗口");
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
|
||||||
android.graphics.Rect bounds = new android.graphics.Rect();
|
|
||||||
getWindow().getDecorView().getDisplay().getRectSize(bounds);
|
|
||||||
int height = bounds.height();
|
|
||||||
int width = bounds.width();
|
|
||||||
bounds.set(0, 0, width, height / 2);
|
|
||||||
LogUtils.d(TAG, "onSplitScreenMode() 分屏窗口范围: " + bounds);
|
|
||||||
android.content.Intent intent = new android.content.Intent(this, MainActivityAlias.class);
|
|
||||||
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
LogUtils.d(TAG, "onSplitScreenMode() 准备启动MainActivityAlias");
|
|
||||||
android.app.ActivityOptions options = android.app.ActivityOptions.makeBasic();
|
|
||||||
options.setLaunchBounds(bounds);
|
|
||||||
startActivity(intent, options.toBundle());
|
|
||||||
LogUtils.d(TAG, "onSplitScreenMode() MainActivityAlias已启动");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onMultiInstance(View view) {
|
public void onMultiInstance(View view) {
|
||||||
LogUtils.d(TAG, "onMultiInstance() 多开窗口按钮已点击");
|
LogUtils.d(TAG, "onMultiInstance() 多开窗口按钮已点击");
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package cc.winboll.studio.appbase;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Toolbar;
|
|
||||||
import cc.winboll.studio.appbase.R;
|
|
||||||
|
|
||||||
public class MainActivityAlias extends MainActivity {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
|
||||||
setActionBar(toolbar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
22
appbase/src/main/res/layout-night/activity_about.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
|
<android.widget.Toolbar
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/toolbarBackgroundColor"
|
||||||
|
android:id="@+id/toolbar"/>
|
||||||
|
|
||||||
|
<cc.winboll.studio.libappbase.views.AboutView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1.0"
|
||||||
|
android:id="@+id/aboutview"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
106
appbase/src/main/res/layout-night/activity_main.xml
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="0dp"
|
||||||
|
android:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
|
<android.widget.Toolbar
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/toolbarBackgroundColor"
|
||||||
|
android:id="@+id/toolbar"/>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1.0">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:spacing="12dp">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="关于应用"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="?attr/activityTextColor"
|
||||||
|
android:background="?attr/buttonBackgroundColor"
|
||||||
|
android:paddingVertical="12dp"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:onClick="onAboutActivity"
|
||||||
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="应用崩溃测试"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="?attr/activityTextColor"
|
||||||
|
android:background="?attr/buttonBackgroundColor"
|
||||||
|
android:paddingVertical="12dp"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:onClick="onCrashTest"
|
||||||
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="应用日志测试"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="?attr/activityTextColor"
|
||||||
|
android:background="?attr/buttonBackgroundColor"
|
||||||
|
android:paddingVertical="12dp"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:onClick="onLogTest"
|
||||||
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="应用日志测试(新窗口)"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="?attr/activityTextColor"
|
||||||
|
android:background="?attr/buttonBackgroundColor"
|
||||||
|
android:paddingVertical="12dp"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:onClick="onLogTestNewTask"
|
||||||
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="应用吐司测试"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="?attr/activityTextColor"
|
||||||
|
android:background="?attr/buttonBackgroundColor"
|
||||||
|
android:paddingVertical="12dp"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:onClick="onToastUtilsTest"
|
||||||
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="多开窗口"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="?attr/activityTextColor"
|
||||||
|
android:background="?attr/buttonBackgroundColor"
|
||||||
|
android:paddingVertical="12dp"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:onClick="onMultiInstance"
|
||||||
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
17
appbase/src/main/res/layout-night/activity_main2.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:background="@android:color/white">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Main2Activity"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textColor="@color/gray_900"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -4,11 +4,13 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
<android.widget.Toolbar
|
<android.widget.Toolbar
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/toolbarBackgroundColor"
|
||||||
android:id="@+id/toolbar"/>
|
android:id="@+id/toolbar"/>
|
||||||
|
|
||||||
<cc.winboll.studio.libappbase.views.AboutView
|
<cc.winboll.studio.libappbase.views.AboutView
|
||||||
|
|||||||
60
appbase/src/main/res/layout/activity_crash_test.xml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="0dp"
|
||||||
|
android:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
|
<android.widget.Toolbar
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/toolbarBackgroundColor"
|
||||||
|
android:id="@+id/toolbar"/>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1.0">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<cc.winboll.studio.appbase.UndefinedCustomView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="返回"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="?attr/activityTextColor"
|
||||||
|
android:background="?attr/buttonBackgroundColor"
|
||||||
|
android:paddingVertical="12dp"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:onClick="onBack"
|
||||||
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="测试崩溃"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="?attr/activityTextColor"
|
||||||
|
android:background="?attr/buttonBackgroundColor"
|
||||||
|
android:paddingVertical="12dp"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:onClick="onTestCrash"
|
||||||
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -4,11 +4,13 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="16dp">
|
android:padding="0dp"
|
||||||
|
android:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
<android.widget.Toolbar
|
<android.widget.Toolbar
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/toolbarBackgroundColor"
|
||||||
android:id="@+id/toolbar"/>
|
android:id="@+id/toolbar"/>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
@@ -28,8 +30,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="关于应用"
|
android:text="关于应用"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="?attr/activityTextColor"
|
||||||
android:background="#81C7F5"
|
android:background="?attr/buttonBackgroundColor"
|
||||||
android:paddingVertical="12dp"
|
android:paddingVertical="12dp"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:onClick="onAboutActivity"
|
android:onClick="onAboutActivity"
|
||||||
@@ -40,8 +42,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="应用崩溃测试"
|
android:text="应用崩溃测试"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="?attr/activityTextColor"
|
||||||
android:background="#81C7F5"
|
android:background="?attr/buttonBackgroundColor"
|
||||||
android:paddingVertical="12dp"
|
android:paddingVertical="12dp"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:onClick="onCrashTest"
|
android:onClick="onCrashTest"
|
||||||
@@ -52,8 +54,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="应用日志测试"
|
android:text="应用日志测试"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="?attr/activityTextColor"
|
||||||
android:background="#81C7F5"
|
android:background="?attr/buttonBackgroundColor"
|
||||||
android:paddingVertical="12dp"
|
android:paddingVertical="12dp"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:onClick="onLogTest"
|
android:onClick="onLogTest"
|
||||||
@@ -64,8 +66,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="应用日志测试(新窗口)"
|
android:text="应用日志测试(新窗口)"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="?attr/activityTextColor"
|
||||||
android:background="#81C7F5"
|
android:background="?attr/buttonBackgroundColor"
|
||||||
android:paddingVertical="12dp"
|
android:paddingVertical="12dp"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:onClick="onLogTestNewTask"
|
android:onClick="onLogTestNewTask"
|
||||||
@@ -76,32 +78,22 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="应用吐司测试"
|
android:text="应用吐司测试"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="?attr/activityTextColor"
|
||||||
android:background="#81C7F5"
|
android:background="?attr/buttonBackgroundColor"
|
||||||
android:paddingVertical="12dp"
|
android:paddingVertical="12dp"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:onClick="onToastUtilsTest"
|
android:onClick="onToastUtilsTest"
|
||||||
android:layout_margin="10dp"/>
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
<Button
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="分屏测试"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:background="#81C7F5"
|
|
||||||
android:paddingVertical="12dp"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
android:onClick="onSplitScreenMode"
|
|
||||||
android:layout_margin="10dp"/>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="多开窗口"
|
android:text="多开窗口"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="?attr/activityTextColor"
|
||||||
android:background="#81C7F5"
|
android:background="?attr/buttonBackgroundColor"
|
||||||
android:paddingVertical="12dp"
|
android:paddingVertical="12dp"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:onClick="onMultiInstance"
|
android:onClick="onMultiInstance"
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:background="@android:color/white">
|
android:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Main2Activity"
|
android:text="Main2Activity"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:textColor="@color/gray_900"/>
|
android:textColor="?attr/activityTextColor"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
7
appbase/src/main/res/values-night/colors.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="colorPrimary">#FF1B8B29</color>
|
||||||
|
<color name="colorPrimaryDark">#FF0A5520</color>
|
||||||
|
<color name="colorAccent">#FF6EE87C</color>
|
||||||
|
<color name="colorText">#FFB8FF7D</color>
|
||||||
|
</resources>
|
||||||
13
appbase/src/main/res/values-night/styles.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="MyAPPBaseTheme" parent="APPBaseTheme">
|
||||||
|
<item name="themeDebug">@style/MyDebugActivityTheme</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="MyDebugActivityTheme" parent="DebugActivityTheme">
|
||||||
|
<item name="colorTittle">?attr/mainWindowDarkTextColor</item>
|
||||||
|
<item name="colorTittleBackgound">@color/buttonBackgroundColor</item>
|
||||||
|
<item name="colorText">?attr/debugTextColor</item>
|
||||||
|
<item name="colorTextBackgound">?attr/mainWindowDarkBackgroundColor</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<declare-styleable name="AboutView">
|
|
||||||
<attr name="app_name" format="string" />
|
|
||||||
<attr name="app_apkfoldername" format="string" />
|
|
||||||
<attr name="app_apkname" format="string" />
|
|
||||||
<attr name="app_gitname" format="string" />
|
|
||||||
<attr name="app_gitowner" format="string" />
|
|
||||||
<attr name="app_gitappbranch" format="string" />
|
|
||||||
<attr name="app_gitappsubprojectfolder" format="string" />
|
|
||||||
<attr name="appdescription" format="string" />
|
|
||||||
<attr name="appicon" format="reference" />
|
|
||||||
<attr name="is_adddebugtools" format="boolean" />
|
|
||||||
</declare-styleable>
|
|
||||||
</resources>
|
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<style name="MyAPPBaseTheme" parent="APPBaseTheme">
|
<style name="MyAPPBaseTheme" parent="APPBaseTheme">
|
||||||
<item name="themeGlobalCrashActivity">@style/MyGlobalCrashActivityTheme</item>
|
<item name="themeDebug">@style/MyDebugActivityTheme</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="MyGlobalCrashActivityTheme" parent="GlobalCrashActivityTheme">
|
<style name="MyDebugActivityTheme" parent="DebugActivityTheme">
|
||||||
<item name="colorTittle">#FFFFFFFF</item>
|
<item name="colorTittle">?attr/mainWindowTextColor</item>
|
||||||
<item name="colorTittleBackgound">#FF00A4B3</item>
|
<item name="colorTittleBackgound">@color/buttonBackgroundColor</item>
|
||||||
<item name="colorText">#FFFFFFFF</item>
|
<item name="colorText">?attr/debugTextColor</item>
|
||||||
<item name="colorTextBackgound">#FF000000</item>
|
<item name="colorTextBackgound">?attr/mainWindowBackgroundColor</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -93,12 +93,11 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
// 1. 对纯 Java 模块的 JavaCompile 任务配置(升级为 Java 11)
|
// 1. 对纯 Java 模块的 JavaCompile 任务配置(强制Java 7)
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.compilerArgs << "-parameters"
|
options.compilerArgs << "-parameters"
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
targetCompatibility = JavaVersion.VERSION_1_7
|
||||||
// 可选:确保编码一致
|
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
# WinBoLL
|
|
||||||
|
|
||||||
#### 介绍
|
|
||||||
WinBoLL 网站浏览器。
|
|
||||||
|
|
||||||
#### 软件架构
|
|
||||||
适配安卓应用 [AIDE Pro] 的 Gradle 编译结构。
|
|
||||||
也适配安卓应用 [AndroidIDE] 的 Gradle 编译结构。
|
|
||||||
|
|
||||||
|
|
||||||
#### Gradle 编译说明
|
|
||||||
调试版编译命令 :gradle assembleBetaDebug
|
|
||||||
阶段版编译命令 :bash .winboll/bashPublishAPKAddTag.sh winboll
|
|
||||||
|
|
||||||
#### 使用说明
|
|
||||||
3. Termux应用配置:
|
|
||||||
- 已安装Termux(包名 com.termux );
|
|
||||||
- 执行 echo "allow-external-apps = true" > ~/.termux/termux.properties
|
|
||||||
|
|
||||||
#### 参与贡献
|
|
||||||
|
|
||||||
1. Fork 本仓库
|
|
||||||
2. 新建 Feat_xxx 分支
|
|
||||||
3. 提交代码 : ZhanGSKen(ZhanGSKen<zhangsken@188.com>)
|
|
||||||
4. 新建 Pull Request
|
|
||||||
|
|
||||||
|
|
||||||
#### 特技
|
|
||||||
|
|
||||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
|
||||||
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
|
|
||||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
|
|
||||||
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
|
|
||||||
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
|
||||||
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
|
||||||
|
|
||||||
#### 参考文档
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
apply plugin: 'com.android.application'
|
|
||||||
apply from: '../.winboll/winboll_app_build.gradle'
|
|
||||||
apply from: '../.winboll/winboll_lint_build.gradle'
|
|
||||||
|
|
||||||
def genVersionName(def versionName){
|
|
||||||
// 检查编译标志位配置
|
|
||||||
assert (winbollBuildProps['stageCount'] != null)
|
|
||||||
assert (winbollBuildProps['baseVersion'] != null)
|
|
||||||
// 保存基础版本号
|
|
||||||
winbollBuildProps.setProperty("baseVersion", "${versionName}");
|
|
||||||
//保存编译标志配置
|
|
||||||
FileOutputStream fos = new FileOutputStream(winbollBuildPropsFile)
|
|
||||||
winbollBuildProps.store(fos, "${winbollBuildPropsDesc}");
|
|
||||||
fos.close();
|
|
||||||
|
|
||||||
// 返回编译版本号
|
|
||||||
return "${versionName}." + winbollBuildProps['stageCount']
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
// 适配MIUI12
|
|
||||||
compileSdkVersion 30
|
|
||||||
buildToolsVersion "30.0.3"
|
|
||||||
|
|
||||||
defaultConfig {
|
|
||||||
applicationId "cc.winboll.studio.gpsrelaysentinel"
|
|
||||||
minSdkVersion 26
|
|
||||||
// 适配MIUI12
|
|
||||||
targetSdkVersion 30
|
|
||||||
versionCode 1
|
|
||||||
// versionName 更新后需要手动设置
|
|
||||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
|
||||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
|
||||||
versionName "15.11"
|
|
||||||
if(true) {
|
|
||||||
versionName = genVersionName("${versionName}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 米盟 SDK
|
|
||||||
packagingOptions {
|
|
||||||
doNotStrip "*/*/libmimo_1011.so"
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
main {
|
|
||||||
jniLibs.srcDirs = ['libs'] // 若SO库放在libs目录下
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
|
|
||||||
api 'com.google.code.gson:gson:2.10.1'
|
|
||||||
|
|
||||||
// 下拉控件
|
|
||||||
api 'com.baoyz.pullrefreshlayout:library:1.2.0'
|
|
||||||
|
|
||||||
// SSH
|
|
||||||
api 'com.jcraft:jsch:0.1.55'
|
|
||||||
// Html 解析
|
|
||||||
api 'org.jsoup:jsoup:1.13.1'
|
|
||||||
// 二维码类库
|
|
||||||
api 'com.google.zxing:core:3.4.1'
|
|
||||||
api 'com.journeyapps:zxing-android-embedded:3.6.0'
|
|
||||||
// 应用介绍页类库
|
|
||||||
api 'io.github.medyo:android-about-page:2.0.0'
|
|
||||||
// 网络连接类库
|
|
||||||
api 'com.squareup.okhttp3:okhttp:4.4.1'
|
|
||||||
// OkHttp网络请求
|
|
||||||
implementation 'com.squareup.okhttp3:okhttp:3.14.9'
|
|
||||||
// FastJSON解析
|
|
||||||
implementation 'com.alibaba:fastjson:1.2.76'
|
|
||||||
|
|
||||||
// AndroidX 类库
|
|
||||||
/*api 'androidx.appcompat:appcompat:1.1.0'
|
|
||||||
//api 'com.google.android.material:material:1.4.0'
|
|
||||||
//api 'androidx.viewpager:viewpager:1.0.0'
|
|
||||||
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
|
|
||||||
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
|
||||||
//api 'androidx.fragment:fragment:1.1.0'*/
|
|
||||||
|
|
||||||
|
|
||||||
// 米盟
|
|
||||||
api 'com.miui.zeus:mimo-ad-sdk:5.3.+'//请使用最新版sdk
|
|
||||||
//注意:以下5个库必须要引入
|
|
||||||
//implementation 'androidx.appcompat:appcompat:1.4.1'
|
|
||||||
api 'androidx.recyclerview:recyclerview:1.0.0'
|
|
||||||
api 'com.google.code.gson:gson:2.8.5'
|
|
||||||
api 'com.github.bumptech.glide:glide:4.9.0'
|
|
||||||
//annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
|
|
||||||
|
|
||||||
implementation "androidx.annotation:annotation:1.3.0"
|
|
||||||
implementation "androidx.core:core:1.6.0"
|
|
||||||
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
|
|
||||||
implementation "androidx.preference:preference:1.1.1"
|
|
||||||
implementation "androidx.viewpager:viewpager:1.0.0"
|
|
||||||
implementation "com.google.android.material:material:1.4.0"
|
|
||||||
implementation "com.google.guava:guava:24.1-jre"
|
|
||||||
/*
|
|
||||||
implementation "io.noties.markwon:core:$markwonVersion"
|
|
||||||
implementation "io.noties.markwon:ext-strikethrough:$markwonVersion"
|
|
||||||
implementation "io.noties.markwon:linkify:$markwonVersion"
|
|
||||||
implementation "io.noties.markwon:recycler:$markwonVersion"
|
|
||||||
*/
|
|
||||||
implementation 'com.termux:terminal-emulator:0.118.0'
|
|
||||||
implementation 'com.termux:terminal-view:0.118.0'
|
|
||||||
implementation 'com.termux:termux-shared:0.118.0'
|
|
||||||
|
|
||||||
// WinBoLL库 nexus.winboll.cc 地址
|
|
||||||
api 'cc.winboll.studio:libaes:15.15.2'
|
|
||||||
api 'cc.winboll.studio:libappbase:15.15.11'
|
|
||||||
|
|
||||||
// WinBoLL备用库 jitpack.io 地址
|
|
||||||
//api 'com.github.ZhanGSKen:AES:aes-v15.15.7'
|
|
||||||
//api 'com.github.ZhanGSKen:APPBase:appbase-v15.15.4'
|
|
||||||
|
|
||||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
|
||||||
}
|
|
||||||
137
gpsrelaysentinel/proguard-rules.pro
vendored
@@ -1,137 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# By default, the flags in this file are appended to flags specified
|
|
||||||
# in C:\tools\adt-bundle-windows-x86_64-20131030\sdk/tools/proguard/proguard-android.txt
|
|
||||||
# You can edit the include path and order by changing the proguardFiles
|
|
||||||
# directive in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# Add any project specific keep options here:
|
|
||||||
|
|
||||||
# ============================== 基础通用规则 ==============================
|
|
||||||
# 保留系统组件
|
|
||||||
-keep public class * extends android.app.Activity
|
|
||||||
-keep public class * extends android.app.Service
|
|
||||||
-keep public class * extends android.content.BroadcastReceiver
|
|
||||||
-keep public class * extends android.content.ContentProvider
|
|
||||||
-keep public class * extends android.app.backup.BackupAgentHelper
|
|
||||||
-keep public class * extends android.preference.Preference
|
|
||||||
|
|
||||||
# 保留 WinBoLL 核心包及子类(合并简化规则)
|
|
||||||
-keep class cc.winboll.studio.** { *; }
|
|
||||||
-keepclassmembers class cc.winboll.studio.** { *; }
|
|
||||||
|
|
||||||
# 保留所有类中的 public static final String TAG 字段(便于日志定位)
|
|
||||||
-keepclassmembers class * {
|
|
||||||
public static final java.lang.String TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 保留序列化类(避免Parcelable/Gson解析异常)
|
|
||||||
-keep class * implements android.os.Parcelable {
|
|
||||||
public static final android.os.Parcelable$Creator *;
|
|
||||||
}
|
|
||||||
-keepclassmembers class * implements java.io.Serializable {
|
|
||||||
static final long serialVersionUID;
|
|
||||||
private static final java.io.ObjectStreamField[] serialPersistentFields;
|
|
||||||
private void writeObject(java.io.ObjectOutputStream);
|
|
||||||
private void readObject(java.io.ObjectInputStream);
|
|
||||||
java.lang.Object writeReplace();
|
|
||||||
java.lang.Object readResolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
# 保留 R 文件(避免资源ID混淆)
|
|
||||||
-keepclassmembers class **.R$* {
|
|
||||||
public static <fields>;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 保留 native 方法(避免JNI调用失败)
|
|
||||||
-keepclasseswithmembernames class * {
|
|
||||||
native <methods>;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 保留注解和泛型(避免反射/序列化异常)
|
|
||||||
-keepattributes *Annotation*
|
|
||||||
-keepattributes Signature
|
|
||||||
|
|
||||||
# 屏蔽 Java 8+ 警告(适配 Java 7 语法)
|
|
||||||
-dontwarn java.lang.invoke.*
|
|
||||||
-dontwarn android.support.v8.renderscript.*
|
|
||||||
-dontwarn java.util.function.**
|
|
||||||
|
|
||||||
# ============================== 第三方框架专项规则 ==============================
|
|
||||||
# OkHttp 4.4.1(米盟广告请求依赖,完善Lambda兼容)
|
|
||||||
-keep class okhttp3.** { *; }
|
|
||||||
-keep interface okhttp3.** { *; }
|
|
||||||
-keep class okhttp3.internal.** { *; }
|
|
||||||
-keep class okio.** { *; }
|
|
||||||
-dontwarn okhttp3.internal.platform.**
|
|
||||||
-dontwarn okio.**
|
|
||||||
|
|
||||||
# Glide 4.9.0(米盟广告图片加载依赖)
|
|
||||||
-keep public class * implements com.bumptech.glide.module.GlideModule
|
|
||||||
-keep public class * extends com.bumptech.glide.module.AppGlideModule
|
|
||||||
-keep public enum com.bumptech.glide.load.ImageHeaderParser$ImageType {
|
|
||||||
**[] $VALUES;
|
|
||||||
public *;
|
|
||||||
}
|
|
||||||
-keepclassmembers class * implements com.bumptech.glide.module.AppGlideModule {
|
|
||||||
<init>();
|
|
||||||
}
|
|
||||||
-dontwarn com.bumptech.glide.**
|
|
||||||
|
|
||||||
# Gson 2.8.5(米盟广告数据序列化依赖)
|
|
||||||
-keep class com.google.gson.** { *; }
|
|
||||||
-keep interface com.google.gson.** { *; }
|
|
||||||
-keepclassmembers class * {
|
|
||||||
@com.google.gson.annotations.SerializedName <fields>;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 米盟 SDK(核心广告组件,完整保留避免加载失败)
|
|
||||||
-keep class com.miui.zeus.** { *; }
|
|
||||||
-keep interface com.miui.zeus.** { *; }
|
|
||||||
# 保留米盟日志字段(便于广告加载失败排查)
|
|
||||||
-keepclassmembers class com.miui.zeus.mimo.sdk.** {
|
|
||||||
public static final java.lang.String TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
# RecyclerView 1.0.0(米盟广告布局渲染依赖)
|
|
||||||
-keep class androidx.recyclerview.** { *; }
|
|
||||||
-keep interface androidx.recyclerview.** { *; }
|
|
||||||
-keepclassmembers class androidx.recyclerview.widget.RecyclerView$Adapter {
|
|
||||||
public *;
|
|
||||||
}
|
|
||||||
|
|
||||||
# 其他第三方框架(按引入依赖保留,无则可删除)
|
|
||||||
# XXPermissions 18.63
|
|
||||||
-keep class com.hjq.permissions.** { *; }
|
|
||||||
-keep interface com.hjq.permissions.** { *; }
|
|
||||||
|
|
||||||
# ZXing 二维码(核心解析组件)
|
|
||||||
-keep class com.google.zxing.** { *; }
|
|
||||||
-keep class com.journeyapps.zxing.** { *; }
|
|
||||||
|
|
||||||
# Jsoup HTML解析
|
|
||||||
-keep class org.jsoup.** { *; }
|
|
||||||
|
|
||||||
# Pinyin4j 拼音搜索
|
|
||||||
-keep class net.sourceforge.pinyin4j.** { *; }
|
|
||||||
|
|
||||||
# JSch SSH组件
|
|
||||||
-keep class com.jcraft.jsch.** { *; }
|
|
||||||
|
|
||||||
# AndroidX 基础组件
|
|
||||||
-keep class androidx.appcompat.** { *; }
|
|
||||||
-keep interface androidx.appcompat.** { *; }
|
|
||||||
|
|
||||||
# ============================== 优化与调试配置 ==============================
|
|
||||||
# 优化级别(平衡混淆效果与性能)
|
|
||||||
-optimizationpasses 5
|
|
||||||
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
|
|
||||||
|
|
||||||
# 调试辅助(保留行号便于崩溃定位)
|
|
||||||
-verbose
|
|
||||||
-dontpreverify
|
|
||||||
-dontusemixedcaseclassnames
|
|
||||||
-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools" >
|
|
||||||
|
|
||||||
<application>
|
|
||||||
|
|
||||||
<!-- Put flavor specific code here -->
|
|
||||||
|
|
||||||
</application>
|
|
||||||
|
|
||||||
</manifest>
|
|
||||||
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
|
|
||||||
<string name="app_name">GPSRelaySentinel★</string>
|
|
||||||
|
|
||||||
</resources>
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
|
||||||
<manifest
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="cc.winboll.studio.gpsrelaysentinel">
|
|
||||||
|
|
||||||
<application
|
|
||||||
android:allowBackup="true"
|
|
||||||
android:icon="@mipmap/ic_launcher"
|
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
|
||||||
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"/>
|
|
||||||
|
|
||||||
</application>
|
|
||||||
|
|
||||||
</manifest>
|
|
||||||
@@ -1,340 +0,0 @@
|
|||||||
package cc.winboll.studio.gpsrelaysentinel;
|
|
||||||
|
|
||||||
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.libappbase.GlobalApplication;
|
|
||||||
import cc.winboll.studio.libappbase.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);
|
|
||||||
|
|
||||||
//CrashHandler.getInstance().registerGlobal(this);
|
|
||||||
//CrashHandler.getInstance().registerPart(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void write(InputStream input, OutputStream output) throws IOException {
|
|
||||||
byte[] buf = new byte[1024 * 8];
|
|
||||||
int len;
|
|
||||||
while ((len = input.read(buf)) != -1) {
|
|
||||||
output.write(buf, 0, len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void write(File file, byte[] data) throws IOException {
|
|
||||||
File parent = file.getParentFile();
|
|
||||||
if (parent != null && !parent.exists()) parent.mkdirs();
|
|
||||||
|
|
||||||
ByteArrayInputStream input = new ByteArrayInputStream(data);
|
|
||||||
FileOutputStream output = new FileOutputStream(file);
|
|
||||||
try {
|
|
||||||
write(input, output);
|
|
||||||
} finally {
|
|
||||||
closeIO(input, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toString(InputStream input) throws IOException {
|
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
||||||
write(input, output);
|
|
||||||
try {
|
|
||||||
return output.toString("UTF-8");
|
|
||||||
} finally {
|
|
||||||
closeIO(input, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void closeIO(Closeable... closeables) {
|
|
||||||
for (Closeable closeable : closeables) {
|
|
||||||
try {
|
|
||||||
if (closeable != null) closeable.close();
|
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CrashHandler {
|
|
||||||
|
|
||||||
public static final UncaughtExceptionHandler DEFAULT_UNCAUGHT_EXCEPTION_HANDLER = Thread.getDefaultUncaughtExceptionHandler();
|
|
||||||
|
|
||||||
private static CrashHandler sInstance;
|
|
||||||
|
|
||||||
private PartCrashHandler mPartCrashHandler;
|
|
||||||
|
|
||||||
public static CrashHandler getInstance() {
|
|
||||||
if (sInstance == null) {
|
|
||||||
sInstance = new CrashHandler();
|
|
||||||
}
|
|
||||||
return sInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerGlobal(Context context) {
|
|
||||||
registerGlobal(context, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerGlobal(Context context, String crashDir) {
|
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandlerImpl(context.getApplicationContext(), crashDir));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unregister() {
|
|
||||||
Thread.setDefaultUncaughtExceptionHandler(DEFAULT_UNCAUGHT_EXCEPTION_HANDLER);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerPart(Context context) {
|
|
||||||
unregisterPart(context);
|
|
||||||
mPartCrashHandler = new PartCrashHandler(context.getApplicationContext());
|
|
||||||
MAIN_HANDLER.postAtFrontOfQueue(mPartCrashHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unregisterPart(Context context) {
|
|
||||||
if (mPartCrashHandler != null) {
|
|
||||||
mPartCrashHandler.isRunning.set(false);
|
|
||||||
mPartCrashHandler = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class PartCrashHandler implements Runnable {
|
|
||||||
|
|
||||||
private final Context mContext;
|
|
||||||
|
|
||||||
public AtomicBoolean isRunning = new AtomicBoolean(true);
|
|
||||||
|
|
||||||
public PartCrashHandler(Context context) {
|
|
||||||
this.mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
while (isRunning.get()) {
|
|
||||||
try {
|
|
||||||
Looper.loop();
|
|
||||||
} catch (final Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
if (isRunning.get()) {
|
|
||||||
MAIN_HANDLER.post(new Runnable(){
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(mContext, e.toString(), Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (e instanceof RuntimeException) {
|
|
||||||
throw (RuntimeException)e;
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class UncaughtExceptionHandlerImpl implements UncaughtExceptionHandler {
|
|
||||||
|
|
||||||
private static DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss");
|
|
||||||
|
|
||||||
private final Context mContext;
|
|
||||||
|
|
||||||
private final File mCrashDir;
|
|
||||||
|
|
||||||
public UncaughtExceptionHandlerImpl(Context context, String crashDir) {
|
|
||||||
this.mContext = context;
|
|
||||||
this.mCrashDir = TextUtils.isEmpty(crashDir) ? new File(mContext.getExternalCacheDir(), "crash") : new File(crashDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
String log = buildLog(throwable);
|
|
||||||
writeLog(log);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Intent intent = new Intent(mContext, CrashActivity.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, log);
|
|
||||||
mContext.startActivity(intent);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
writeLog(e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
throwable.printStackTrace();
|
|
||||||
android.os.Process.killProcess(android.os.Process.myPid());
|
|
||||||
System.exit(0);
|
|
||||||
|
|
||||||
} catch (Throwable e) {
|
|
||||||
if (DEFAULT_UNCAUGHT_EXCEPTION_HANDLER != null) DEFAULT_UNCAUGHT_EXCEPTION_HANDLER.uncaughtException(thread, throwable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String buildLog(Throwable throwable) {
|
|
||||||
String time = DATE_FORMAT.format(new Date());
|
|
||||||
|
|
||||||
String versionName = "unknown";
|
|
||||||
long versionCode = 0;
|
|
||||||
try {
|
|
||||||
PackageInfo packageInfo = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
|
|
||||||
versionName = packageInfo.versionName;
|
|
||||||
versionCode = Build.VERSION.SDK_INT >= 28 ? packageInfo.getLongVersionCode() : packageInfo.versionCode;
|
|
||||||
} catch (Throwable ignored) {}
|
|
||||||
|
|
||||||
LinkedHashMap<String, String> head = new LinkedHashMap<String, String>();
|
|
||||||
head.put("Time Of Crash", time);
|
|
||||||
head.put("Device", String.format("%s, %s", Build.MANUFACTURER, Build.MODEL));
|
|
||||||
head.put("Android Version", String.format("%s (%d)", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
|
|
||||||
head.put("App Version", String.format("%s (%d)", versionName, versionCode));
|
|
||||||
head.put("Kernel", getKernel());
|
|
||||||
head.put("Support Abis", Build.VERSION.SDK_INT >= 21 && Build.SUPPORTED_ABIS != null ? Arrays.toString(Build.SUPPORTED_ABIS): "unknown");
|
|
||||||
head.put("Fingerprint", Build.FINGERPRINT);
|
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
|
|
||||||
for (String key : head.keySet()) {
|
|
||||||
if (builder.length() != 0) builder.append("\n");
|
|
||||||
builder.append(key);
|
|
||||||
builder.append(" : ");
|
|
||||||
builder.append(head.get(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.append("\n\n");
|
|
||||||
builder.append(Log.getStackTraceString(throwable));
|
|
||||||
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeLog(String log) {
|
|
||||||
String time = DATE_FORMAT.format(new Date());
|
|
||||||
File file = new File(mCrashDir, "crash_" + time + ".txt");
|
|
||||||
try {
|
|
||||||
write(file, log.getBytes("UTF-8"));
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getKernel() {
|
|
||||||
try {
|
|
||||||
return App.toString(new FileInputStream("/proc/version")).trim();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
return e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class CrashActivity extends Activity {
|
|
||||||
|
|
||||||
private String mLog;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
setTheme(android.R.style.Theme_DeviceDefault);
|
|
||||||
setTitle("App Crash");
|
|
||||||
|
|
||||||
mLog = getIntent().getStringExtra(Intent.EXTRA_TEXT);
|
|
||||||
|
|
||||||
ScrollView contentView = new ScrollView(this);
|
|
||||||
contentView.setFillViewport(true);
|
|
||||||
|
|
||||||
HorizontalScrollView horizontalScrollView = new HorizontalScrollView(this);
|
|
||||||
|
|
||||||
TextView textView = new TextView(this);
|
|
||||||
int padding = dp2px(16);
|
|
||||||
textView.setPadding(padding, padding, padding, padding);
|
|
||||||
textView.setText(mLog);
|
|
||||||
textView.setTextIsSelectable(true);
|
|
||||||
textView.setTypeface(Typeface.DEFAULT);
|
|
||||||
textView.setLinksClickable(true);
|
|
||||||
|
|
||||||
horizontalScrollView.addView(textView);
|
|
||||||
contentView.addView(horizontalScrollView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
|
||||||
|
|
||||||
setContentView(contentView);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void restart() {
|
|
||||||
Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName());
|
|
||||||
if (intent != null) {
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
finish();
|
|
||||||
android.os.Process.killProcess(android.os.Process.myPid());
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int dp2px(float dpValue) {
|
|
||||||
final float scale = Resources.getSystem().getDisplayMetrics().density;
|
|
||||||
return (int) (dpValue * scale + 0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
menu.add(0, android.R.id.copy, 0, android.R.string.copy)
|
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case android.R.id.copy:
|
|
||||||
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
|
||||||
cm.setPrimaryClip(ClipData.newPlainText(getPackageName(), mLog));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
restart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package cc.winboll.studio.gpsrelaysentinel;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import cc.winboll.studio.libappbase.LogView;
|
|
||||||
import cc.winboll.studio.libappbase.ToastUtils;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
LogView mLogView;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
|
|
||||||
Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
|
|
||||||
mLogView = findViewById(R.id.logview);
|
|
||||||
|
|
||||||
ToastUtils.show("onCreate");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
mLogView.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void onLibraryActivity(View view) {
|
|
||||||
// startActivity(new Intent(this, LibraryActivity.class));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:aapt="http://schemas.android.com/aapt"
|
|
||||||
android:width="108dp"
|
|
||||||
android:height="108dp"
|
|
||||||
android:viewportHeight="108"
|
|
||||||
android:viewportWidth="108">
|
|
||||||
<path
|
|
||||||
android:fillType="evenOdd"
|
|
||||||
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
|
|
||||||
android:strokeColor="#00000000"
|
|
||||||
android:strokeWidth="1">
|
|
||||||
<aapt:attr name="android:fillColor">
|
|
||||||
<gradient
|
|
||||||
android:endX="78.5885"
|
|
||||||
android:endY="90.9159"
|
|
||||||
android:startX="48.7653"
|
|
||||||
android:startY="61.0927"
|
|
||||||
android:type="linear">
|
|
||||||
<item
|
|
||||||
android:color="#44000000"
|
|
||||||
android:offset="0.0" />
|
|
||||||
<item
|
|
||||||
android:color="#00000000"
|
|
||||||
android:offset="1.0" />
|
|
||||||
</gradient>
|
|
||||||
</aapt:attr>
|
|
||||||
</path>
|
|
||||||
<path
|
|
||||||
android:fillColor="#FFFFFF"
|
|
||||||
android:fillType="nonZero"
|
|
||||||
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
|
|
||||||
android:strokeColor="#00000000"
|
|
||||||
android:strokeWidth="1" />
|
|
||||||
</vector>
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
<?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>
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android: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="vertical"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1.0"
|
|
||||||
android:gravity="center_vertical|center_horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="GPSRelaySentinel"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Open LibraryActivity"
|
|
||||||
android:onClick="onLibraryActivity"/>
|
|
||||||
|
|
||||||
</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>
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<background android:drawable="@drawable/ic_launcher_background" />
|
|
||||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
|
||||||
</adaptive-icon>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<background android:drawable="@drawable/ic_launcher_background" />
|
|
||||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
|
||||||
</adaptive-icon>
|
|
||||||
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 15 KiB |
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<color name="colorPrimary">#009688</color>
|
|
||||||
<color name="colorPrimaryDark">#00796B</color>
|
|
||||||
<color name="colorAccent">#FF9800</color>
|
|
||||||
</resources>
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<string name="app_name">GPSRelaySentinel</string>
|
|
||||||
|
|
||||||
</resources>
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
|
|
||||||
<!-- Put flavor specific strings here -->
|
|
||||||
|
|
||||||
</resources>
|
|
||||||
@@ -9,7 +9,7 @@ android {
|
|||||||
buildToolsVersion "30.0.3"
|
buildToolsVersion "30.0.3"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 21
|
minSdkVersion 26
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@@ -18,6 +18,10 @@ android {
|
|||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Tue Apr 28 17:08:04 HKT 2026
|
#Mon May 11 16:56:19 HKT 2026
|
||||||
stageCount=22
|
stageCount=7
|
||||||
libraryProject=libappbase
|
libraryProject=libappbase
|
||||||
baseVersion=15.15
|
baseVersion=15.20
|
||||||
publishVersion=15.15.21
|
publishVersion=15.20.6
|
||||||
buildCount=0
|
buildCount=0
|
||||||
baseBetaVersion=15.15.22
|
baseBetaVersion=15.20.7
|
||||||
|
|||||||
@@ -0,0 +1,194 @@
|
|||||||
|
package cc.winboll.studio.libappbase;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用崩溃保险丝内部类(单例)
|
||||||
|
* 核心作用:限制短时间内重复崩溃,通过「熔断等级」控制崩溃页面启动策略
|
||||||
|
* 等级范围:MINI(1)~ MAX(2),每次崩溃等级-1,熔断后启动基础版崩溃页面
|
||||||
|
*/
|
||||||
|
public final class AppCrashSafetyWire {
|
||||||
|
|
||||||
|
public static final String TAG = "AppCrashSafetyWire";
|
||||||
|
|
||||||
|
/** 单例实例(volatile 保证多线程可见性) */
|
||||||
|
private static volatile AppCrashSafetyWire _AppCrashSafetyWire;
|
||||||
|
|
||||||
|
/** 当前熔断等级(1:最低防护;2:最高防护;≤0:熔断) */
|
||||||
|
private volatile Integer currentSafetyLevel;
|
||||||
|
/** 最低熔断等级(1,再崩溃则熔断) */
|
||||||
|
private static final int _MINI = 1;
|
||||||
|
/** 最高熔断等级(2,初始状态) */
|
||||||
|
private static final int _MAX = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 私有构造方法(单例模式,禁止外部实例化)
|
||||||
|
* 初始化时加载本地存储的熔断等级
|
||||||
|
*/
|
||||||
|
private AppCrashSafetyWire() {
|
||||||
|
LogUtils.d(TAG, "AppCrashSafetyWire()");
|
||||||
|
currentSafetyLevel = loadCurrentSafetyLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单例实例(双重检查锁定,线程安全)
|
||||||
|
* @return AppCrashSafetyWire 单例
|
||||||
|
*/
|
||||||
|
public static synchronized AppCrashSafetyWire getInstance() {
|
||||||
|
if (_AppCrashSafetyWire == null) {
|
||||||
|
_AppCrashSafetyWire = new AppCrashSafetyWire();
|
||||||
|
}
|
||||||
|
return _AppCrashSafetyWire;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置当前熔断等级(内存中)
|
||||||
|
* @param currentSafetyLevel 目标等级(1~2)
|
||||||
|
*/
|
||||||
|
public void setCurrentSafetyLevel(int currentSafetyLevel) {
|
||||||
|
this.currentSafetyLevel = currentSafetyLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前熔断等级(内存中)
|
||||||
|
* @return 当前等级(1~2 或 null)
|
||||||
|
*/
|
||||||
|
public int getCurrentSafetyLevel() {
|
||||||
|
return currentSafetyLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存熔断等级到本地文件(持久化,重启应用生效)
|
||||||
|
* @param currentSafetyLevel 待保存的等级
|
||||||
|
*/
|
||||||
|
public void saveCurrentSafetyLevel(int currentSafetyLevel) {
|
||||||
|
LogUtils.d(TAG, "saveCurrentSafetyLevel()");
|
||||||
|
this.currentSafetyLevel = currentSafetyLevel;
|
||||||
|
try {
|
||||||
|
// 序列化等级到文件(ObjectOutputStream 写入 int)
|
||||||
|
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(CrashHandler._CrashCountFilePath));
|
||||||
|
oos.writeInt(currentSafetyLevel);
|
||||||
|
oos.flush();
|
||||||
|
oos.close();
|
||||||
|
LogUtils.d(TAG, String.format("saveCurrentSafetyLevel writeInt currentSafetyLevel %d", currentSafetyLevel));
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从本地文件加载熔断等级(应用启动时初始化)
|
||||||
|
* @return 加载的等级(文件不存在则初始化为 MAX(2))
|
||||||
|
*/
|
||||||
|
public int loadCurrentSafetyLevel() {
|
||||||
|
LogUtils.d(TAG, "loadCurrentSafetyLevel()");
|
||||||
|
try {
|
||||||
|
File f = new File(CrashHandler._CrashCountFilePath);
|
||||||
|
if (f.exists()) {
|
||||||
|
// 反序列化从文件读取等级
|
||||||
|
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(CrashHandler._CrashCountFilePath));
|
||||||
|
currentSafetyLevel = ois.readInt();
|
||||||
|
LogUtils.d(TAG, String.format("loadCurrentSafetyLevel() readInt currentSafetyLevel %d", currentSafetyLevel));
|
||||||
|
} else {
|
||||||
|
// 文件不存在,初始化等级为最高(2)并保存
|
||||||
|
currentSafetyLevel = _MAX;
|
||||||
|
LogUtils.d(TAG, String.format("loadCurrentSafetyLevel() currentSafetyLevel init to _MAX->%d", _MAX));
|
||||||
|
saveCurrentSafetyLevel(currentSafetyLevel);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return currentSafetyLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 熔断保险丝(每次崩溃调用,降低防护等级)
|
||||||
|
* @return 熔断后是否仍在防护范围内(true:是;false:已熔断)
|
||||||
|
*/
|
||||||
|
boolean burnSafetyWire() {
|
||||||
|
LogUtils.d(TAG, "burnSafetyWire()");
|
||||||
|
// 加载当前等级
|
||||||
|
int safeLevel = loadCurrentSafetyLevel();
|
||||||
|
// 若在防护范围内(1~2),等级-1 并保存
|
||||||
|
if (isSafetyWireWorking(safeLevel)) {
|
||||||
|
LogUtils.d(TAG, "burnSafetyWire() use");
|
||||||
|
saveCurrentSafetyLevel(safeLevel - 1);
|
||||||
|
// 返回熔断后的状态
|
||||||
|
return isSafetyWireWorking(safeLevel - 1);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查熔断等级是否在有效范围内(1~2)
|
||||||
|
* @param safetyLevel 待检查的等级
|
||||||
|
* @return true:在范围内(防护有效);false:超出范围(已熔断)
|
||||||
|
*/
|
||||||
|
boolean isSafetyWireWorking(int safetyLevel) {
|
||||||
|
LogUtils.d(TAG, "isSafetyWireOK()");
|
||||||
|
LogUtils.d(TAG, String.format("SafetyLevel %d", safetyLevel));
|
||||||
|
|
||||||
|
if (safetyLevel >= _MINI && safetyLevel <= _MAX) {
|
||||||
|
LogUtils.d(TAG, String.format("In Safety Level"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
LogUtils.d(TAG, String.format("Out of Safety Level"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 立即恢复熔断等级到最高(2)
|
||||||
|
* 用于重启应用后重置防护状态
|
||||||
|
*/
|
||||||
|
void resumeToMaximumImmediately() {
|
||||||
|
LogUtils.d(TAG, "resumeToMaximumImmediately() call saveCurrentSafetyLevel(_MAX)");
|
||||||
|
AppCrashSafetyWire.getInstance().saveCurrentSafetyLevel(_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭防护(设置等级为最低(1))
|
||||||
|
* 下次崩溃直接熔断
|
||||||
|
*/
|
||||||
|
void off() {
|
||||||
|
LogUtils.d(TAG, "off()");
|
||||||
|
saveCurrentSafetyLevel(_MINI);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查当前保险丝是否有效(防护未熔断)
|
||||||
|
* @return true:有效(等级 1~2);false:已熔断
|
||||||
|
*/
|
||||||
|
public boolean isAppCrashSafetyWireOK() {
|
||||||
|
LogUtils.d(TAG, "isAppCrashSafetyWireOK()");
|
||||||
|
currentSafetyLevel = loadCurrentSafetyLevel();
|
||||||
|
return isSafetyWireWorking(currentSafetyLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 延迟恢复保险丝到最高等级(500ms 后)
|
||||||
|
* 核心作用:崩溃页面启动后,若下次即将熔断,提前恢复防护等级,避免持续崩溃
|
||||||
|
* @param context 上下文(用于获取主线程 Handler)
|
||||||
|
*/
|
||||||
|
void postResumeCrashSafetyWireHandler(final Context context) {
|
||||||
|
// 主线程延迟 500ms 执行(避免页面启动时阻塞)
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
LogUtils.d(TAG, "Handler run()");
|
||||||
|
// 检查:若当前等级-1 后超出防护范围(即将熔断),则恢复到最高等级
|
||||||
|
if (!AppCrashSafetyWire.getInstance().isSafetyWireWorking(currentSafetyLevel - 1)) {
|
||||||
|
AppCrashSafetyWire.getInstance().resumeToMaximumImmediately();
|
||||||
|
LogUtils.d(TAG, "postResumeCrashSafetyWireHandler: 恢复保险丝到最高等级");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,6 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -23,7 +22,9 @@ import android.widget.HorizontalScrollView;
|
|||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import cc.winboll.studio.libappbase.utils.CrashHandleNotifyUtils;
|
import cc.winboll.studio.libappbase.utils.CrashHandleNotifyUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@@ -38,521 +39,292 @@ import java.util.Date;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
* 应用全局崩溃处理类(单例逻辑)
|
||||||
* @Date 2025/11/11 20:14
|
|
||||||
* @Describe * 应用全局崩溃处理类(单例逻辑)
|
|
||||||
* 核心功能:捕获应用未捕获异常,记录崩溃日志到文件,启动崩溃报告页面,
|
* 核心功能:捕获应用未捕获异常,记录崩溃日志到文件,启动崩溃报告页面,
|
||||||
* 并通过「崩溃保险丝」机制防止重复崩溃,保障基础功能可用
|
* 并通过「崩溃保险丝」机制防止重复崩溃,保障基础功能可用
|
||||||
|
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
|
||||||
|
* @CreateTime 2025/11/11 20:14:00
|
||||||
|
* @EditTime 2026/05/11 15:36:45
|
||||||
*/
|
*/
|
||||||
public final class CrashHandler {
|
public final class CrashHandler {
|
||||||
|
|
||||||
/** 日志标签,用于当前类的日志输出标识 */
|
// ====================== 常量定义 ======================
|
||||||
public static final String TAG = "CrashHandler";
|
/** 日志标签 */
|
||||||
|
public static final String TAG = "CrashHandler";
|
||||||
|
/** 崩溃报告页面标题 */
|
||||||
|
public static final String TITTLE = "CrashReport";
|
||||||
|
/** Intent 传递崩溃信息键 */
|
||||||
|
public static final String EXTRA_CRASH_LOG = "crashInfo";
|
||||||
|
/** SharedPreferences 存储键 */
|
||||||
|
static final String PREFS = CrashHandler.class.getName() + "PREFS";
|
||||||
|
/** 标记是否发生崩溃键 */
|
||||||
|
static final String PREFS_CRASHHANDLER_ISCRASHHAPPEN = "PREFS_CRASHHANDLER_ISCRASHHAPPEN";
|
||||||
|
|
||||||
/** 崩溃报告页面标题 */
|
// ====================== 成员变量 ======================
|
||||||
public static final String TITTLE = "CrashReport";
|
/** 崩溃保险丝状态文件路径 */
|
||||||
|
public static String _CrashCountFilePath;
|
||||||
|
/** 系统默认异常处理器兜底 */
|
||||||
|
public static final UncaughtExceptionHandler DEFAULT_UNCAUGHT_EXCEPTION_HANDLER
|
||||||
|
= Thread.getDefaultUncaughtExceptionHandler();
|
||||||
|
|
||||||
/** Intent 传递崩溃信息的键(用于向崩溃页面传递日志) */
|
// ====================== 对外初始化方法 ======================
|
||||||
public static final String EXTRA_CRASH_LOG = "crashInfo";
|
/**
|
||||||
|
* 初始化崩溃处理器(默认存储路径)
|
||||||
|
* @param app 全局Application实例
|
||||||
|
*/
|
||||||
|
public static void init(final Application app) {
|
||||||
|
_CrashCountFilePath = app.getExternalFilesDir("CrashHandler") + "/IsCrashHandlerCrashHappen.dat";
|
||||||
|
LogUtils.d(TAG, "init _CrashCountFilePath = " + _CrashCountFilePath);
|
||||||
|
init(app, null);
|
||||||
|
}
|
||||||
|
|
||||||
/** SharedPreferences 存储键(用于记录崩溃状态) */
|
/**
|
||||||
final static String PREFS = CrashHandler.class.getName() + "PREFS";
|
* 初始化崩溃处理器(自定义日志目录)
|
||||||
/** SharedPreferences 中存储「是否发生崩溃」的键 */
|
* @param app 全局Application实例
|
||||||
final static String PREFS_CRASHHANDLER_ISCRASHHAPPEN = "PREFS_CRASHHANDLER_ISCRASHHAPPEN";
|
* @param crashDir 自定义崩溃日志目录,传null使用默认
|
||||||
|
*/
|
||||||
/** 崩溃保险丝状态文件路径(存储当前熔断等级) */
|
public static void init(final Application app, final String crashDir) {
|
||||||
public static String _CrashCountFilePath;
|
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
|
||||||
|
|
||||||
/** 系统默认的未捕获异常处理器(用于降级处理,避免 CrashHandler 自身崩溃) */
|
|
||||||
public static final UncaughtExceptionHandler DEFAULT_UNCAUGHT_EXCEPTION_HANDLER = Thread.getDefaultUncaughtExceptionHandler();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化崩溃处理器(默认存储路径)
|
|
||||||
* 调用重载方法,崩溃日志默认存储在应用外部私有目录的 crash 文件夹下
|
|
||||||
* @param app 全局 Application 实例(用于获取存储目录、包信息等)
|
|
||||||
*/
|
|
||||||
public static void init(Application app) {
|
|
||||||
// 初始化崩溃保险丝状态文件路径(外部存储/CrashHandler/IsCrashHandlerCrashHappen.dat)
|
|
||||||
_CrashCountFilePath = app.getExternalFilesDir("CrashHandler") + "/IsCrashHandlerCrashHappen.dat";
|
|
||||||
LogUtils.d(TAG, String.format("_CrashCountFilePath %s", _CrashCountFilePath));
|
|
||||||
// 调用带目录参数的初始化方法,传入 null 使用默认路径
|
|
||||||
init(app, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化崩溃处理器(指定日志存储目录)
|
|
||||||
* 替换系统默认的未捕获异常处理器,自定义崩溃处理逻辑
|
|
||||||
* @param app 全局 Application 实例
|
|
||||||
* @param crashDir 崩溃日志存储目录(null 则使用默认路径)
|
|
||||||
*/
|
|
||||||
public static void init(final Application app, final String crashDir) {
|
|
||||||
// 设置自定义未捕获异常处理器
|
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
|
|
||||||
@Override
|
@Override
|
||||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
public void uncaughtException(final Thread thread, final Throwable throwable) {
|
||||||
try {
|
try {
|
||||||
// 尝试处理崩溃(捕获内部异常,避免 CrashHandler 自身崩溃)
|
tryUncaughtException(thread, throwable, crashDir, app);
|
||||||
tryUncaughtException(thread, throwable);
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
LogUtils.e(TAG, "uncaughtException error", e);
|
||||||
// 处理失败时,交给系统默认处理器兜底
|
|
||||||
if (DEFAULT_UNCAUGHT_EXCEPTION_HANDLER != null) {
|
if (DEFAULT_UNCAUGHT_EXCEPTION_HANDLER != null) {
|
||||||
DEFAULT_UNCAUGHT_EXCEPTION_HANDLER.uncaughtException(thread, throwable);
|
DEFAULT_UNCAUGHT_EXCEPTION_HANDLER.uncaughtException(thread, throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 实际处理崩溃的核心方法
|
|
||||||
* 1. 熔断保险丝(记录崩溃次数);2. 收集崩溃信息;3. 写入日志文件;4. 启动崩溃报告页面
|
|
||||||
* @param thread 发生崩溃的线程
|
|
||||||
* @param throwable 崩溃异常对象(包含堆栈信息)
|
|
||||||
*/
|
|
||||||
private void tryUncaughtException(Thread thread, Throwable throwable) {
|
|
||||||
// 触发崩溃保险丝(每次崩溃熔断一次,降低防护等级)
|
|
||||||
AppCrashSafetyWire.getInstance().burnSafetyWire();
|
|
||||||
|
|
||||||
// 格式化崩溃发生时间(用于日志文件名和内容)
|
|
||||||
final String time = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss", Locale.getDefault()).format(new Date());
|
|
||||||
// 创建崩溃日志文件(默认路径:外部存储/crash/[时间].txt)
|
|
||||||
File crashFile = new File(
|
|
||||||
TextUtils.isEmpty(crashDir) ? new File(app.getExternalFilesDir(null), "crash") : new File(crashDir),
|
|
||||||
"crash_" + time + ".txt"
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取应用版本信息(版本名、版本号)
|
|
||||||
String versionName = "unknown";
|
|
||||||
long versionCode = 0;
|
|
||||||
try {
|
|
||||||
PackageInfo packageInfo = app.getPackageManager().getPackageInfo(app.getPackageName(), 0);
|
|
||||||
versionName = packageInfo.versionName;
|
|
||||||
// 适配 Android 9.0+(API 28)的版本号获取方式
|
|
||||||
versionCode = Build.VERSION.SDK_INT >= 28 ? packageInfo.getLongVersionCode() : packageInfo.versionCode;
|
|
||||||
} catch (PackageManager.NameNotFoundException ignored) {}
|
|
||||||
|
|
||||||
// 将异常堆栈信息转换为字符串
|
|
||||||
String fullStackTrace;
|
|
||||||
{
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
|
||||||
throwable.printStackTrace(pw); // 将异常堆栈写入 PrintWriter
|
|
||||||
fullStackTrace = sw.toString();
|
|
||||||
pw.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 拼接崩溃信息(设备信息 + 应用信息 + 堆栈信息)
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("************* Crash Head ****************\n");
|
|
||||||
sb.append("Time Of Crash : ").append(time).append("\n");
|
|
||||||
sb.append("Device Manufacturer : ").append(Build.MANUFACTURER).append("\n"); // 设备厂商
|
|
||||||
sb.append("Device Model : ").append(Build.MODEL).append("\n"); // 设备型号
|
|
||||||
sb.append("Android Version : ").append(Build.VERSION.RELEASE).append("\n"); // Android 版本
|
|
||||||
sb.append("Android SDK : ").append(Build.VERSION.SDK_INT).append("\n"); // SDK 版本
|
|
||||||
sb.append("App VersionName : ").append(versionName).append("\n"); // 应用版本名
|
|
||||||
sb.append("App VersionCode : ").append(versionCode).append("\n"); // 应用版本号
|
|
||||||
sb.append("************* Crash Head ****************\n");
|
|
||||||
sb.append("\n").append(fullStackTrace); // 拼接异常堆栈
|
|
||||||
|
|
||||||
final String errorLog = sb.toString();
|
|
||||||
|
|
||||||
// 将崩溃日志写入文件(忽略写入失败)
|
|
||||||
try {
|
|
||||||
writeFile(crashFile, errorLog);
|
|
||||||
} catch (IOException ignored) {}
|
|
||||||
|
|
||||||
// 启动崩溃报告页面(标签用于代码块折叠)
|
|
||||||
gotoCrashActiviy: {
|
|
||||||
Intent intent = new Intent();
|
|
||||||
LogUtils.d(TAG, "gotoCrashActiviy: ");
|
|
||||||
|
|
||||||
// 根据保险丝状态选择启动的崩溃页面
|
|
||||||
if (AppCrashSafetyWire.getInstance().isAppCrashSafetyWireOK()) {
|
|
||||||
LogUtils.d(TAG, "gotoCrashActiviy: isAppCrashSafetyWireOK");
|
|
||||||
// 保险丝正常:启动自定义样式的崩溃报告页面(GlobalCrashActivity)
|
|
||||||
intent.setClass(app, GlobalCrashActivity.class);
|
|
||||||
intent.putExtra(EXTRA_CRASH_LOG, errorLog); // 传递崩溃日志
|
|
||||||
} else {
|
|
||||||
LogUtils.d(TAG, "gotoCrashActiviy: else");
|
|
||||||
// 保险丝熔断:启动基础版崩溃页面(CrashActivity,避免复杂页面再次崩溃)
|
|
||||||
intent.setClass(app, CrashActivity.class);
|
|
||||||
intent.putExtra(EXTRA_CRASH_LOG, errorLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置意图标志:清除原有任务栈,创建新任务(避免回到崩溃前页面)
|
|
||||||
intent.addFlags(
|
|
||||||
Intent.FLAG_ACTIVITY_NEW_TASK
|
|
||||||
| Intent.FLAG_ACTIVITY_CLEAR_TOP
|
|
||||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (GlobalApplication.isDebugging()&&AppCrashSafetyWire.getInstance().isAppCrashSafetyWireOK()) {
|
|
||||||
// 如果是 debug 版,启动崩溃页面窗口
|
|
||||||
app.startActivity(intent);
|
|
||||||
} else {
|
|
||||||
// 如果是 release 版,就只发送一个通知
|
|
||||||
CrashHandleNotifyUtils.handleUncaughtException(app, intent);
|
|
||||||
}
|
|
||||||
// 终止当前进程(确保完全重启)
|
|
||||||
android.os.Process.killProcess(android.os.Process.myPid());
|
|
||||||
System.exit(0);
|
|
||||||
|
|
||||||
} catch (ActivityNotFoundException e) {
|
|
||||||
// 未找到崩溃页面(如未在 Manifest 注册),交给系统默认处理器
|
|
||||||
e.printStackTrace();
|
|
||||||
if (DEFAULT_UNCAUGHT_EXCEPTION_HANDLER != null) {
|
|
||||||
DEFAULT_UNCAUGHT_EXCEPTION_HANDLER.uncaughtException(thread, throwable);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// 其他异常,兜底处理
|
|
||||||
e.printStackTrace();
|
|
||||||
if (DEFAULT_UNCAUGHT_EXCEPTION_HANDLER != null) {
|
|
||||||
DEFAULT_UNCAUGHT_EXCEPTION_HANDLER.uncaughtException(thread, throwable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将字符串内容写入文件(创建父目录、覆盖写入)
|
|
||||||
* @param file 目标文件(包含路径)
|
|
||||||
* @param content 待写入的内容(崩溃日志)
|
|
||||||
* @throws IOException 文件创建或写入失败时抛出
|
|
||||||
*/
|
|
||||||
private void writeFile(File file, String content) throws IOException {
|
|
||||||
File parentFile = file.getParentFile();
|
|
||||||
// 父目录不存在则创建
|
|
||||||
if (parentFile != null && !parentFile.exists()) {
|
|
||||||
parentFile.mkdirs();
|
|
||||||
}
|
|
||||||
file.createNewFile(); // 创建文件
|
|
||||||
FileOutputStream fos = new FileOutputStream(file);
|
|
||||||
fos.write(content.getBytes()); // 写入内容(默认 UTF-8 编码)
|
|
||||||
try {
|
|
||||||
fos.close(); // 关闭流
|
|
||||||
} catch (IOException e) {}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// ====================== 内部崩溃处理核心 ======================
|
||||||
* 应用崩溃保险丝内部类(单例)
|
/**
|
||||||
* 核心作用:限制短时间内重复崩溃,通过「熔断等级」控制崩溃页面启动策略
|
* 执行崩溃信息收集、日志写入、跳转崩溃页面
|
||||||
* 等级范围:MINI(1)~ MAX(2),每次崩溃等级-1,熔断后启动基础版崩溃页面
|
*/
|
||||||
*/
|
private static void tryUncaughtException(final Thread thread,
|
||||||
public static final class AppCrashSafetyWire {
|
final Throwable throwable,
|
||||||
|
final String crashDir,
|
||||||
|
final Application app) {
|
||||||
|
// 触发崩溃保险丝
|
||||||
|
AppCrashSafetyWire.getInstance().burnSafetyWire();
|
||||||
|
|
||||||
/** 单例实例(volatile 保证多线程可见性) */
|
// 格式化时间
|
||||||
private static volatile AppCrashSafetyWire _AppCrashSafetyWire;
|
final String time = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss",
|
||||||
|
Locale.getDefault()).format(new Date());
|
||||||
|
|
||||||
/** 当前熔断等级(1:最低防护;2:最高防护;≤0:熔断) */
|
// 创建日志文件
|
||||||
private volatile Integer currentSafetyLevel;
|
File logParent = TextUtils.isEmpty(crashDir)
|
||||||
/** 最低熔断等级(1,再崩溃则熔断) */
|
? new File(app.getExternalFilesDir(null), "crash")
|
||||||
private static final int _MINI = 1;
|
: new File(crashDir);
|
||||||
/** 最高熔断等级(2,初始状态) */
|
final File crashFile = new File(logParent, "crash_" + time + ".txt");
|
||||||
private static final int _MAX = 2;
|
|
||||||
|
|
||||||
/**
|
// 获取应用版本信息
|
||||||
* 私有构造方法(单例模式,禁止外部实例化)
|
String versionName = "unknown";
|
||||||
* 初始化时加载本地存储的熔断等级
|
long versionCode = 0;
|
||||||
*/
|
try {
|
||||||
private AppCrashSafetyWire() {
|
final PackageInfo packageInfo = app.getPackageManager()
|
||||||
LogUtils.d(TAG, "AppCrashSafetyWire()");
|
.getPackageInfo(app.getPackageName(), 0);
|
||||||
currentSafetyLevel = loadCurrentSafetyLevel();
|
versionName = packageInfo.versionName;
|
||||||
}
|
if (Build.VERSION.SDK_INT >= 28) {
|
||||||
|
versionCode = packageInfo.getLongVersionCode();
|
||||||
|
} else {
|
||||||
|
versionCode = packageInfo.versionCode;
|
||||||
|
}
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
LogUtils.e(TAG, "get package info fail");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
// 抓取异常堆栈
|
||||||
* 获取单例实例(双重检查锁定,线程安全)
|
String fullStackTrace;
|
||||||
* @return AppCrashSafetyWire 单例
|
StringWriter sw = new StringWriter();
|
||||||
*/
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
public static synchronized AppCrashSafetyWire getInstance() {
|
throwable.printStackTrace(pw);
|
||||||
if (_AppCrashSafetyWire == null) {
|
fullStackTrace = sw.toString();
|
||||||
_AppCrashSafetyWire = new AppCrashSafetyWire();
|
pw.close();
|
||||||
}
|
|
||||||
return _AppCrashSafetyWire;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// 拼接崩溃头部信息
|
||||||
* 设置当前熔断等级(内存中)
|
StringBuilder sb = new StringBuilder();
|
||||||
* @param currentSafetyLevel 目标等级(1~2)
|
sb.append("************* Crash Head ****************\n");
|
||||||
*/
|
sb.append("Time Of Crash : ").append(time).append("\n");
|
||||||
public void setCurrentSafetyLevel(int currentSafetyLevel) {
|
sb.append("Device Manufacturer : ").append(Build.MANUFACTURER).append("\n");
|
||||||
this.currentSafetyLevel = currentSafetyLevel;
|
sb.append("Device Model : ").append(Build.MODEL).append("\n");
|
||||||
}
|
sb.append("Android Version : ").append(Build.VERSION.RELEASE).append("\n");
|
||||||
|
sb.append("Android SDK : ").append(Build.VERSION.SDK_INT).append("\n");
|
||||||
|
sb.append("App VersionName : ").append(versionName).append("\n");
|
||||||
|
sb.append("App VersionCode : ").append(versionCode).append("\n");
|
||||||
|
sb.append("************* Crash Head ****************\n");
|
||||||
|
sb.append("\n").append(fullStackTrace);
|
||||||
|
|
||||||
/**
|
final String errorLog = sb.toString();
|
||||||
* 获取当前熔断等级(内存中)
|
|
||||||
* @return 当前等级(1~2 或 null)
|
|
||||||
*/
|
|
||||||
public int getCurrentSafetyLevel() {
|
|
||||||
return currentSafetyLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// 写入日志文件
|
||||||
* 保存熔断等级到本地文件(持久化,重启应用生效)
|
try {
|
||||||
* @param currentSafetyLevel 待保存的等级
|
writeFile(crashFile, errorLog);
|
||||||
*/
|
} catch (IOException e) {
|
||||||
public void saveCurrentSafetyLevel(int currentSafetyLevel) {
|
LogUtils.e(TAG, "write crash log file fail");
|
||||||
LogUtils.d(TAG, "saveCurrentSafetyLevel()");
|
}
|
||||||
this.currentSafetyLevel = currentSafetyLevel;
|
|
||||||
try {
|
|
||||||
// 序列化等级到文件(ObjectOutputStream 写入 int)
|
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(_CrashCountFilePath));
|
|
||||||
oos.writeInt(currentSafetyLevel);
|
|
||||||
oos.flush();
|
|
||||||
oos.close();
|
|
||||||
LogUtils.d(TAG, String.format("saveCurrentSafetyLevel writeInt currentSafetyLevel %d", currentSafetyLevel));
|
|
||||||
} catch (IOException e) {
|
|
||||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// 跳转崩溃页面
|
||||||
* 从本地文件加载熔断等级(应用启动时初始化)
|
gotoCrashActivity(errorLog, app);
|
||||||
* @return 加载的等级(文件不存在则初始化为 MAX(2))
|
}
|
||||||
*/
|
|
||||||
public int loadCurrentSafetyLevel() {
|
|
||||||
LogUtils.d(TAG, "loadCurrentSafetyLevel()");
|
|
||||||
try {
|
|
||||||
File f = new File(_CrashCountFilePath);
|
|
||||||
if (f.exists()) {
|
|
||||||
// 反序列化从文件读取等级
|
|
||||||
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(_CrashCountFilePath));
|
|
||||||
currentSafetyLevel = ois.readInt();
|
|
||||||
LogUtils.d(TAG, String.format("loadCurrentSafetyLevel() readInt currentSafetyLevel %d", currentSafetyLevel));
|
|
||||||
} else {
|
|
||||||
// 文件不存在,初始化等级为最高(2)并保存
|
|
||||||
currentSafetyLevel = _MAX;
|
|
||||||
LogUtils.d(TAG, String.format("loadCurrentSafetyLevel() currentSafetyLevel init to _MAX->%d", _MAX));
|
|
||||||
saveCurrentSafetyLevel(currentSafetyLevel);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return currentSafetyLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 熔断保险丝(每次崩溃调用,降低防护等级)
|
* 写入文本到文件
|
||||||
* @return 熔断后是否仍在防护范围内(true:是;false:已熔断)
|
*/
|
||||||
*/
|
private static void writeFile(final File file, final String content) throws IOException {
|
||||||
boolean burnSafetyWire() {
|
final File parentFile = file.getParentFile();
|
||||||
LogUtils.d(TAG, "burnSafetyWire()");
|
if (parentFile != null && !parentFile.exists()) {
|
||||||
// 加载当前等级
|
parentFile.mkdirs();
|
||||||
int safeLevel = loadCurrentSafetyLevel();
|
}
|
||||||
// 若在防护范围内(1~2),等级-1 并保存
|
file.createNewFile();
|
||||||
if (isSafetyWireWorking(safeLevel)) {
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
LogUtils.d(TAG, "burnSafetyWire() use");
|
fos.write(content.getBytes());
|
||||||
saveCurrentSafetyLevel(safeLevel - 1);
|
fos.close();
|
||||||
// 返回熔断后的状态
|
}
|
||||||
return isSafetyWireWorking(safeLevel - 1);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查熔断等级是否在有效范围内(1~2)
|
* 根据保险丝状态跳转对应崩溃页面
|
||||||
* @param safetyLevel 待检查的等级
|
*/
|
||||||
* @return true:在范围内(防护有效);false:超出范围(已熔断)
|
private static void gotoCrashActivity(final String errorLog, final Application app) {
|
||||||
*/
|
final Intent intent = new Intent();
|
||||||
boolean isSafetyWireWorking(int safetyLevel) {
|
if (AppCrashSafetyWire.getInstance().isAppCrashSafetyWireOK()) {
|
||||||
LogUtils.d(TAG, "isSafetyWireOK()");
|
intent.setClass(app, GlobalCrashActivity.class);
|
||||||
LogUtils.d(TAG, String.format("SafetyLevel %d", safetyLevel));
|
} else {
|
||||||
|
intent.setClass(app, CrashActivity.class);
|
||||||
|
}
|
||||||
|
intent.putExtra(EXTRA_CRASH_LOG, errorLog);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
| Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
|
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
|
||||||
if (safetyLevel >= _MINI && safetyLevel <= _MAX) {
|
try {
|
||||||
LogUtils.d(TAG, String.format("In Safety Level"));
|
if (GlobalApplication.isDebugging()) {
|
||||||
return true;
|
app.startActivity(intent);
|
||||||
}
|
} else {
|
||||||
LogUtils.d(TAG, String.format("Out of Safety Level"));
|
CrashHandleNotifyUtils.handleUncaughtException(app, intent, GlobalCrashActivity.class);
|
||||||
return false;
|
}
|
||||||
}
|
android.os.Process.killProcess(android.os.Process.myPid());
|
||||||
|
System.exit(0);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
LogUtils.e(TAG, "CrashActivity not found");
|
||||||
|
if (DEFAULT_UNCAUGHT_EXCEPTION_HANDLER != null) {
|
||||||
|
DEFAULT_UNCAUGHT_EXCEPTION_HANDLER.uncaughtException(Thread.currentThread(), e);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e(TAG, "start CrashActivity error");
|
||||||
|
if (DEFAULT_UNCAUGHT_EXCEPTION_HANDLER != null) {
|
||||||
|
DEFAULT_UNCAUGHT_EXCEPTION_HANDLER.uncaughtException(Thread.currentThread(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
// ====================== 内部Activity页面 ======================
|
||||||
* 立即恢复熔断等级到最高(2)
|
/**
|
||||||
* 用于重启应用后重置防护状态
|
* 基础极简崩溃页面
|
||||||
*/
|
* 保险丝熔断时启动,避免复杂布局二次崩溃
|
||||||
void resumeToMaximumImmediately() {
|
*/
|
||||||
LogUtils.d(TAG, "resumeToMaximumImmediately() call saveCurrentSafetyLevel(_MAX)");
|
public static final class CrashActivity extends Activity implements MenuItem.OnMenuItemClickListener {
|
||||||
AppCrashSafetyWire.getInstance().saveCurrentSafetyLevel(_MAX);
|
private static final int MENUITEM_COPY = 0;
|
||||||
}
|
private static final int MENUITEM_RESTART = 1;
|
||||||
|
|
||||||
/**
|
private String mLog;
|
||||||
* 关闭防护(设置等级为最低(1))
|
|
||||||
* 下次崩溃直接熔断
|
|
||||||
*/
|
|
||||||
void off() {
|
|
||||||
LogUtils.d(TAG, "off()");
|
|
||||||
saveCurrentSafetyLevel(_MINI);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 检查当前保险丝是否有效(防护未熔断)
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
* @return true:有效(等级 1~2);false:已熔断
|
super.onCreate(savedInstanceState);
|
||||||
*/
|
AppCrashSafetyWire.getInstance().postResumeCrashSafetyWireHandler(getApplicationContext());
|
||||||
boolean isAppCrashSafetyWireOK() {
|
mLog = getIntent().getStringExtra(EXTRA_CRASH_LOG);
|
||||||
LogUtils.d(TAG, "isAppCrashSafetyWireOK()");
|
setTheme(android.R.style.Theme_DeviceDefault_Light_DarkActionBar);
|
||||||
currentSafetyLevel = loadCurrentSafetyLevel();
|
initLayout();
|
||||||
return isSafetyWireWorking(currentSafetyLevel);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 延迟恢复保险丝到最高等级(500ms 后)
|
* 动态初始化布局
|
||||||
* 核心作用:崩溃页面启动后,若下次即将熔断,提前恢复防护等级,避免持续崩溃
|
*/
|
||||||
* @param context 上下文(用于获取主线程 Handler)
|
private void initLayout() {
|
||||||
*/
|
ScrollView contentView = new ScrollView(this);
|
||||||
void postResumeCrashSafetyWireHandler(final Context context) {
|
contentView.setFillViewport(true);
|
||||||
// 主线程延迟 500ms 执行(避免页面启动时阻塞)
|
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
LogUtils.d(TAG, "Handler run()");
|
|
||||||
// 检查:若当前等级-1 后超出防护范围(即将熔断),则恢复到最高等级
|
|
||||||
if (!AppCrashSafetyWire.getInstance().isSafetyWireWorking(currentSafetyLevel - 1)) {
|
|
||||||
AppCrashSafetyWire.getInstance().resumeToMaximumImmediately();
|
|
||||||
LogUtils.d(TAG, "postResumeCrashSafetyWireHandler: 恢复保险丝到最高等级");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
HorizontalScrollView hw = new HorizontalScrollView(this);
|
||||||
* 基础版崩溃报告页面(保险丝熔断时启动)
|
hw.setBackgroundColor(0xFFF5F5F5);
|
||||||
* 极简实现:仅展示崩溃日志,提供复制、重启功能,避免复杂布局导致二次崩溃
|
|
||||||
*/
|
|
||||||
public static final class CrashActivity extends Activity implements MenuItem.OnMenuItemClickListener {
|
|
||||||
/** 菜单标识:复制崩溃日志 */
|
|
||||||
private static final int MENUITEM_COPY = 0;
|
|
||||||
/** 菜单标识:重启应用 */
|
|
||||||
private static final int MENUITEM_RESTART = 1;
|
|
||||||
|
|
||||||
/** 崩溃日志文本(从 CrashHandler 传递过来) */
|
TextView message = new TextView(this);
|
||||||
private String mLog;
|
final int padding = dp2px(16);
|
||||||
|
message.setPadding(padding, padding, padding, padding);
|
||||||
|
message.setText(mLog);
|
||||||
|
message.setTextColor(0xFF000000);
|
||||||
|
message.setTextIsSelectable(true);
|
||||||
|
|
||||||
@Override
|
hw.addView(message);
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
contentView.addView(hw, ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
super.onCreate(savedInstanceState);
|
ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
// 初始化崩溃保险丝延迟恢复机制
|
setContentView(contentView);
|
||||||
AppCrashSafetyWire.getInstance().postResumeCrashSafetyWireHandler(getApplicationContext());
|
|
||||||
|
|
||||||
// 获取传递的崩溃日志
|
getActionBar().setTitle(TITTLE);
|
||||||
mLog = getIntent().getStringExtra(EXTRA_CRASH_LOG);
|
getActionBar().setSubtitle(GlobalApplication.class.getSimpleName() + " Error");
|
||||||
// 设置系统默认主题(避免自定义主题冲突)
|
}
|
||||||
setTheme(android.R.style.Theme_DeviceDefault_Light_DarkActionBar);
|
|
||||||
|
|
||||||
// 动态创建布局(避免 XML 布局加载异常)
|
@Override
|
||||||
setContentView: {
|
public void onBackPressed() {
|
||||||
// 垂直滚动视图(处理日志过长)
|
restartApp();
|
||||||
ScrollView contentView = new ScrollView(this);
|
}
|
||||||
contentView.setFillViewport(true);
|
|
||||||
|
|
||||||
// 水平滚动视图(处理日志行过长)
|
/**
|
||||||
HorizontalScrollView hw = new HorizontalScrollView(this);
|
* 重启应用
|
||||||
hw.setBackgroundColor(Color.GRAY); // 背景色设为灰色
|
*/
|
||||||
|
private void restartApp() {
|
||||||
|
final Intent intent = getPackageManager()
|
||||||
|
.getLaunchIntentForPackage(getPackageName());
|
||||||
|
if (intent != null) {
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
| Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
|
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
android.os.Process.killProcess(android.os.Process.myPid());
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
// 日志显示文本框
|
/**
|
||||||
TextView message = new TextView(this);
|
* dp转px
|
||||||
{
|
*/
|
||||||
int padding = dp2px(16); // 内边距 16dp(适配不同屏幕)
|
private int dp2px(final float dpValue) {
|
||||||
message.setPadding(padding, padding, padding, padding);
|
final float scale = Resources.getSystem().getDisplayMetrics().density;
|
||||||
message.setText(mLog); // 设置崩溃日志
|
return (int) (dpValue * scale + 0.5f);
|
||||||
message.setTextColor(Color.BLACK); // 文字黑色
|
}
|
||||||
message.setTextIsSelectable(true); // 支持文本选择(便于手动复制)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 组装布局:TextView -> HorizontalScrollView -> ScrollView
|
@Override
|
||||||
hw.addView(message);
|
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||||
contentView.addView(hw, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
menu.add(0, MENUITEM_COPY, 0, "Copy")
|
||||||
// 设置当前 Activity 布局
|
|
||||||
setContentView(contentView);
|
|
||||||
|
|
||||||
// 配置 ActionBar 标题和副标题
|
|
||||||
getActionBar().setTitle(TITTLE);
|
|
||||||
getActionBar().setSubtitle(GlobalApplication.class.getSimpleName() + " Error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 重写返回键逻辑:点击返回键直接重启应用
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 重启当前应用(与 GlobalCrashActivity 逻辑一致)
|
|
||||||
* 清除任务栈,启动主 Activity,终止当前进程
|
|
||||||
*/
|
|
||||||
private void restart() {
|
|
||||||
PackageManager pm = getPackageManager();
|
|
||||||
// 获取应用启动意图(默认启动主 Activity)
|
|
||||||
Intent intent = pm.getLaunchIntentForPackage(getPackageName());
|
|
||||||
if (intent != null) {
|
|
||||||
// 设置意图标志:清除原有任务栈,创建新任务
|
|
||||||
intent.addFlags(
|
|
||||||
Intent.FLAG_ACTIVITY_NEW_TASK
|
|
||||||
| Intent.FLAG_ACTIVITY_CLEAR_TOP
|
|
||||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK
|
|
||||||
);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
// 关闭当前页面,终止进程,确保完全重启
|
|
||||||
finish();
|
|
||||||
android.os.Process.killProcess(android.os.Process.myPid());
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dp 转 px(适配不同屏幕密度)
|
|
||||||
* @param dpValue dp 值
|
|
||||||
* @return 转换后的 px 值
|
|
||||||
*/
|
|
||||||
private int dp2px(final float dpValue) {
|
|
||||||
final float scale = Resources.getSystem().getDisplayMetrics().density;
|
|
||||||
return (int) (dpValue * scale + 0.5f); // 四舍五入确保精度
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单点击事件回调(处理复制、重启)
|
|
||||||
* @param item 被点击的菜单项
|
|
||||||
* @return false:不消费事件(保持默认行为)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case MENUITEM_COPY:
|
|
||||||
// 复制日志到剪贴板
|
|
||||||
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
|
||||||
cm.setPrimaryClip(ClipData.newPlainText(getPackageName(), mLog));
|
|
||||||
Toast.makeText(getApplication(), "The text is copied.", Toast.LENGTH_SHORT).show();
|
|
||||||
break;
|
|
||||||
case MENUITEM_RESTART:
|
|
||||||
// 恢复保险丝到最高等级,然后重启应用
|
|
||||||
AppCrashSafetyWire.getInstance().resumeToMaximumImmediately();
|
|
||||||
restart();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建 ActionBar 菜单(添加复制、重启项)
|
|
||||||
* @param menu 菜单容器
|
|
||||||
* @return true:显示菜单
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
// 添加「复制」菜单:有空间时显示在 ActionBar,否则放入溢出菜单
|
|
||||||
menu.add(0, MENUITEM_COPY, 0, "Copy")
|
|
||||||
.setOnMenuItemClickListener(this)
|
.setOnMenuItemClickListener(this)
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
// 添加「重启」菜单:同上
|
|
||||||
menu.add(0, MENUITEM_RESTART, 0, "Restart")
|
menu.add(0, MENUITEM_RESTART, 0, "Restart")
|
||||||
.setOnMenuItemClickListener(this)
|
.setOnMenuItemClickListener(this)
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(final MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case MENUITEM_COPY:
|
||||||
|
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
cm.setPrimaryClip(ClipData.newPlainText(getPackageName(), mLog));
|
||||||
|
Toast.makeText(getApplication(), "The text is copied.", Toast.LENGTH_SHORT).show();
|
||||||
|
break;
|
||||||
|
case MENUITEM_RESTART:
|
||||||
|
AppCrashSafetyWire.getInstance().resumeToMaximumImmediately();
|
||||||
|
restartApp();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class GlobalApplication extends Application {
|
|||||||
public static boolean isDebugging() {
|
public static boolean isDebugging() {
|
||||||
return isDebugging;
|
return isDebugging;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增:设置 WinBoLL 服务器主机地址(同时保存到 SP 持久化)
|
// 新增:设置 WinBoLL 服务器主机地址(同时保存到 SP 持久化)
|
||||||
public static void setWinbollHost(String host) {
|
public static void setWinbollHost(String host) {
|
||||||
if (sInstance == null) {
|
if (sInstance == null) {
|
||||||
@@ -100,7 +100,7 @@ public class GlobalApplication extends Application {
|
|||||||
sp.edit().putString(SP_KEY_WINBOLL_HOST, host).apply();
|
sp.edit().putString(SP_KEY_WINBOLL_HOST, host).apply();
|
||||||
LogUtils.d(TAG, "setWinbollHost: 服务器地址已设置并持久化,host=" + host);
|
LogUtils.d(TAG, "setWinbollHost: 服务器地址已设置并持久化,host=" + host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 新增:获取 WinBoLL 服务器主机地址(优先内存,内存为空则从 SP 读取)
|
// 新增:获取 WinBoLL 服务器主机地址(优先内存,内存为空则从 SP 读取)
|
||||||
public static String getWinbollHost() {
|
public static String getWinbollHost() {
|
||||||
|
|||||||
@@ -10,176 +10,141 @@ import android.os.Bundle;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import cc.winboll.studio.libappbase.R;
|
|
||||||
|
import cc.winboll.studio.libappbase.utils.CrashHandleNotifyUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
* 应用异常报告观察活动窗口类
|
||||||
* @Date 2025/11/11 19:58
|
|
||||||
* @Describe 应用异常报告观察活动窗口类
|
|
||||||
* 核心功能:应用发生未捕获崩溃时,由 CrashHandler 启动此页面,展示崩溃日志详情,
|
* 核心功能:应用发生未捕获崩溃时,由 CrashHandler 启动此页面,展示崩溃日志详情,
|
||||||
* 并提供「复制日志」「重启应用」操作入口,便于开发者定位问题和用户恢复应用
|
* 并提供「复制日志」「重启应用」操作入口,便于开发者定位问题和用户恢复应用
|
||||||
|
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
|
||||||
|
* @CreateTime 2025/11/11 19:58:00
|
||||||
|
* @EditTime 2026/05/11 15:40:12
|
||||||
*/
|
*/
|
||||||
public final class GlobalCrashActivity extends Activity implements MenuItem.OnMenuItemClickListener {
|
public final class GlobalCrashActivity extends Activity implements MenuItem.OnMenuItemClickListener {
|
||||||
|
|
||||||
/** 日志标签(用于调试日志输出,唯一标识当前 Activity) */
|
// ====================== 常量定义 ======================
|
||||||
public static final String TAG = "GlobalCrashActivity";
|
public static final String TAG = "GlobalCrashActivity";
|
||||||
|
/** 菜单标识:复制崩溃日志 */
|
||||||
/** 菜单标识:复制崩溃日志(用于区分菜单项点击事件) */
|
|
||||||
private static final int MENU_ITEM_COPY = 0;
|
private static final int MENU_ITEM_COPY = 0;
|
||||||
/** 菜单标识:重启应用(用于区分菜单项点击事件) */
|
/** 菜单标识:重启应用 */
|
||||||
private static final int MENU_ITEM_RESTART = 1;
|
private static final int MENU_ITEM_RESTART = 1;
|
||||||
|
|
||||||
|
// ====================== 成员变量 ======================
|
||||||
/** 崩溃报告展示自定义视图 */
|
/** 崩溃报告展示自定义视图 */
|
||||||
// 负责渲染崩溃日志文本、提供 Toolbar 容器,封装了日志展示和菜单样式控制逻辑
|
|
||||||
private GlobalCrashReportView mCrashReportView;
|
private GlobalCrashReportView mCrashReportView;
|
||||||
|
|
||||||
/** 崩溃日志文本内容 */
|
/** 崩溃日志文本内容 */
|
||||||
// 从 CrashHandler 通过 Intent 传递过来,包含异常堆栈、设备信息等完整崩溃数据
|
|
||||||
private String mCrashLog;
|
private String mCrashLog;
|
||||||
|
|
||||||
/**
|
// ====================== 生命周期方法 ======================
|
||||||
* Activity 创建时初始化(生命周期核心方法,仅执行一次)
|
|
||||||
* @param savedInstanceState 保存的实例状态(崩溃页面无需恢复状态,此处仅作兼容)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
LogUtils.d(TAG, "onCreate 方法进入");
|
||||||
|
try {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
final Context appContext = getApplicationContext();
|
||||||
|
// 初始化崩溃安全防护机制
|
||||||
|
AppCrashSafetyWire.getInstance().postResumeCrashSafetyWireHandler(appContext);
|
||||||
|
|
||||||
// 初始化崩溃安全防护机制
|
// 获取传递的崩溃日志
|
||||||
// 作用:防止应用重启后短时间内再次崩溃,由 CrashHandler 内部实现防护逻辑
|
mCrashLog = getIntent().getStringExtra(CrashHandler.EXTRA_CRASH_LOG);
|
||||||
CrashHandler.AppCrashSafetyWire.getInstance()
|
LogUtils.d(TAG, "获取到崩溃日志,长度:" + (mCrashLog != null ? mCrashLog.length() : 0));
|
||||||
.postResumeCrashSafetyWireHandler(getApplicationContext());
|
|
||||||
|
|
||||||
// 从 Intent 中获取崩溃日志数据(EXTRA_CRASH_INFO 为 CrashHandler 定义的常量键)
|
setContentView(R.layout.activity_globalcrash);
|
||||||
mCrashLog = getIntent().getStringExtra(CrashHandler.EXTRA_CRASH_LOG);
|
mCrashReportView = findViewById(R.id.activityglobalcrashGlobalCrashReportView1);
|
||||||
|
mCrashReportView.setReport(mCrashLog);
|
||||||
|
|
||||||
// 设置当前 Activity 的布局文件(展示崩溃报告的 UI 结构)
|
setActionBar(mCrashReportView.getToolbar());
|
||||||
setContentView(R.layout.activity_globalcrash);
|
if (getActionBar() != null) {
|
||||||
|
getActionBar().setTitle(CrashHandler.TITTLE);
|
||||||
|
getActionBar().setSubtitle(GlobalApplication.getAppName(appContext));
|
||||||
|
}
|
||||||
|
} catch (final Exception e) {
|
||||||
|
LogUtils.e(TAG, "GlobalCrashActivity onCreate 发生异常", e);
|
||||||
|
AppCrashSafetyWire.getInstance().burnSafetyWire();
|
||||||
|
|
||||||
// 初始化崩溃报告展示视图(通过布局 ID 找到自定义 View 实例)
|
mCrashLog = getIntent().getStringExtra(CrashHandler.EXTRA_CRASH_LOG);
|
||||||
mCrashReportView = findViewById(R.id.activityglobalcrashGlobalCrashReportView1);
|
final Intent intent = new Intent();
|
||||||
// 将崩溃日志设置到视图中,由自定义 View 负责排版和显示
|
intent.putExtra(CrashHandler.EXTRA_CRASH_LOG, mCrashLog);
|
||||||
mCrashReportView.setReport(mCrashLog);
|
CrashHandleNotifyUtils.handleUncaughtException(GlobalApplication.getInstance(), intent, CrashHandler.CrashActivity.class);
|
||||||
|
|
||||||
// 设置页面的 ActionBar(复用自定义 View 中的 Toolbar 作为系统 ActionBar)
|
StackTraceElement[] stackElements = Thread.currentThread().getStackTrace();
|
||||||
setActionBar(mCrashReportView.getToolbar());
|
StringBuilder sb = new StringBuilder("GlobalCrashActivity onCreate StackTrace");
|
||||||
|
for (StackTraceElement item : stackElements) {
|
||||||
// 配置 ActionBar 标题和副标题(非空判断避免空指针异常)
|
sb.append("\n").append(item.toString());
|
||||||
if (getActionBar() != null) {
|
}
|
||||||
// 设置标题:使用 CrashHandler 中定义的统一标题(如 "应用崩溃报告")
|
LogUtils.d(TAG, sb.toString());
|
||||||
getActionBar().setTitle(CrashHandler.TITTLE);
|
finish();
|
||||||
// 设置副标题:显示当前应用名称(从全局 Application 工具方法获取)
|
|
||||||
getActionBar().setSubtitle(GlobalApplication.getAppName(getApplicationContext()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 重写返回键点击事件
|
|
||||||
* 逻辑:点击手机返回键时,直接重启应用(而非返回上一页,因崩溃后上一页状态可能异常)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
|
LogUtils.d(TAG, "onBackPressed 触发重启应用");
|
||||||
restartApp();
|
restartApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// ====================== 菜单相关回调 ======================
|
||||||
* 重启当前应用(核心工具方法)
|
@Override
|
||||||
* 实现逻辑:
|
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||||
* 1. 获取应用的启动意图(默认启动 AndroidManifest 中配置的主 Activity)
|
LogUtils.d(TAG, "onCreateOptionsView 初始化菜单");
|
||||||
* 2. 设置意图标志,清除原有任务栈,避免残留异常页面
|
menu.add(0, MENU_ITEM_COPY, 0, "Copy")
|
||||||
* 3. 启动主 Activity 并终止当前进程,确保应用完全重启
|
.setOnMenuItemClickListener(this)
|
||||||
*/
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
private void restartApp() {
|
|
||||||
// 获取 PackageManager 实例(用于获取应用相关信息和意图)
|
|
||||||
PackageManager packageManager = getPackageManager();
|
|
||||||
// 获取应用的启动意图(参数为当前应用包名,返回主 Activity 的意图)
|
|
||||||
Intent launchIntent = packageManager.getLaunchIntentForPackage(getPackageName());
|
|
||||||
|
|
||||||
if (launchIntent != null) {
|
menu.add(0, MENU_ITEM_RESTART, 0, "Restart")
|
||||||
// 设置意图标志:
|
.setOnMenuItemClickListener(this)
|
||||||
// FLAG_ACTIVITY_NEW_TASK:创建新的任务栈启动 Activity
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
// FLAG_ACTIVITY_CLEAR_TOP:清除目标 Activity 之上的所有 Activity
|
|
||||||
// FLAG_ACTIVITY_CLEAR_TASK:清除当前任务栈中的所有 Activity
|
|
||||||
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
|
||||||
| Intent.FLAG_ACTIVITY_CLEAR_TOP
|
|
||||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
||||||
// 启动应用主 Activity
|
|
||||||
startActivity(launchIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 关闭当前崩溃报告页面
|
mCrashReportView.updateMenuStyle();
|
||||||
finish();
|
return true;
|
||||||
// 终止当前应用进程(确保释放所有资源,避免内存泄漏)
|
|
||||||
android.os.Process.killProcess(android.os.Process.myPid());
|
|
||||||
// 强制退出虚拟机(彻底终止应用,防止残留线程继续运行)
|
|
||||||
System.exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单项点击事件回调(实现 MenuItem.OnMenuItemClickListener 接口)
|
|
||||||
* @param item 被点击的菜单项实例
|
|
||||||
* @return boolean:true 表示事件已消费,不再向下传递;false 表示未消费
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(final MenuItem item) {
|
||||||
// 根据菜单项 ID 判断点击的是哪个功能
|
LogUtils.d(TAG, "菜单项被点击,ID:" + item.getItemId());
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case MENU_ITEM_COPY:
|
case MENU_ITEM_COPY:
|
||||||
// 点击「复制」菜单,执行复制崩溃日志到剪贴板
|
|
||||||
copyCrashLogToClipboard();
|
copyCrashLogToClipboard();
|
||||||
break;
|
break;
|
||||||
case MENU_ITEM_RESTART:
|
case MENU_ITEM_RESTART:
|
||||||
// 点击「重启」菜单:先恢复崩溃防护机制到最大等级,再重启应用
|
AppCrashSafetyWire.getInstance().resumeToMaximumImmediately();
|
||||||
CrashHandler.AppCrashSafetyWire.getInstance().resumeToMaximumImmediately();
|
|
||||||
restartApp();
|
restartApp();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ====================== 内部私有工具方法 ======================
|
||||||
/**
|
/**
|
||||||
* 创建页面顶部菜单(ActionBar 菜单)
|
* 重启当前应用
|
||||||
* @param menu 菜单容器,用于添加菜单项
|
|
||||||
* @return boolean:true 表示显示菜单;false 表示不显示
|
|
||||||
*/
|
*/
|
||||||
@Override
|
private void restartApp() {
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
LogUtils.d(TAG, "开始执行应用重启逻辑");
|
||||||
// 添加「复制」菜单项:
|
final PackageManager packageManager = getPackageManager();
|
||||||
// 参数说明:菜单组 ID(0 表示默认组)、菜单项 ID(MENU_ITEM_COPY)、排序号(0)、菜单文本("Copy")
|
final Intent launchIntent = packageManager.getLaunchIntentForPackage(getPackageName());
|
||||||
// setOnMenuItemClickListener(this):绑定点击事件到当前 Activity
|
|
||||||
// setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM):有空间时显示在 ActionBar 上,否则放入溢出菜单
|
|
||||||
menu.add(0, MENU_ITEM_COPY, 0, "Copy")
|
|
||||||
.setOnMenuItemClickListener(this)
|
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
|
|
||||||
// 添加「重启」菜单项(参数含义同上)
|
if (launchIntent != null) {
|
||||||
menu.add(0, MENU_ITEM_RESTART, 0, "Restart")
|
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
.setOnMenuItemClickListener(this)
|
| Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
startActivity(launchIntent);
|
||||||
// 调用自定义视图的方法,更新菜单文字样式(如颜色、字体大小等,由自定义 View 内部实现)
|
}
|
||||||
mCrashReportView.updateMenuStyle();
|
finish();
|
||||||
|
android.os.Process.killProcess(android.os.Process.myPid());
|
||||||
return true;
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将崩溃日志复制到系统剪贴板(工具方法)
|
* 将崩溃日志复制到系统剪贴板
|
||||||
* 功能:用户点击复制菜单后,将完整崩溃日志存入剪贴板,方便粘贴到聊天工具或文档中
|
|
||||||
*/
|
*/
|
||||||
private void copyCrashLogToClipboard() {
|
private void copyCrashLogToClipboard() {
|
||||||
// 获取系统剪贴板服务(需通过 getSystemService 方法获取)
|
LogUtils.d(TAG, "执行复制崩溃日志到剪贴板");
|
||||||
ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
final ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
final ClipData clipData = ClipData.newPlainText(getPackageName(), mCrashLog);
|
||||||
// 创建剪贴板数据:
|
|
||||||
// 参数 1:标签(用于标识剪贴板内容来源,此处用应用包名)
|
|
||||||
// 参数 2:实际复制的文本内容(崩溃日志)
|
|
||||||
ClipData clipData = ClipData.newPlainText(getPackageName(), mCrashLog);
|
|
||||||
|
|
||||||
// 将数据设置到剪贴板(完成复制操作)
|
|
||||||
clipboardManager.setPrimaryClip(clipData);
|
clipboardManager.setPrimaryClip(clipData);
|
||||||
|
|
||||||
// 显示复制成功的 Toast 提示(告知用户操作结果)
|
|
||||||
Toast.makeText(getApplication(), "The text is copied.", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplication(), "The text is copied.", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toolbar;
|
import android.widget.Toolbar;
|
||||||
import cc.winboll.studio.libappbase.R;
|
import cc.winboll.studio.libappbase.R;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||||
@@ -175,10 +176,11 @@ public class GlobalCrashReportView extends LinearLayout {
|
|||||||
* 初始化默认配置(无自定义属性时使用)
|
* 初始化默认配置(无自定义属性时使用)
|
||||||
*/
|
*/
|
||||||
private void initDefaultConfig() {
|
private void initDefaultConfig() {
|
||||||
// 设置默认配色
|
// 设置默认配色(使用 debugTextColor 属性)
|
||||||
mTitleColor = Color.WHITE;
|
Resources.Theme theme = mContext.getTheme();
|
||||||
mTitleBackgroundColor = Color.BLACK;
|
mTitleColor = theme.getResources().getColor(android.R.color.holo_green_dark);
|
||||||
mTextColor = Color.BLACK;
|
mTitleBackgroundColor = Color.GRAY;
|
||||||
|
mTextColor = obtainDebugTextColor(theme);
|
||||||
mTextBackgroundColor = Color.WHITE;
|
mTextBackgroundColor = Color.WHITE;
|
||||||
// 加载布局
|
// 加载布局
|
||||||
inflateView();
|
inflateView();
|
||||||
@@ -186,6 +188,21 @@ public class GlobalCrashReportView extends LinearLayout {
|
|||||||
initWidgetStyle();
|
initWidgetStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int obtainDebugTextColor(Resources.Theme theme) {
|
||||||
|
int[] attrs = new int[] { cc.winboll.studio.libappbase.R.attr.themeDebug };
|
||||||
|
TypedArray themeTypedArray = theme.obtainStyledAttributes(attrs);
|
||||||
|
int themeResId = themeTypedArray.getResourceId(0, 0);
|
||||||
|
themeTypedArray.recycle();
|
||||||
|
if (themeResId != 0) {
|
||||||
|
int[] debugAttrs = new int[] { cc.winboll.studio.libappbase.R.attr.debugTextColor };
|
||||||
|
TypedArray debugTypedArray = theme.obtainStyledAttributes(themeResId, debugAttrs);
|
||||||
|
int color = debugTypedArray.getColor(0, Color.GRAY);
|
||||||
|
debugTypedArray.recycle();
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
return Color.GRAY;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化视图(解析自定义属性 + 加载布局 + 设置样式)
|
* 初始化视图(解析自定义属性 + 加载布局 + 设置样式)
|
||||||
* @param attrs 自定义属性集合
|
* @param attrs 自定义属性集合
|
||||||
@@ -195,23 +212,20 @@ public class GlobalCrashReportView extends LinearLayout {
|
|||||||
TypedArray typedArray = mContext.obtainStyledAttributes(
|
TypedArray typedArray = mContext.obtainStyledAttributes(
|
||||||
attrs,
|
attrs,
|
||||||
R.styleable.GlobalCrashActivity,
|
R.styleable.GlobalCrashActivity,
|
||||||
R.attr.themeGlobalCrashActivity,
|
R.attr.themeDebug,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
// 读取自定义属性值(无设置时使用默认值)
|
// 读取自定义属性值(无设置时使用默认值)
|
||||||
mTitleColor = typedArray.getColor(
|
mTitleColor = typedArray.getColor(
|
||||||
R.styleable.GlobalCrashActivity_colorTittle,
|
R.styleable.GlobalCrashActivity_colorTittle,
|
||||||
Color.WHITE
|
Color.BLACK
|
||||||
);
|
);
|
||||||
mTitleBackgroundColor = typedArray.getColor(
|
mTitleBackgroundColor = typedArray.getColor(
|
||||||
R.styleable.GlobalCrashActivity_colorTittleBackgound, // 注:原拼写错误(Backgound→Background),保持与 attrs.xml 一致
|
R.styleable.GlobalCrashActivity_colorTittleBackgound, // 注:原拼写错误(Backgound→Background),保持与 attrs.xml 一致
|
||||||
Color.BLACK
|
Color.BLACK
|
||||||
);
|
);
|
||||||
mTextColor = typedArray.getColor(
|
mTextColor = obtainDebugTextColor(mContext.getTheme());
|
||||||
R.styleable.GlobalCrashActivity_colorText,
|
|
||||||
Color.BLACK
|
|
||||||
);
|
|
||||||
mTextBackgroundColor = typedArray.getColor(
|
mTextBackgroundColor = typedArray.getColor(
|
||||||
R.styleable.GlobalCrashActivity_colorTextBackgound, // 注:原拼写错误,保持与 attrs.xml 一致
|
R.styleable.GlobalCrashActivity_colorTextBackgound, // 注:原拼写错误,保持与 attrs.xml 一致
|
||||||
Color.WHITE
|
Color.WHITE
|
||||||
@@ -241,12 +255,8 @@ public class GlobalCrashReportView extends LinearLayout {
|
|||||||
* 初始化控件样式(设置配色和基础属性)
|
* 初始化控件样式(设置配色和基础属性)
|
||||||
*/
|
*/
|
||||||
private void initWidgetStyle() {
|
private void initWidgetStyle() {
|
||||||
// 设置主布局背景颜色
|
|
||||||
setBackgroundColor(mTextBackgroundColor);
|
|
||||||
|
|
||||||
// 配置工具栏样式
|
// 配置工具栏样式
|
||||||
if (mToolbar != null) {
|
if (mToolbar != null) {
|
||||||
mToolbar.setBackgroundColor(mTitleBackgroundColor);
|
|
||||||
mToolbar.setTitleTextColor(mTitleColor);
|
mToolbar.setTitleTextColor(mTitleColor);
|
||||||
mToolbar.setSubtitleTextColor(mTitleColor);
|
mToolbar.setSubtitleTextColor(mTitleColor);
|
||||||
}
|
}
|
||||||
@@ -254,8 +264,6 @@ public class GlobalCrashReportView extends LinearLayout {
|
|||||||
// 配置日志文本控件样式
|
// 配置日志文本控件样式
|
||||||
if (mTvReport != null) {
|
if (mTvReport != null) {
|
||||||
mTvReport.setTextColor(mTextColor);
|
mTvReport.setTextColor(mTextColor);
|
||||||
mTvReport.setBackgroundColor(mTextBackgroundColor);
|
|
||||||
// 可选:设置日志文本换行方式(默认已换行,此处增强可读性)
|
|
||||||
mTvReport.setSingleLine(false);
|
mTvReport.setSingleLine(false);
|
||||||
mTvReport.setHorizontallyScrolling(false);
|
mTvReport.setHorizontallyScrolling(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,11 +62,11 @@ public class BackupUtils {
|
|||||||
|
|
||||||
// 核心修改:入参Map非空且非空集合时,使用入参初始化;否则内部new HashMap()
|
// 核心修改:入参Map非空且非空集合时,使用入参初始化;否则内部new HashMap()
|
||||||
this.mDataDirFileMap = (dataDirFileMap != null && !dataDirFileMap.isEmpty())
|
this.mDataDirFileMap = (dataDirFileMap != null && !dataDirFileMap.isEmpty())
|
||||||
? new HashMap<>(dataDirFileMap) // 新建Map避免外部篡改内部数据
|
? new HashMap<String, String>(dataDirFileMap)
|
||||||
: new HashMap<>();
|
: new HashMap<String, String>();
|
||||||
this.mSdcardFileMap = (sdcardFileMap != null && !sdcardFileMap.isEmpty())
|
this.mSdcardFileMap = (sdcardFileMap != null && !sdcardFileMap.isEmpty())
|
||||||
? new HashMap<>(sdcardFileMap) // 深拷贝,隔离外部引用
|
? new HashMap<String, String>(sdcardFileMap)
|
||||||
: new HashMap<>();
|
: new HashMap<String, String>();
|
||||||
|
|
||||||
LogUtils.d(TAG, "BackupUtils初始化完成 → SFTP服务器:" + ftpAuthModel.getFtpServer() + ":" + ftpAuthModel.getFtpPort() + " | 上传目录:" + mFtpTargetDir);
|
LogUtils.d(TAG, "BackupUtils初始化完成 → SFTP服务器:" + ftpAuthModel.getFtpServer() + ":" + ftpAuthModel.getFtpPort() + " | 上传目录:" + mFtpTargetDir);
|
||||||
LogUtils.d(TAG, "SDCard Map基础根目录:" + (mAppExternalFilesDir == null ? "获取失败" : mAppExternalFilesDir.getAbsolutePath()));
|
LogUtils.d(TAG, "SDCard Map基础根目录:" + (mAppExternalFilesDir == null ? "获取失败" : mAppExternalFilesDir.getAbsolutePath()));
|
||||||
|
|||||||
@@ -10,24 +10,20 @@ import android.os.Build;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import cc.winboll.studio.libappbase.CrashHandler;
|
import cc.winboll.studio.libappbase.CrashHandler;
|
||||||
import cc.winboll.studio.libappbase.GlobalCrashActivity;
|
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
* 应用崩溃处理通知实用工具集(类库兼容版)
|
||||||
* @Date 2025/11/29 21:12
|
|
||||||
* @Describe 应用崩溃处理通知实用工具集(类库兼容版)
|
|
||||||
* 核心功能:作为独立类库使用,发送崩溃通知,点击跳转宿主应用的 GlobalCrashActivity 并传递日志
|
* 核心功能:作为独立类库使用,发送崩溃通知,点击跳转宿主应用的 GlobalCrashActivity 并传递日志
|
||||||
* 适配说明:移除固定包名依赖,通过外部传入宿主包名,支持任意应用集成使用
|
* 适配说明:移除固定包名依赖,通过外部传入宿主包名,支持任意应用集成使用
|
||||||
|
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
|
||||||
|
* @CreateTime 2025/11/29 21:12:00
|
||||||
|
* @EditTime 2026/05/11 15:38:21
|
||||||
*/
|
*/
|
||||||
public class CrashHandleNotifyUtils {
|
public class CrashHandleNotifyUtils {
|
||||||
|
|
||||||
|
// ====================== 常量定义 ======================
|
||||||
public static final String TAG = "CrashHandleNotifyUtils";
|
public static final String TAG = "CrashHandleNotifyUtils";
|
||||||
|
|
||||||
/** 通知渠道ID(Android 8.0+ 必须) */
|
/** 通知渠道ID(Android 8.0+ 必须) */
|
||||||
private static final String CRASH_NOTIFY_CHANNEL_ID = "crash_notify_channel";
|
private static final String CRASH_NOTIFY_CHANNEL_ID = "crash_notify_channel";
|
||||||
/** 通知渠道名称(用户可见) */
|
/** 通知渠道名称(用户可见) */
|
||||||
@@ -38,202 +34,186 @@ public class CrashHandleNotifyUtils {
|
|||||||
private static final int API_LEVEL_ANDROID_12 = 31;
|
private static final int API_LEVEL_ANDROID_12 = 31;
|
||||||
/** PendingIntent.FLAG_IMMUTABLE 常量值(API 31+) */
|
/** PendingIntent.FLAG_IMMUTABLE 常量值(API 31+) */
|
||||||
private static final int FLAG_IMMUTABLE = 0x00000040;
|
private static final int FLAG_IMMUTABLE = 0x00000040;
|
||||||
|
|
||||||
/** 通知内容最大行数(控制在3行,超出部分省略) */
|
/** 通知内容最大行数(控制在3行,超出部分省略) */
|
||||||
private static final int NOTIFICATION_MAX_LINES = 3;
|
private static final int NOTIFICATION_MAX_LINES = 3;
|
||||||
|
|
||||||
|
// ====================== 对外核心方法 ======================
|
||||||
/**
|
/**
|
||||||
* 处理未捕获异常(核心方法,类库入口)
|
* 处理未捕获异常(类库入口核心方法)
|
||||||
* 改进点:新增宿主包名参数,移除类库对固定包名的依赖
|
* @param hostApp 宿主Application实例
|
||||||
* @param hostApp 宿主应用的 Application 实例(用于获取宿主上下文)
|
* @param hostPackageName 宿主应用包名
|
||||||
* @param hostPackageName 宿主应用的包名(关键:用于绑定意图、匹配 Activity)
|
* @param errorLog 崩溃日志内容
|
||||||
* @param errorLog 崩溃日志(从宿主 CrashHandler 传递过来)
|
* @param reportCrashActivity 崩溃详情跳转Activity类
|
||||||
*/
|
*/
|
||||||
public static void handleUncaughtException(Application hostApp, String hostPackageName, String errorLog) {
|
public static void handleUncaughtException(final Application hostApp,
|
||||||
// 1. 校验核心参数(类库场景必须严格校验,避免空指针)
|
final String hostPackageName,
|
||||||
|
final String errorLog,
|
||||||
|
final Class<?> reportCrashActivity) {
|
||||||
|
LogUtils.d(TAG, "handleUncaughtException 进入方法");
|
||||||
|
// 校验入参
|
||||||
if (hostApp == null || TextUtils.isEmpty(hostPackageName) || TextUtils.isEmpty(errorLog)) {
|
if (hostApp == null || TextUtils.isEmpty(hostPackageName) || TextUtils.isEmpty(errorLog)) {
|
||||||
LogUtils.e(TAG, "发送崩溃通知失败:参数为空(hostApp=" + hostApp + ", hostPackageName=" + hostPackageName + ", errorLog=" + errorLog + ")");
|
LogUtils.e(TAG, "handleUncaughtException 参数为空校验不通过");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final String hostAppName = getHostAppName(hostApp, hostPackageName);
|
||||||
// 2. 获取宿主应用名称(使用宿主上下文,避免类库包名混淆)
|
sendCrashNotification(hostApp, hostPackageName, hostAppName, errorLog, reportCrashActivity);
|
||||||
String hostAppName = getHostAppName(hostApp, hostPackageName);
|
|
||||||
|
|
||||||
// 3. 发送崩溃通知到宿主通知栏(点击跳转宿主的 GlobalCrashActivity)
|
|
||||||
sendCrashNotification(hostApp, hostPackageName, hostAppName, errorLog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重载方法:兼容原有调用逻辑(避免宿主集成时改动过大)
|
* 重载兼容方法:适配原有CrashHandler调用方式
|
||||||
* 从 Intent 中提取崩溃日志和宿主包名,适配原有 CrashHandler 调用方式
|
* @param hostApp 宿主Application实例
|
||||||
* @param hostApp 宿主应用的 Application 实例
|
* @param intent 携带崩溃信息Intent
|
||||||
* @param intent 存储崩溃信息的意图(extra 中携带崩溃日志)
|
* @param reportCrashActivity 崩溃详情Activity
|
||||||
*/
|
*/
|
||||||
public static void handleUncaughtException(Application hostApp, Intent intent) {
|
public static void handleUncaughtException(final Application hostApp,
|
||||||
// 从意图中提取宿主包名(优先使用意图中携带的包名,无则用宿主 Application 包名)
|
final Intent intent,
|
||||||
|
final Class<?> reportCrashActivity) {
|
||||||
|
LogUtils.d(TAG, "handleUncaughtException 重载方法进入");
|
||||||
String hostPackageName = intent.getStringExtra("EXTRA_HOST_PACKAGE_NAME");
|
String hostPackageName = intent.getStringExtra("EXTRA_HOST_PACKAGE_NAME");
|
||||||
if (TextUtils.isEmpty(hostPackageName)) {
|
if (TextUtils.isEmpty(hostPackageName)) {
|
||||||
hostPackageName = hostApp.getPackageName();
|
hostPackageName = hostApp.getPackageName();
|
||||||
LogUtils.w(TAG, "意图中未携带宿主包名,使用 Application 包名:" + hostPackageName);
|
LogUtils.w(TAG, "未携带宿主包名,默认使用应用自身包名");
|
||||||
}
|
}
|
||||||
|
final String errorLog = intent.getStringExtra(CrashHandler.EXTRA_CRASH_LOG);
|
||||||
// 从意图中提取崩溃日志(与 CrashHandler.EXTRA_CRASH_INFO 保持一致)
|
handleUncaughtException(hostApp, hostPackageName, errorLog, reportCrashActivity);
|
||||||
String errorLog = intent.getStringExtra(CrashHandler.EXTRA_CRASH_LOG);
|
|
||||||
|
|
||||||
// 调用核心方法处理
|
|
||||||
handleUncaughtException(hostApp, hostPackageName, errorLog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ====================== 内部工具方法 ======================
|
||||||
/**
|
/**
|
||||||
* 获取宿主应用名称(类库场景适配:使用宿主包名获取,避免类库包名干扰)
|
* 获取宿主应用名称
|
||||||
* @param hostContext 宿主应用的上下文(Application 实例)
|
* @param hostContext 宿主上下文
|
||||||
* @param hostPackageName 宿主应用的包名
|
* @param hostPackageName 宿主包名
|
||||||
* @return 宿主应用名称(读取失败返回 "未知应用")
|
* @return 应用名称,失败返回未知应用
|
||||||
*/
|
*/
|
||||||
private static String getHostAppName(Context hostContext, String hostPackageName) {
|
private static String getHostAppName(final Context hostContext, final String hostPackageName) {
|
||||||
try {
|
try {
|
||||||
// 用宿主包名获取宿主应用信息,确保获取的是宿主的应用名称(类库关键改进)
|
return hostContext.getPackageManager()
|
||||||
return hostContext.getPackageManager().getApplicationLabel(
|
.getApplicationLabel(hostContext.getPackageManager()
|
||||||
hostContext.getPackageManager().getApplicationInfo(hostPackageName, 0)
|
.getApplicationInfo(hostPackageName, 0)).toString();
|
||||||
).toString();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtils.e(TAG, "获取宿主应用名称失败(包名:" + hostPackageName + ")", e);
|
LogUtils.e(TAG, "获取宿主应用名称失败", e);
|
||||||
return "未知应用";
|
return "未知应用";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送崩溃通知到宿主系统通知栏(类库兼容版)
|
* 发送崩溃系统通知
|
||||||
* 改进点:全程使用宿主上下文和宿主包名,避免类库包名依赖
|
* @param hostContext 宿主上下文
|
||||||
* @param hostContext 宿主应用的上下文(Application 实例)
|
* @param hostPackageName 宿主包名
|
||||||
* @param hostPackageName 宿主应用的包名
|
* @param hostAppName 宿主应用名
|
||||||
* @param hostAppName 宿主应用的名称(用于通知标题)
|
* @param errorLog 崩溃日志
|
||||||
* @param errorLog 崩溃日志(传递给宿主的 GlobalCrashActivity)
|
* @param reportCrashActivity 跳转Activity
|
||||||
*/
|
*/
|
||||||
private static void sendCrashNotification(Context hostContext, String hostPackageName, String hostAppName, String errorLog) {
|
private static void sendCrashNotification(final Context hostContext,
|
||||||
// 1. 获取宿主的通知管理器(使用宿主上下文,确保通知归属宿主应用)
|
final String hostPackageName,
|
||||||
NotificationManager notificationManager = (NotificationManager) hostContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
final String hostAppName,
|
||||||
|
final String errorLog,
|
||||||
|
final Class<?> reportCrashActivity) {
|
||||||
|
final NotificationManager notificationManager =
|
||||||
|
(NotificationManager) hostContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
if (notificationManager == null) {
|
if (notificationManager == null) {
|
||||||
LogUtils.e(TAG, "获取宿主 NotificationManager 失败(包名:" + hostPackageName + ")");
|
LogUtils.e(TAG, "获取NotificationManager失败");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 8.0以上创建通知渠道
|
||||||
// 2. 适配 Android 8.0+(API 26+):创建宿主的通知渠道(归属宿主,避免类库渠道冲突)
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
createCrashNotifyChannel(hostContext, notificationManager);
|
createCrashNotifyChannel(hostContext, notificationManager);
|
||||||
}
|
}
|
||||||
|
final PendingIntent jumpIntent = getGlobalCrashPendingIntent(hostContext,
|
||||||
// 3. 构建通知意图(核心改进:绑定宿主包名,跳转宿主的 GlobalCrashActivity)
|
hostPackageName, errorLog, reportCrashActivity);
|
||||||
PendingIntent jumpIntent = getGlobalCrashPendingIntent(hostContext, hostPackageName, errorLog);
|
|
||||||
if (jumpIntent == null) {
|
if (jumpIntent == null) {
|
||||||
LogUtils.e(TAG, "构建跳转意图失败(宿主包名:" + hostPackageName + ")");
|
LogUtils.e(TAG, "构建跳转PendingIntent失败");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final Notification notification = buildNotification(hostContext, hostAppName, errorLog, jumpIntent);
|
||||||
// 4. 构建通知实例(使用宿主上下文,确保通知资源归属宿主)
|
|
||||||
Notification notification = buildNotification(hostContext, hostAppName, errorLog, jumpIntent);
|
|
||||||
|
|
||||||
// 5. 发送通知(归属宿主应用,避免类库与宿主通知混淆)
|
|
||||||
notificationManager.notify(CRASH_NOTIFY_ID, notification);
|
notificationManager.notify(CRASH_NOTIFY_ID, notification);
|
||||||
LogUtils.d(TAG, "崩溃通知发送成功(宿主包名:" + hostPackageName + ",标题:" + hostAppName + ",日志长度:" + errorLog.length() + "字符)");
|
LogUtils.d(TAG, "崩溃通知发送成功,宿主包名:" + hostPackageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建宿主应用的崩溃通知渠道(类库场景:渠道归属宿主,避免类库与宿主渠道冲突)
|
* 创建通知渠道(适配Android O及以上)
|
||||||
* @param hostContext 宿主应用的上下文
|
* @param hostContext 宿主上下文
|
||||||
* @param notificationManager 宿主的通知管理器
|
* @param notificationManager 通知管理器
|
||||||
*/
|
*/
|
||||||
private static void createCrashNotifyChannel(Context hostContext, NotificationManager notificationManager) {
|
private static void createCrashNotifyChannel(final Context hostContext,
|
||||||
// 仅 Android 8.0+ 执行(避免低版本报错)
|
final NotificationManager notificationManager) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
// 构建通知渠道(归属宿主应用,描述明确类库用途)
|
|
||||||
android.app.NotificationChannel channel = new android.app.NotificationChannel(
|
android.app.NotificationChannel channel = new android.app.NotificationChannel(
|
||||||
CRASH_NOTIFY_CHANNEL_ID,
|
CRASH_NOTIFY_CHANNEL_ID,
|
||||||
CRASH_NOTIFY_CHANNEL_NAME,
|
CRASH_NOTIFY_CHANNEL_NAME,
|
||||||
NotificationManager.IMPORTANCE_DEFAULT
|
NotificationManager.IMPORTANCE_DEFAULT
|
||||||
);
|
);
|
||||||
channel.setDescription("应用崩溃通知(由 WinBoLL Studio 类库提供,点击查看详情)");
|
channel.setDescription("应用崩溃通知(由 WinBoLL Studio 类库提供,点击查看详情)");
|
||||||
// 注册渠道到宿主的通知管理器,确保渠道归属宿主
|
|
||||||
notificationManager.createNotificationChannel(channel);
|
notificationManager.createNotificationChannel(channel);
|
||||||
LogUtils.d(TAG, "宿主崩溃通知渠道创建成功(宿主包名:" + hostContext.getPackageName() + ",渠道ID:" + CRASH_NOTIFY_CHANNEL_ID + ")");
|
LogUtils.d(TAG, "通知渠道创建完成");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 核心改进:构建跳转宿主 GlobalCrashActivity 的意图(类库关键)
|
* 构建跳转崩溃详情页PendingIntent
|
||||||
* 1. 绑定宿主包名,确保类库能正确启动宿主的 Activity;
|
* @param hostContext 宿主上下文
|
||||||
* 2. 传递崩溃日志,与宿主 GlobalCrashActivity 日志接收逻辑匹配;
|
* @param hostPackageName 宿主包名
|
||||||
* 3. 使用宿主上下文,避免类库上下文导致的适配问题。
|
* @param errorLog 崩溃日志
|
||||||
* @param hostContext 宿主应用的上下文
|
* @param reportCrashActivity 目标Activity
|
||||||
* @param hostPackageName 宿主应用的包名
|
* @return PendingIntent实例
|
||||||
* @param errorLog 崩溃日志(传递给宿主的 GlobalCrashActivity)
|
|
||||||
* @return 跳转崩溃详情页的 PendingIntent
|
|
||||||
*/
|
*/
|
||||||
private static PendingIntent getGlobalCrashPendingIntent(Context hostContext, String hostPackageName, String errorLog) {
|
private static PendingIntent getGlobalCrashPendingIntent(final Context hostContext,
|
||||||
|
final String hostPackageName,
|
||||||
|
final String errorLog,
|
||||||
|
final Class<?> reportCrashActivity) {
|
||||||
try {
|
try {
|
||||||
// 1. 构建跳转宿主 GlobalCrashActivity 的显式意图(类库场景必须显式指定宿主包名)
|
final Intent crashIntent = new Intent(hostContext, reportCrashActivity);
|
||||||
Intent crashIntent = new Intent(hostContext, GlobalCrashActivity.class);
|
|
||||||
// 关键:绑定宿主包名,确保意图能正确匹配宿主的 Activity(避免类库包名干扰)
|
|
||||||
crashIntent.setPackage(hostPackageName);
|
crashIntent.setPackage(hostPackageName);
|
||||||
// 传递崩溃日志(键:EXTRA_CRASH_INFO,与宿主 GlobalCrashActivity 完全匹配)
|
|
||||||
crashIntent.putExtra(CrashHandler.EXTRA_CRASH_LOG, errorLog);
|
crashIntent.putExtra(CrashHandler.EXTRA_CRASH_LOG, errorLog);
|
||||||
// 设置意图标志:确保在宿主应用中正常启动,避免重复创建和任务栈混乱
|
|
||||||
crashIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
crashIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
|
||||||
// 2. 构建 PendingIntent(使用宿主上下文,适配高版本)
|
|
||||||
int flags = PendingIntent.FLAG_UPDATE_CURRENT;
|
int flags = PendingIntent.FLAG_UPDATE_CURRENT;
|
||||||
if (Build.VERSION.SDK_INT >= API_LEVEL_ANDROID_12) {
|
if (Build.VERSION.SDK_INT >= API_LEVEL_ANDROID_12) {
|
||||||
flags |= FLAG_IMMUTABLE;
|
flags |= FLAG_IMMUTABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PendingIntent.getActivity(
|
return PendingIntent.getActivity(
|
||||||
hostContext,
|
hostContext,
|
||||||
CRASH_NOTIFY_ID, // 用通知ID作为请求码,确保唯一(避免意图复用)
|
CRASH_NOTIFY_ID,
|
||||||
crashIntent,
|
crashIntent,
|
||||||
flags
|
flags
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtils.e(TAG, "构建跳转意图失败(宿主包名:" + hostPackageName + ")", e);
|
LogUtils.e(TAG, "构建跳转Intent异常", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建通知实例(类库兼容版)
|
* 构建Notification通知实例
|
||||||
* 改进点:使用宿主上下文加载资源,确保通知样式适配宿主应用
|
* @param hostContext 宿主上下文
|
||||||
* @param hostContext 宿主应用的上下文
|
* @param hostAppName 宿主应用名
|
||||||
* @param hostAppName 宿主应用的名称(通知标题)
|
* @param errorLog 崩溃日志
|
||||||
* @param errorLog 崩溃日志(通知内容)
|
* @param jumpIntent 点击跳转意图
|
||||||
* @param jumpIntent 通知点击跳转意图(跳转宿主的 GlobalCrashActivity)
|
* @return 构建好的Notification
|
||||||
* @return 构建完成的 Notification 对象
|
|
||||||
*/
|
*/
|
||||||
private static Notification buildNotification(Context hostContext, String hostAppName, String errorLog, PendingIntent jumpIntent) {
|
@SuppressWarnings("deprecation")
|
||||||
// 兼容 Android 8.0+:指定宿主的通知渠道ID
|
private static Notification buildNotification(final Context hostContext,
|
||||||
|
final String hostAppName,
|
||||||
|
final String errorLog,
|
||||||
|
final PendingIntent jumpIntent) {
|
||||||
Notification.Builder builder = new Notification.Builder(hostContext);
|
Notification.Builder builder = new Notification.Builder(hostContext);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
builder.setChannelId(CRASH_NOTIFY_CHANNEL_ID);
|
builder.setChannelId(CRASH_NOTIFY_CHANNEL_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 核心:用BigTextStyle控制“默认3行省略,下拉显示完整”(使用宿主上下文构建)
|
|
||||||
Notification.BigTextStyle bigTextStyle = new Notification.BigTextStyle();
|
Notification.BigTextStyle bigTextStyle = new Notification.BigTextStyle();
|
||||||
bigTextStyle.setSummaryText("日志已省略,下拉查看完整内容");
|
bigTextStyle.setSummaryText("日志已省略,下拉查看完整内容");
|
||||||
bigTextStyle.bigText(errorLog);
|
bigTextStyle.bigText(errorLog);
|
||||||
bigTextStyle.setBigContentTitle(hostAppName + " 崩溃"); // 标题明确标识宿主和崩溃状态
|
bigTextStyle.setBigContentTitle(hostAppName + " 崩溃");
|
||||||
builder.setStyle(bigTextStyle);
|
builder.setStyle(bigTextStyle);
|
||||||
|
|
||||||
// 配置通知核心参数(全程使用宿主上下文,确保资源归属宿主)
|
builder.setSmallIcon(hostContext.getApplicationInfo().icon)
|
||||||
builder
|
.setContentTitle(hostAppName + " 崩溃")
|
||||||
// 关键:使用宿主应用的小图标(避免类库图标显示异常)
|
.setContentText(getShortContent(errorLog))
|
||||||
.setSmallIcon(hostContext.getApplicationInfo().icon)
|
.setContentIntent(jumpIntent)
|
||||||
.setContentTitle(hostAppName + " 崩溃")
|
.setAutoCancel(true)
|
||||||
.setContentText(getShortContent(errorLog)) // 3行内缩略文本
|
.setWhen(System.currentTimeMillis())
|
||||||
.setContentIntent(jumpIntent) // 点击跳转宿主的 GlobalCrashActivity
|
.setPriority(Notification.PRIORITY_DEFAULT);
|
||||||
.setAutoCancel(true) // 点击后自动关闭
|
|
||||||
.setWhen(System.currentTimeMillis())
|
|
||||||
.setPriority(Notification.PRIORITY_DEFAULT);
|
|
||||||
|
|
||||||
// 适配 Android 4.1+:确保在宿主应用中正常显示
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
return builder.build();
|
return builder.build();
|
||||||
} else {
|
} else {
|
||||||
@@ -242,23 +222,24 @@ public class CrashHandleNotifyUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 辅助方法:截取日志文本,确保显示在3行内(通用逻辑,无包名依赖)
|
* 截取缩略日志文本
|
||||||
* @param content 完整崩溃日志
|
* @param content 原始日志
|
||||||
* @return 3行内的缩略文本
|
* @return 缩略文案
|
||||||
*/
|
*/
|
||||||
private static String getShortContent(String content) {
|
private static String getShortContent(final String content) {
|
||||||
if (content == null || content.isEmpty()) {
|
if (content == null || content.isEmpty()) {
|
||||||
return "无崩溃日志";
|
return "无崩溃日志";
|
||||||
}
|
}
|
||||||
int maxLength = 80; // 估算3行字符数(可根据需求调整)
|
final int maxLength = 80;
|
||||||
return content.length() <= maxLength ? content : content.substring(0, maxLength) + "...";
|
return content.length() <= maxLength ? content : content.substring(0, maxLength) + "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 释放资源(类库场景:空实现,避免宿主调用时报错,预留扩展)
|
* 资源释放预留方法
|
||||||
* @param hostContext 宿主应用的上下文(显式传入,避免类库上下文依赖)
|
* @param hostContext 宿主上下文
|
||||||
*/
|
*/
|
||||||
public static void release(Context hostContext) {
|
public static void release(final Context hostContext) {
|
||||||
LogUtils.d(TAG, "CrashHandleNotifyUtils 资源释放完成(宿主包名:" + (hostContext != null ? hostContext.getPackageName() : "未知") + ")");
|
LogUtils.d(TAG, "CrashHandleNotifyUtils 执行资源释放");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -421,9 +421,10 @@ public class AboutView extends LinearLayout {
|
|||||||
*/
|
*/
|
||||||
private android.graphics.drawable.Drawable create_item_background() {
|
private android.graphics.drawable.Drawable create_item_background() {
|
||||||
android.graphics.drawable.GradientDrawable drawable = new android.graphics.drawable.GradientDrawable();
|
android.graphics.drawable.GradientDrawable drawable = new android.graphics.drawable.GradientDrawable();
|
||||||
drawable.setStroke(1, mItemContext.getResources().getColor(R.color.gray_200));
|
drawable.setStroke(1, mItemContext.getResources().getColor(R.color.gray_300));
|
||||||
drawable.setCornerRadius(4);
|
drawable.setCornerRadius(4);
|
||||||
drawable.setColor(mItemContext.getResources().getColor(android.R.color.white));
|
boolean isNightMode = (mItemContext.getResources().getConfiguration().uiMode & android.content.res.Configuration.UI_MODE_NIGHT_MASK) == android.content.res.Configuration.UI_MODE_NIGHT_YES;
|
||||||
|
drawable.setColor(isNightMode ? mItemContext.getResources().getColor(R.color.gray_800) : mItemContext.getResources().getColor(android.R.color.white));
|
||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +450,8 @@ public class AboutView extends LinearLayout {
|
|||||||
TextView tvTitle = new TextView(mItemContext);
|
TextView tvTitle = new TextView(mItemContext);
|
||||||
tvTitle.setText(mTitle);
|
tvTitle.setText(mTitle);
|
||||||
tvTitle.setTextSize(16);
|
tvTitle.setTextSize(16);
|
||||||
tvTitle.setTextColor(mItemContext.getResources().getColor(R.color.gray_900));
|
boolean isNightMode = (mItemContext.getResources().getConfiguration().uiMode & android.content.res.Configuration.UI_MODE_NIGHT_MASK) == android.content.res.Configuration.UI_MODE_NIGHT_YES;
|
||||||
|
tvTitle.setTextColor(isNightMode ? mItemContext.getResources().getColor(R.color.gray_500) : mItemContext.getResources().getColor(R.color.gray_900));
|
||||||
llText.addView(tvTitle);
|
llText.addView(tvTitle);
|
||||||
// 内容
|
// 内容
|
||||||
TextView tvContent = new TextView(mItemContext);
|
TextView tvContent = new TextView(mItemContext);
|
||||||
|
|||||||
22
libappbase/src/main/res/layout-night/activity_about.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
|
<android.widget.Toolbar
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/toolbarBackgroundColor"
|
||||||
|
android:id="@+id/toolbar"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1.0"
|
||||||
|
android:id="@+id/aboutviewroot_ll"/>
|
||||||
|
</LinearLayout>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/activityBackgroundColor">>
|
||||||
|
|
||||||
|
<cc.winboll.studio.libappbase.GlobalCrashReportView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/activityglobalcrashGlobalCrashReportView1"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
15
libappbase/src/main/res/layout-night/activity_log.xml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?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:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
|
<cc.winboll.studio.libappbase.LogView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/logview"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="24dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
|
<!-- NFC状态提示文本 -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_nfc_state"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="正在监听NFC卡片,请贴近设备检测密钥..."
|
||||||
|
android:textSize="17sp"
|
||||||
|
android:textColor="?attr/activityTextColor"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="12dp"
|
||||||
|
android:layout_marginBottom="30dp"/>
|
||||||
|
|
||||||
|
<!-- 私钥显示区域 -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_private_key"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="私钥内容:无"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="?attr/activityTextColor"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:maxLines="5"
|
||||||
|
android:ellipsize="end"/>
|
||||||
|
|
||||||
|
<!-- 公钥显示区域 -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_public_key"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="公钥内容:无"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="?attr/activityTextColor"
|
||||||
|
android:layout_marginBottom="40dp"
|
||||||
|
android:maxLines="5"
|
||||||
|
android:ellipsize="end"/>
|
||||||
|
|
||||||
|
<!-- 核心功能按钮(复用:保存本地/初始化密钥) -->
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_create_write_key"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="功能按钮待激活"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="?attr/buttonTextColor"
|
||||||
|
android:backgroundTint="?attr/buttonBackgroundColor"
|
||||||
|
android:padding="14dp"
|
||||||
|
android:enabled="false"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
52
libappbase/src/main/res/layout-night/dialog_sign_get.xml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:background="?attr/dialogBackgroundColor">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="应用指纹校验"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="?attr/dialogTextColor"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_marginBottom="12dp"/>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/et_sign_fingerprint"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@android:drawable/edit_text"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:gravity="top"
|
||||||
|
android:hint="签名获取中..."
|
||||||
|
android:singleLine="false"
|
||||||
|
android:scrollHorizontally="false"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:overScrollMode="always"
|
||||||
|
android:typeface="monospace"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingRight="10dp"/>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_auth_result"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:textSize="11sp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="?attr/dialogTextColor"/>/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
62
libappbase/src/main/res/layout-night/dialog_winboll_host.xml
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:background="?attr/dialogBackgroundColor">
|
||||||
|
|
||||||
|
<!-- 标题 -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="设置服务器地址"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="?attr/dialogTextColor"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_marginBottom="16dp"/>
|
||||||
|
|
||||||
|
<!-- 地址输入框 -->
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/et_host_input"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="请输入服务器地址(如http://localhost:8080)"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="?attr/dialogTextColor"
|
||||||
|
android:inputType="textUri"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:background="@android:drawable/edit_text"
|
||||||
|
android:layout_marginBottom="16dp"/>
|
||||||
|
|
||||||
|
<!-- 按钮容器 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="end">
|
||||||
|
|
||||||
|
<!-- 取消按钮 -->
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_cancel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="取消"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="?attr/dialogTextColor"
|
||||||
|
android:layout_marginRight="8dp"/>
|
||||||
|
|
||||||
|
<!-- 确认按钮 -->
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_confirm"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="确认"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:backgroundTint="?attr/buttonBackgroundColor"
|
||||||
|
android:textColor="?attr/buttonTextColor"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
24
libappbase/src/main/res/layout-night/item_logtag.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/bg_border_round">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/log_button_height"
|
||||||
|
android:textSize="@dimen/log_text_size"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:id="@+id/viewlogtagTextView1"/>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/log_button_height"
|
||||||
|
android:textSize="@dimen/log_text_size"
|
||||||
|
android:id="@+id/viewlogtagCheckBox1"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
93
libappbase/src/main/res/layout-night/layout_about_view.xml
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/aboutViewBackgroundColor">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
|
<cc.winboll.studio.libappbase.views.DebugSwitchImageView
|
||||||
|
android:id="@+id/iv_app_icon"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:scaleType="centerCrop"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_app_name_version"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textColor="?attr/aboutViewTitleColor"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_app_desc"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="?attr/aboutViewTextColor"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1px"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:background="?attr/aboutViewDividerColor"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/ll_function_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:spacing="20dp">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:src="@drawable/ic_debug_step_over"
|
||||||
|
android:id="@+id/ib_debug_step_over"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:background="@null"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:src="@drawable/ic_winboll"
|
||||||
|
android:id="@+id/ib_winbollhostdialog"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:background="@null"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:src="@drawable/ic_key"
|
||||||
|
android:id="@+id/ib_signgetdialog"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:background="@null"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?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:theme="?attr/themeDebug"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/colorTextBackgound"
|
||||||
|
android:id="@+id/viewglobalcrashreportLinearLayout1">
|
||||||
|
|
||||||
|
<android.widget.Toolbar
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/colorTittleBackgound"
|
||||||
|
android:titleTextColor="?attr/colorTittle"
|
||||||
|
android:id="@+id/viewglobalcrashreportToolbar1"/>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1.0"
|
||||||
|
android:fillViewport="true">
|
||||||
|
|
||||||
|
<HorizontalScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:textColor="?attr/colorText"
|
||||||
|
android:id="@+id/viewglobalcrashreportTextView1"/>
|
||||||
|
|
||||||
|
</HorizontalScrollView>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
151
libappbase/src/main/res/layout-night/view_log.xml
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:theme="?attr/themeDebug"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/colorTextBackgound">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="34dp"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:background="?attr/colorTittleBackgound"
|
||||||
|
android:id="@+id/viewlogRelativeLayoutToolbar">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="@dimen/log_button_width"
|
||||||
|
android:layout_height="@dimen/log_button_height"
|
||||||
|
android:textSize="@dimen/log_text_size"
|
||||||
|
android:text="Clean"
|
||||||
|
android:textColor="?attr/colorText"
|
||||||
|
android:backgroundTint="?attr/colorTittleBackgound"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:id="@+id/viewlogButtonClean"
|
||||||
|
android:layout_marginLeft="5dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:textSize="@dimen/log_text_size"
|
||||||
|
android:padding="@dimen/log_text_padding"
|
||||||
|
android:text="LV:"
|
||||||
|
android:layout_toRightOf="@+id/viewlogButtonClean"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:id="@+id/viewlogTextView1"
|
||||||
|
android:background="?attr/colorTittleBackgound"
|
||||||
|
android:textColor="?attr/colorText"/>
|
||||||
|
|
||||||
|
<cc.winboll.studio.libappbase.widget.LogTagSpinner
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toRightOf="@+id/viewlogTextView1"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:id="@+id/viewlogSpinner1"
|
||||||
|
android:padding="@dimen/log_spinner_text_padding"/>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:layout_width="@dimen/log_checkbox_width"
|
||||||
|
android:layout_height="@dimen/log_checkbox_height"
|
||||||
|
android:textSize="@dimen/log_text_size"
|
||||||
|
android:layout_toLeftOf="@+id/viewlogButtonCopy"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:text="Selectable"
|
||||||
|
android:background="?attr/colorTittleBackgound"
|
||||||
|
android:id="@+id/viewlogCheckBoxSelectable"
|
||||||
|
android:padding="@dimen/log_text_padding"
|
||||||
|
android:textColor="?attr/colorText"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="@dimen/log_button_width"
|
||||||
|
android:layout_height="@dimen/log_button_height"
|
||||||
|
android:textSize="@dimen/log_text_size"
|
||||||
|
android:textColor="?attr/colorText"
|
||||||
|
android:backgroundTint="?attr/colorTittleBackgound"
|
||||||
|
android:text="Copy"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:id="@+id/viewlogButtonCopy"
|
||||||
|
android:layout_marginRight="5dp"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/log_button_height"
|
||||||
|
android:layout_below="@+id/viewlogRelativeLayoutToolbar"
|
||||||
|
android:id="@+id/viewlogLinearLayout1"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:background="?attr/colorTittleBackgound">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/log_button_height"
|
||||||
|
android:textSize="@dimen/log_text_size"
|
||||||
|
android:text="ALL"
|
||||||
|
android:padding="2dp"
|
||||||
|
android:id="@+id/viewlogCheckBox1"
|
||||||
|
android:background="?attr/colorTittleBackgound"
|
||||||
|
android:textColor="?attr/colorText"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:ems="10"
|
||||||
|
android:layout_height="@dimen/log_button_height"
|
||||||
|
android:textSize="@dimen/log_text_size"
|
||||||
|
android:textColor="?attr/colorText"
|
||||||
|
android:background="?attr/colorTittleBackgound"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:id="@+id/tagsearch_et"/>
|
||||||
|
|
||||||
|
<HorizontalScrollView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/colorTittleBackgound"
|
||||||
|
android:scrollbars="none"
|
||||||
|
android:padding="2dp"
|
||||||
|
android:layout_weight="1.0"
|
||||||
|
android:id="@+id/viewlogHorizontalScrollView1">
|
||||||
|
|
||||||
|
<cc.winboll.studio.libappbase.views.HorizontalListView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/tags_listview"/>
|
||||||
|
|
||||||
|
</HorizontalScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1.0"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_below="@+id/viewlogLinearLayout1">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/colorTextBackgound"
|
||||||
|
android:id="@+id/viewlogScrollViewLog">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:textSize="@dimen/log_text_size"
|
||||||
|
android:text="Text"
|
||||||
|
android:textColor="?attr/debugTextColor"
|
||||||
|
android:textIsSelectable="true"
|
||||||
|
android:id="@+id/viewlogTextViewLog"/>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
@@ -4,11 +4,13 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
<android.widget.Toolbar
|
<android.widget.Toolbar
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/toolbarBackgroundColor"
|
||||||
android:id="@+id/toolbar"/>
|
android:id="@+id/toolbar"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
<cc.winboll.studio.libappbase.GlobalCrashReportView
|
<cc.winboll.studio.libappbase.GlobalCrashReportView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
<cc.winboll.studio.libappbase.LogView
|
<cc.winboll.studio.libappbase.LogView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="24dp"
|
android:padding="24dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:background="@android:color/white">
|
android:background="?attr/activityBackgroundColor">
|
||||||
|
|
||||||
<!-- NFC状态提示文本 -->
|
<!-- NFC状态提示文本 -->
|
||||||
<TextView
|
<TextView
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="正在监听NFC卡片,请贴近设备检测密钥..."
|
android:text="正在监听NFC卡片,请贴近设备检测密钥..."
|
||||||
android:textSize="17sp"
|
android:textSize="17sp"
|
||||||
android:textColor="@android:color/black"
|
android:textColor="?attr/activityTextColor"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:layout_marginBottom="30dp"/>
|
android:layout_marginBottom="30dp"/>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="私钥内容:无"
|
android:text="私钥内容:无"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@android:color/darker_gray"
|
android:textColor="?attr/activityTextColor"
|
||||||
android:layout_marginBottom="12dp"
|
android:layout_marginBottom="12dp"
|
||||||
android:maxLines="5"
|
android:maxLines="5"
|
||||||
android:ellipsize="end"/>
|
android:ellipsize="end"/>
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="公钥内容:无"
|
android:text="公钥内容:无"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@android:color/darker_gray"
|
android:textColor="?attr/activityTextColor"
|
||||||
android:layout_marginBottom="40dp"
|
android:layout_marginBottom="40dp"
|
||||||
android:maxLines="5"
|
android:maxLines="5"
|
||||||
android:ellipsize="end"/>
|
android:ellipsize="end"/>
|
||||||
@@ -50,10 +50,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="功能按钮待激活"
|
android:text="功能按钮待激活"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="?attr/buttonTextColor"
|
||||||
android:backgroundTint="@android:color/holo_blue_light"
|
android:backgroundTint="?attr/buttonBackgroundColor"
|
||||||
android:padding="14dp"
|
android:padding="14dp"
|
||||||
android:enabled="false"/>
|
android:enabled="false"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -6,14 +6,14 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:background="#FFDCDCDC">
|
android:background="?attr/dialogBackgroundColor">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="应用指纹校验"
|
android:text="应用指纹校验"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textColor="@color/gray_900"
|
android:textColor="?attr/dialogTextColor"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_marginBottom="12dp"/>
|
android:layout_marginBottom="12dp"/>
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:textSize="11sp"
|
android:textSize="11sp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="@color/gray_900"/>
|
android:textColor="?attr/dialogTextColor"/>/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:background="#FFFFFF">
|
android:background="?attr/dialogBackgroundColor">
|
||||||
|
|
||||||
<!-- 标题 -->
|
<!-- 标题 -->
|
||||||
<TextView
|
<TextView
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="设置服务器地址"
|
android:text="设置服务器地址"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textColor="#212121"
|
android:textColor="?attr/dialogTextColor"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_marginBottom="16dp"/>
|
android:layout_marginBottom="16dp"/>
|
||||||
|
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="请输入服务器地址(如http://localhost:8080)"
|
android:hint="请输入服务器地址(如http://localhost:8080)"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
|
android:textColor="?attr/dialogTextColor"
|
||||||
android:inputType="textUri"
|
android:inputType="textUri"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:background="@android:drawable/edit_text"
|
android:background="@android:drawable/edit_text"
|
||||||
@@ -42,6 +43,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="取消"
|
android:text="取消"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
|
android:textColor="?attr/dialogTextColor"
|
||||||
android:layout_marginRight="8dp"/>
|
android:layout_marginRight="8dp"/>
|
||||||
|
|
||||||
<!-- 确认按钮 -->
|
<!-- 确认按钮 -->
|
||||||
@@ -51,8 +53,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="确认"
|
android:text="确认"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:backgroundTint="#2196F3"
|
android:backgroundTint="?attr/buttonBackgroundColor"
|
||||||
android:textColor="#FFFFFF"/>
|
android:textColor="?attr/buttonTextColor"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
<ScrollView
|
<ScrollView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/aboutViewBackgroundColor">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -26,7 +27,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:textColor="@color/gray_900"/>
|
android:textColor="?attr/aboutViewTitleColor"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_app_desc"
|
android:id="@+id/tv_app_desc"
|
||||||
@@ -35,14 +36,14 @@
|
|||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@color/gray_500"/>
|
android:textColor="?attr/aboutViewTextColor"/>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1px"
|
android:layout_height="1px"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:background="@color/gray_200"/>
|
android:background="?attr/aboutViewDividerColor"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/ll_function_container"
|
android:id="@+id/ll_function_container"
|
||||||
|
|||||||
@@ -2,29 +2,35 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:theme="?attr/themeDebug"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/colorTextBackgound"
|
||||||
android:id="@+id/viewglobalcrashreportLinearLayout1">
|
android:id="@+id/viewglobalcrashreportLinearLayout1">
|
||||||
|
|
||||||
<android.widget.Toolbar
|
<android.widget.Toolbar
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/colorTittleBackgound"
|
||||||
|
android:titleTextColor="?attr/colorTittle"
|
||||||
android:id="@+id/viewglobalcrashreportToolbar1"/>
|
android:id="@+id/viewglobalcrashreportToolbar1"/>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1.0">
|
android:layout_weight="1.0"
|
||||||
|
android:fillViewport="true">
|
||||||
|
|
||||||
<HorizontalScrollView
|
<HorizontalScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#FFFFFFFF"
|
android:padding="16dp"
|
||||||
|
android:textColor="?attr/colorText"
|
||||||
android:id="@+id/viewglobalcrashreportTextView1"/>
|
android:id="@+id/viewglobalcrashreportTextView1"/>
|
||||||
|
|
||||||
</HorizontalScrollView>
|
</HorizontalScrollView>
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:theme="?attr/themeDebug"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#FF000000">
|
android:background="?attr/colorTextBackgound">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="34dp"
|
android:layout_height="34dp"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:background="@drawable/bg_toolbar_log"
|
android:background="?attr/colorTittleBackgound"
|
||||||
android:id="@+id/viewlogRelativeLayoutToolbar">
|
android:id="@+id/viewlogRelativeLayoutToolbar">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@@ -19,8 +20,8 @@
|
|||||||
android:layout_height="@dimen/log_button_height"
|
android:layout_height="@dimen/log_button_height"
|
||||||
android:textSize="@dimen/log_text_size"
|
android:textSize="@dimen/log_text_size"
|
||||||
android:text="Clean"
|
android:text="Clean"
|
||||||
android:textColor="@color/white"
|
android:textColor="?attr/colorText"
|
||||||
android:backgroundTint="@drawable/btn_gray_bg"
|
android:backgroundTint="?attr/colorTittleBackgound"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:id="@+id/viewlogButtonClean"
|
android:id="@+id/viewlogButtonClean"
|
||||||
android:layout_marginLeft="5dp"/>
|
android:layout_marginLeft="5dp"/>
|
||||||
@@ -34,8 +35,8 @@
|
|||||||
android:layout_toRightOf="@+id/viewlogButtonClean"
|
android:layout_toRightOf="@+id/viewlogButtonClean"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:id="@+id/viewlogTextView1"
|
android:id="@+id/viewlogTextView1"
|
||||||
android:background="@color/btn_gray_normal"
|
android:background="?attr/colorTittleBackgound"
|
||||||
android:textColor="@color/black"/>
|
android:textColor="?attr/colorText"/>
|
||||||
|
|
||||||
<cc.winboll.studio.libappbase.widget.LogTagSpinner
|
<cc.winboll.studio.libappbase.widget.LogTagSpinner
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -52,17 +53,17 @@
|
|||||||
android:layout_toLeftOf="@+id/viewlogButtonCopy"
|
android:layout_toLeftOf="@+id/viewlogButtonCopy"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:text="Selectable"
|
android:text="Selectable"
|
||||||
android:background="@color/btn_gray_normal"
|
android:background="?attr/colorTittleBackgound"
|
||||||
android:id="@+id/viewlogCheckBoxSelectable"
|
android:id="@+id/viewlogCheckBoxSelectable"
|
||||||
android:padding="@dimen/log_text_padding"
|
android:padding="@dimen/log_text_padding"
|
||||||
android:textColor="@color/white"/>
|
android:textColor="?attr/colorText"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="@dimen/log_button_width"
|
android:layout_width="@dimen/log_button_width"
|
||||||
android:layout_height="@dimen/log_button_height"
|
android:layout_height="@dimen/log_button_height"
|
||||||
android:textSize="@dimen/log_text_size"
|
android:textSize="@dimen/log_text_size"
|
||||||
android:textColor="@color/white"
|
android:textColor="?attr/colorText"
|
||||||
android:backgroundTint="@drawable/btn_gray_bg"
|
android:backgroundTint="?attr/colorTittleBackgound"
|
||||||
android:text="Copy"
|
android:text="Copy"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
@@ -78,7 +79,7 @@
|
|||||||
android:layout_below="@+id/viewlogRelativeLayoutToolbar"
|
android:layout_below="@+id/viewlogRelativeLayoutToolbar"
|
||||||
android:id="@+id/viewlogLinearLayout1"
|
android:id="@+id/viewlogLinearLayout1"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:background="@drawable/bg_toolbar_log">
|
android:background="?attr/colorTittleBackgound">
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -87,7 +88,8 @@
|
|||||||
android:text="ALL"
|
android:text="ALL"
|
||||||
android:padding="2dp"
|
android:padding="2dp"
|
||||||
android:id="@+id/viewlogCheckBox1"
|
android:id="@+id/viewlogCheckBox1"
|
||||||
android:background="@drawable/bg_border_round"
|
android:background="?attr/colorTittleBackgound"
|
||||||
|
android:textColor="?attr/colorText"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_marginRight="5dp"/>
|
android:layout_marginRight="5dp"/>
|
||||||
|
|
||||||
@@ -96,13 +98,15 @@
|
|||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:layout_height="@dimen/log_button_height"
|
android:layout_height="@dimen/log_button_height"
|
||||||
android:textSize="@dimen/log_text_size"
|
android:textSize="@dimen/log_text_size"
|
||||||
|
android:textColor="?attr/colorText"
|
||||||
|
android:background="?attr/colorTittleBackgound"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:id="@+id/tagsearch_et"/>
|
android:id="@+id/tagsearch_et"/>
|
||||||
|
|
||||||
<HorizontalScrollView
|
<HorizontalScrollView
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/bg_border"
|
android:background="?attr/colorTittleBackgound"
|
||||||
android:scrollbars="none"
|
android:scrollbars="none"
|
||||||
android:padding="2dp"
|
android:padding="2dp"
|
||||||
android:layout_weight="1.0"
|
android:layout_weight="1.0"
|
||||||
@@ -128,7 +132,7 @@
|
|||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#FF000000"
|
android:background="?attr/colorTextBackgound"
|
||||||
android:id="@+id/viewlogScrollViewLog">
|
android:id="@+id/viewlogScrollViewLog">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -136,7 +140,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:textSize="@dimen/log_text_size"
|
android:textSize="@dimen/log_text_size"
|
||||||
android:text="Text"
|
android:text="Text"
|
||||||
android:textColor="#FF00FF00"
|
android:textColor="?attr/debugTextColor"
|
||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
android:id="@+id/viewlogTextViewLog"/>
|
android:id="@+id/viewlogTextViewLog"/>
|
||||||
|
|
||||||
@@ -144,5 +148,4 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
61
libappbase/src/main/res/values-night/attrs.xml
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<!-- 全局主题属性 -->
|
||||||
|
<attr name="themeDebug" format="reference"/>
|
||||||
|
|
||||||
|
<!-- GlobalCrashActivity 样式属性 -->
|
||||||
|
<declare-styleable name="GlobalCrashActivity">
|
||||||
|
<attr name="colorTittle" format="color" />
|
||||||
|
<attr name="colorTittleBackgound" format="color" />
|
||||||
|
<attr name="colorText" format="color" />
|
||||||
|
<attr name="colorTextBackgound" format="color" />
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
<!-- AboutView 样式属性 -->
|
||||||
|
<declare-styleable name="AboutViewStyle">
|
||||||
|
<attr name="aboutViewBackgroundColor" format="color" />
|
||||||
|
<attr name="aboutViewTextColor" format="color" />
|
||||||
|
<attr name="aboutViewTitleColor" format="color" />
|
||||||
|
<attr name="aboutViewDividerColor" format="color" />
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
<!-- ButtonStyle 样式属性 -->
|
||||||
|
<declare-styleable name="ButtonStyle">
|
||||||
|
<attr name="buttonBackgroundColor" format="color" />
|
||||||
|
<attr name="buttonTextColor" format="color" />
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
<!-- DialogStyle 样式属性 -->
|
||||||
|
<declare-styleable name="DialogStyle">
|
||||||
|
<attr name="dialogBackgroundColor" format="color" />
|
||||||
|
<attr name="dialogTextColor" format="color" />
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
<!-- 窗体/控件通用背景色属性 -->
|
||||||
|
<attr name="toolbarBackgroundColor" format="color"/>
|
||||||
|
<attr name="textViewBackgroundColor" format="color"/>
|
||||||
|
<attr name="editTextBackgroundColor" format="color"/>
|
||||||
|
<attr name="scrollViewBackgroundColor" format="color"/>
|
||||||
|
|
||||||
|
<!-- 窗体/控件通用文字色属性 -->
|
||||||
|
<attr name="toolbarTextColor" format="color"/>
|
||||||
|
<attr name="textViewTextColor" format="color"/>
|
||||||
|
<attr name="editTextTextColor" format="color"/>
|
||||||
|
|
||||||
|
<!-- ActivityStyle 样式属性 -->
|
||||||
|
<attr name="activityBackgroundColor" format="color"/>
|
||||||
|
<attr name="activityTextColor" format="color"/>
|
||||||
|
|
||||||
|
<!-- MainWindowStyle 主窗口样式属性 -->
|
||||||
|
<attr name="mainWindowBackgroundColor" format="color"/>
|
||||||
|
<attr name="mainWindowTextColor" format="color"/>
|
||||||
|
|
||||||
|
<!-- MainWindowDarkStyle 深色模式主窗口样式属性 -->
|
||||||
|
<attr name="mainWindowDarkBackgroundColor" format="color"/>
|
||||||
|
<attr name="mainWindowDarkTextColor" format="color"/>
|
||||||
|
|
||||||
|
<!-- DebugLogStyle 应用调试日志样式属性 -->
|
||||||
|
<attr name="debugTextColor" format="color"/>
|
||||||
|
|
||||||
|
</resources>
|
||||||
69
libappbase/src/main/res/values-night/colors.xml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="colorPrimary">#FF1E3A5F</color>
|
||||||
|
<color name="colorPrimaryDark">#FF15253D</color>
|
||||||
|
<color name="colorAccent">#FF4DA6FF</color>
|
||||||
|
<color name="colorText">#FFE0E0E0</color>
|
||||||
|
<color name="colorTextBackgound">#FF0D1B2A</color>
|
||||||
|
|
||||||
|
<!-- ============== 基础黑白(必含,适配文字/背景) ============== -->
|
||||||
|
<color name="white">#FFFFFF</color>
|
||||||
|
<color name="black">#000000</color>
|
||||||
|
|
||||||
|
<!-- ============== 基础色系(按钮/强调色常用) ============== -->
|
||||||
|
<color name="blue_light">#4A90E2</color>
|
||||||
|
<color name="blue_normal">#2196F3</color>
|
||||||
|
<color name="blue_dark">#1976D2</color>
|
||||||
|
<color name="green_light">#66BB6A</color>
|
||||||
|
<color name="green_normal">#4CAF50</color>
|
||||||
|
<color name="green_dark">#388E3C</color>
|
||||||
|
<color name="red_light">#EF5350</color>
|
||||||
|
<color name="red_normal">#F44336</color>
|
||||||
|
<color name="red_dark">#D32F2F</color>
|
||||||
|
<color name="yellow_light">#FFF59D</color>
|
||||||
|
<color name="yellow_normal">#FFC107</color>
|
||||||
|
<color name="yellow_dark">#FFA000</color>
|
||||||
|
<color name="orange_normal">#FF9800</color>
|
||||||
|
<color name="purple_normal">#9C27B0</color>
|
||||||
|
|
||||||
|
<!-- ============== 透明色(遮罩/背景叠加) ============== -->
|
||||||
|
<color name="transparent">#00000000</color>
|
||||||
|
<color name="black_transparent_50">#80000000</color>
|
||||||
|
|
||||||
|
<!-- ============== 不透明灰色(常用深浅梯度) ============== -->
|
||||||
|
<color name="gray_100">#1A1A1A</color>
|
||||||
|
<color name="gray_200">#262626</color>
|
||||||
|
<color name="gray_300">#333333</color>
|
||||||
|
<color name="gray_400">#4D4D4D</color>
|
||||||
|
<color name="gray_500">#666666</color>
|
||||||
|
<color name="gray_600">#808080</color>
|
||||||
|
<color name="gray_700">#999999</color>
|
||||||
|
<color name="gray_800">#B3B3B3</color>
|
||||||
|
<color name="gray_900">#CCCCCC</color>
|
||||||
|
|
||||||
|
<!-- ============== 半透明灰色 ============== -->
|
||||||
|
<color name="gray_transparent_30">#4D333333</color>
|
||||||
|
<color name="gray_transparent_50">#80333333</color>
|
||||||
|
<color name="gray_transparent_70">#B3333333</color>
|
||||||
|
|
||||||
|
<color name="gray_light">#333333</color>
|
||||||
|
<color name="gray_mid">#666666</color>
|
||||||
|
<color name="gray_dark">#999999</color>
|
||||||
|
<color name="gray_black">#CCCCCC</color>
|
||||||
|
|
||||||
|
<!-- ============== 遮罩/蒙层 ============== -->
|
||||||
|
<color name="mask_gray">#804D4D4D</color>
|
||||||
|
<color name="bg_overlay_gray">#4D1A1A1A</color>
|
||||||
|
|
||||||
|
<!-- ============== 按钮灰色 ============== -->
|
||||||
|
<color name="btn_gray_normal">#666666</color>
|
||||||
|
<color name="btn_gray_pressed">#4D4D4D</color>
|
||||||
|
<color name="btn_gray_disabled">#333333</color>
|
||||||
|
|
||||||
|
<!-- ============== 主题颜色 ============== -->
|
||||||
|
<color name="mainWindowBackgroundColor">#FF0D1B2A</color>
|
||||||
|
<color name="mainWindowTextColor">#FFE0E0E0</color>
|
||||||
|
<color name="buttonBackgroundColor">#FF1E3A5F</color>
|
||||||
|
<color name="debugTextColor">#FF00FF00</color>
|
||||||
|
|
||||||
|
</resources>
|
||||||
46
libappbase/src/main/res/values-night/styles.xml
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<!-- APPBaseTheme 深色模式主题 -->
|
||||||
|
<style name="APPBaseTheme" parent="@android:style/Theme.DeviceDefault.NoActionBar">
|
||||||
|
<item name="themeDebug">@style/DebugActivityTheme</item>
|
||||||
|
<item name="aboutViewBackgroundColor">?attr/mainWindowDarkBackgroundColor</item>
|
||||||
|
<item name="aboutViewTextColor">?attr/mainWindowDarkTextColor</item>
|
||||||
|
<item name="aboutViewTitleColor">?attr/mainWindowDarkTextColor</item>
|
||||||
|
<item name="aboutViewDividerColor">?attr/mainWindowTextColor</item>
|
||||||
|
<item name="buttonBackgroundColor">@color/buttonBackgroundColor</item>
|
||||||
|
<item name="buttonTextColor">?attr/mainWindowDarkTextColor</item>
|
||||||
|
<item name="dialogBackgroundColor">?attr/mainWindowDarkBackgroundColor</item>
|
||||||
|
<item name="dialogTextColor">?attr/mainWindowDarkTextColor</item>
|
||||||
|
<item name="toolbarBackgroundColor">?attr/buttonBackgroundColor</item>
|
||||||
|
<item name="toolbarTextColor">?attr/mainWindowDarkTextColor</item>
|
||||||
|
<item name="textViewBackgroundColor">?attr/mainWindowDarkBackgroundColor</item>
|
||||||
|
<item name="textViewTextColor">?attr/mainWindowDarkTextColor</item>
|
||||||
|
<item name="editTextBackgroundColor">?attr/mainWindowDarkBackgroundColor</item>
|
||||||
|
<item name="editTextTextColor">?attr/mainWindowDarkTextColor</item>
|
||||||
|
<item name="scrollViewBackgroundColor">?attr/mainWindowDarkBackgroundColor</item>
|
||||||
|
<item name="activityBackgroundColor">?attr/mainWindowDarkBackgroundColor</item>
|
||||||
|
<item name="activityTextColor">?attr/mainWindowDarkTextColor</item>
|
||||||
|
<item name="mainWindowBackgroundColor">@color/mainWindowBackgroundColor</item>
|
||||||
|
<item name="mainWindowTextColor">@color/mainWindowTextColor</item>
|
||||||
|
<item name="mainWindowDarkBackgroundColor">@color/mainWindowBackgroundColor</item>
|
||||||
|
<item name="mainWindowDarkTextColor">@color/mainWindowTextColor</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- DebugActivityTheme 深色模式样式 -->
|
||||||
|
<style name="DebugActivityTheme" parent="@android:style/Theme.DeviceDefault.NoActionBar">
|
||||||
|
<item name="android:statusBarColor">@color/mainWindowBackgroundColor</item>
|
||||||
|
<item name="colorTittle">?attr/mainWindowDarkTextColor</item>
|
||||||
|
<item name="colorTittleBackgound">@color/buttonBackgroundColor</item>
|
||||||
|
<item name="colorText">?attr/debugTextColor</item>
|
||||||
|
<item name="colorTextBackgound">?attr/mainWindowDarkBackgroundColor</item>
|
||||||
|
<item name="debugTextColor">@color/debugTextColor</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- DialogStyle 对话框样式 -->
|
||||||
|
<style name="DialogStyle" parent="@android:style/Theme.Dialog">
|
||||||
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
||||||
@@ -1,13 +1,67 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<attr name="themeGlobalCrashActivity" format="reference"/>
|
<!-- 全局主题属性 -->
|
||||||
|
<attr name="themeDebug" format="reference"/>
|
||||||
|
|
||||||
<declare-styleable name="GlobalCrashActivity">
|
<!-- AboutView 样式属性 -->
|
||||||
<attr name="colorTittle" format="color" />
|
<declare-styleable name="AboutView">
|
||||||
<attr name="colorTittleBackgound" format="color" />
|
<attr name="app_name" format="string" />
|
||||||
<attr name="colorText" format="color" />
|
<attr name="app_apkfoldername" format="string" />
|
||||||
<attr name="colorTextBackgound" format="color" />
|
<attr name="app_apkname" format="string" />
|
||||||
|
<attr name="app_gitname" format="string" />
|
||||||
|
<attr name="app_gitowner" format="string" />
|
||||||
|
<attr name="app_gitappbranch" format="string" />
|
||||||
|
<attr name="app_gitappsubprojectfolder" format="string" />
|
||||||
|
<attr name="appdescription" format="string" />
|
||||||
|
<attr name="appicon" format="reference" />
|
||||||
|
<attr name="is_adddebugtools" format="boolean" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
</resources>
|
<!-- AboutViewStyle 样式属性 -->
|
||||||
|
<declare-styleable name="AboutViewStyle">
|
||||||
|
<attr name="aboutViewBackgroundColor" format="color" />
|
||||||
|
<attr name="aboutViewTextColor" format="color" />
|
||||||
|
<attr name="aboutViewTitleColor" format="color" />
|
||||||
|
<attr name="aboutViewDividerColor" format="color" />
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
<!-- ButtonStyle 样式属性 -->
|
||||||
|
<declare-styleable name="ButtonStyle">
|
||||||
|
<attr name="buttonBackgroundColor" format="color" />
|
||||||
|
<attr name="buttonTextColor" format="color" />
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
<!-- DialogStyle 样式属性 -->
|
||||||
|
<declare-styleable name="DialogStyle">
|
||||||
|
<attr name="dialogBackgroundColor" format="color" />
|
||||||
|
<attr name="dialogTextColor" format="color" />
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
<!-- 窗体/控件通用背景色属性 -->
|
||||||
|
<attr name="toolbarBackgroundColor" format="color"/>
|
||||||
|
<attr name="textViewBackgroundColor" format="color"/>
|
||||||
|
<attr name="editTextBackgroundColor" format="color"/>
|
||||||
|
<attr name="scrollViewBackgroundColor" format="color"/>
|
||||||
|
|
||||||
|
<!-- 窗体/控件通用文字色属性 -->
|
||||||
|
<attr name="toolbarTextColor" format="color"/>
|
||||||
|
<attr name="textViewTextColor" format="color"/>
|
||||||
|
<attr name="editTextTextColor" format="color"/>
|
||||||
|
|
||||||
|
<!-- ActivityStyle 样式属性 -->
|
||||||
|
<attr name="activityBackgroundColor" format="color"/>
|
||||||
|
<attr name="activityTextColor" format="color"/>
|
||||||
|
|
||||||
|
<!-- MainWindowStyle 主窗口样式属性 -->
|
||||||
|
<attr name="mainWindowBackgroundColor" format="color"/>
|
||||||
|
<attr name="mainWindowTextColor" format="color"/>
|
||||||
|
|
||||||
|
<!-- MainWindowDarkStyle 深色模式主窗口样式属性 -->
|
||||||
|
<attr name="mainWindowDarkBackgroundColor" format="color"/>
|
||||||
|
<attr name="mainWindowDarkTextColor" format="color"/>
|
||||||
|
|
||||||
|
<!-- DebugLogStyle 应用调试日志样式属性 -->
|
||||||
|
<attr name="debugTextColor" format="color"/>
|
||||||
|
|
||||||
|
</resources>
|
||||||
@@ -1,74 +1,69 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="colorPrimary">#FF00B322</color>
|
<color name="colorPrimary">#FF00B322</color>
|
||||||
<color name="colorPrimaryDark">#FF005C12</color>
|
<color name="colorPrimaryDark">#FF008F1A</color>
|
||||||
<color name="colorAccent">#FF8DFFA2</color>
|
<color name="colorAccent">#FF8DFFA2</color>
|
||||||
<color name="colorText">#FFFFFB8D</color>
|
<color name="colorText">#FF000000</color>
|
||||||
<color name="colorTextBackgound">#FF000000</color>
|
<color name="colorTextBackgound">#FFF5F5F5</color>
|
||||||
|
|
||||||
<!-- ============== 基础黑白(必含,适配文字/背景) ============== -->
|
<!-- ============== 基础黑白(必含,适配文字/背景) ============== -->
|
||||||
<color name="white">#FFFFFF</color> <!-- 纯白色(文字/背景) -->
|
<color name="white">#FFFFFF</color>
|
||||||
<color name="black">#000000</color> <!-- 近黑色(重要文字) -->
|
<color name="black">#000000</color>
|
||||||
|
|
||||||
<!-- ============== 基础色系(按钮/强调色常用) ============== -->
|
<!-- ============== 基础色系(按钮/强调色常用) ============== -->
|
||||||
<!-- 蓝色系(常用:确认/链接/主题色) -->
|
<color name="blue_light">#4A90E2</color>
|
||||||
<color name="blue_light">#4A90E2</color> <!-- 浅蓝(次要按钮) -->
|
<color name="blue_normal">#2196F3</color>
|
||||||
<color name="blue_normal">#2196F3</color> <!-- 标准蓝(主题/确认按钮) -->
|
<color name="blue_dark">#1976D2</color>
|
||||||
<color name="blue_dark">#1976D2</color> <!-- 深蓝(按压态/重要强调) -->
|
<color name="green_light">#66BB6A</color>
|
||||||
<!-- 绿色系(常用:成功/完成/安全提示) -->
|
<color name="green_normal">#4CAF50</color>
|
||||||
<color name="green_light">#66BB6A</color> <!-- 浅绿(次要成功态) -->
|
<color name="green_dark">#388E3C</color>
|
||||||
<color name="green_normal">#4CAF50</color> <!-- 标准绿(成功按钮/提示) -->
|
<color name="red_light">#EF5350</color>
|
||||||
<color name="green_dark">#388E3C</color> <!-- 深绿(按压态/重要成功) -->
|
<color name="red_normal">#F44336</color>
|
||||||
<!-- 红色系(常用:错误/警告/删除按钮) -->
|
<color name="red_dark">#D32F2F</color>
|
||||||
<color name="red_light">#EF5350</color> <!-- 浅红(次要错误提示) -->
|
<color name="yellow_light">#FFF59D</color>
|
||||||
<color name="red_normal">#F44336</color> <!-- 标准红(删除/错误按钮) -->
|
<color name="yellow_normal">#FFC107</color>
|
||||||
<color name="red_dark">#D32F2F</color> <!-- 深红(按压态/重要错误) -->
|
<color name="yellow_dark">#FFA000</color>
|
||||||
<!-- 黄色系(常用:警告/提醒/高亮) -->
|
<color name="orange_normal">#FF9800</color>
|
||||||
<color name="yellow_light">#FFF59D</color> <!-- 浅黄(次要提醒) -->
|
<color name="purple_normal">#9C27B0</color>
|
||||||
<color name="yellow_normal">#FFC107</color> <!-- 标准黄(警告提示/高亮) -->
|
|
||||||
<color name="yellow_dark">#FFA000</color> <!-- 深黄(重要警告) -->
|
|
||||||
<!-- 橙色系(常用:提醒/进度/活力色) -->
|
|
||||||
<color name="orange_normal">#FF9800</color> <!-- 标准橙(提醒按钮/进度) -->
|
|
||||||
<!-- 紫色系(常用:特殊强调/个性按钮) -->
|
|
||||||
<color name="purple_normal">#9C27B0</color> <!-- 标准紫(特殊功能按钮) -->
|
|
||||||
|
|
||||||
<!-- ============== 透明色(遮罩/背景叠加) ============== -->
|
<!-- ============== 透明色(遮罩/背景叠加) ============== -->
|
||||||
<color name="transparent">#00000000</color> <!-- 全透明 -->
|
<color name="transparent">#00000000</color>
|
||||||
<color name="black_transparent_50">#80000000</color> <!-- 50%透明黑(遮罩) -->
|
<color name="black_transparent_50">#80000000</color>
|
||||||
|
|
||||||
|
<!-- ============== 不透明灰色(常用深浅梯度) ============== -->
|
||||||
|
<color name="gray_100">#F5F5F5</color>
|
||||||
|
<color name="gray_200">#EEEEEE</color>
|
||||||
|
<color name="gray_300">#E0E0E0</color>
|
||||||
|
<color name="gray_400">#BDBDBD</color>
|
||||||
|
<color name="gray_500">#9E9E9E</color>
|
||||||
|
<color name="gray_600">#757575</color>
|
||||||
|
<color name="gray_700">#616161</color>
|
||||||
|
<color name="gray_800">#424242</color>
|
||||||
|
<color name="gray_900">#212121</color>
|
||||||
|
|
||||||
|
<!-- ============== 半透明灰色 ============== -->
|
||||||
|
<color name="gray_transparent_30">#4D9E9E9E</color>
|
||||||
|
<color name="gray_transparent_50">#809E9E9E</color>
|
||||||
|
<color name="gray_transparent_70">#B39E9E9E</color>
|
||||||
|
|
||||||
<!-- 1. 不透明灰色(常用深浅梯度,直接用) -->
|
<color name="gray_light">#EEE</color>
|
||||||
<color name="gray_100">#F5F5F5</color> <!-- 极浅灰(接近白色,背景用) -->
|
<color name="gray_mid">#999</color>
|
||||||
<color name="gray_200">#EEEEEE</color> <!-- 浅灰(卡片/分割线背景) -->
|
<color name="gray_dark">#666</color>
|
||||||
<color name="gray_300">#E0E0E0</color> <!-- 中浅灰(边框/次要背景) -->
|
<color name="gray_black">#333</color>
|
||||||
<color name="gray_400">#BDBDBD</color> <!-- 中灰(次要文字/图标) -->
|
|
||||||
<color name="gray_500">#9E9E9E</color> <!-- 标准中灰(常用辅助文字) -->
|
|
||||||
<color name="gray_600">#757575</color> <!-- 中深灰(常规辅助文字) -->
|
|
||||||
<color name="gray_700">#616161</color> <!-- 深灰(重要辅助文字) -->
|
|
||||||
<color name="gray_800">#424242</color> <!-- 极深灰(接近黑色,标题副文本) -->
|
|
||||||
<color name="gray_900">#212121</color> <!-- 近黑色(特殊场景用) -->
|
|
||||||
|
|
||||||
<!-- 2. 半透明灰色(带透明度,遮罩/蒙层用) -->
|
<!-- ============== 遮罩/蒙层 ============== -->
|
||||||
<color name="gray_transparent_30">#4D9E9E9E</color> <!-- 30%透明中灰(A=4D) -->
|
|
||||||
<color name="gray_transparent_50">#809E9E9E</color> <!-- 50%透明中灰(A=80) -->
|
|
||||||
<color name="gray_transparent_70">#B39E9E9E</color> <!-- 70%透明中灰(A=B3) -->
|
|
||||||
|
|
||||||
<color name="gray_light">#EEE</color> <!-- 等价 #EEEEEE(浅灰) -->
|
|
||||||
<color name="gray_mid">#999</color> <!-- 等价 #999999(中灰) -->
|
|
||||||
<color name="gray_dark">#666</color> <!-- 等价 #666666(深灰) -->
|
|
||||||
<color name="gray_black">#333</color> <!-- 等价 #333333(极深灰) -->
|
|
||||||
|
|
||||||
<!-- 50% 透明中灰(弹窗遮罩常用) -->
|
|
||||||
<color name="mask_gray">#809E9E9E</color>
|
<color name="mask_gray">#809E9E9E</color>
|
||||||
<!-- 30% 透明深灰(背景叠加) -->
|
|
||||||
<color name="bg_overlay_gray">#4D424242</color>
|
<color name="bg_overlay_gray">#4D424242</color>
|
||||||
|
|
||||||
<!-- 1. 常规灰色(按钮默认态,常用中灰) -->
|
<!-- ============== 按钮灰色 ============== -->
|
||||||
<color name="btn_gray_normal">#9E9E9E</color>
|
<color name="btn_gray_normal">#9E9E9E</color>
|
||||||
<!-- 2. 按压深色(按钮点击态,加深一级,提升交互感) -->
|
|
||||||
<color name="btn_gray_pressed">#757575</color>
|
<color name="btn_gray_pressed">#757575</color>
|
||||||
<!-- 3. 禁用灰色(按钮不可点击态,浅灰) -->
|
|
||||||
<color name="btn_gray_disabled">#E0E0E0</color>
|
<color name="btn_gray_disabled">#E0E0E0</color>
|
||||||
|
|
||||||
</resources>
|
<!-- ============== 主题颜色 ============== -->
|
||||||
|
<color name="mainWindowBackgroundColor">#FFF5F5F5</color>
|
||||||
|
<color name="mainWindowTextColor">#FF000000</color>
|
||||||
|
<color name="buttonBackgroundColor">#FF00B322</color>
|
||||||
|
<color name="debugTextColor">#FF808080</color>
|
||||||
|
|
||||||
|
</resources>
|
||||||
@@ -3,4 +3,6 @@
|
|||||||
|
|
||||||
<string name="lib_name">libappbase</string>
|
<string name="lib_name">libappbase</string>
|
||||||
<string name="hello_world">Hello, world!</string>
|
<string name="hello_world">Hello, world!</string>
|
||||||
|
<string name="shared_user_id">cc.winboll.studio</string>
|
||||||
|
<string name="shared_user_label">studio@winboll.cc</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1,20 +1,46 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
|
<!-- APPBaseTheme 普通模式主题 -->
|
||||||
<style name="APPBaseTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
|
<style name="APPBaseTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
|
||||||
<item name="themeGlobalCrashActivity">@style/GlobalCrashActivityTheme</item>
|
<item name="themeDebug">@style/DebugActivityTheme</item>
|
||||||
|
<item name="aboutViewBackgroundColor">?attr/mainWindowBackgroundColor</item>
|
||||||
|
<item name="aboutViewTextColor">?attr/mainWindowTextColor</item>
|
||||||
|
<item name="aboutViewTitleColor">?attr/mainWindowTextColor</item>
|
||||||
|
<item name="aboutViewDividerColor">?attr/mainWindowDarkTextColor</item>
|
||||||
|
<item name="buttonBackgroundColor">@color/buttonBackgroundColor</item>
|
||||||
|
<item name="buttonTextColor">?attr/mainWindowTextColor</item>
|
||||||
|
<item name="dialogBackgroundColor">?attr/mainWindowBackgroundColor</item>
|
||||||
|
<item name="dialogTextColor">?attr/mainWindowTextColor</item>
|
||||||
|
<item name="toolbarBackgroundColor">?attr/buttonBackgroundColor</item>
|
||||||
|
<item name="toolbarTextColor">?attr/mainWindowTextColor</item>
|
||||||
|
<item name="textViewBackgroundColor">?attr/mainWindowBackgroundColor</item>
|
||||||
|
<item name="textViewTextColor">?attr/mainWindowTextColor</item>
|
||||||
|
<item name="editTextBackgroundColor">?attr/mainWindowBackgroundColor</item>
|
||||||
|
<item name="editTextTextColor">?attr/mainWindowTextColor</item>
|
||||||
|
<item name="scrollViewBackgroundColor">?attr/mainWindowBackgroundColor</item>
|
||||||
|
<item name="activityBackgroundColor">?attr/mainWindowBackgroundColor</item>
|
||||||
|
<item name="activityTextColor">?attr/mainWindowTextColor</item>
|
||||||
|
<item name="mainWindowBackgroundColor">@color/mainWindowBackgroundColor</item>
|
||||||
|
<item name="mainWindowTextColor">@color/mainWindowTextColor</item>
|
||||||
|
<item name="mainWindowDarkBackgroundColor">@color/mainWindowBackgroundColor</item>
|
||||||
|
<item name="mainWindowDarkTextColor">@color/mainWindowTextColor</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="GlobalCrashActivityTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
|
<!-- DebugActivityTheme 普通模式样式 -->
|
||||||
<item name="colorTittle">#FFFFF600</item>
|
<style name="DebugActivityTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
|
||||||
<item name="colorTittleBackgound">#FF00B322</item>
|
<item name="android:statusBarColor">@color/buttonBackgroundColor</item>
|
||||||
<item name="colorText">#FF00B322</item>
|
<item name="colorTittle">?attr/mainWindowTextColor</item>
|
||||||
<item name="colorTextBackgound">#FF000000</item>
|
<item name="colorTittleBackgound">@color/buttonBackgroundColor</item>
|
||||||
|
<item name="colorText">?attr/debugTextColor</item>
|
||||||
|
<item name="colorTextBackgound">?attr/mainWindowBackgroundColor</item>
|
||||||
|
<item name="debugTextColor">@color/debugTextColor</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- DialogStyle 对话框样式 -->
|
||||||
<style name="DialogStyle" parent="@android:style/Theme.Dialog">
|
<style name="DialogStyle" parent="@android:style/Theme.Dialog">
|
||||||
<item name="android:windowBackground">@android:color/transparent</item>
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
<item name="android:windowNoTitle">true</item>
|
<item name="android:windowNoTitle">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
1
libwinboll/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
38
libwinboll/build.gradle
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'maven-publish'
|
||||||
|
apply from: '../.winboll/winboll_lib_build.gradle'
|
||||||
|
apply from: '../.winboll/winboll_lint_build.gradle'
|
||||||
|
|
||||||
|
android {
|
||||||
|
// 适配MIUI12
|
||||||
|
compileSdkVersion 30
|
||||||
|
buildToolsVersion "30.0.3"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 26
|
||||||
|
targetSdkVersion 30
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// 网络连接类库
|
||||||
|
api 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||||
|
// Gson
|
||||||
|
api 'com.google.code.gson:gson:2.8.9'
|
||||||
|
// Html 解析
|
||||||
|
api 'org.jsoup:jsoup:1.13.1'
|
||||||
|
// 添加JSch依赖(SFTP核心,com.jcraft:jsch:0.1.54)
|
||||||
|
api 'com.jcraft:jsch:0.1.54'
|
||||||
|
|
||||||
|
// WinBoLL库 nexus.winboll.cc 地址
|
||||||
|
api 'cc.winboll.studio:libaes:15.15.2'
|
||||||
|
api 'cc.winboll.studio:libappbase:15.15.11'
|
||||||
|
|
||||||
|
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Wed May 06 12:49:48 GMT 2026
|
#Sat May 09 19:01:46 GMT 2026
|
||||||
stageCount=27
|
stageCount=27
|
||||||
libraryProject=
|
libraryProject=libwinboll
|
||||||
baseVersion=15.11
|
baseVersion=15.11
|
||||||
publishVersion=15.11.26
|
publishVersion=15.11.26
|
||||||
buildCount=25
|
buildCount=29
|
||||||
baseBetaVersion=15.11.27
|
baseBetaVersion=15.11.27
|
||||||
17
libwinboll/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# By default, the flags in this file are appended to flags specified
|
||||||
|
# in C:/tools/adt-bundle-windows-x86_64-20131030/sdk/tools/proguard/proguard-android.txt
|
||||||
|
# You can edit the include path and order by changing the proguardFiles
|
||||||
|
# directive in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# Add any project specific keep options here:
|
||||||
|
|
||||||
|
# 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 *;
|
||||||
|
#}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools" >
|
package="cc.winboll.studio.libwinboll" >
|
||||||
|
|
||||||
<application>
|
<application>
|
||||||
|
<activity
|
||||||
<!-- Put flavor specific code here -->
|
android:name=".WinBoLLLibraryActivity">
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package cc.winboll.studio.libwinboll;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import cc.winboll.studio.libappbase.ToastUtils;
|
||||||
|
|
||||||
|
public class WinBoLLLibraryActivity extends Activity
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_winbolllibrary);
|
||||||
|
|
||||||
|
ToastUtils.show("WinBoLLLibraryActivity onCreate");
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
libwinboll/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
libwinboll/src/main/res/drawable-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
libwinboll/src/main/res/drawable-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
libwinboll/src/main/res/drawable-xxhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
11
libwinboll/src/main/res/layout/activity_winbolllibrary.xml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="cc.winboll.studio.libwinboll.WinBoLLLibraryActivity"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
5
libwinboll/src/main/res/values-v21/styles.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="AppTheme" parent="@android:style/Theme.Material.Light">
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
7
libwinboll/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<string name="lib_name">libwinboll</string>
|
||||||
|
<string name="hello_world">Hello world!</string>
|
||||||
|
|
||||||
|
</resources>
|
||||||
5
libwinboll/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -72,12 +72,9 @@
|
|||||||
|
|
||||||
// WinBoLL 项目编译设置
|
// WinBoLL 项目编译设置
|
||||||
//include ':winboll'
|
//include ':winboll'
|
||||||
|
//include ':libwinboll'
|
||||||
//rootProject.name = "winboll"
|
//rootProject.name = "winboll"
|
||||||
|
|
||||||
// RegExpUtils 项目编译设置
|
// RegExpUtils 项目编译设置
|
||||||
//include ':regexputils'
|
//include ':regexputils'
|
||||||
//rootProject.name = "regexputils"
|
//rootProject.name = "regexputils"
|
||||||
|
|
||||||
// GPSRelaySentinel 项目编译设置
|
|
||||||
//include ':gpsrelaysentinel'
|
|
||||||
//rootProject.name = "gpsrelaysentinel"
|
|
||||||
|
|||||||