mirror of
http://gitea.winboll.cc/Studio/WinBoLL.git
synced 2026-06-30 04:22:24 +08:00
Compare commits
109 Commits
appbase-v1
...
appbase
| Author | SHA1 | Date | |
|---|---|---|---|
| a9ac51eb12 | |||
| bd03705240 | |||
| 8641196cdf | |||
| 49acdd7022 | |||
| 70ab6d02c3 | |||
| cb11da95ed | |||
| 73ea9147aa | |||
| 8556d3a253 | |||
| 34b982de8a | |||
| 2b37edd2b2 | |||
| fd713f5906 | |||
| 3e4044ac9c | |||
| bcbdde2197 | |||
| 54d8257e9c | |||
| 4c7dd3b3a6 | |||
| 188dcb0648 | |||
| cd41c13bd6 | |||
| 78642d7d23 | |||
| 8ba85fa51d | |||
| 589e62279d | |||
| f78caf762c | |||
| cc0ea4861d | |||
| 3ca34b513a | |||
| 780054d909 | |||
| 5028780d90 | |||
| 38da5d18d8 | |||
| 052c887177 | |||
| 5c20c6af73 | |||
| eac283319c | |||
| 7fd7a84889 | |||
| c2890807cf | |||
| 1ba5b113eb | |||
|
|
ba6b27c15c | ||
|
|
940db88af3 | ||
| 286f40c707 | |||
|
|
8a2b518a62 | ||
|
|
d3943aa5b7 | ||
| c7c953f655 | |||
|
|
86c9fbad4d | ||
|
|
e234436853 | ||
| 79d49fbc10 | |||
| 406b15ccc5 | |||
| bdefa7dec9 | |||
|
|
b931a1e0bd | ||
|
|
60afeabed0 | ||
| cbfebb921a | |||
| 208ced7af5 | |||
| bf9a89dc7a | |||
| b28054cf57 | |||
| 102aae8e66 | |||
| 9e52dc29a7 | |||
| dc622003bd | |||
| 91841962f1 | |||
|
|
ab4cef21f0 | ||
| 9071d3abd0 | |||
| d34fd0368f | |||
|
|
5185ecee3c | ||
|
|
7efd1b5f5c | ||
|
|
61933ae75b | ||
|
|
463585988d | ||
| 2754a2ad7c | |||
| da0fb646ab | |||
| 77d278501a | |||
| d2cd5f189f | |||
| 8876896cbc | |||
| d6fde41a8c | |||
| 048433b422 | |||
|
|
1b02e96088 | ||
| 28e6a8ee78 | |||
| fd45d0de01 | |||
| 9b2e5f152b | |||
| 3b6e7586be | |||
| 13f5ad2a6b | |||
| 7d872fd14c | |||
| 2b2fb495b6 | |||
| 71fd0ae1da | |||
|
|
003e1ccca2 | ||
| 3649020434 | |||
| 12ed35d807 | |||
| d6fab2133f | |||
| 45821b8daa | |||
| 9e5ec3c51f | |||
| edd312a525 | |||
| aec680e36e | |||
| 1c6f7783e5 | |||
|
|
193011a80d | ||
|
|
eb3d8f4806 | ||
| aa1b701c8b | |||
| fc20bd56b4 | |||
| e92538850f | |||
| 81b7af0ec4 | |||
| e2b4bddb61 | |||
| cbca61ad84 | |||
| 28bc3a86e3 | |||
| 79f7f682b3 | |||
| 8fa09a9f99 | |||
| 555c5deef9 | |||
| 3707891e0b | |||
| 0c9c6c9fd4 | |||
| be3d042ade | |||
|
|
33dc49267e | ||
| e3166b639e | |||
| 3d26bbe090 | |||
| cd375cefc5 | |||
| 025c095bcd | |||
| c88a0a52a8 | |||
| dc4eeefa55 | |||
| c7d79e160b | |||
|
|
771f591a3a |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -97,8 +97,9 @@ lint-results.html
|
|||||||
## WinBoLL 基础应用(避免上传敏感配置)
|
## WinBoLL 基础应用(避免上传敏感配置)
|
||||||
/winboll.properties
|
/winboll.properties
|
||||||
/local.properties
|
/local.properties
|
||||||
/settings.gradle
|
#/settings.gradle
|
||||||
/gradle.properties
|
#/gradle.properties
|
||||||
|
|
||||||
## APPBase 项目配置
|
## APPBase 项目配置
|
||||||
|
aes/
|
||||||
|
libaes/
|
||||||
|
|||||||
145
.winboll/bashMergeProjects-to-Projects_Keeper_Tag.sh
Normal file
145
.winboll/bashMergeProjects-to-Projects_Keeper_Tag.sh
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
#!/system/bin/sh
|
||||||
|
## 逻辑:按时间取最新标签 → 拉取该标签目录合并
|
||||||
|
|
||||||
|
# 按创建时间取模块最新标签(最新打的标签排最后)
|
||||||
|
get_latest_module_tag(){
|
||||||
|
local mod=$1
|
||||||
|
git for-each-ref --sort=-creatordate --format='%(refname)' refs/tags/${mod}-* \
|
||||||
|
| grep -v '\^{}' \
|
||||||
|
| head -1 \
|
||||||
|
| sed 's/refs\/tags\///'
|
||||||
|
}
|
||||||
|
|
||||||
|
# 通过标签获取commit
|
||||||
|
get_commit_from_tag(){
|
||||||
|
local tag=$1
|
||||||
|
git rev-parse --short "${tag}^{commit}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 工作目录
|
||||||
|
TARGET_DIR="/sdcard/AppProjects/Projects_Keeper_Tag"
|
||||||
|
echo "进入目录:${TARGET_DIR}"
|
||||||
|
cd "${TARGET_DIR}" || exit 1
|
||||||
|
|
||||||
|
# 同步远程
|
||||||
|
echo "========================================"
|
||||||
|
echo "同步远程分支与全部版本标签"
|
||||||
|
echo "========================================"
|
||||||
|
git fetch origin --prune
|
||||||
|
git fetch origin --tags
|
||||||
|
echo "同步完成"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 校验目标分支
|
||||||
|
NOW_BRANCH=$(git symbolic-ref --short HEAD)
|
||||||
|
TARGET_BRANCH="projects_keeper_tag"
|
||||||
|
if [ "${NOW_BRANCH}" != "${TARGET_BRANCH}" ];then
|
||||||
|
echo "错误:请先切换到 ${TARGET_BRANCH} 分支"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 目录结构校验
|
||||||
|
MERGE_OBJECTS_LIST=(
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.gitmodules
|
||||||
|
.winboll
|
||||||
|
GenKeyStore
|
||||||
|
LICENSE
|
||||||
|
LICENSE-Private-Demo
|
||||||
|
LICENSE-Private-Demo_docs
|
||||||
|
README.md
|
||||||
|
aes
|
||||||
|
appbase
|
||||||
|
autonfc
|
||||||
|
build.gradle
|
||||||
|
contacts
|
||||||
|
debugtemp
|
||||||
|
gallery
|
||||||
|
gpsrelaysentinel
|
||||||
|
gradle
|
||||||
|
gradle.properties-android-demo
|
||||||
|
gradle.properties-androidx-demo
|
||||||
|
gradlew
|
||||||
|
libaes
|
||||||
|
libappbase
|
||||||
|
libdebugtemp
|
||||||
|
libgpsrelaysentinel
|
||||||
|
libwinboll
|
||||||
|
local.properties-demo
|
||||||
|
mymessagemanager
|
||||||
|
positions
|
||||||
|
powerbell
|
||||||
|
settings.gradle-demo
|
||||||
|
winboll
|
||||||
|
winboll.properties-demo
|
||||||
|
)
|
||||||
|
|
||||||
|
REAL_ITEMS=()
|
||||||
|
while IFS= read -r line; do
|
||||||
|
[[ $line != "." && $line != ".." ]] && REAL_ITEMS+=("$line")
|
||||||
|
done < <(ls -a)
|
||||||
|
|
||||||
|
check_diff(){
|
||||||
|
local miss=() extra=()
|
||||||
|
for i in "${MERGE_OBJECTS_LIST[@]}";do
|
||||||
|
[[ ! " ${REAL_ITEMS[@]} " =~ " ${i} " ]] && miss+=("$i")
|
||||||
|
done
|
||||||
|
for i in "${REAL_ITEMS[@]}";do
|
||||||
|
[[ ! " ${MERGE_OBJECTS_LIST[@]} " =~ " ${i} " ]] && extra+=("$i")
|
||||||
|
done
|
||||||
|
if [[ ${#miss[@]} -gt 0 || ${#extra[@]} -gt 0 ]];then
|
||||||
|
echo "本地目录结构不一致,终止运行"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
check_diff
|
||||||
|
|
||||||
|
echo -e "#@@@ 按时间获取最新标签合并模块源码 @@@#"
|
||||||
|
|
||||||
|
# 应用型模块
|
||||||
|
MERGE_APP_PROJECT_LIST=(DemoAPP)
|
||||||
|
echo -e "---------- 应用型模块 ----------"
|
||||||
|
for name in "${MERGE_APP_PROJECT_LIST[@]}";do
|
||||||
|
low_name=$(echo "$name" | tr 'A-Z' 'a-z')
|
||||||
|
tag=$(get_latest_module_tag "${low_name}")
|
||||||
|
if [[ -z "${tag}" ]];then
|
||||||
|
echo "跳过 ${low_name}:无远程标签"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
commit=$(get_commit_from_tag "${tag}")
|
||||||
|
if [[ -z "${commit}" ]];then
|
||||||
|
echo "跳过 ${low_name}:标签无有效提交点"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "模块:${low_name} 最新时间标签:${tag} 提交ID:${commit}"
|
||||||
|
# 强制拉取覆盖
|
||||||
|
git checkout -f "${tag}" -- "${low_name}"
|
||||||
|
git add "${low_name}"
|
||||||
|
git commit -m "合并模块${name} 同步最新时间标签${tag}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# 类库模块
|
||||||
|
MERGE_LIB_PROJECT_LIST=(WinBoLL APPBase AES)
|
||||||
|
echo -e "---------- 类库模块 ----------"
|
||||||
|
for name in "${MERGE_LIB_PROJECT_LIST[@]}";do
|
||||||
|
low_name=$(echo "$name" | tr 'A-Z' 'a-z')
|
||||||
|
tag=$(get_latest_module_tag "${low_name}")
|
||||||
|
if [[ -z "${tag}" ]];then
|
||||||
|
echo "跳过 ${low_name}:无远程标签"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
commit=$(get_commit_from_tag "${tag}")
|
||||||
|
if [[ -z "${commit}" ]];then
|
||||||
|
echo "跳过 ${low_name}:标签无有效提交点"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "模块:${low_name} 最新时间标签:${tag} 提交ID:${commit}"
|
||||||
|
git checkout -f "${tag}" -- "${low_name}" "lib${low_name}"
|
||||||
|
git add "${low_name}" "lib${low_name}"
|
||||||
|
git commit -m "合并模块${name} 同步最新时间标签${tag}"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "全部模块合并执行完毕"
|
||||||
|
echo "执行推送:git push"
|
||||||
|
git push
|
||||||
224
.winboll/bashPublishAPKAddTag.sh.save
Normal file
224
.winboll/bashPublishAPKAddTag.sh.save
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
exit
|
||||||
|
#!/usr/bin/bash
|
||||||
|
# ==============================================================================
|
||||||
|
# WinBoLL 应用发布脚本
|
||||||
|
# 功能:检查Git源码状态 → 编译Stage Release包 → 添加WinBoLL标签 → 提交并推送源码
|
||||||
|
# 依赖:build.properties、app_update_description.txt(项目根目录下)
|
||||||
|
# 使用:./script_name.sh <APP_NAME>
|
||||||
|
# 作者:豆包&ZhanGSKen<zhangsken@qq.com>
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# ==================== 常量定义 ====================
|
||||||
|
# 脚本退出码
|
||||||
|
EXIT_CODE_SUCCESS=0
|
||||||
|
EXIT_CODE_ERR_NO_APP_NAME=2
|
||||||
|
EXIT_CODE_ERR_WORK_DIR=1
|
||||||
|
EXIT_CODE_ERR_GIT_CHECK=1
|
||||||
|
EXIT_CODE_ERR_ADD_WINBOLL_TAG=1
|
||||||
|
|
||||||
|
# Gradle 任务(正式发布)
|
||||||
|
GRADLE_TASK_PUBLISH="assembleStageRelease"
|
||||||
|
# Gradle 任务(调试用,注释备用)
|
||||||
|
# GRADLE_TASK_DEBUG="assembleBetaDebug"
|
||||||
|
|
||||||
|
# ==================== 函数定义 ====================
|
||||||
|
# 检查Git源码是否已完全提交(无未提交变更)
|
||||||
|
# 返回值:0=已完全提交,1=存在未提交变更
|
||||||
|
function checkGitSources() {
|
||||||
|
# 配置Git安全目录(解决权限问题)
|
||||||
|
git config --global --add safe.directory "$(pwd)"
|
||||||
|
|
||||||
|
# 检查是否有未提交的变更
|
||||||
|
if [[ -n $(git diff --stat) ]]; then
|
||||||
|
echo "[ERROR] Git源码存在未提交变更,请先提交所有修改!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[INFO] Git源码检查通过:所有变更已提交。"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# 询问是否添加GitHub Workflows标签(当前逻辑注释,保留扩展能力)
|
||||||
|
# 返回值:1=用户选择是,0=用户选择否
|
||||||
|
function askAddWorkflowsTag() {
|
||||||
|
read -p "是否添加GitHub Workflows标签?(Y/n) " answer
|
||||||
|
if [[ $answer =~ ^[Yy]$ ]]; then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 添加WinBoLL正式标签
|
||||||
|
# 参数:$1=应用名称(项目根目录名)
|
||||||
|
# 返回值:0=标签添加成功,1=标签已存在/添加失败
|
||||||
|
function addWinBoLLTag() {
|
||||||
|
local app_name=$1
|
||||||
|
local build_prop_path="${app_name}/build.properties"
|
||||||
|
|
||||||
|
# 从build.properties中提取publishVersion
|
||||||
|
local publish_version=$(grep -o "publishVersion=.*" "${build_prop_path}" | awk -F '=' '{print $2}')
|
||||||
|
if [[ -z ${publish_version} ]]; then
|
||||||
|
echo "[ERROR] 未从${build_prop_path}中提取到publishVersion配置!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo "[INFO] 从${build_prop_path}读取到publishVersion:${publish_version}"
|
||||||
|
|
||||||
|
# 构造WinBoLL标签(格式:<APP_NAME>-v<publishVersion>)
|
||||||
|
local tag="${app_name}-v${publish_version}"
|
||||||
|
echo "[INFO] 准备添加WinBoLL标签:${tag}"
|
||||||
|
|
||||||
|
# 检查标签是否已存在
|
||||||
|
if [[ "$(git tag -l ${tag})" == "${tag}" ]]; then
|
||||||
|
echo "[ERROR] WinBoLL标签${tag}已存在!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 添加带注释的标签(注释来自app_update_description.txt)
|
||||||
|
git tag -a "${tag}" -F "${app_name}/app_update_description.txt"
|
||||||
|
echo "[INFO] WinBoLL标签${tag}添加成功!"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# 添加GitHub Workflows Beta标签(当前逻辑注释,保留扩展能力)
|
||||||
|
# 参数:$1=应用名称(项目根目录名)
|
||||||
|
# 返回值:0=标签添加成功,1=标签已存在/添加失败
|
||||||
|
function addWorkflowsTag() {
|
||||||
|
local app_name=$1
|
||||||
|
local build_prop_path="${app_name}/build.properties"
|
||||||
|
|
||||||
|
# 从build.properties中提取baseBetaVersion
|
||||||
|
local base_beta_version=$(grep -o "baseBetaVersion=.*" "${build_prop_path}" | awk -F '=' '{print $2}')
|
||||||
|
if [[ -z ${base_beta_version} ]]; then
|
||||||
|
echo "[ERROR] 未从${build_prop_path}中提取到baseBetaVersion配置!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo "[INFO] 从${build_prop_path}读取到baseBetaVersion:${base_beta_version}"
|
||||||
|
|
||||||
|
# 构造Workflows标签(格式:<APP_NAME>-v<baseBetaVersion>-beta)
|
||||||
|
local tag="${app_name}-v${base_beta_version}-beta"
|
||||||
|
echo "[INFO] 准备添加Workflows标签:${tag}"
|
||||||
|
|
||||||
|
# 检查标签是否已存在
|
||||||
|
if [[ "$(git tag -l ${tag})" == "${tag}" ]]; then
|
||||||
|
echo "[ERROR] Workflows标签${tag}已存在!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 添加带注释的标签(注释来自app_update_description.txt)
|
||||||
|
git tag -a "${tag}" -F "${app_name}/app_update_description.txt"
|
||||||
|
echo "[INFO] Workflows标签${tag}添加成功!"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# ==================== 主流程开始 ====================
|
||||||
|
echo "============================================="
|
||||||
|
echo " WinBoLL 应用发布脚本"
|
||||||
|
echo "============================================="
|
||||||
|
|
||||||
|
# 1. 检查应用名称参数是否指定
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "[ERROR] 未指定应用名称!使用方式:${0} <APP_NAME>"
|
||||||
|
exit ${EXIT_CODE_ERR_NO_APP_NAME}
|
||||||
|
fi
|
||||||
|
APP_NAME=$1
|
||||||
|
echo "[INFO] 待发布应用名称:${APP_NAME}"
|
||||||
|
|
||||||
|
# 2. 检查并切换到项目根目录(确保build.properties存在)
|
||||||
|
echo "[INFO] 当前工作目录:$(pwd)"
|
||||||
|
if [[ ! -e "${APP_NAME}/build.properties" ]]; then
|
||||||
|
echo "[WARNING] 当前目录不存在${APP_NAME}/build.properties,尝试切换到上级目录..."
|
||||||
|
cd ..
|
||||||
|
echo "[INFO] 切换后工作目录:$(pwd)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 验证最终工作目录是否正确
|
||||||
|
if [[ ! -e "${APP_NAME}/build.properties" ]]; then
|
||||||
|
echo "[ERROR] 工作目录错误!${APP_NAME}/build.properties 文件不存在。"
|
||||||
|
exit ${EXIT_CODE_ERR_WORK_DIR}
|
||||||
|
fi
|
||||||
|
echo "[INFO] 工作目录验证通过:${APP_NAME}/build.properties 存在。"
|
||||||
|
|
||||||
|
# 3. 检查Git源码状态
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo " 步骤1:检查Git源码状态"
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
checkGitSources
|
||||||
|
if [[ $? -ne ${EXIT_CODE_SUCCESS} ]]; then
|
||||||
|
echo "[ERROR] Git源码检查失败,脚本终止!"
|
||||||
|
exit ${EXIT_CODE_ERR_GIT_CHECK}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4. 编译Stage Release版本APK
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo " 步骤2:编译Stage Release APK"
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo "[INFO] 开始执行Gradle任务:${GRADLE_TASK_PUBLISH}"
|
||||||
|
# 调试用(注释正式任务,启用调试任务)
|
||||||
|
# bash gradlew :${APP_NAME}:${GRADLE_TASK_DEBUG}
|
||||||
|
bash gradlew :${APP_NAME}:${GRADLE_TASK_PUBLISH}
|
||||||
|
|
||||||
|
if [[ $? -ne ${EXIT_CODE_SUCCESS} ]]; then
|
||||||
|
echo "[ERROR] Gradle编译任务失败!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "[INFO] Stage Release APK编译成功!"
|
||||||
|
|
||||||
|
# 5. 添加WinBoLL正式标签
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo " 步骤3:添加WinBoLL标签"
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
addWinBoLLTag ${APP_NAME}
|
||||||
|
if [[ $? -ne ${EXIT_CODE_SUCCESS} ]]; then
|
||||||
|
echo "[ERROR] WinBoLL标签添加失败,脚本终止!"
|
||||||
|
exit ${EXIT_CODE_ERR_ADD_WINBOLL_TAG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 6. (可选)添加GitHub Workflows标签(当前逻辑注释,保留扩展能力)
|
||||||
|
# echo "---------------------------------------------"
|
||||||
|
# echo " 步骤4:添加Workflows标签(可选)"
|
||||||
|
# echo "---------------------------------------------"
|
||||||
|
# echo "是否添加GitHub Workflows Beta标签?(Y/n) "
|
||||||
|
# askAddWorkflowsTag
|
||||||
|
# nAskAddWorkflowsTag=$?
|
||||||
|
# if [[ ${nAskAddWorkflowsTag} -eq 1 ]]; then
|
||||||
|
# addWorkflowsTag ${APP_NAME}
|
||||||
|
# if [[ $? -ne ${EXIT_CODE_SUCCESS} ]]; then
|
||||||
|
# echo "[ERROR] Workflows标签添加失败,脚本终止!"
|
||||||
|
# exit 1
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# 7. 清理更新描述文件
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo " 步骤5:清理更新描述文件"
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo "" > "${APP_NAME}/app_update_description.txt"
|
||||||
|
echo "[INFO] 已清空${APP_NAME}/app_update_description.txt"
|
||||||
|
|
||||||
|
# 8. 提交并推送源码与标签
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo " 步骤6:提交并推送源码"
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
git add .
|
||||||
|
git commit -m "<${APP_NAME}> 开始新的Stage版本开发。"
|
||||||
|
echo "[INFO] 源码提交成功,开始推送..."
|
||||||
|
|
||||||
|
# 推送源码到远程仓库
|
||||||
|
git push origin
|
||||||
|
# 推送标签到远程仓库
|
||||||
|
git push origin --tags
|
||||||
|
|
||||||
|
if [[ $? -eq ${EXIT_CODE_SUCCESS} ]]; then
|
||||||
|
echo "[INFO] 源码与标签推送成功!"
|
||||||
|
else
|
||||||
|
echo "[ERROR] 源码与标签推送失败!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ==================== 主流程结束 ====================
|
||||||
|
echo "============================================="
|
||||||
|
echo " WinBoLL 应用发布完成!"
|
||||||
|
echo "============================================="
|
||||||
|
exit ${EXIT_CODE_SUCCESS}
|
||||||
|
|
||||||
228
.winboll/bashPublishAPKAddTagInTermux.sh
Normal file
228
.winboll/bashPublishAPKAddTagInTermux.sh
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
# ==============================================================================
|
||||||
|
# WinBoLL 应用发布脚本
|
||||||
|
# 功能:检查Git源码状态 → 编译Stage Release包 → 添加WinBoLL标签 → 提交并推送源码
|
||||||
|
# 依赖:build.properties、app_update_description.txt(项目根目录下)
|
||||||
|
# 使用:./script_name.sh <APP_NAME>
|
||||||
|
# 作者:豆包&ZhanGSKen<zhangsken@qq.com>
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# ==================== 常量定义 ====================
|
||||||
|
# 脚本退出码
|
||||||
|
EXIT_CODE_SUCCESS=0
|
||||||
|
EXIT_CODE_ERR_NO_APP_NAME=2
|
||||||
|
EXIT_CODE_ERR_WORK_DIR=1
|
||||||
|
EXIT_CODE_ERR_GIT_CHECK=1
|
||||||
|
EXIT_CODE_ERR_ADD_WINBOLL_TAG=1
|
||||||
|
|
||||||
|
# Gradle 任务(正式发布)
|
||||||
|
GRADLE_TASK_PUBLISH="assembleStageRelease"
|
||||||
|
# Gradle 任务(调试用,注释备用)
|
||||||
|
# GRADLE_TASK_DEBUG="assembleBetaDebug"
|
||||||
|
|
||||||
|
# aapt2本地覆盖参数
|
||||||
|
AAPT2_OVERRIDE_ARG="-Pandroid.aapt2FromMavenOverride=/data/data/com.termux/files/usr/bin/aapt2"
|
||||||
|
# 禁用Gradle守护进程
|
||||||
|
GRADLE_NO_DAEMON="--no-daemon"
|
||||||
|
|
||||||
|
# ==================== 函数定义 ====================
|
||||||
|
# 检查Git源码是否已完全提交(无未提交变更)
|
||||||
|
# 返回值:0=已完全提交,1=存在未提交变更
|
||||||
|
function checkGitSources() {
|
||||||
|
# 配置Git安全目录(解决权限问题)
|
||||||
|
git config --global --add safe.directory "$(pwd)"
|
||||||
|
|
||||||
|
# 检查是否有未提交的变更
|
||||||
|
if [[ -n $(git diff --stat) ]]; then
|
||||||
|
echo "[ERROR] Git源码存在未提交变更,请先提交所有修改!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[INFO] Git源码检查通过:所有变更已提交。"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# 询问是否添加GitHub Workflows标签(当前逻辑注释,保留扩展能力)
|
||||||
|
# 返回值:1=用户选择是,0=用户选择否
|
||||||
|
function askAddWorkflowsTag() {
|
||||||
|
read -p "是否添加GitHub Workflows标签?(Y/n) " answer
|
||||||
|
if [[ $answer =~ ^[Yy]$ ]]; then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 添加WinBoLL正式标签
|
||||||
|
# 参数:$1=应用名称(项目根目录名)
|
||||||
|
# 返回值:0=标签添加成功,1=标签已存在/添加失败
|
||||||
|
function addWinBoLLTag() {
|
||||||
|
local app_name=$1
|
||||||
|
local build_prop_path="${app_name}/build.properties"
|
||||||
|
|
||||||
|
# 从build.properties中提取publishVersion
|
||||||
|
local publish_version=$(grep -o "publishVersion=.*" "${build_prop_path}" | awk -F '=' '{print $2}')
|
||||||
|
if [[ -z ${publish_version} ]]; then
|
||||||
|
echo "[ERROR] 未从${build_prop_path}中提取到publishVersion配置!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo "[INFO] 从${build_prop_path}读取到publishVersion:${publish_version}"
|
||||||
|
|
||||||
|
# 构造WinBoLL标签(格式:<APP_NAME>-v<publishVersion>)
|
||||||
|
local tag="${app_name}-v${publish_version}"
|
||||||
|
echo "[INFO] 准备添加WinBoLL标签:${tag}"
|
||||||
|
|
||||||
|
# 检查标签是否已存在
|
||||||
|
if [[ "$(git tag -l ${tag})" == "${tag}" ]]; then
|
||||||
|
echo "[ERROR] WinBoLL标签${tag}已存在!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 添加带注释的标签(注释来自app_update_description.txt)
|
||||||
|
git tag -a "${tag}" -F "${app_name}/app_update_description.txt"
|
||||||
|
echo "[INFO] WinBoLL标签${tag}添加成功!"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# 添加GitHub Workflows Beta标签(当前逻辑注释,保留扩展能力)
|
||||||
|
# 参数:$1=应用名称(项目根目录名)
|
||||||
|
# 返回值:0=标签添加成功,1=标签已存在/添加失败
|
||||||
|
function addWorkflowsTag() {
|
||||||
|
local app_name=$1
|
||||||
|
local build_prop_path="${app_name}/build.properties"
|
||||||
|
|
||||||
|
# 从build.properties中提取baseBetaVersion
|
||||||
|
local base_beta_version=$(grep -o "baseBetaVersion=.*" "${build_prop_path}" | awk -F '=' '{print $2}')
|
||||||
|
if [[ -z ${base_beta_version} ]]; then
|
||||||
|
echo "[ERROR] 未从${build_prop_path}中提取到baseBetaVersion配置!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo "[INFO] 从${build_prop_path}读取到baseBetaVersion:${base_beta_version}"
|
||||||
|
|
||||||
|
# 构造Workflows标签(格式:<APP_NAME>-v<baseBetaVersion>-beta)
|
||||||
|
local tag="${app_name}-v${base_beta_version}-beta"
|
||||||
|
echo "[INFO] 准备添加Workflows标签:${tag}"
|
||||||
|
|
||||||
|
# 检查标签是否已存在
|
||||||
|
if [[ "$(git tag -l ${tag})" == "${tag}" ]]; then
|
||||||
|
echo "[ERROR] Workflows标签${tag}已存在!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 添加带注释的标签(注释来自app_update_description.txt)
|
||||||
|
git tag -a "${tag}" -F "${app_name}/app_update_description.txt"
|
||||||
|
echo "[INFO] Workflows标签${tag}添加成功!"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# ==================== 主流程开始 ====================
|
||||||
|
echo "============================================="
|
||||||
|
echo " WinBoLL 应用发布脚本"
|
||||||
|
echo "============================================="
|
||||||
|
|
||||||
|
# 1. 检查应用名称参数是否指定
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "[ERROR] 未指定应用名称!使用方式:${0} <APP_NAME>"
|
||||||
|
exit ${EXIT_CODE_ERR_NO_APP_NAME}
|
||||||
|
fi
|
||||||
|
APP_NAME=$1
|
||||||
|
echo "[INFO] 待发布应用名称:${APP_NAME}"
|
||||||
|
|
||||||
|
# 2. 检查并切换到项目根目录(确保build.properties存在)
|
||||||
|
echo "[INFO] 当前工作目录:$(pwd)"
|
||||||
|
if [[ ! -e "${APP_NAME}/build.properties" ]]; then
|
||||||
|
echo "[WARNING] 当前目录不存在${APP_NAME}/build.properties,尝试切换到上级目录..."
|
||||||
|
cd ..
|
||||||
|
echo "[INFO] 切换后工作目录:$(pwd)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 验证最终工作目录是否正确
|
||||||
|
if [[ ! -e "${APP_NAME}/build.properties" ]]; then
|
||||||
|
echo "[ERROR] 工作目录错误!${APP_NAME}/build.properties 文件不存在。"
|
||||||
|
exit ${EXIT_CODE_ERR_WORK_DIR}
|
||||||
|
fi
|
||||||
|
echo "[INFO] 工作目录验证通过:${APP_NAME}/build.properties 存在。"
|
||||||
|
|
||||||
|
# 3. 检查Git源码状态
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo " 步骤1:检查Git源码状态"
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
checkGitSources
|
||||||
|
if [[ $? -ne ${EXIT_CODE_SUCCESS} ]]; then
|
||||||
|
echo "[ERROR] Git源码检查失败,脚本终止!"
|
||||||
|
exit ${EXIT_CODE_ERR_GIT_CHECK}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4. 编译Stage Release版本APK(携带aapt2覆盖参数 + --no-daemon)
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo " 步骤2:编译Stage Release APK"
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo "[INFO] 开始执行Gradle任务:${GRADLE_TASK_PUBLISH}"
|
||||||
|
# 调试用(注释正式任务,启用调试任务)
|
||||||
|
# bash gradlew ${AAPT2_OVERRIDE_ARG} ${GRADLE_NO_DAEMON} :${APP_NAME}:${GRADLE_TASK_DEBUG}
|
||||||
|
bash gradlew ${AAPT2_OVERRIDE_ARG} ${GRADLE_NO_DAEMON} :${APP_NAME}:${GRADLE_TASK_PUBLISH}
|
||||||
|
|
||||||
|
if [[ $? -ne ${EXIT_CODE_SUCCESS} ]]; then
|
||||||
|
echo "[ERROR] Gradle编译任务失败!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "[INFO] Stage Release APK编译成功!"
|
||||||
|
|
||||||
|
# 5. 添加WinBoLL正式标签
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo " 步骤3:添加WinBoLL标签"
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
addWinBoLLTag ${APP_NAME}
|
||||||
|
if [[ $? -ne ${EXIT_CODE_SUCCESS} ]]; then
|
||||||
|
echo "[ERROR] WinBoLL标签添加失败,脚本终止!"
|
||||||
|
exit ${EXIT_CODE_ERR_ADD_WINBOLL_TAG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 6. (可选)添加GitHub Workflows标签(当前逻辑注释,保留扩展能力)
|
||||||
|
# echo "---------------------------------------------"
|
||||||
|
# echo " 步骤4:添加Workflows标签(可选)"
|
||||||
|
# echo "---------------------------------------------"
|
||||||
|
# echo "是否添加GitHub Workflows Beta标签?(Y/n) "
|
||||||
|
# askAddWorkflowsTag
|
||||||
|
# nAskAddWorkflowsTag=$?
|
||||||
|
# if [[ ${nAskAddWorkflowsTag} -eq 1 ]]; then
|
||||||
|
# addWorkflowsTag ${APP_NAME}
|
||||||
|
# if [[ $? -ne ${EXIT_CODE_SUCCESS} ]]; then
|
||||||
|
# echo "[ERROR] Workflows标签添加失败,脚本终止!"
|
||||||
|
# exit 1
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# 7. 清理更新描述文件
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo " 步骤5:清理更新描述文件"
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo "" > "${APP_NAME}/app_update_description.txt"
|
||||||
|
echo "[INFO] 已清空${APP_NAME}/app_update_description.txt"
|
||||||
|
|
||||||
|
# 8. 提交并推送源码与标签
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo " 步骤6:提交并推送源码"
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
git add .
|
||||||
|
git commit -m "<${APP_NAME}> 开始新的Stage版本开发。"
|
||||||
|
echo "[INFO] 源码提交成功,开始推送..."
|
||||||
|
|
||||||
|
# 推送源码到远程仓库
|
||||||
|
git push origin
|
||||||
|
# 推送标签到远程仓库
|
||||||
|
git push origin --tags
|
||||||
|
|
||||||
|
if [[ $? -eq ${EXIT_CODE_SUCCESS} ]]; then
|
||||||
|
echo "[INFO] 源码与标签推送成功!"
|
||||||
|
else
|
||||||
|
echo "[ERROR] 源码与标签推送失败!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ==================== 主流程结束 ====================
|
||||||
|
echo "============================================="
|
||||||
|
echo " WinBoLL 应用发布完成!"
|
||||||
|
echo "============================================="
|
||||||
|
exit ${EXIT_CODE_SUCCESS}
|
||||||
|
|
||||||
20
.winboll/bashPublishLIBAddTagInTermux.sh
Normal file
20
.winboll/bashPublishLIBAddTagInTermux.sh
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
# aapt2本地覆盖参数
|
||||||
|
AAPT2_OVERRIDE_ARG="-Pandroid.aapt2FromMavenOverride=/data/data/com.termux/files/usr/bin/aapt2"
|
||||||
|
# Gradle禁用守护进程参数
|
||||||
|
GRADLE_NO_DAEMON="--no-daemon"
|
||||||
|
|
||||||
|
# 检查是否指定了将要发布的类库名称
|
||||||
|
# 使用 `-z` 命令检查变量是否为空
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "No Library name specified : $0"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
## 正式发布使用
|
||||||
|
git pull && bash gradlew ${AAPT2_OVERRIDE_ARG} ${GRADLE_NO_DAEMON} :$1:publishReleasePublicationToWinBoLLReleaseRepository && bash .winboll/bashCommitLibReleaseBuildFlagInfo.sh $1
|
||||||
|
|
||||||
|
## 调试使用
|
||||||
|
#bash gradlew ${AAPT2_OVERRIDE_ARG} ${GRADLE_NO_DAEMON} :$1:publishSnapshotWinBoLLPublicationToWinBoLLSnapshotRepository && bash .winboll/bashCommitLibReleaseBuildFlagInfo.sh $1
|
||||||
|
|
||||||
@@ -122,7 +122,6 @@ android {
|
|||||||
// 如果正在调试,就拷贝到 WinBoLL 备份管理文件夹
|
// 如果正在调试,就拷贝到 WinBoLL 备份管理文件夹
|
||||||
//
|
//
|
||||||
if(variant.flavorName == "beta"&&variant.buildType.name == "debug"){
|
if(variant.flavorName == "beta"&&variant.buildType.name == "debug"){
|
||||||
//File outBuildBckDir = new File(fWinBoLLStudioDir, "/${rootProject.name}/${variant.buildType.name}")
|
|
||||||
File outBuildBckDir = new File(fWinBoLLStudioDir, "/" + project.rootDir.name + "/${variant.buildType.name}")
|
File outBuildBckDir = new File(fWinBoLLStudioDir, "/" + project.rootDir.name + "/${variant.buildType.name}")
|
||||||
// 创建目标路径目录
|
// 创建目标路径目录
|
||||||
if(!outBuildBckDir.exists()) {
|
if(!outBuildBckDir.exists()) {
|
||||||
@@ -130,6 +129,7 @@ android {
|
|||||||
println "Output Folder Created.(WinBoLLStudio) : " + outBuildBckDir.getAbsolutePath()
|
println "Output Folder Created.(WinBoLLStudio) : " + outBuildBckDir.getAbsolutePath()
|
||||||
}
|
}
|
||||||
if(outBuildBckDir.exists()) {
|
if(outBuildBckDir.exists()) {
|
||||||
|
def targetApkFile = new File(outBuildBckDir, outputFileName)
|
||||||
copy{
|
copy{
|
||||||
from file.outputFile
|
from file.outputFile
|
||||||
into outBuildBckDir
|
into outBuildBckDir
|
||||||
@@ -138,6 +138,14 @@ android {
|
|||||||
}
|
}
|
||||||
println "Output APK (WinBoLLStudio): " + outBuildBckDir.getAbsolutePath() + "/${outputFileName}"
|
println "Output APK (WinBoLLStudio): " + outBuildBckDir.getAbsolutePath() + "/${outputFileName}"
|
||||||
}
|
}
|
||||||
|
// ========== 设置文件权限为775 ==========
|
||||||
|
if(targetApkFile.exists()){
|
||||||
|
exec {
|
||||||
|
commandLine 'chmod', '775', targetApkFile.absolutePath
|
||||||
|
}
|
||||||
|
println "Set file permission to 775 : ${targetApkFile.absolutePath}"
|
||||||
|
}
|
||||||
|
|
||||||
// 检查编译标志位配置
|
// 检查编译标志位配置
|
||||||
assert (winbollBuildProps['buildCount'] != null)
|
assert (winbollBuildProps['buildCount'] != null)
|
||||||
assert (winbollBuildProps['libraryProject'] != null)
|
assert (winbollBuildProps['libraryProject'] != null)
|
||||||
@@ -160,8 +168,7 @@ android {
|
|||||||
assert(libraryProjectBuildPropsFile.exists())
|
assert(libraryProjectBuildPropsFile.exists())
|
||||||
java.nio.file.Path sourceFilePath = winbollBuildPropsFile.toPath();
|
java.nio.file.Path sourceFilePath = winbollBuildPropsFile.toPath();
|
||||||
java.nio.file.Path targetFilePath = libraryProjectBuildPropsFile.toPath();
|
java.nio.file.Path targetFilePath = libraryProjectBuildPropsFile.toPath();
|
||||||
// 使用copyTo()方法复制文件,如果目标文件存在会被覆盖,可选参数可以选择不覆盖
|
java.nio.file.Files.copy(sourceFilePath, targetFilePath, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||||
java.nio.file.Files.copy(sourceFilePath, targetFilePath, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
|
|
||||||
println "\n\n>>> Library Project build.properties saved.\n\n";
|
println "\n\n>>> Library Project build.properties saved.\n\n";
|
||||||
}
|
}
|
||||||
@@ -172,16 +179,12 @@ android {
|
|||||||
//
|
//
|
||||||
if(variant.flavorName == "stage"&&variant.buildType.name == "release"){
|
if(variant.flavorName == "stage"&&variant.buildType.name == "release"){
|
||||||
// 发布 APK 文件
|
// 发布 APK 文件
|
||||||
//
|
|
||||||
// 截取版本号的版本字段为短版本名
|
|
||||||
String szVersionName = "${versionName}"
|
String szVersionName = "${versionName}"
|
||||||
String[] szlistTemp = szVersionName.split("-")
|
String[] szlistTemp = szVersionName.split("-")
|
||||||
String szShortVersionName = szlistTemp[0]
|
String szShortVersionName = szlistTemp[0]
|
||||||
//String szCommonTagAPKName = "${rootProject.name}_" + szShortVersionName + ".apk"
|
|
||||||
String szCommonTagAPKName = project.rootDir.name + "_" + szShortVersionName + ".apk"
|
String szCommonTagAPKName = project.rootDir.name + "_" + szShortVersionName + ".apk"
|
||||||
println "CommonTagAPKName is : " + szCommonTagAPKName
|
println "CommonTagAPKName is : " + szCommonTagAPKName
|
||||||
|
|
||||||
//File outTagDir = new File(fWinBoLLStudioDir, "/${rootProject.name}/tag/")
|
|
||||||
File outTagDir = new File(fWinBoLLStudioDir, "/" + project.rootDir.name + "/tag/")
|
File outTagDir = new File(fWinBoLLStudioDir, "/" + project.rootDir.name + "/tag/")
|
||||||
// 创建目标路径目录
|
// 创建目标路径目录
|
||||||
if(!outTagDir.exists()) {
|
if(!outTagDir.exists()) {
|
||||||
@@ -192,12 +195,10 @@ android {
|
|||||||
if(outTagDir.exists()) {
|
if(outTagDir.exists()) {
|
||||||
File targetAPK = new File(outTagDir, "${szCommonTagAPKName}")
|
File targetAPK = new File(outTagDir, "${szCommonTagAPKName}")
|
||||||
if(targetAPK.exists()) {
|
if(targetAPK.exists()) {
|
||||||
// 标签版本APK文件已经存在,构建拷贝任务停止
|
|
||||||
assert (!targetAPK.exists())
|
assert (!targetAPK.exists())
|
||||||
// 可选择删除并继续输出APK文件
|
|
||||||
//delete targetAPK
|
|
||||||
}
|
}
|
||||||
// 复制一个备份
|
// 复制完整版APK
|
||||||
|
def fullApkFile = new File(outTagDir, outputFileName)
|
||||||
copy{
|
copy{
|
||||||
from file.outputFile
|
from file.outputFile
|
||||||
into outTagDir
|
into outTagDir
|
||||||
@@ -206,7 +207,16 @@ android {
|
|||||||
}
|
}
|
||||||
println "Output APK (Tags): "+ outTagDir.getAbsolutePath() + "/${outputFileName}"
|
println "Output APK (Tags): "+ outTagDir.getAbsolutePath() + "/${outputFileName}"
|
||||||
}
|
}
|
||||||
// 复制一个并重命名为短版本名
|
// 设置权限775。
|
||||||
|
if(fullApkFile.exists()){
|
||||||
|
exec {
|
||||||
|
commandLine 'chmod', '775', fullApkFile.absolutePath
|
||||||
|
}
|
||||||
|
println "Set file permission to 775 : ${fullApkFile.absolutePath}"
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制短版本名APK
|
||||||
|
def shortApkFile = new File(outTagDir, szCommonTagAPKName)
|
||||||
copy{
|
copy{
|
||||||
from file.outputFile
|
from file.outputFile
|
||||||
into outTagDir
|
into outTagDir
|
||||||
@@ -215,6 +225,14 @@ android {
|
|||||||
}
|
}
|
||||||
println "Output APK (Tags): "+ outTagDir.getAbsolutePath() + "/${szCommonTagAPKName}"
|
println "Output APK (Tags): "+ outTagDir.getAbsolutePath() + "/${szCommonTagAPKName}"
|
||||||
}
|
}
|
||||||
|
// 设置权限775。
|
||||||
|
if(shortApkFile.exists()){
|
||||||
|
exec {
|
||||||
|
commandLine 'chmod', '775', shortApkFile.absolutePath
|
||||||
|
}
|
||||||
|
println "Set file permission to 775 : ${shortApkFile.absolutePath}"
|
||||||
|
}
|
||||||
|
|
||||||
// 检查编译标志位配置
|
// 检查编译标志位配置
|
||||||
assert (winbollBuildProps['stageCount'] != null)
|
assert (winbollBuildProps['stageCount'] != null)
|
||||||
assert (winbollBuildProps['publishVersion'] != null)
|
assert (winbollBuildProps['publishVersion'] != null)
|
||||||
@@ -239,14 +257,11 @@ android {
|
|||||||
fos.close();
|
fos.close();
|
||||||
|
|
||||||
if(winbollBuildProps['libraryProject'] != "") {
|
if(winbollBuildProps['libraryProject'] != "") {
|
||||||
// 如果应用 build.properties 文件设置了类库模块项目文件名
|
|
||||||
// 就拷贝一份新的编译标志配置到类库项目文件夹
|
|
||||||
File libraryProjectBuildPropsFile = new File("$RootProjectDir/" + winbollBuildProps['libraryProject'] + "/build.properties")
|
File libraryProjectBuildPropsFile = new File("$RootProjectDir/" + winbollBuildProps['libraryProject'] + "/build.properties")
|
||||||
assert(winbollBuildPropsFile.exists())
|
assert(winbollBuildPropsFile.exists())
|
||||||
assert(libraryProjectBuildPropsFile.exists())
|
assert(libraryProjectBuildPropsFile.exists())
|
||||||
java.nio.file.Path sourceFilePath = winbollBuildPropsFile.toPath();
|
java.nio.file.Path sourceFilePath = winbollBuildPropsFile.toPath();
|
||||||
java.nio.file.Path targetFilePath = libraryProjectBuildPropsFile.toPath();
|
java.nio.file.Path targetFilePath = libraryProjectBuildPropsFile.toPath();
|
||||||
// 使用copyTo()方法复制文件,如果目标文件存在会被覆盖,可选参数可以选择不覆盖
|
|
||||||
java.nio.file.Files.copy(sourceFilePath, targetFilePath, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
java.nio.file.Files.copy(sourceFilePath, targetFilePath, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,17 +278,12 @@ android {
|
|||||||
// 如果正在调试发布版,就只生成和输出APK文件,不处理 Git 仓库提交与更新问题。
|
// 如果正在调试发布版,就只生成和输出APK文件,不处理 Git 仓库提交与更新问题。
|
||||||
//
|
//
|
||||||
if(variant.flavorName == "stage"&&variant.buildType.name == "debug"){
|
if(variant.flavorName == "stage"&&variant.buildType.name == "debug"){
|
||||||
// 发布 APK 文件
|
|
||||||
//
|
|
||||||
// 截取版本号的版本字段为短版本名
|
|
||||||
String szVersionName = "${versionName}"
|
String szVersionName = "${versionName}"
|
||||||
String[] szlistTemp = szVersionName.split("-")
|
String[] szlistTemp = szVersionName.split("-")
|
||||||
String szShortVersionName = szlistTemp[0]
|
String szShortVersionName = szlistTemp[0]
|
||||||
//String szCommonTagAPKName = "${rootProject.name}_" + szShortVersionName + ".apk"
|
|
||||||
String szCommonTagAPKName = project.rootDir.name + "_" + szShortVersionName + ".apk"
|
String szCommonTagAPKName = project.rootDir.name + "_" + szShortVersionName + ".apk"
|
||||||
println "CommonTagAPKName is : " + szCommonTagAPKName
|
println "CommonTagAPKName is : " + szCommonTagAPKName
|
||||||
|
|
||||||
//File outTagDir = new File(fWinBoLLStudioDir, "/${rootProject.name}/tag/")
|
|
||||||
File outTagDir = new File(fWinBoLLStudioDir, "/" + project.rootDir.name + "/${variant.buildType.name}/")
|
File outTagDir = new File(fWinBoLLStudioDir, "/" + project.rootDir.name + "/${variant.buildType.name}/")
|
||||||
// 创建目标路径目录
|
// 创建目标路径目录
|
||||||
if(!outTagDir.exists()) {
|
if(!outTagDir.exists()) {
|
||||||
@@ -284,13 +294,11 @@ android {
|
|||||||
if(outTagDir.exists()) {
|
if(outTagDir.exists()) {
|
||||||
File targetAPK = new File(outTagDir, "${szCommonTagAPKName}")
|
File targetAPK = new File(outTagDir, "${szCommonTagAPKName}")
|
||||||
if(targetAPK.exists()) {
|
if(targetAPK.exists()) {
|
||||||
// 标签版本APK文件已经存在,构建拷贝任务停止
|
|
||||||
println '如果是在调试 Stage 版应用包构建,请删除(注:在debug目录)现有的 Stage 应用包('+targetAPK.getAbsolutePath()+')。再编译一次。'
|
println '如果是在调试 Stage 版应用包构建,请删除(注:在debug目录)现有的 Stage 应用包('+targetAPK.getAbsolutePath()+')。再编译一次。'
|
||||||
assert (!targetAPK.exists())
|
assert (!targetAPK.exists())
|
||||||
// 可选择删除并继续输出APK文件
|
|
||||||
//delete targetAPK
|
|
||||||
}
|
}
|
||||||
// 复制一个备份
|
// 复制完整版APK
|
||||||
|
def debugFullApk = new File(outTagDir, outputFileName)
|
||||||
copy{
|
copy{
|
||||||
from file.outputFile
|
from file.outputFile
|
||||||
into outTagDir
|
into outTagDir
|
||||||
@@ -299,7 +307,16 @@ android {
|
|||||||
}
|
}
|
||||||
println "Output APK (Tags): "+ outTagDir.getAbsolutePath() + "/${outputFileName}"
|
println "Output APK (Tags): "+ outTagDir.getAbsolutePath() + "/${outputFileName}"
|
||||||
}
|
}
|
||||||
// 复制一个并重命名为短版本名
|
// 权限设为775。
|
||||||
|
if(debugFullApk.exists()){
|
||||||
|
exec {
|
||||||
|
commandLine 'chmod', '775', debugFullApk.absolutePath
|
||||||
|
}
|
||||||
|
println "Set file permission to 775 : ${debugFullApk.absolutePath}"
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制短版本名APK
|
||||||
|
def debugShortApk = new File(outTagDir, szCommonTagAPKName)
|
||||||
copy{
|
copy{
|
||||||
from file.outputFile
|
from file.outputFile
|
||||||
into outTagDir
|
into outTagDir
|
||||||
@@ -308,8 +325,13 @@ android {
|
|||||||
}
|
}
|
||||||
println "Output APK (Tags): "+ outTagDir.getAbsolutePath() + "/${szCommonTagAPKName}"
|
println "Output APK (Tags): "+ outTagDir.getAbsolutePath() + "/${szCommonTagAPKName}"
|
||||||
}
|
}
|
||||||
|
// 权限设为775
|
||||||
//不保存编译标志配置
|
if(debugShortApk.exists()){
|
||||||
|
exec {
|
||||||
|
commandLine 'chmod', '775', debugShortApk.absolutePath
|
||||||
|
}
|
||||||
|
println "Set file permission to 775 : ${debugShortApk.absolutePath}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,6 +350,13 @@ android {
|
|||||||
}
|
}
|
||||||
println "Output APK (Common): " + outCommonDir.getAbsolutePath() + "/${commandAPKName}"
|
println "Output APK (Common): " + outCommonDir.getAbsolutePath() + "/${commandAPKName}"
|
||||||
}
|
}
|
||||||
|
// 额外输出文件设置775权限
|
||||||
|
if(apkFile.exists()){
|
||||||
|
exec {
|
||||||
|
commandLine 'chmod', '775', apkFile.absolutePath
|
||||||
|
}
|
||||||
|
println "Set file permission to 775 : ${apkFile.absolutePath}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ WinBoLL 安卓手机端安卓应用开发基础类库。
|
|||||||
|
|
||||||
1. Fork 本仓库
|
1. Fork 本仓库
|
||||||
2. 新建 Feat_xxx 分支
|
2. 新建 Feat_xxx 分支
|
||||||
3. 提交代码 : ZhanGSKen(ZhanGSKen<zhangsken@188.com>)
|
3. 提交代码 : ZhanGSKen(ZhanGSKen<ZhanGSKen@QQ.COM>)
|
||||||
4. 新建 Pull Request
|
4. 新建 Pull Request
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Tue May 19 20:49:13 HKT 2026
|
#Sun Jun 28 20:55:57 HKT 2026
|
||||||
stageCount=18
|
stageCount=35
|
||||||
libraryProject=libappbase
|
libraryProject=libappbase
|
||||||
baseVersion=15.20
|
baseVersion=15.20
|
||||||
publishVersion=15.20.17
|
publishVersion=15.20.34
|
||||||
buildCount=0
|
buildCount=0
|
||||||
baseBetaVersion=15.20.18
|
baseBetaVersion=15.20.35
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class AboutActivity extends Activity {
|
|||||||
appInfo.setAppName("APPBase");
|
appInfo.setAppName("APPBase");
|
||||||
appInfo.setAppIcon(R.drawable.ic_winboll);
|
appInfo.setAppIcon(R.drawable.ic_winboll);
|
||||||
appInfo.setAppDescription(getString(R.string.app_description));
|
appInfo.setAppDescription(getString(R.string.app_description));
|
||||||
appInfo.setAppGitName("APPBase");
|
appInfo.setAppGitName("WinBoLL");
|
||||||
appInfo.setAppGitOwner("Studio");
|
appInfo.setAppGitOwner("Studio");
|
||||||
appInfo.setAppGitAPPBranch(branchName);
|
appInfo.setAppGitAPPBranch(branchName);
|
||||||
appInfo.setAppGitAPPSubProjectFolder(branchName);
|
appInfo.setAppGitAPPSubProjectFolder(branchName);
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package cc.winboll.studio.appbase;
|
package cc.winboll.studio.appbase;
|
||||||
|
|
||||||
|
import cc.winboll.studio.libappbase.CrashActivity;
|
||||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||||
import cc.winboll.studio.libappbase.ToastUtils;
|
import cc.winboll.studio.libappbase.ToastUtils;
|
||||||
import cc.winboll.studio.libappbase.BuildConfig;
|
import cc.winboll.studio.libappbase.utils.CrashHandleNotifyUtils;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen<zhangsken@qq.com>
|
* @Author ZhanGSKen<zhangsken@qq.com>
|
||||||
@@ -21,16 +24,24 @@ public class App extends GlobalApplication {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
try {
|
||||||
// 如果应用不在调试状态,就根据编译类型设置调试状态
|
super.onCreate();
|
||||||
if (isDebugging() != true) {
|
|
||||||
setIsDebugging(BuildConfig.DEBUG);
|
|
||||||
}
|
|
||||||
// release 版调试码
|
|
||||||
//setIsDebugging(!BuildConfig.DEBUG);
|
|
||||||
|
|
||||||
// 初始化 Toast 工具类(传入应用全局上下文,确保 Toast 可在任意地方调用)
|
// 初始化 Toast 工具类(传入应用全局上下文,确保 Toast 可在任意地方调用)
|
||||||
ToastUtils.init(getApplicationContext());
|
ToastUtils.init(getApplicationContext());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
e.printStackTrace(pw);
|
||||||
|
pw.close();
|
||||||
|
String stackTraceStr = sw.toString();
|
||||||
|
CrashHandleNotifyUtils.handleUncaughtException(
|
||||||
|
this,
|
||||||
|
getPackageName(),
|
||||||
|
stackTraceStr,
|
||||||
|
CrashActivity.class
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package cc.winboll.studio.appbase.model;
|
|||||||
|
|
||||||
import android.util.JsonReader;
|
import android.util.JsonReader;
|
||||||
import android.util.JsonWriter;
|
import android.util.JsonWriter;
|
||||||
import cc.winboll.studio.libappbase.BaseBean;
|
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
import cc.winboll.studio.libappbase.models.libs1520000.BaseBean;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
14
build.gradle
14
build.gradle
@@ -1,9 +1,6 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://maven.aliyun.com/repository/public/' }
|
|
||||||
maven { url 'https://maven.aliyun.com/repository/google/' }
|
|
||||||
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
|
|
||||||
maven { url 'https://dl.bintray.com/ppartisan/maven/' }
|
maven { url 'https://dl.bintray.com/ppartisan/maven/' }
|
||||||
maven { url "https://clojars.org/repo/" }
|
maven { url "https://clojars.org/repo/" }
|
||||||
maven { url "https://jitpack.io" }
|
maven { url "https://jitpack.io" }
|
||||||
@@ -17,9 +14,9 @@ buildscript {
|
|||||||
|
|
||||||
// Nexus Maven 库地址
|
// Nexus Maven 库地址
|
||||||
// "WinBoLL Release"
|
// "WinBoLL Release"
|
||||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
maven { url "https://nexus.zhangsken.cc/repository/maven-public/" }
|
||||||
// "WinBoLL Snapshot"
|
// "WinBoLL Snapshot"
|
||||||
maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" }
|
maven { url "https://nexus.zhangsken.cc/repository/maven-snapshots/" }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
// 适配MIUI12
|
// 适配MIUI12
|
||||||
@@ -31,9 +28,6 @@ buildscript {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://maven.aliyun.com/repository/public/' }
|
|
||||||
maven { url 'https://maven.aliyun.com/repository/google/' }
|
|
||||||
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
|
|
||||||
maven { url 'https://dl.bintray.com/ppartisan/maven/' }
|
maven { url 'https://dl.bintray.com/ppartisan/maven/' }
|
||||||
maven { url "https://clojars.org/repo/" }
|
maven { url "https://clojars.org/repo/" }
|
||||||
maven { url "https://jitpack.io" }
|
maven { url "https://jitpack.io" }
|
||||||
@@ -47,9 +41,9 @@ allprojects {
|
|||||||
|
|
||||||
// Nexus Maven 库地址
|
// Nexus Maven 库地址
|
||||||
// "WinBoLL Release"
|
// "WinBoLL Release"
|
||||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
maven { url "https://nexus.zhangsken.cc/repository/maven-public/" }
|
||||||
// "WinBoLL Snapshot"
|
// "WinBoLL Snapshot"
|
||||||
maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" }
|
maven { url "https://nexus.zhangsken.cc/repository/maven-snapshots/" }
|
||||||
}
|
}
|
||||||
ext {
|
ext {
|
||||||
// 定义全局变量,常用于版本管理
|
// 定义全局变量,常用于版本管理
|
||||||
|
|||||||
22
gradle.properties
Normal file
22
gradle.properties
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx2048m
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app"s APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.useAndroidX=false
|
||||||
|
# Automatically convert third-party libraries to use AndroidX
|
||||||
|
android.enableJetifier=false
|
||||||
|
# 保持与旧版Gradle插件的兼容
|
||||||
|
android.disableAutomaticComponentCreation=true
|
||||||
|
#org.gradle.daemon=false
|
||||||
@@ -19,3 +19,4 @@ android.useAndroidX=false
|
|||||||
android.enableJetifier=false
|
android.enableJetifier=false
|
||||||
# 保持与旧版Gradle插件的兼容
|
# 保持与旧版Gradle插件的兼容
|
||||||
android.disableAutomaticComponentCreation=true
|
android.disableAutomaticComponentCreation=true
|
||||||
|
org.gradle.daemon=false
|
||||||
|
|||||||
@@ -19,3 +19,4 @@ android.useAndroidX=true
|
|||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
# 保持与旧版Gradle插件的兼容
|
# 保持与旧版Gradle插件的兼容
|
||||||
android.disableAutomaticComponentCreation=true
|
android.disableAutomaticComponentCreation=true
|
||||||
|
org.gradle.daemon=false
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Tue May 19 20:49:13 HKT 2026
|
#Sun Jun 28 20:55:33 HKT 2026
|
||||||
stageCount=18
|
stageCount=35
|
||||||
libraryProject=libappbase
|
libraryProject=libappbase
|
||||||
baseVersion=15.20
|
baseVersion=15.20
|
||||||
publishVersion=15.20.17
|
publishVersion=15.20.34
|
||||||
buildCount=0
|
buildCount=0
|
||||||
baseBetaVersion=15.20.18
|
baseBetaVersion=15.20.35
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
android:networkSecurityConfig="@xml/network_security_config">
|
android:networkSecurityConfig="@xml/network_security_config">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".CrashHandler$CrashActivity"
|
android:name=".CrashActivity"
|
||||||
android:label="CrashActivity"
|
android:label="CrashActivity"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
android:process=":CrashActivity"/>
|
android:process=":CrashActivity"/>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cc.winboll.studio.libappbase;
|
|||||||
|
|
||||||
import android.util.JsonReader;
|
import android.util.JsonReader;
|
||||||
import android.util.JsonWriter;
|
import android.util.JsonWriter;
|
||||||
|
import cc.winboll.studio.libappbase.models.libs1520000.BaseBean;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,436 +0,0 @@
|
|||||||
package cc.winboll.studio.libappbase;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.JsonReader;
|
|
||||||
import android.util.JsonWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
|
||||||
* @Date 2025/11/11 20:03
|
|
||||||
* @Describe WinBoLL JSON 数据模型基类(抽象类)
|
|
||||||
* 定义 Json Bean 的核心规范:序列化/反序列化、文件持久化、列表处理等通用逻辑,
|
|
||||||
* 子类(如 APPModel)需实现抽象方法,实现自身字段的 JSON 读写
|
|
||||||
* @param <T> 泛型约束,限定子类必须继承自 BaseBean
|
|
||||||
*/
|
|
||||||
public abstract class BaseBean<T extends BaseBean> {
|
|
||||||
|
|
||||||
/** 日志标签,用于当前基类的日志输出标识 */
|
|
||||||
public static final String TAG = "BaseBean";
|
|
||||||
/** JSON 中存储 Bean 类名的字段键(用于校验 Bean 类型一致性) */
|
|
||||||
static final String BEAN_NAME = "BeanName";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 无参构造方法(子类需默认实现,支持反射实例化)
|
|
||||||
*/
|
|
||||||
public BaseBean() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 抽象方法:获取当前 Bean 的全限定类名
|
|
||||||
* 子类需实现,用于标识 Bean 类型(序列化/校验时使用)
|
|
||||||
* @return 类的全限定名(如:cc.winboll.studio.libappbase.APPModel)
|
|
||||||
*/
|
|
||||||
public abstract String getName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单个 Bean 的 JSON 持久化文件路径
|
|
||||||
* 路径:外部存储/应用私有目录/BaseBean/[类名].json
|
|
||||||
* @param context 上下文(用于获取应用存储目录)
|
|
||||||
* @return 单个 Bean 的文件绝对路径
|
|
||||||
*/
|
|
||||||
public String getBeanJsonFilePath(Context context) {
|
|
||||||
return context.getExternalFilesDir(TAG) + "/" + getName() + ".json";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取 Bean 列表的 JSON 持久化文件路径
|
|
||||||
* 路径:外部存储/应用私有目录/BaseBean/[类名]_List.json
|
|
||||||
* @param context 上下文(用于获取应用存储目录)
|
|
||||||
* @return Bean 列表的文件绝对路径
|
|
||||||
*/
|
|
||||||
public String getBeanListJsonFilePath(Context context) {
|
|
||||||
return context.getExternalFilesDir(TAG) + "/" + getName() + "_List.json";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将 Bean 类名写入 JSON(序列化基础字段)
|
|
||||||
* 子类可重写扩展,添加自身字段的 JSON 写入逻辑
|
|
||||||
* @param jsonWriter JSON 写入器(用于输出 JSON 数据)
|
|
||||||
* @throws IOException JSON 写入失败时抛出(如流异常)
|
|
||||||
*/
|
|
||||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
|
||||||
// 写入 Bean 类名字段(用于反序列化时校验类型)
|
|
||||||
jsonWriter.name(BEAN_NAME).value(getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从 JSON 读取字段并初始化 Bean(反序列化基础逻辑)
|
|
||||||
* 子类需重写,实现自身字段的解析逻辑
|
|
||||||
* @param jsonReader JSON 读取器(用于读取 JSON 数据)
|
|
||||||
* @param name 当前解析的 JSON 字段名
|
|
||||||
* @return true:字段解析成功(当前类处理);false:字段未处理(需跳过)
|
|
||||||
* @throws IOException JSON 读取失败时抛出(如流异常)
|
|
||||||
*/
|
|
||||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
|
||||||
return false; // 基类未处理任何字段,返回 false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 抽象方法:从 JSON 读取器解析并返回 Bean 实例
|
|
||||||
* 子类需实现,处理自身字段的完整解析逻辑
|
|
||||||
* @param jsonReader JSON 读取器(用于读取 JSON 数据)
|
|
||||||
* @return 解析完成的 Bean 实例
|
|
||||||
* @throws IOException JSON 读取失败时抛出(如流异常)
|
|
||||||
*/
|
|
||||||
abstract public T readBeanFromJsonReader(JsonReader jsonReader) throws IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验 JSON 文件中的 Bean 列表与目标类是否一致
|
|
||||||
* 对比文件中每个 Bean 的类名与目标类名,返回不一致信息
|
|
||||||
* @param szFilePath JSON 文件路径(存储 Bean 列表的文件)
|
|
||||||
* @param clazz 目标 Bean 类(用于校验类型)
|
|
||||||
* @return 空串:校验一致;非空串:不一致信息(总数/差异数)或异常信息
|
|
||||||
* @param <T> 泛型约束,限定为 BaseBean 子类
|
|
||||||
*/
|
|
||||||
public static <T extends BaseBean> String checkIsTheSameBeanListAndFile(String szFilePath, Class<T> clazz) {
|
|
||||||
StringBuilder sbResult = new StringBuilder();
|
|
||||||
String szErrorInfo = "Check Is The Same Bean List And File Error : ";
|
|
||||||
|
|
||||||
try {
|
|
||||||
int sameCount = 0; // 类名匹配的 Bean 数量
|
|
||||||
int totalCount = 0; // 文件中 Bean 总数量
|
|
||||||
|
|
||||||
// 反射创建目标 Bean 实例(用于获取类名)
|
|
||||||
T beanTemp = clazz.newInstance();
|
|
||||||
String targetBeanName = beanTemp.getName();
|
|
||||||
// 读取文件中的 JSON 字符串
|
|
||||||
String listJson = UTF8FileUtils.readStringFromFile(szFilePath);
|
|
||||||
StringReader stringReader = new StringReader(listJson);
|
|
||||||
JsonReader jsonReader = new JsonReader(stringReader);
|
|
||||||
|
|
||||||
jsonReader.beginArray(); // 开始解析 JSON 数组(Bean 列表)
|
|
||||||
while (jsonReader.hasNext()) {
|
|
||||||
totalCount++;
|
|
||||||
jsonReader.beginObject(); // 开始解析单个 Bean 对象
|
|
||||||
while (jsonReader.hasNext()) {
|
|
||||||
String name = jsonReader.nextName();
|
|
||||||
// 只校验 BEAN_NAME 字段,其他字段跳过
|
|
||||||
if (name.equals(BEAN_NAME)) {
|
|
||||||
// 对比当前 Bean 类名与目标类名
|
|
||||||
if (targetBeanName.equals(jsonReader.nextString())) {
|
|
||||||
sameCount++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
jsonReader.skipValue(); // 跳过非目标字段
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jsonReader.endObject(); // 结束单个 Bean 对象解析
|
|
||||||
}
|
|
||||||
jsonReader.endArray(); // 结束 JSON 数组解析
|
|
||||||
|
|
||||||
// 生成校验结果
|
|
||||||
if (sameCount == totalCount) {
|
|
||||||
return ""; // 全部匹配,返回空串
|
|
||||||
} else {
|
|
||||||
// 部分不匹配,返回统计信息
|
|
||||||
sbResult.append("Total : ").append(totalCount)
|
|
||||||
.append(" Diff : ").append(totalCount - sameCount);
|
|
||||||
}
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
// 反射实例化失败(如无无参构造)
|
|
||||||
sbResult.append(szErrorInfo).append(e);
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
// 反射访问权限异常
|
|
||||||
sbResult.append(szErrorInfo).append(e);
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
} catch (IOException e) {
|
|
||||||
// 文件读取或 JSON 解析异常
|
|
||||||
sbResult.append(szErrorInfo).append(e);
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return sbResult.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将 JSON 字符串解析为目标 Bean 实例
|
|
||||||
* 通过反射创建 Bean 实例,调用子类解析逻辑完成初始化
|
|
||||||
* @param szBean JSON 字符串(单个 Bean 的 JSON 数据)
|
|
||||||
* @param clazz 目标 Bean 类(用于反射实例化)
|
|
||||||
* @return 解析成功的 Bean 实例;失败返回 null
|
|
||||||
* @throws IOException JSON 解析失败时抛出
|
|
||||||
* @param <T> 泛型约束,限定为 BaseBean 子类
|
|
||||||
*/
|
|
||||||
public static <T extends BaseBean> T parseStringToBean(String szBean, Class<T> clazz) throws IOException {
|
|
||||||
StringReader stringReader = new StringReader(szBean);
|
|
||||||
JsonReader jsonReader = new JsonReader(stringReader);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 反射创建 Bean 实例
|
|
||||||
T beanTemp = clazz.newInstance();
|
|
||||||
// 调用子类解析方法,返回解析后的实例
|
|
||||||
return (T) beanTemp.readBeanFromJsonReader(jsonReader);
|
|
||||||
} catch (InstantiationException | IllegalAccessException e) {
|
|
||||||
// 反射异常日志记录
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将 JSON 字符串解析为 Bean 列表
|
|
||||||
* 清空目标列表,将解析后的 Bean 逐个添加到列表中
|
|
||||||
* @param szBeanList JSON 字符串(Bean 列表的 JSON 数组)
|
|
||||||
* @param beanList 目标列表(存储解析后的 Bean)
|
|
||||||
* @param clazz 目标 Bean 类(用于反射实例化)
|
|
||||||
* @return true:解析成功;false:解析失败
|
|
||||||
* @param <T> 泛型约束,限定为 BaseBean 子类
|
|
||||||
*/
|
|
||||||
public static <T extends BaseBean> boolean parseStringToBeanList(String szBeanList, ArrayList<T> beanList, Class<T> clazz) {
|
|
||||||
try {
|
|
||||||
// 初始化目标列表(为空则创建,非空则清空)
|
|
||||||
if (beanList == null) {
|
|
||||||
beanList = new ArrayList<T>();
|
|
||||||
} else {
|
|
||||||
beanList.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
StringReader stringReader = new StringReader(szBeanList);
|
|
||||||
JsonReader jsonReader = new JsonReader(stringReader);
|
|
||||||
|
|
||||||
jsonReader.beginArray(); // 开始解析 JSON 数组
|
|
||||||
while (jsonReader.hasNext()) {
|
|
||||||
// 反射创建 Bean 实例,解析并添加到列表
|
|
||||||
T beanTemp = clazz.newInstance();
|
|
||||||
T bean = (T) beanTemp.readBeanFromJsonReader(jsonReader);
|
|
||||||
if (bean != null) {
|
|
||||||
beanList.add(bean);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jsonReader.endArray(); // 结束 JSON 数组解析
|
|
||||||
return true;
|
|
||||||
} catch (InstantiationException | IllegalAccessException | IOException e) {
|
|
||||||
// 异常日志记录
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 重写 toString(),将 Bean 序列化为格式化的 JSON 字符串
|
|
||||||
* 调用自身序列化逻辑,生成带缩进的 JSON(便于调试)
|
|
||||||
* @return Bean 的 JSON 字符串;失败返回空串
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringWriter stringWriter = new StringWriter();
|
|
||||||
JsonWriter jsonWriter = new JsonWriter(stringWriter);
|
|
||||||
jsonWriter.setIndent(" "); // 设置 JSON 缩进(格式化输出)
|
|
||||||
|
|
||||||
try {
|
|
||||||
jsonWriter.beginObject(); // 开始 JSON 对象
|
|
||||||
writeThisToJsonWriter(jsonWriter); // 写入 Bean 字段(子类扩展)
|
|
||||||
jsonWriter.endObject(); // 结束 JSON 对象
|
|
||||||
return stringWriter.toString();
|
|
||||||
} catch (IOException e) {
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将 Bean 列表序列化为格式化的 JSON 字符串
|
|
||||||
* 遍历列表,逐个序列化每个 Bean,生成 JSON 数组
|
|
||||||
* @param beanList 待序列化的 Bean 列表
|
|
||||||
* @return 列表的 JSON 字符串;失败返回空串
|
|
||||||
* @param <T> 泛型约束,限定为 BaseBean 子类
|
|
||||||
*/
|
|
||||||
public static <T extends BaseBean> String toStringByBeanList(ArrayList<T> beanList) {
|
|
||||||
try {
|
|
||||||
StringWriter stringWriter = new StringWriter();
|
|
||||||
JsonWriter jsonWriter = new JsonWriter(stringWriter);
|
|
||||||
jsonWriter.setIndent(" "); // 格式化缩进
|
|
||||||
|
|
||||||
jsonWriter.beginArray(); // 开始 JSON 数组
|
|
||||||
for (int i = 0; i < beanList.size(); i++) {
|
|
||||||
jsonWriter.beginObject(); // 单个 Bean 开始
|
|
||||||
beanList.get(i).writeThisToJsonWriter(jsonWriter); // 调用 Bean 自身序列化
|
|
||||||
jsonWriter.endObject(); // 单个 Bean 结束
|
|
||||||
}
|
|
||||||
jsonWriter.endArray(); // 结束 JSON 数组
|
|
||||||
jsonWriter.close();
|
|
||||||
return stringWriter.toString();
|
|
||||||
} catch (IOException e) {
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从默认路径(getBeanJsonFilePath)加载 Bean 实例
|
|
||||||
* 读取应用私有目录下的 JSON 文件,解析为目标 Bean
|
|
||||||
* @param context 上下文(用于获取文件路径)
|
|
||||||
* @param clazz 目标 Bean 类(用于反射实例化)
|
|
||||||
* @return 加载成功的 Bean 实例;失败返回 null
|
|
||||||
* @param <T> 泛型约束,限定为 BaseBean 子类
|
|
||||||
*/
|
|
||||||
public static <T extends BaseBean> T loadBean(Context context, Class<T> clazz) {
|
|
||||||
try {
|
|
||||||
// 反射创建 Bean 实例,获取默认文件路径
|
|
||||||
T beanTemp = clazz.newInstance();
|
|
||||||
return loadBeanFromFile(beanTemp.getBeanJsonFilePath(context), clazz);
|
|
||||||
} catch (InstantiationException | IllegalAccessException e) {
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从指定文件路径加载 Bean 实例
|
|
||||||
* 检查文件是否存在,存在则读取 JSON 并解析为目标 Bean
|
|
||||||
* @param szFilePath 目标文件路径(存储 Bean 的 JSON 文件)
|
|
||||||
* @param clazz 目标 Bean 类(用于反射实例化)
|
|
||||||
* @return 加载成功的 Bean 实例;失败返回 null
|
|
||||||
* @param <T> 泛型约束,限定为 BaseBean 子类
|
|
||||||
*/
|
|
||||||
public static <T extends BaseBean> T loadBeanFromFile(String szFilePath, Class<T> clazz) {
|
|
||||||
try {
|
|
||||||
File file = new File(szFilePath);
|
|
||||||
if (file.exists()) { // 检查文件是否存在
|
|
||||||
T beanTemp = clazz.newInstance();
|
|
||||||
// 读取文件 JSON 字符串,解析为 Bean
|
|
||||||
String json = UTF8FileUtils.readStringFromFile(szFilePath);
|
|
||||||
return beanTemp.parseStringToBean(json, clazz);
|
|
||||||
}
|
|
||||||
} catch (InstantiationException | IllegalAccessException | IOException e) {
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将 Bean 保存到默认路径(getBeanJsonFilePath)的文件中
|
|
||||||
* 序列化 Bean 为 JSON,写入应用私有目录下的文件
|
|
||||||
* @param context 上下文(用于获取文件路径)
|
|
||||||
* @param bean 待保存的 Bean 实例
|
|
||||||
* @return true:保存成功;false:保存失败
|
|
||||||
* @param <T> 泛型约束,限定为 BaseBean 子类
|
|
||||||
*/
|
|
||||||
public static <T extends BaseBean> boolean saveBean(Context context, T bean) {
|
|
||||||
return saveBeanToFile(bean.getBeanJsonFilePath(context), bean);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将 Bean 保存到指定文件路径
|
|
||||||
* 序列化 Bean 为 JSON 字符串,写入目标文件(覆盖原有内容)
|
|
||||||
* @param szFilePath 目标文件路径(保存 JSON 的文件)
|
|
||||||
* @param bean 待保存的 Bean 实例
|
|
||||||
* @return true:保存成功;false:保存失败
|
|
||||||
* @param <T> 泛型约束,限定为 BaseBean 子类
|
|
||||||
*/
|
|
||||||
public static <T extends BaseBean> boolean saveBeanToFile(String szFilePath, T bean) {
|
|
||||||
try {
|
|
||||||
// 序列化 Bean 为 JSON 字符串
|
|
||||||
String json = bean.toString();
|
|
||||||
// 写入文件(UTF-8 编码)
|
|
||||||
UTF8FileUtils.writeStringToFile(szFilePath, json);
|
|
||||||
return true;
|
|
||||||
} catch (IOException e) {
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从默认路径(getBeanListJsonFilePath)加载 Bean 列表
|
|
||||||
* 读取应用私有目录下的列表 JSON 文件,解析并填充到目标列表
|
|
||||||
* @param context 上下文(用于获取文件路径)
|
|
||||||
* @param beanListDst 目标列表(存储加载后的 Bean)
|
|
||||||
* @param clazz 目标 Bean 类(用于反射实例化)
|
|
||||||
* @return true:加载成功;false:加载失败
|
|
||||||
* @param <T> 泛型约束,限定为 BaseBean 子类
|
|
||||||
*/
|
|
||||||
public static <T extends BaseBean> boolean loadBeanList(Context context, ArrayList<T> beanListDst, Class<T> clazz) {
|
|
||||||
try {
|
|
||||||
// 反射创建 Bean 实例,获取默认列表文件路径
|
|
||||||
T beanTemp = clazz.newInstance();
|
|
||||||
return loadBeanListFromFile(beanTemp.getBeanListJsonFilePath(context), beanListDst, clazz);
|
|
||||||
} catch (InstantiationException | IllegalAccessException e) {
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从指定文件路径加载 Bean 列表
|
|
||||||
* 检查文件是否存在,存在则读取 JSON 数组,解析并填充到目标列表
|
|
||||||
* @param szFilePath 目标文件路径(存储列表 JSON 的文件)
|
|
||||||
* @param beanList 目标列表(存储加载后的 Bean)
|
|
||||||
* @param clazz 目标 Bean 类(用于反射实例化)
|
|
||||||
* @return true:加载成功;false:加载失败
|
|
||||||
* @param <T> 泛型约束,限定为 BaseBean 子类
|
|
||||||
*/
|
|
||||||
public static <T extends BaseBean> boolean loadBeanListFromFile(String szFilePath, ArrayList<T> beanList, Class<T> clazz) {
|
|
||||||
try {
|
|
||||||
File file = new File(szFilePath);
|
|
||||||
if (file.exists()) { // 检查文件是否存在
|
|
||||||
// 读取文件中的 JSON 字符串(Bean 列表数组)
|
|
||||||
String listJson = UTF8FileUtils.readStringFromFile(szFilePath);
|
|
||||||
// 解析 JSON 字符串为 Bean 列表,填充到目标列表
|
|
||||||
return parseStringToBeanList(listJson, beanList, clazz);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
// 日志记录文件读取或解析异常
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将 Bean 列表保存到默认路径(getBeanListJsonFilePath)的文件中
|
|
||||||
* 序列化列表为 JSON 数组,写入应用私有目录下的文件
|
|
||||||
* @param context 上下文(用于获取文件路径)
|
|
||||||
* @param beanList 待保存的 Bean 列表
|
|
||||||
* @param clazz 目标 Bean 类(用于反射获取保存路径)
|
|
||||||
* @return true:保存成功;false:保存失败
|
|
||||||
* @param <T> 泛型约束,限定为 BaseBean 子类
|
|
||||||
*/
|
|
||||||
public static <T extends BaseBean> boolean saveBeanList(Context context, ArrayList<T> beanList, Class<T> clazz) {
|
|
||||||
try {
|
|
||||||
// 反射创建 Bean 实例,获取默认列表保存路径
|
|
||||||
T beanTemp = clazz.newInstance();
|
|
||||||
return saveBeanListToFile(beanTemp.getBeanListJsonFilePath(context), beanList);
|
|
||||||
} catch (InstantiationException | IllegalAccessException e) {
|
|
||||||
// 日志记录反射实例化异常
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将 Bean 列表保存到指定文件路径
|
|
||||||
* 序列化列表为 JSON 数组字符串,写入目标文件(覆盖原有内容)
|
|
||||||
* @param szFilePath 目标文件路径(保存列表 JSON 的文件)
|
|
||||||
* @param beanList 待保存的 Bean 列表
|
|
||||||
* @return true:保存成功;false:保存失败
|
|
||||||
* @param <T> 泛型约束,限定为 BaseBean 子类
|
|
||||||
*/
|
|
||||||
public static <T extends BaseBean> boolean saveBeanListToFile(String szFilePath, ArrayList<T> beanList) {
|
|
||||||
try {
|
|
||||||
// 序列化 Bean 列表为 JSON 字符串(数组格式)
|
|
||||||
String json = toStringByBeanList(beanList);
|
|
||||||
// 将 JSON 字符串写入文件(UTF-8 编码)
|
|
||||||
UTF8FileUtils.writeStringToFile(szFilePath, json);
|
|
||||||
return true;
|
|
||||||
} catch (IOException e) {
|
|
||||||
// 日志记录文件写入或序列化异常
|
|
||||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package cc.winboll.studio.libappbase;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.os.Bundle;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public final class CrashActivity extends Activity implements MenuItem.OnMenuItemClickListener {
|
||||||
|
private static final int MENUITEM_COPY = 0;
|
||||||
|
private static final int MENUITEM_RESTART = 1;
|
||||||
|
|
||||||
|
private String mLog;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
AppCrashSafetyWire.getInstance().postResumeCrashSafetyWireHandler(getApplicationContext());
|
||||||
|
mLog = getIntent().getStringExtra(CrashHandler.EXTRA_CRASH_LOG);
|
||||||
|
setTheme(android.R.style.Theme_DeviceDefault_Light_DarkActionBar);
|
||||||
|
initLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initLayout() {
|
||||||
|
ScrollView contentView = new ScrollView(this);
|
||||||
|
contentView.setFillViewport(true);
|
||||||
|
|
||||||
|
HorizontalScrollView hw = new HorizontalScrollView(this);
|
||||||
|
hw.setBackgroundColor(0xFFF5F5F5);
|
||||||
|
|
||||||
|
TextView message = new TextView(this);
|
||||||
|
final int padding = dp2px(16);
|
||||||
|
message.setPadding(padding, padding, padding, padding);
|
||||||
|
message.setText(mLog);
|
||||||
|
message.setTextColor(0xFF000000);
|
||||||
|
message.setTextIsSelectable(true);
|
||||||
|
|
||||||
|
hw.addView(message);
|
||||||
|
contentView.addView(hw, ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
|
setContentView(contentView);
|
||||||
|
|
||||||
|
getActionBar().setTitle(CrashHandler.TITTLE);
|
||||||
|
getActionBar().setSubtitle(GlobalApplication.getAppName(getApplicationContext()) + " Error");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
restartApp();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int dp2px(final float dpValue) {
|
||||||
|
final float scale = Resources.getSystem().getDisplayMetrics().density;
|
||||||
|
return (int) (dpValue * scale + 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||||
|
menu.add(0, MENUITEM_COPY, 0, "Copy")
|
||||||
|
.setOnMenuItemClickListener(this)
|
||||||
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
|
|
||||||
|
menu.add(0, MENUITEM_RESTART, 0, "Restart")
|
||||||
|
.setOnMenuItemClickListener(this)
|
||||||
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +1,13 @@
|
|||||||
package cc.winboll.studio.libappbase;
|
package cc.winboll.studio.libappbase;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
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.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
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.utils.CrashHandleNotifyUtils;
|
import cc.winboll.studio.libappbase.utils.CrashHandleNotifyUtils;
|
||||||
|
|
||||||
@@ -220,111 +206,5 @@ public final class CrashHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================== 内部Activity页面 ======================
|
|
||||||
/**
|
|
||||||
* 基础极简崩溃页面
|
|
||||||
* 保险丝熔断时启动,避免复杂布局二次崩溃
|
|
||||||
*/
|
|
||||||
public static final class CrashActivity extends Activity implements MenuItem.OnMenuItemClickListener {
|
|
||||||
private static final int MENUITEM_COPY = 0;
|
|
||||||
private static final int MENUITEM_RESTART = 1;
|
|
||||||
|
|
||||||
private String mLog;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
AppCrashSafetyWire.getInstance().postResumeCrashSafetyWireHandler(getApplicationContext());
|
|
||||||
mLog = getIntent().getStringExtra(EXTRA_CRASH_LOG);
|
|
||||||
setTheme(android.R.style.Theme_DeviceDefault_Light_DarkActionBar);
|
|
||||||
initLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动态初始化布局
|
|
||||||
*/
|
|
||||||
private void initLayout() {
|
|
||||||
ScrollView contentView = new ScrollView(this);
|
|
||||||
contentView.setFillViewport(true);
|
|
||||||
|
|
||||||
HorizontalScrollView hw = new HorizontalScrollView(this);
|
|
||||||
hw.setBackgroundColor(0xFFF5F5F5);
|
|
||||||
|
|
||||||
TextView message = new TextView(this);
|
|
||||||
final int padding = dp2px(16);
|
|
||||||
message.setPadding(padding, padding, padding, padding);
|
|
||||||
message.setText(mLog);
|
|
||||||
message.setTextColor(0xFF000000);
|
|
||||||
message.setTextIsSelectable(true);
|
|
||||||
|
|
||||||
hw.addView(message);
|
|
||||||
contentView.addView(hw, ViewGroup.LayoutParams.MATCH_PARENT,
|
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT);
|
|
||||||
setContentView(contentView);
|
|
||||||
|
|
||||||
getActionBar().setTitle(TITTLE);
|
|
||||||
getActionBar().setSubtitle(GlobalApplication.class.getSimpleName() + " Error");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
restartApp();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 重启应用
|
|
||||||
*/
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dp转px
|
|
||||||
*/
|
|
||||||
private int dp2px(final float dpValue) {
|
|
||||||
final float scale = Resources.getSystem().getDisplayMetrics().density;
|
|
||||||
return (int) (dpValue * scale + 0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
|
||||||
menu.add(0, MENUITEM_COPY, 0, "Copy")
|
|
||||||
.setOnMenuItemClickListener(this)
|
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
|
|
||||||
menu.add(0, MENUITEM_RESTART, 0, "Restart")
|
|
||||||
.setOnMenuItemClickListener(this)
|
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ import android.content.SharedPreferences;
|
|||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
|
import android.util.Log;
|
||||||
|
import cc.winboll.studio.libappbase.utils.CrashHandleNotifyUtils;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||||
@@ -125,18 +129,32 @@ public class GlobalApplication extends Application {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
try {
|
||||||
// 初始化单例实例(确保在所有初始化操作前完成)
|
super.onCreate();
|
||||||
sInstance = this;
|
|
||||||
|
|
||||||
// 初始化基础组件(日志、崩溃处理、Toast)
|
// 初始化单例实例(确保在所有初始化操作前完成)
|
||||||
initCoreComponents();
|
sInstance = this;
|
||||||
// 恢复/初始化调试模式状态(从本地文件读取,无文件则默认关闭调试)
|
|
||||||
restoreDebugStatus();
|
|
||||||
// 新增:初始化服务器地址(从 SP 读取到内存,提高后续访问效率)
|
|
||||||
initWinbollHost();
|
|
||||||
|
|
||||||
LogUtils.d(TAG, "GlobalApplication 初始化完成,单例实例已创建");
|
restoreDebugStatus();
|
||||||
|
// 初始化基础组件(日志、崩溃处理、Toast)
|
||||||
|
initCoreComponents();
|
||||||
|
// 初始化服务器地址(从 SP 读取到内存,提高后续访问效率)
|
||||||
|
initWinbollHost();
|
||||||
|
|
||||||
|
LogUtils.d(TAG, "GlobalApplication 初始化完成,单例实例已创建");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
e.printStackTrace(pw);
|
||||||
|
pw.close();
|
||||||
|
String stackTraceStr = sw.toString();
|
||||||
|
CrashHandleNotifyUtils.handleUncaughtException(
|
||||||
|
this,
|
||||||
|
getPackageName(),
|
||||||
|
stackTraceStr,
|
||||||
|
CrashActivity.class
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,7 +162,11 @@ public class GlobalApplication extends Application {
|
|||||||
*/
|
*/
|
||||||
private void initCoreComponents() {
|
private void initCoreComponents() {
|
||||||
// 初始化日志工具(传入 Application 上下文)
|
// 初始化日志工具(传入 Application 上下文)
|
||||||
LogUtils.init(this);
|
|
||||||
|
// 调试状态下初始化日志工具
|
||||||
|
if (GlobalApplication.isDebugging()) {
|
||||||
|
LogUtils.init(this);
|
||||||
|
}
|
||||||
// 初始化全局异常处理器(捕获应用崩溃信息,用于调试或上报)
|
// 初始化全局异常处理器(捕获应用崩溃信息,用于调试或上报)
|
||||||
CrashHandler.init(this);
|
CrashHandler.init(this);
|
||||||
// 初始化 Toast 工具(统一 Toast 样式、避免内存泄漏等)
|
// 初始化 Toast 工具(统一 Toast 样式、避免内存泄漏等)
|
||||||
@@ -187,7 +209,7 @@ public class GlobalApplication extends Application {
|
|||||||
*/
|
*/
|
||||||
public static String getAppName(Context context) {
|
public static String getAppName(Context context) {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
LogUtils.w(TAG, "getAppName: 上下文为空,返回 null");
|
Log.w(TAG, "getAppName: 上下文为空,返回 null");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
PackageManager packageManager = context.getPackageManager();
|
PackageManager packageManager = context.getPackageManager();
|
||||||
@@ -203,8 +225,7 @@ public class GlobalApplication extends Application {
|
|||||||
return appName;
|
return appName;
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
// 包名不存在(理论上不会发生,捕获异常避免崩溃)
|
// 包名不存在(理论上不会发生,捕获异常避免崩溃)
|
||||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
Log.e(TAG, "获取应用名称失败:包名不存在", e);
|
||||||
//LogUtils.e(TAG, "获取应用名称失败:包名不存在", e);
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public final class GlobalCrashActivity extends Activity implements MenuItem.OnMe
|
|||||||
mCrashLog = getIntent().getStringExtra(CrashHandler.EXTRA_CRASH_LOG);
|
mCrashLog = getIntent().getStringExtra(CrashHandler.EXTRA_CRASH_LOG);
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.putExtra(CrashHandler.EXTRA_CRASH_LOG, mCrashLog);
|
intent.putExtra(CrashHandler.EXTRA_CRASH_LOG, mCrashLog);
|
||||||
CrashHandleNotifyUtils.handleUncaughtException(GlobalApplication.getInstance(), intent, CrashHandler.CrashActivity.class);
|
CrashHandleNotifyUtils.handleUncaughtException(GlobalApplication.getInstance(), intent, CrashActivity.class);
|
||||||
|
|
||||||
StackTraceElement[] stackElements = Thread.currentThread().getStackTrace();
|
StackTraceElement[] stackElements = Thread.currentThread().getStackTrace();
|
||||||
StringBuilder sb = new StringBuilder("GlobalCrashActivity onCreate StackTrace");
|
StringBuilder sb = new StringBuilder("GlobalCrashActivity onCreate StackTrace");
|
||||||
|
|||||||
@@ -27,6 +27,11 @@ public class LogActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
if(!GlobalApplication.isDebugging()) {
|
||||||
|
ToastUtils.show("非调试状态日志功能不可用");
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
// 设置布局文件(包含 LogView 控件)
|
// 设置布局文件(包含 LogView 控件)
|
||||||
setContentView(R.layout.activity_log);
|
setContentView(R.layout.activity_log);
|
||||||
|
|
||||||
|
|||||||
@@ -67,45 +67,29 @@ public class LogUtils {
|
|||||||
|
|
||||||
// ====================== 初始化入口 ======================
|
// ====================== 初始化入口 ======================
|
||||||
public static void init(final Context context) {
|
public static void init(final Context context) {
|
||||||
init(context, LOG_LEVEL.Off);
|
init(context, LOG_LEVEL.Off);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(final Context context, final LOG_LEVEL logLevel) {
|
public static void init(final Context context, final LOG_LEVEL logLevel) {
|
||||||
Log.d(TAG, "init 执行日志工具初始化");
|
if (!GlobalApplication.isDebugging()) {
|
||||||
_mContext = context;
|
return;
|
||||||
|
}
|
||||||
|
Log.d(TAG, "init 执行日志工具初始化");
|
||||||
|
_mContext = context;
|
||||||
|
|
||||||
if (GlobalApplication.isDebugging()) {
|
initLogUtilsDir();
|
||||||
initDebugDir();
|
|
||||||
} else {
|
|
||||||
initReleaseDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
initLogConfigBean();
|
initLogConfigBean();
|
||||||
addClassTAGList();
|
addClassTAGList();
|
||||||
loadTAGBeanSettings();
|
loadTAGBeanSettings();
|
||||||
checkAndTrimLogFileSize();
|
checkAndTrimLogFileSize();
|
||||||
|
|
||||||
_IsInited = true;
|
_IsInited = true;
|
||||||
Log.d(TAG, "init 日志工具初始化完成");
|
Log.d(TAG, "init 执行日志工具初始化完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================== 目录初始化 ======================
|
// ====================== 目录初始化 ======================
|
||||||
private static void initDebugDir() {
|
private static void initLogUtilsDir() {
|
||||||
final Context appContext = _mContext.getApplicationContext();
|
|
||||||
_mfLogCacheDir = new File(appContext.getExternalCacheDir(), TAG);
|
|
||||||
if (!_mfLogCacheDir.exists()) {
|
|
||||||
_mfLogCacheDir.mkdirs();
|
|
||||||
}
|
|
||||||
_mfLogCatchFile = new File(_mfLogCacheDir, "log.txt");
|
|
||||||
|
|
||||||
_mfLogDataDir = appContext.getExternalFilesDir(TAG);
|
|
||||||
if (!_mfLogDataDir.exists()) {
|
|
||||||
_mfLogDataDir.mkdirs();
|
|
||||||
}
|
|
||||||
_mfLogUtilsBeanFile = new File(_mfLogDataDir, TAG + ".json");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void initReleaseDir() {
|
|
||||||
final Context appContext = _mContext.getApplicationContext();
|
final Context appContext = _mContext.getApplicationContext();
|
||||||
_mfLogCacheDir = new File(appContext.getCacheDir(), TAG);
|
_mfLogCacheDir = new File(appContext.getCacheDir(), TAG);
|
||||||
if (!_mfLogCacheDir.exists()) {
|
if (!_mfLogCacheDir.exists()) {
|
||||||
@@ -113,7 +97,7 @@ public class LogUtils {
|
|||||||
}
|
}
|
||||||
_mfLogCatchFile = new File(_mfLogCacheDir, "log.txt");
|
_mfLogCatchFile = new File(_mfLogCacheDir, "log.txt");
|
||||||
|
|
||||||
_mfLogDataDir = new File(appContext.getFilesDir(), TAG);
|
_mfLogDataDir = appContext.getExternalFilesDir(TAG);
|
||||||
if (!_mfLogDataDir.exists()) {
|
if (!_mfLogDataDir.exists()) {
|
||||||
_mfLogDataDir.mkdirs();
|
_mfLogDataDir.mkdirs();
|
||||||
}
|
}
|
||||||
@@ -136,7 +120,7 @@ public class LogUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final long KEEP_FILE_SIZE = 25000L; // ~25KB 确保剪贴板可完整复制
|
final long KEEP_FILE_SIZE = 25000L; // ~25KB 确保剪贴板可完整复制
|
||||||
final long MAX_FILE_SIZE = 2*KEEP_FILE_SIZE;
|
final long MAX_FILE_SIZE = 2 * KEEP_FILE_SIZE;
|
||||||
final long fileSize = _mfLogCatchFile.length();
|
final long fileSize = _mfLogCatchFile.length();
|
||||||
|
|
||||||
if (fileSize <= MAX_FILE_SIZE) {
|
if (fileSize <= MAX_FILE_SIZE) {
|
||||||
@@ -266,6 +250,9 @@ public class LogUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setTAGListEnable(final String tag, final boolean isEnable) {
|
public static void setTAGListEnable(final String tag, final boolean isEnable) {
|
||||||
|
if (!_IsInited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final Iterator<Map.Entry<String, Boolean>> iterator = mapTAGList.entrySet().iterator();
|
final Iterator<Map.Entry<String, Boolean>> iterator = mapTAGList.entrySet().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
final Map.Entry<String, Boolean> entry = iterator.next();
|
final Map.Entry<String, Boolean> entry = iterator.next();
|
||||||
@@ -279,6 +266,9 @@ public class LogUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setALlTAGListEnable(final boolean isEnable) {
|
public static void setALlTAGListEnable(final boolean isEnable) {
|
||||||
|
if (!_IsInited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (final Map.Entry<String, Boolean> entry : mapTAGList.entrySet()) {
|
for (final Map.Entry<String, Boolean> entry : mapTAGList.entrySet()) {
|
||||||
entry.setValue(isEnable);
|
entry.setValue(isEnable);
|
||||||
}
|
}
|
||||||
@@ -288,15 +278,22 @@ public class LogUtils {
|
|||||||
|
|
||||||
// ====================== 日志级别控制 ======================
|
// ====================== 日志级别控制 ======================
|
||||||
public static void setLogLevel(final LOG_LEVEL logLevel) {
|
public static void setLogLevel(final LOG_LEVEL logLevel) {
|
||||||
|
if (_mLogUtilsBean == null) {
|
||||||
|
Log.d(TAG, "setLogLevel LogUtils未初始化,忽略设置日志级别");
|
||||||
|
return;
|
||||||
|
}
|
||||||
_mLogUtilsBean.setLogLevel(logLevel);
|
_mLogUtilsBean.setLogLevel(logLevel);
|
||||||
_mLogUtilsBean.saveBeanToFile(_mfLogUtilsBeanFile.getPath(), _mLogUtilsBean);
|
_mLogUtilsBean.saveBeanToFile(_mfLogUtilsBeanFile.getPath(), _mLogUtilsBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LOG_LEVEL getLogLevel() {
|
public static LOG_LEVEL getLogLevel() {
|
||||||
return _mLogUtilsBean.getLogLevel();
|
return _mLogUtilsBean == null ?LOG_LEVEL.Off: _mLogUtilsBean.getLogLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isLoggable(final String tag, final LOG_LEVEL logLevel) {
|
private static boolean isLoggable(final String tag, final LOG_LEVEL logLevel) {
|
||||||
|
if (!GlobalApplication.isDebugging()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!_IsInited) {
|
if (!_IsInited) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cc.winboll.studio.libappbase;
|
|||||||
|
|
||||||
import android.util.JsonReader;
|
import android.util.JsonReader;
|
||||||
import android.util.JsonWriter;
|
import android.util.JsonWriter;
|
||||||
|
import cc.winboll.studio.libappbase.models.libs1520000.BaseBean;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cc.winboll.studio.libappbase;
|
|||||||
|
|
||||||
import android.util.JsonReader;
|
import android.util.JsonReader;
|
||||||
import android.util.JsonWriter;
|
import android.util.JsonWriter;
|
||||||
|
import cc.winboll.studio.libappbase.models.libs1520000.BaseBean;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cc.winboll.studio.libappbase;
|
package cc.winboll.studio.libappbase;
|
||||||
|
|
||||||
import android.os.FileObserver;
|
import android.os.FileObserver;
|
||||||
|
import java.io.File;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,30 +52,38 @@ public class LogViewThread extends Thread {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// 获取日志缓存目录路径(从 LogUtils 统一获取,确保路径一致性)
|
// 调试状态进行日志输出任务
|
||||||
String logDirPath = LogUtils.getLogCacheDir().getPath();
|
if (GlobalApplication.isDebugging()) {
|
||||||
LogUtils.d(TAG, "启动日志文件监听,监听目录:" + logDirPath);
|
// 获取日志缓存目录路径(从 LogUtils 统一获取,确保路径一致性)
|
||||||
|
File logDir = LogUtils.getLogCacheDir();
|
||||||
|
if (logDir == null) {
|
||||||
|
LogUtils.d(TAG, "日志缓存目录未初始化,线程退出");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String logDirPath = logDir.getPath();
|
||||||
|
LogUtils.d(TAG, "启动日志文件监听,监听目录:" + logDirPath);
|
||||||
|
|
||||||
// 初始化日志文件监听器(监听目标目录的文件事件)
|
// 初始化日志文件监听器(监听目标目录的文件事件)
|
||||||
mLogListener = new LogListener(logDirPath);
|
mLogListener = new LogListener(logDirPath);
|
||||||
// 开始监听文件事件(非阻塞,内部通过 Native 层实现)
|
// 开始监听文件事件(非阻塞,内部通过 Native 层实现)
|
||||||
mLogListener.startWatching();
|
mLogListener.startWatching();
|
||||||
|
|
||||||
// 循环等待退出标志(每 1 秒检查一次,降低 CPU 占用)
|
// 循环等待退出标志(每 1 秒检查一次,降低 CPU 占用)
|
||||||
while (!isExit()) {
|
while (!isExit()) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000); // 休眠 1 秒,避免忙等
|
Thread.sleep(1000); // 休眠 1 秒,避免忙等
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// 线程被中断时,恢复中断标志并退出循环(避免无限阻塞)
|
// 线程被中断时,恢复中断标志并退出循环(避免无限阻塞)
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
LogUtils.d(TAG, "日志监听线程被中断,准备退出。" + e);
|
LogUtils.d(TAG, "日志监听线程被中断,准备退出。" + e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收到退出标志,停止监听并释放资源
|
// 收到退出标志,停止监听并释放资源
|
||||||
mLogListener.stopWatching();
|
mLogListener.stopWatching();
|
||||||
LogUtils.d(TAG, "日志文件监听已停止,线程退出");
|
LogUtils.d(TAG, "日志文件监听已停止,线程退出");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,415 @@
|
|||||||
|
package cc.winboll.studio.libappbase.models.libs1520000;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.JsonReader;
|
||||||
|
import android.util.JsonWriter;
|
||||||
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
import cc.winboll.studio.libappbase.UTF8FileUtils;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WinBoLL JSON 数据模型基类(抽象类)
|
||||||
|
* 定义 Json Bean 的核心规范:序列化/反序列化、文件持久化、列表处理等通用逻辑,
|
||||||
|
* 子类需实现抽象方法,完成自身字段JSON读写业务逻辑
|
||||||
|
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
|
||||||
|
* @CreateTime 2026/05/19 22:33:00
|
||||||
|
* @EditTime 2026/05/19 23:15:48
|
||||||
|
* @param <T> 泛型约束,限定子类必须继承自BaseBean
|
||||||
|
*/
|
||||||
|
public abstract class BaseBean<T extends BaseBean> {
|
||||||
|
|
||||||
|
// ====================== 静态常量 ======================
|
||||||
|
/** 日志输出标识TAG */
|
||||||
|
public static final String TAG = "BaseBean";
|
||||||
|
/** JSON存储Bean类名字段Key,用于类型校验 */
|
||||||
|
static final String BEAN_NAME = "BeanName";
|
||||||
|
|
||||||
|
// ====================== 构造方法 ======================
|
||||||
|
/**
|
||||||
|
* 无参空构造,满足反射实例化要求
|
||||||
|
*/
|
||||||
|
public BaseBean() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====================== 抽象方法 ======================
|
||||||
|
/**
|
||||||
|
* 获取当前实体类全类名
|
||||||
|
* @return 全限定类名字符串
|
||||||
|
*/
|
||||||
|
public abstract String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从JSON读取器解析构建实体对象
|
||||||
|
* @param jsonReader JSON读取流
|
||||||
|
* @return 解析完成实体对象
|
||||||
|
* @throws IOException IO读写异常
|
||||||
|
*/
|
||||||
|
public abstract T readBeanFromJsonReader(final JsonReader jsonReader) throws IOException;
|
||||||
|
|
||||||
|
// ====================== 路径获取相关 ======================
|
||||||
|
/**
|
||||||
|
* 获取单个实体默认存储JSON文件路径
|
||||||
|
* @param context 应用上下文
|
||||||
|
* @return 文件绝对路径
|
||||||
|
*/
|
||||||
|
public String getBeanJsonFilePath(final Context context) {
|
||||||
|
return context.getExternalFilesDir(TAG) + "/" + getName() + ".json";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取实体列表默认存储JSON文件路径
|
||||||
|
* @param context 应用上下文
|
||||||
|
* @return 文件绝对路径
|
||||||
|
*/
|
||||||
|
public String getBeanListJsonFilePath(final Context context) {
|
||||||
|
return context.getExternalFilesDir(TAG) + "/" + getName() + "_List.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====================== JSON序列化基础方法 ======================
|
||||||
|
/**
|
||||||
|
* 写入基础Bean标识字段至JSON
|
||||||
|
* @param jsonWriter JSON写入流
|
||||||
|
* @throws IOException 写入异常
|
||||||
|
*/
|
||||||
|
public void writeThisToJsonWriter(final JsonWriter jsonWriter) throws IOException {
|
||||||
|
jsonWriter.name(BEAN_NAME).value(getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基类通用字段解析回调
|
||||||
|
* @param jsonReader JSON读取流
|
||||||
|
* @param name 字段名
|
||||||
|
* @return 是否完成当前字段解析
|
||||||
|
* @throws IOException 读取异常
|
||||||
|
*/
|
||||||
|
public boolean initObjectsFromJsonReader(final JsonReader jsonReader, final String name) throws IOException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====================== 实体字符串序列化 ======================
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
LogUtils.d(TAG, "执行BaseBean实体转JSON字符串");
|
||||||
|
final StringWriter stringWriter = new StringWriter();
|
||||||
|
final JsonWriter jsonWriter = new JsonWriter(stringWriter);
|
||||||
|
jsonWriter.setIndent(" ");
|
||||||
|
try {
|
||||||
|
jsonWriter.beginObject();
|
||||||
|
writeThisToJsonWriter(jsonWriter);
|
||||||
|
jsonWriter.endObject();
|
||||||
|
return stringWriter.toString();
|
||||||
|
} catch (final IOException e) {
|
||||||
|
LogUtils.d(TAG, "实体转JSON字符串异常", Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====================== 列表序列化工具 ======================
|
||||||
|
/**
|
||||||
|
* Bean列表转为格式化JSON数组字符串
|
||||||
|
* @param beanList 实体集合
|
||||||
|
* @param <T> 实体泛型
|
||||||
|
* @return JSON字符串
|
||||||
|
*/
|
||||||
|
public static <T extends BaseBean> String toStringByBeanList(final ArrayList<T> beanList) {
|
||||||
|
LogUtils.d(TAG, "执行Bean列表序列化JSON操作");
|
||||||
|
try {
|
||||||
|
final StringWriter stringWriter = new StringWriter();
|
||||||
|
final JsonWriter jsonWriter = new JsonWriter(stringWriter);
|
||||||
|
jsonWriter.setIndent(" ");
|
||||||
|
jsonWriter.beginArray();
|
||||||
|
for (int i = 0; i < beanList.size(); i++) {
|
||||||
|
jsonWriter.beginObject();
|
||||||
|
beanList.get(i).writeThisToJsonWriter(jsonWriter);
|
||||||
|
jsonWriter.endObject();
|
||||||
|
}
|
||||||
|
jsonWriter.endArray();
|
||||||
|
jsonWriter.close();
|
||||||
|
return stringWriter.toString();
|
||||||
|
} catch (final IOException e) {
|
||||||
|
LogUtils.d(TAG, "列表序列化JSON异常", Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====================== JSON字符串解析实体 ======================
|
||||||
|
/**
|
||||||
|
* JSON文本解析为单个实体对象
|
||||||
|
* @param szBean JSON文本
|
||||||
|
* @param clazz 实体Class字节码
|
||||||
|
* @param <T> 实体泛型
|
||||||
|
* @return 解析完成实体
|
||||||
|
* @throws IOException 解析IO异常
|
||||||
|
*/
|
||||||
|
public static <T extends BaseBean> T parseStringToBean(final String szBean, final Class<T> clazz) throws IOException {
|
||||||
|
LogUtils.d(TAG, "进入字符串解析实体方法,目标Class:" + clazz.getSimpleName());
|
||||||
|
final StringReader stringReader = new StringReader(szBean);
|
||||||
|
final JsonReader jsonReader = new JsonReader(stringReader);
|
||||||
|
try {
|
||||||
|
final T beanTemp = clazz.newInstance();
|
||||||
|
return (T) beanTemp.readBeanFromJsonReader(jsonReader);
|
||||||
|
} catch (final InstantiationException e) {
|
||||||
|
LogUtils.d(TAG, "实体反射实例化失败(InstantiationException)", Thread.currentThread().getStackTrace());
|
||||||
|
} catch (final IllegalAccessException e) {
|
||||||
|
LogUtils.d(TAG, "实体反射权限访问失败(IllegalAccessException)", Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON数组文本解析填充实体列表
|
||||||
|
* @param szBeanList JSON数组文本
|
||||||
|
* @param beanList 目标存储集合
|
||||||
|
* @param clazz 实体字节码
|
||||||
|
* @param <T> 实体泛型
|
||||||
|
* @return 解析结果
|
||||||
|
*/
|
||||||
|
public static <T extends BaseBean> boolean parseStringToBeanList(final String szBeanList, ArrayList<T> beanList, final Class<T> clazz) {
|
||||||
|
LogUtils.d(TAG, "进入列表字符串解析方法");
|
||||||
|
try {
|
||||||
|
if (beanList == null) {
|
||||||
|
beanList = new ArrayList<T>();
|
||||||
|
} else {
|
||||||
|
beanList.clear();
|
||||||
|
}
|
||||||
|
final StringReader stringReader = new StringReader(szBeanList);
|
||||||
|
final JsonReader jsonReader = new JsonReader(stringReader);
|
||||||
|
jsonReader.beginArray();
|
||||||
|
while (jsonReader.hasNext()) {
|
||||||
|
final T beanTemp = clazz.newInstance();
|
||||||
|
final T bean = (T) beanTemp.readBeanFromJsonReader(jsonReader);
|
||||||
|
if (bean != null) {
|
||||||
|
beanList.add(bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsonReader.endArray();
|
||||||
|
return true;
|
||||||
|
} catch (final InstantiationException e) {
|
||||||
|
LogUtils.d(TAG, "列表解析反射实例化异常", Thread.currentThread().getStackTrace());
|
||||||
|
} catch (final IllegalAccessException e) {
|
||||||
|
LogUtils.d(TAG, "列表解析反射权限异常", Thread.currentThread().getStackTrace());
|
||||||
|
} catch (final IOException e) {
|
||||||
|
LogUtils.d(TAG, "列表解析JSON读写异常", Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====================== 文件加载实体 ======================
|
||||||
|
/**
|
||||||
|
* 从默认路径加载单个实体
|
||||||
|
* @param context 上下文
|
||||||
|
* @param clazz 实体字节码
|
||||||
|
* @param <T> 实体泛型
|
||||||
|
* @return 加载实体
|
||||||
|
*/
|
||||||
|
public static <T extends BaseBean> T loadBean(final Context context, final Class<T> clazz) {
|
||||||
|
LogUtils.d(TAG, "执行默认路径加载实体数据");
|
||||||
|
try {
|
||||||
|
final T beanTemp = clazz.newInstance();
|
||||||
|
return loadBeanFromFile(beanTemp.getBeanJsonFilePath(context), clazz);
|
||||||
|
} catch (final InstantiationException e) {
|
||||||
|
LogUtils.d(TAG, "加载实体反射实例化失败", Thread.currentThread().getStackTrace());
|
||||||
|
} catch (final IllegalAccessException e) {
|
||||||
|
LogUtils.d(TAG, "加载实体反射权限失败", Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义文件路径加载单个实体
|
||||||
|
* @param szFilePath 文件路径
|
||||||
|
* @param clazz 实体字节码
|
||||||
|
* @param <T> 实体泛型
|
||||||
|
* @return 实体对象
|
||||||
|
*/
|
||||||
|
public static <T extends BaseBean> T loadBeanFromFile(final String szFilePath, final Class<T> clazz) {
|
||||||
|
LogUtils.d(TAG, "指定路径加载实体,路径:" + szFilePath);
|
||||||
|
try {
|
||||||
|
final File file = new File(szFilePath);
|
||||||
|
if (file.exists()) {
|
||||||
|
final T beanTemp = clazz.newInstance();
|
||||||
|
final String json = UTF8FileUtils.readStringFromFile(szFilePath);
|
||||||
|
return beanTemp.parseStringToBean(json, clazz);
|
||||||
|
}
|
||||||
|
} catch (final InstantiationException e) {
|
||||||
|
LogUtils.d(TAG, "文件加载实体反射实例化异常", Thread.currentThread().getStackTrace());
|
||||||
|
} catch (final IllegalAccessException e) {
|
||||||
|
LogUtils.d(TAG, "文件加载实体反射权限异常", Thread.currentThread().getStackTrace());
|
||||||
|
} catch (final IOException e) {
|
||||||
|
LogUtils.d(TAG, "文件读取JSON数据异常", Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认路径加载实体列表
|
||||||
|
* @param context 上下文
|
||||||
|
* @param beanListDst 目标集合
|
||||||
|
* @param clazz 实体字节码
|
||||||
|
* @param <T> 实体泛型
|
||||||
|
* @return 加载结果
|
||||||
|
*/
|
||||||
|
public static <T extends BaseBean> boolean loadBeanList(final Context context, final ArrayList<T> beanListDst, final Class<T> clazz) {
|
||||||
|
LogUtils.d(TAG, "默认路径加载实体列表数据");
|
||||||
|
try {
|
||||||
|
final T beanTemp = clazz.newInstance();
|
||||||
|
return loadBeanListFromFile(beanTemp.getBeanListJsonFilePath(context), beanListDst, clazz);
|
||||||
|
} catch (final InstantiationException e) {
|
||||||
|
LogUtils.d(TAG, "列表加载反射实例化异常", Thread.currentThread().getStackTrace());
|
||||||
|
} catch (final IllegalAccessException e) {
|
||||||
|
LogUtils.d(TAG, "列表加载反射权限异常", Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义路径加载实体列表
|
||||||
|
* @param szFilePath 文件路径
|
||||||
|
* @param beanList 目标集合
|
||||||
|
* @param clazz 实体字节码
|
||||||
|
* @param <T> 实体泛型
|
||||||
|
* @return 加载结果
|
||||||
|
*/
|
||||||
|
public static <T extends BaseBean> boolean loadBeanListFromFile(final String szFilePath, final ArrayList<T> beanList, final Class<T> clazz) {
|
||||||
|
LogUtils.d(TAG, "指定路径加载实体列表,路径:" + szFilePath);
|
||||||
|
try {
|
||||||
|
final File file = new File(szFilePath);
|
||||||
|
if (file.exists()) {
|
||||||
|
final String listJson = UTF8FileUtils.readStringFromFile(szFilePath);
|
||||||
|
return parseStringToBeanList(listJson, beanList, clazz);
|
||||||
|
}
|
||||||
|
} catch (final IOException e) {
|
||||||
|
LogUtils.d(TAG, "列表文件读取异常", Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====================== 实体数据保存文件 ======================
|
||||||
|
/**
|
||||||
|
* 默认路径保存单个实体
|
||||||
|
* @param context 上下文
|
||||||
|
* @param bean 待保存实体
|
||||||
|
* @param <T> 实体泛型
|
||||||
|
* @return 保存结果
|
||||||
|
*/
|
||||||
|
public static <T extends BaseBean> boolean saveBean(final Context context, final T bean) {
|
||||||
|
return saveBeanToFile(bean.getBeanJsonFilePath(context), bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义路径保存单个实体
|
||||||
|
* @param szFilePath 保存路径
|
||||||
|
* @param bean 待保存实体
|
||||||
|
* @param <T> 实体泛型
|
||||||
|
* @return 保存结果
|
||||||
|
*/
|
||||||
|
public static <T extends BaseBean> boolean saveBeanToFile(final String szFilePath, final T bean) {
|
||||||
|
LogUtils.d(TAG, "执行实体数据写入文件操作");
|
||||||
|
try {
|
||||||
|
final String json = bean.toString();
|
||||||
|
UTF8FileUtils.writeStringToFile(szFilePath, json);
|
||||||
|
return true;
|
||||||
|
} catch (final IOException e) {
|
||||||
|
LogUtils.d(TAG, "实体写入文件异常", Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认路径保存实体列表
|
||||||
|
* @param context 上下文
|
||||||
|
* @param beanList 实体集合
|
||||||
|
* @param clazz 实体字节码
|
||||||
|
* @param <T> 实体泛型
|
||||||
|
* @return 保存结果
|
||||||
|
*/
|
||||||
|
public static <T extends BaseBean> boolean saveBeanList(final Context context, final ArrayList<T> beanList, final Class<T> clazz) {
|
||||||
|
LogUtils.d(TAG, "默认路径保存实体列表数据");
|
||||||
|
try {
|
||||||
|
final T beanTemp = clazz.newInstance();
|
||||||
|
return saveBeanListToFile(beanTemp.getBeanListJsonFilePath(context), beanList);
|
||||||
|
} catch (final InstantiationException e) {
|
||||||
|
LogUtils.d(TAG, "列表保存反射实例化异常", Thread.currentThread().getStackTrace());
|
||||||
|
} catch (final IllegalAccessException e) {
|
||||||
|
LogUtils.d(TAG, "列表保存反射权限异常", Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义路径保存实体列表
|
||||||
|
* @param szFilePath 保存路径
|
||||||
|
* @param beanList 实体集合
|
||||||
|
* @param <T> 实体泛型
|
||||||
|
* @return 保存结果
|
||||||
|
*/
|
||||||
|
public static <T extends BaseBean> boolean saveBeanListToFile(final String szFilePath, final ArrayList<T> beanList) {
|
||||||
|
LogUtils.d(TAG, "指定路径保存实体列表数据");
|
||||||
|
try {
|
||||||
|
final String json = toStringByBeanList(beanList);
|
||||||
|
UTF8FileUtils.writeStringToFile(szFilePath, json);
|
||||||
|
return true;
|
||||||
|
} catch (final IOException e) {
|
||||||
|
LogUtils.d(TAG, "列表数据写入文件异常", Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====================== Bean类型一致性校验 ======================
|
||||||
|
/**
|
||||||
|
* 校验本地JSON列表内实体类型是否统一
|
||||||
|
* @param szFilePath 列表文件路径
|
||||||
|
* @param clazz 目标校验实体Class
|
||||||
|
* @param <T> 实体泛型
|
||||||
|
* @return 校验结果信息
|
||||||
|
*/
|
||||||
|
public static <T extends BaseBean> String checkIsTheSameBeanListAndFile(final String szFilePath, final Class<T> clazz) {
|
||||||
|
final StringBuilder sbResult = new StringBuilder();
|
||||||
|
final String szErrorInfo = "Check Is The Same Bean List And File Error : ";
|
||||||
|
try {
|
||||||
|
int sameCount = 0;
|
||||||
|
int totalCount = 0;
|
||||||
|
final T beanTemp = clazz.newInstance();
|
||||||
|
final String targetBeanName = beanTemp.getName();
|
||||||
|
final String listJson = UTF8FileUtils.readStringFromFile(szFilePath);
|
||||||
|
final StringReader stringReader = new StringReader(listJson);
|
||||||
|
final JsonReader jsonReader = new JsonReader(stringReader);
|
||||||
|
jsonReader.beginArray();
|
||||||
|
while (jsonReader.hasNext()) {
|
||||||
|
totalCount++;
|
||||||
|
jsonReader.beginObject();
|
||||||
|
while (jsonReader.hasNext()) {
|
||||||
|
final String name = jsonReader.nextName();
|
||||||
|
if (BEAN_NAME.equals(name)) {
|
||||||
|
if (targetBeanName.equals(jsonReader.nextString())) {
|
||||||
|
sameCount++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
jsonReader.skipValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsonReader.endObject();
|
||||||
|
}
|
||||||
|
jsonReader.endArray();
|
||||||
|
if (sameCount != totalCount) {
|
||||||
|
sbResult.append("Total : ").append(totalCount).append(" Diff : ").append(totalCount - sameCount);
|
||||||
|
}
|
||||||
|
} catch (final InstantiationException e) {
|
||||||
|
sbResult.append(szErrorInfo).append(e);
|
||||||
|
LogUtils.d(TAG, "类型校验反射实例化异常", Thread.currentThread().getStackTrace());
|
||||||
|
} catch (final IllegalAccessException e) {
|
||||||
|
sbResult.append(szErrorInfo).append(e);
|
||||||
|
LogUtils.d(TAG, "类型校验反射权限异常", Thread.currentThread().getStackTrace());
|
||||||
|
} catch (final IOException e) {
|
||||||
|
sbResult.append(szErrorInfo).append(e);
|
||||||
|
LogUtils.d(TAG, "类型校验文件读取解析异常", Thread.currentThread().getStackTrace());
|
||||||
|
}
|
||||||
|
return sbResult.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package cc.winboll.studio.libappbase.views;
|
package cc.winboll.studio.libappbase.views;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -12,6 +14,7 @@ import android.widget.ImageButton;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.R;
|
import cc.winboll.studio.libappbase.R;
|
||||||
@@ -74,12 +77,12 @@ public class AboutView extends LinearLayout {
|
|||||||
private EditText metDevUserPassword;
|
private EditText metDevUserPassword;
|
||||||
|
|
||||||
// ===================================== 页面视图控件 =====================================
|
// ===================================== 页面视图控件 =====================================
|
||||||
private DebugSwitchImageView ivAppIcon;
|
private DebugSwitchInfoImageView ivAppIcon;
|
||||||
private TextView tvAppNameVersion;
|
private TextView tvAppNameVersion;
|
||||||
private TextView tvAppDesc;
|
private TextView tvAppDesc;
|
||||||
private LinearLayout llFunctionContainer;
|
private LinearLayout llFunctionContainer;
|
||||||
private ImageButton ibSebugStepOver;
|
private ImageButton ibSebugStepOver;
|
||||||
private ImageButton ibSigngetDialog;
|
private ImageButton ibDebugUnlock;
|
||||||
private ImageButton ibWinBoLLHostDialog;
|
private ImageButton ibWinBoLLHostDialog;
|
||||||
|
|
||||||
// ===================================== 构造方法(按参数从少到多排序) =====================================
|
// ===================================== 构造方法(按参数从少到多排序) =====================================
|
||||||
@@ -193,12 +196,12 @@ public class AboutView extends LinearLayout {
|
|||||||
llFunctionContainer = findViewById(R.id.ll_function_container);
|
llFunctionContainer = findViewById(R.id.ll_function_container);
|
||||||
// 功能按钮绑定
|
// 功能按钮绑定
|
||||||
ibSebugStepOver = findViewById(R.id.ib_debug_step_over);
|
ibSebugStepOver = findViewById(R.id.ib_debug_step_over);
|
||||||
ibSigngetDialog = findViewById(R.id.ib_signgetdialog);
|
ibDebugUnlock = findViewById(R.id.ib_debug_unlock);
|
||||||
ibWinBoLLHostDialog = findViewById(R.id.ib_winbollhostdialog);
|
ibWinBoLLHostDialog = findViewById(R.id.ib_winbollhostdialog);
|
||||||
|
|
||||||
// 调试按钮统一只在调试模式显示
|
// 调试按钮统一只在调试模式显示
|
||||||
ibWinBoLLHostDialog.setVisibility(GlobalApplication.isDebugging() ? View.VISIBLE : View.GONE);
|
ibWinBoLLHostDialog.setVisibility(GlobalApplication.isDebugging() ? View.VISIBLE : View.GONE);
|
||||||
//ibSigngetDialog.setVisibility(GlobalApplication.isDebugging() ? View.VISIBLE : View.GONE);
|
//ibDebugUnlock.setVisibility(GlobalApplication.isDebugging() ? View.VISIBLE : View.GONE);
|
||||||
ibSebugStepOver.setVisibility(GlobalApplication.isDebugging() ? View.VISIBLE : View.GONE);
|
ibSebugStepOver.setVisibility(GlobalApplication.isDebugging() ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
// 绑定按钮点击事件
|
// 绑定按钮点击事件
|
||||||
@@ -310,6 +313,47 @@ public class AboutView extends LinearLayout {
|
|||||||
LogUtils.d(TAG, "initAboutPageView():视图组装完成,功能项加载完毕");
|
LogUtils.d(TAG, "initAboutPageView():视图组装完成,功能项加载完毕");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===================================== 调试解锁弹窗 =====================================
|
||||||
|
private void showDebugUnlockDialog() {
|
||||||
|
final AlertDialog dialog = new AlertDialog.Builder(mContext).create();
|
||||||
|
dialog.setTitle("应用调试解锁");
|
||||||
|
dialog.setCanceledOnTouchOutside(true);
|
||||||
|
|
||||||
|
final EditText etToken = new EditText(mContext);
|
||||||
|
etToken.setHint("请输入调试Token");
|
||||||
|
dialog.setView(etToken);
|
||||||
|
|
||||||
|
dialog.setButton(DialogInterface.BUTTON_POSITIVE, "调试解锁", (DialogInterface.OnClickListener) null);
|
||||||
|
dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "关闭", (DialogInterface.OnClickListener) null);
|
||||||
|
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||||
|
@Override
|
||||||
|
public void onShow(DialogInterface d) {
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
String inputToken = etToken.getText().toString().trim();
|
||||||
|
String savedToken = DebugSwitchInfoImageView.getDebugToken();
|
||||||
|
if (savedToken != null && savedToken.equals(inputToken)) {
|
||||||
|
GlobalApplication.setIsDebugging(true);
|
||||||
|
GlobalApplication.saveDebugStatus(GlobalApplication.getInstance());
|
||||||
|
Toast.makeText(mContext, "调试解锁成功,重启应用后生效", Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(mContext, "调试Token不匹配", Toast.LENGTH_SHORT).show();
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
// ===================================== 内部工具/事件方法 =====================================
|
// ===================================== 内部工具/事件方法 =====================================
|
||||||
/**
|
/**
|
||||||
* 绑定功能按钮点击事件,处理正版校验、调试地址配置弹窗唤起
|
* 绑定功能按钮点击事件,处理正版校验、调试地址配置弹窗唤起
|
||||||
@@ -335,6 +379,15 @@ public class AboutView extends LinearLayout {
|
|||||||
new DebugHostDialog(mContext).show();
|
new DebugHostDialog(mContext).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 应用调试解锁按钮
|
||||||
|
ibDebugUnlock.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
LogUtils.d(TAG, "ibDebugUnlock onClick:弹出调试解锁对话框");
|
||||||
|
showDebugUnlockDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
LogUtils.d(TAG, "setBtnClickListener():功能按钮点击事件绑定完成");
|
LogUtils.d(TAG, "setBtnClickListener():功能按钮点击事件绑定完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
package cc.winboll.studio.libappbase.views;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
|
|
||||||
* @Date 2026/04/06 19:32
|
|
||||||
* @Describe 具有调试模式切换功能的应用Logo控件,连续点击10次弹出提示
|
|
||||||
*/
|
|
||||||
public class DebugSwitchImageView extends ImageView {
|
|
||||||
|
|
||||||
public static final String TAG = "DebugSwitchImageView";
|
|
||||||
|
|
||||||
// 连续点击计数
|
|
||||||
private int mClickCount = 0;
|
|
||||||
// 目标点击次数
|
|
||||||
private static final int TARGET_CLICK_COUNT = 10;
|
|
||||||
|
|
||||||
public DebugSwitchImageView(Context context) {
|
|
||||||
super(context);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public DebugSwitchImageView(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public DebugSwitchImageView(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
||||||
super(context, attrs, defStyleAttr);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public DebugSwitchImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init() {
|
|
||||||
setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
mClickCount++;
|
|
||||||
if (mClickCount == TARGET_CLICK_COUNT) {
|
|
||||||
// 达到10次,弹出Toast
|
|
||||||
Toast.makeText(getContext(), "连续点击已达到10次,现在开启应用调试功能。", Toast.LENGTH_SHORT).show();
|
|
||||||
GlobalApplication.setIsDebugging(true);
|
|
||||||
GlobalApplication.saveDebugStatus(GlobalApplication.getInstance());
|
|
||||||
// 重置计数,可再次触发
|
|
||||||
mClickCount = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
package cc.winboll.studio.libappbase.views;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import java.util.UUID;
|
||||||
|
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
|
||||||
|
* @Date 2026/04/06 19:32
|
||||||
|
* @Describe 应用Logo控件,连续点击6次弹出调试Token对话框,支持复制与重置
|
||||||
|
*/
|
||||||
|
public class DebugSwitchInfoImageView extends ImageView {
|
||||||
|
|
||||||
|
public static final String TAG = "DebugSwitchInfoImageView";
|
||||||
|
|
||||||
|
// 连续点击计数
|
||||||
|
private int mClickCount = 0;
|
||||||
|
// 目标点击次数
|
||||||
|
private static final int TARGET_CLICK_COUNT = 7;
|
||||||
|
|
||||||
|
private static String mDebugToken = null;
|
||||||
|
private static final String SP_DEBUG_TOKEN = "debug_token_prefs";
|
||||||
|
private static final String KEY_DEBUG_TOKEN = "debug_token";
|
||||||
|
|
||||||
|
public static String getDebugToken() {
|
||||||
|
if (mDebugToken != null) {
|
||||||
|
return mDebugToken;
|
||||||
|
}
|
||||||
|
Context context = GlobalApplication.getInstance();
|
||||||
|
if (context != null) {
|
||||||
|
SharedPreferences sp = context.getSharedPreferences(SP_DEBUG_TOKEN, Context.MODE_PRIVATE);
|
||||||
|
mDebugToken = sp.getString(KEY_DEBUG_TOKEN, null);
|
||||||
|
if (mDebugToken == null) {
|
||||||
|
mDebugToken = UUID.randomUUID().toString();
|
||||||
|
sp.edit().putString(KEY_DEBUG_TOKEN, mDebugToken).apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mDebugToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void resetDebugToken() {
|
||||||
|
Context context = GlobalApplication.getInstance();
|
||||||
|
if (context != null) {
|
||||||
|
mDebugToken = UUID.randomUUID().toString();
|
||||||
|
SharedPreferences sp = context.getSharedPreferences(SP_DEBUG_TOKEN, Context.MODE_PRIVATE);
|
||||||
|
sp.edit().putString(KEY_DEBUG_TOKEN, mDebugToken).apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showDebugTokenDialog() {
|
||||||
|
final AlertDialog dialog = new AlertDialog.Builder(getContext()).create();
|
||||||
|
dialog.setTitle("调试Token");
|
||||||
|
dialog.setMessage(getDebugToken());
|
||||||
|
dialog.setCanceledOnTouchOutside(false);
|
||||||
|
dialog.setButton(DialogInterface.BUTTON_POSITIVE, "复制到剪贴板", (DialogInterface.OnClickListener) null);
|
||||||
|
dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "重置", (DialogInterface.OnClickListener) null);
|
||||||
|
dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "关闭", (DialogInterface.OnClickListener) null);
|
||||||
|
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||||
|
@Override
|
||||||
|
public void onShow(DialogInterface d) {
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
ClipboardManager cm = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
cm.setPrimaryClip(ClipData.newPlainText("DebugToken", getDebugToken()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
resetDebugToken();
|
||||||
|
dialog.setMessage(getDebugToken());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DebugSwitchInfoImageView(Context context) {
|
||||||
|
super(context);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DebugSwitchInfoImageView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DebugSwitchInfoImageView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DebugSwitchInfoImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
mClickCount++;
|
||||||
|
if (mClickCount >= TARGET_CLICK_COUNT) {
|
||||||
|
mClickCount = 0;
|
||||||
|
showDebugTokenDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp"
|
||||||
android:paddingBottom="16dp">
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
<cc.winboll.studio.libappbase.views.DebugSwitchImageView
|
<cc.winboll.studio.libappbase.views.DebugSwitchInfoImageView
|
||||||
android:id="@+id/iv_app_icon"
|
android:id="@+id/iv_app_icon"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
@@ -81,7 +81,8 @@
|
|||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:src="@drawable/ic_key"
|
android:src="@drawable/ic_key"
|
||||||
android:id="@+id/ib_signgetdialog"
|
android:id="@+id/ib_debug_unlock"
|
||||||
|
android:contentDescription="应用调试解锁"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:background="@null"/>
|
android:background="@null"/>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp"
|
||||||
android:paddingBottom="16dp">
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
<cc.winboll.studio.libappbase.views.DebugSwitchImageView
|
<cc.winboll.studio.libappbase.views.DebugSwitchInfoImageView
|
||||||
android:id="@+id/iv_app_icon"
|
android:id="@+id/iv_app_icon"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
@@ -81,7 +81,8 @@
|
|||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:src="@drawable/ic_key"
|
android:src="@drawable/ic_key"
|
||||||
android:id="@+id/ib_signgetdialog"
|
android:id="@+id/ib_debug_unlock"
|
||||||
|
android:contentDescription="应用调试解锁"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:background="@null"/>
|
android:background="@null"/>
|
||||||
|
|||||||
@@ -60,4 +60,7 @@
|
|||||||
<!-- DebugLogStyle 应用调试日志样式属性 -->
|
<!-- DebugLogStyle 应用调试日志样式属性 -->
|
||||||
<attr name="debugTextColor" format="color"/>
|
<attr name="debugTextColor" format="color"/>
|
||||||
|
|
||||||
|
<!-- 边框圆角属性 -->
|
||||||
|
<attr name="borderCornerRadius" format="dimension"/>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
98
settings.gradle
Normal file
98
settings.gradle
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
// AutoInstaller 项目编译设置
|
||||||
|
//include ':autoinstaller'
|
||||||
|
//rootProject.name = "autoinstaller"
|
||||||
|
|
||||||
|
// MJ 项目编译设置
|
||||||
|
//include ':mj'
|
||||||
|
//rootProject.name = "mj"
|
||||||
|
|
||||||
|
// PowerBell 项目编译设置
|
||||||
|
//include ':powerbell'
|
||||||
|
//rootProject.name = "powerbell"
|
||||||
|
|
||||||
|
// APPBase 项目编译设置
|
||||||
|
include ':appbase'
|
||||||
|
include ':libappbase'
|
||||||
|
rootProject.name = "appbase"
|
||||||
|
|
||||||
|
// APPUtils 项目编译设置
|
||||||
|
//include ':apputils'
|
||||||
|
//include ':libapputils'
|
||||||
|
//rootProject.name = "apputils"
|
||||||
|
|
||||||
|
// JC 项目编译设置
|
||||||
|
//include ':jc'
|
||||||
|
//include ':libjc'
|
||||||
|
//rootProject.name = "jc"
|
||||||
|
|
||||||
|
// AES 项目编译设置
|
||||||
|
//include ':aes'
|
||||||
|
//include ':libaes'
|
||||||
|
//rootProject.name = "aes"
|
||||||
|
|
||||||
|
// Contacts 项目编译设置
|
||||||
|
//include ':contacts'
|
||||||
|
//rootProject.name = "contacts"
|
||||||
|
|
||||||
|
// MyMessageManager 项目编译设置
|
||||||
|
//include ':mymessagemanager'
|
||||||
|
//rootProject.name = "mymessagemanager"
|
||||||
|
|
||||||
|
// TimeStamp 项目编译设置
|
||||||
|
//include ':timestamp'
|
||||||
|
//rootProject.name = "timestamp"
|
||||||
|
|
||||||
|
// AndroidDemo 项目编译设置
|
||||||
|
//include ':androiddemo'
|
||||||
|
//rootProject.name = "androiddemo"
|
||||||
|
|
||||||
|
// AndroidXDemo 项目编译设置
|
||||||
|
//include ':androidxdemo'
|
||||||
|
//rootProject.name = "androidxdemo"
|
||||||
|
|
||||||
|
// Ollama 项目编译设置
|
||||||
|
//include ':ollama'
|
||||||
|
//rootProject.name = "ollama"
|
||||||
|
|
||||||
|
// NumTable 项目编译设置
|
||||||
|
//include ':numtable'
|
||||||
|
//rootProject.name = "numtable"
|
||||||
|
|
||||||
|
// MidiPlayer 项目编译设置
|
||||||
|
//include ':midiplayer'
|
||||||
|
//rootProject.name = "midiplayer"
|
||||||
|
|
||||||
|
// WebPageSources 项目编译设置
|
||||||
|
//include ':webpagesources'
|
||||||
|
//rootProject.name = "webpagesources"
|
||||||
|
|
||||||
|
// Positions 项目编译设置
|
||||||
|
//include ':positions'
|
||||||
|
//rootProject.name = "positions"
|
||||||
|
|
||||||
|
// WinBoLL 项目编译设置
|
||||||
|
//include ':winboll'
|
||||||
|
//include ':libwinboll'
|
||||||
|
//rootProject.name = "winboll"
|
||||||
|
|
||||||
|
// RegExpUtils 项目编译设置
|
||||||
|
//include ':regexputils'
|
||||||
|
//rootProject.name = "regexputils"
|
||||||
|
|
||||||
|
// GPSRelaySentinel 项目编译设置
|
||||||
|
//include ':gpsrelaysentinel'
|
||||||
|
//include ':libgpsrelaysentinel'
|
||||||
|
//rootProject.name = "gpsrelaysentinel"
|
||||||
|
|
||||||
|
// Gallery 项目编译设置
|
||||||
|
//include ':gallery'
|
||||||
|
//rootProject.name = "gallery"
|
||||||
|
|
||||||
|
// DebugTemp 项目编译设置
|
||||||
|
//include ':debugtemp'
|
||||||
|
//include ':libdebugtemp'
|
||||||
|
//rootProject.name = "debugtemp"
|
||||||
|
|
||||||
|
// AutoNFC 项目编译设置
|
||||||
|
//include ':autonfc'
|
||||||
|
//rootProject.name = "autonfc"
|
||||||
Reference in New Issue
Block a user