Compare commits
31 Commits
debugtemp-
...
colorpicke
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c267682bd | |||
| 9f18ba65ab | |||
| eb3b4d42d6 | |||
| 8608f8be78 | |||
| f3b3036591 | |||
| 28ecc605e1 | |||
| 523a8e49e0 | |||
| 59a9e0ee45 | |||
| cbf1341435 | |||
| dadf573675 | |||
| 7420a5cd48 | |||
| dc6a589db4 | |||
| e3f47043ef | |||
| a825951aad | |||
| 79cb841349 | |||
| d3c40efffa | |||
| 6c8867e15c | |||
| 610d3811db | |||
| 2d949eb5a3 | |||
| e6940805d9 | |||
| 1641424276 | |||
| 5d1cdff283 | |||
| da66cea1e5 | |||
| 5eb7441dc7 | |||
| 5f3168e17f | |||
| e3c4bab6c9 | |||
| 2af6427ca8 | |||
| b8c70bef98 | |||
| 7713d6c460 | |||
| 73c69bd665 | |||
| a076fe50cd |
205
README.md
@@ -1,104 +1,103 @@
|
||||
WinBoLL 源生态计划项目说明书
|
||||
# WinBoLL 源生态计划项目说明书
|
||||
|
||||
## 一、项目概述
|
||||
|
||||
### 1. 核心定位
|
||||
WinBoLL 手机源码计划,旨在通过核心项目 WinBoLL 构建手机端与服务器端的 Android 项目的开发源码生态。实现手机与服务器的源码的联合开发。
|
||||
|
||||
### 2. 仓库架构
|
||||
#### **仓库类型:功能说明**
|
||||
☆ 基础项目分支 WinBoLL:手机端安卓应用开发基础模板。
|
||||
☆ 应用项目分支 APPBase、AES、PowerBell、Positions**:安卓应用单一管理系列项目。
|
||||
☆ 源码汇总管理 OriginMaster**:各类分支源码合并存档,不适宜作为开发库使用。
|
||||
|
||||
### 3. 源码合并管理推送路线图
|
||||
⚠️ **注意**:仅仅展示不同应用模块源码的综合管理路线。分支合并操作时,必须具备 Git 管理经验。
|
||||
|
||||
★ WinBoLL → APPBase → OriginMaster
|
||||
★ WinBoLL → AES → OriginMaster
|
||||
★ WinBoLL → PowerBell → OriginMaster
|
||||
★ WinBoLL → Positions → OriginMaster
|
||||
|
||||
## 二、WinBoLL 项目核心信息
|
||||
|
||||
### 1. 项目简介
|
||||
☆ WinBoLL 项目是为手机端开发Android 项目的需求而设计的项目。
|
||||
|
||||
### 2. 官方资源
|
||||
#### ☆ 官方网站**:https://www.winboll.cc/
|
||||
#### ☆ 源码地址:
|
||||
★ Gitea:https://gitea.winboll.cc/Studio/WinBoLL.git
|
||||
★ GitHub:https://github.com/ZhanGSKen/WinBoLL.git
|
||||
★ 码云:https://gitee.com/zhangsken/winboll.git
|
||||
|
||||
## 三、应用编译环境检查问题
|
||||
### 核心判断条件:
|
||||
☆ WinBoLL 项目以文件夹 `"/sdcard/WinBoLLStudio/APKs"` 是否存在为判断环境编译输出条件,因为编译输出的APK文件需要一个可供保存的环境。
|
||||
|
||||
☆ 文件夹"/sdcard/WinBoLLStudio/APKs" 目录条件设置方法:
|
||||
***Linux 服务器端方面***:建立 `/sdcard/WinBoLLStudio/APKs` 目录即可。
|
||||
***手机开发端方面***:建立 `"/sdcard/WinBoLLStudio/APKs"` 目录(即 `"/storage/emulated/0/WinBoLLStudio/APKs"` 目录) 即可。
|
||||
|
||||
## 四、前置条件
|
||||
|
||||
### 1. WinBoLL APP 开发环境配置介绍
|
||||
#### WinBoLL APK 编译输出内容包括:
|
||||
☆ "/sdcard/WinBoLLStudio/APKs"` 目录内的所有应用分支的 APK 文件。
|
||||
☆ "/sdcard/AppProjects/app.apk"文件。
|
||||
#### WinBoLL APK 源码命名空间规范
|
||||
☆ WinBoLL 项目使用 "cc.winboll.studio" 作为源码命名空间。在此命名空间下进行源码定义。
|
||||
|
||||
## 五、核心需求规划
|
||||
|
||||
### 1. WinBoLL 应用安全验证需求
|
||||
#### ☆ 支持访问 https://console.winboll.cc/ 服务器以校验应用包签名与版本。
|
||||
|
||||
### 2. 手机端源码开发管理需求
|
||||
#### ☆ 支持切换不同 WinBoLL 分支,以开发不同安卓应用。
|
||||
|
||||
## 六、编译与使用指南
|
||||
|
||||
### 1. 项目初始化(必须)
|
||||
#### 1. 复制 `settings.gradle-demo` 为 `settings.gradle`。编辑 `settings.gradle` 文件内容,取消对应项目模块注释。
|
||||
#### 2. 复制 `gradle.properties-androidx-demo` (Android X 项目) 或 `gradle.properties-android-demo` (基本 Android 项目) 为 `gradle.properties`。
|
||||
#### 3. 复制(可选)`local.properties-demo` 为 `local.properties`,编辑 `local.properties` 文件内容,配置 Android SDK 目录。
|
||||
#### 4. **签名设置**:
|
||||
☆ **调试编译秘钥制作**:使用 Termux 应用终端,cd 进入 GenKeyStore 目录,运行 `bash gen_debug_keystore.sh` 脚本即可生成应用调试秘钥。
|
||||
☆ **应用秘钥配置方法**:拷贝调试编译秘钥制作生成的 `appkey.jks` 与 `appkey.keystore` 文件到项目根目录即可。
|
||||
|
||||
## 七、应用编译命令介绍
|
||||
|
||||
### (1)类库型模块配置要点
|
||||
#### 1. **优先修改配置文件**:优先修改应用测试项目(目录为 `"<WinBoLl根目录>/<类库测试应用>/"`)内 `build.properties` 文件,设置对应的类库项目名称:`libraryProject=<类库项目模块名>`。
|
||||
#### 2. **编译优先启动步骤**:使用 Termux 应用,进入 `"<WinBoLl根目录>"`,运行 `$ bash .winboll/bashPublishAPKAddTag.sh <类库测试项目模块名>` 命令。运行后可生成测试项目与类库项目的编译参数文件 `build.properties`。生成的 `build.properties` 文件有两份,一份在测试项目模块的文件夹内,一份在类库项目本身的模块文件夹内。
|
||||
#### 3. **最后类库编译发布步骤**:使用 Termux 应用,进入 `"<WinBoLl根目录>"`,运行 `$ bash .winboll/bashPublishLIBAddTag.sh <类库项目模块名>` 命令。运行后可发布至 WinBoLL Nexus Maven 库、本地 maven 目录或者是通用默认的 Gradle Maven 库。
|
||||
|
||||
### (2)单一应用型模块与类库测试型模块配置要点
|
||||
#### ☆ APK 编译方法:
|
||||
使用 Termux 应用,进入 `"<WinBoLl根目录>"`,运行 `$ bash .winboll/bashPublishAPKAddTag.sh <应用项目模块名>`。
|
||||
#### ☆ 运行后的 APK 输出路径:
|
||||
★ 默认路径 (`$ bash gradlew assembleBetaDebug` 任务):APK 在 `/sdcard/WinBoLLStudio/APKs/<项目根目录名称>/debug/` 目录。
|
||||
★ 默认路径 (`$ bash assembleStageRelease` 任务):APK 在 `/sdcard/WinBoLLStudio/APKs/<项目根目录名称>/tag/` 目录。
|
||||
★ 额外输出路径:(假设 `winboll.properties` 文件已配置 `ExtraAPKOutputPath` 属性) 输出至 `ExtraAPKOutputPath` 属性配置的目录下。
|
||||
|
||||
### (3)手机端应用调试命令介绍
|
||||
#### ☆ Beta 渠道调试命令
|
||||
$bash gradlew assembleBetaDebug
|
||||
|
||||
#### ☆ Stage 渠道调试命令
|
||||
$bash gradlew assembleStageDebug
|
||||
|
||||
### (4)服务器端开发命令介绍
|
||||
##### ☆ Stage 渠道应用发布命令为:
|
||||
("<WinBoLl根目录>/settings.gradle"文件需要配置编译模块开启参数,拷贝 settings.gradle-demo 为 settings.gradle 文件取消对应的分支配置部分即可。)
|
||||
$bash .winboll/bashPublishAPKAddTag.sh <应用项目模块名>
|
||||
或者是
|
||||
$bash gradlew assembleStageRelease
|
||||
|
||||
一、项目概述
|
||||
|
||||
1. 核心定位
|
||||
|
||||
【OriginMaster】WinBoLL 源生态计划,旨在通过核心项目 WinBoLL 联动系列开发库,构建手机端 Android 项目开发与多端编译同步的完整生态,实现手机与电脑的源码同步开发。
|
||||
|
||||
2. 仓库架构
|
||||
|
||||
仓库类型 包含仓库 功能说明
|
||||
开发库 WinBoLL、APPBase、AES、PowerBell、Positions 核心开发依赖库,其中 WinBoLL 可作为应用开发的基础继承模板
|
||||
分支汇总存档库 OriginMaster 仅用于汇总各开发库分支,不适宜作为开发库克隆使用,非应用开发基础库
|
||||
|
||||
3. 源码推送路径
|
||||
|
||||
- WinBoLL → APPBase → OriginMaster
|
||||
- WinBoLL → AES → OriginMaster
|
||||
- WinBoLL → PowerBell → OriginMaster
|
||||
- WinBoLL → Positions → OriginMaster
|
||||
|
||||
二、WinBoLL APP 核心信息
|
||||
|
||||
1. 项目简介
|
||||
|
||||
WinBoLL Studio Android 应用开源项目,专注于手机端 Android 开发与多端编译同步。
|
||||
|
||||
2. 官方资源
|
||||
|
||||
- 官方网站:https://www.winboll.cc/
|
||||
- 源码地址:
|
||||
- Gitea:https://gitea.winboll.cc/Studio/WinBoLL.git
|
||||
- GitHub:https://github.com/ZhanGSKen/WinBoLL.git
|
||||
- 码云:https://gitee.com/zhangsken/winboll.git
|
||||
- 托管类库源码:
|
||||
- APPBase(jitpack.io):https://github.com/ZhanGSKen/APPBase.git
|
||||
- AES(jitpack.io):https://github.com/ZhanGSKen/AES.git
|
||||
|
||||
三、通用特征文件夹前置(/sdcard)
|
||||
|
||||
- Linux 系统文件夹直接使用 /sdcard 。
|
||||
- 手机 SD 卡存储( /storage/emulated/0 )挂载的别名也可为 /sdcard 。
|
||||
|
||||
四、前置条件
|
||||
|
||||
1. WinBoLL-APP 配置
|
||||
|
||||
- APK 编译输出目录: /sdcard/WinBoLLStudio/APKs/ ,以及 /sdcard/AppProjects/ (命名为 app.apk )
|
||||
- 签名与命名空间:支持应用签名验证定制化,与衍生 APP 共享 cc.winboll.studio 命名空间
|
||||
|
||||
五、核心需求规划
|
||||
|
||||
1. 主机端需求
|
||||
|
||||
- 支持 winboll.cc 域名的用户注册登录服务
|
||||
- 支持 https://console.winboll.cc/api 访问
|
||||
|
||||
2. APP 端需求
|
||||
|
||||
- 实现手机端 Android 应用开发与管理功能
|
||||
|
||||
六、编译与使用指南
|
||||
|
||||
1. 项目初始化(必须)
|
||||
|
||||
1. 复制 settings.gradle-demo 为 settings.gradle ,取消对应项目模块注释
|
||||
2. 复制 gradle.properties-androidx-demo 或 gradle.properties-android-demo 为 gradle.properties
|
||||
3. (可选)复制 local.properties-demo 为 local.properties ,配置 Android SDK 目录
|
||||
4. 签名设置:
|
||||
- 调试编译:进入 GenKeyStore 目录执行 bash gen_debug_keystore.sh
|
||||
- 非必须:clone keystore 模块,拷贝 appkey.jks 与 appkey.keystore 到项目根目录
|
||||
|
||||
2. 编译命令
|
||||
|
||||
(1)类库型项目
|
||||
|
||||
1. 修改测试项目 build.properties ,设置 libraryProject=<类库项目模块名>
|
||||
2. 编译测试项目: bash .winboll/bashPublishAPKAddTag.sh <应用项目模块名>
|
||||
3. 编译类库项目: bash .winboll/bashPublishLIBAddTag.sh <类库项目模块名> (发布至 WinBoLL Nexus Maven 库)
|
||||
|
||||
(2)应用型项目
|
||||
|
||||
- 编译命令: bash .winboll/bashPublishAPKAddTag.sh <应用项目模块名>
|
||||
|
||||
(3)调试编译
|
||||
|
||||
- Beta 调试: bash gradlew assembleBetaDebug
|
||||
- Stage 调试: bash gradlew assembleStageDebug
|
||||
|
||||
(4)发布编译
|
||||
|
||||
- Stage 发布:bash .winboll/bashPublishAPKAddTag.sh <应用项目模块名>
|
||||
或者执行 bash gradlew assembleStageRelease
|
||||
|
||||
3. 编译输出路径
|
||||
|
||||
- 默认路径(assembleBetaDebug任务): /sdcard/WinBoLLStudio/APKs/<项目根目录名称>/debug/
|
||||
- 默认路径(assembleStageRelease任务): /sdcard/WinBoLLStudio/APKs/<项目根目录名称>/tag/
|
||||
- 额外路径:若 winboll.properties 配置 ExtraAPKOutputPath ,APK 同步拷贝至该ExtraAPKOutputPath路径
|
||||
|
||||
4. 版本号命名规则
|
||||
|
||||
- Stage 渠道: V<应用开发环境编号><应用功能变更号><应用调试阶段号> (示例: APPBase_15.7.0 )
|
||||
- Beta 渠道: V<应用开发环境编号><应用功能变更号><应用调试阶段号>-beta<调试编译计数>_<调试编译时间(分钟+秒钟)> (示例: APPBase_15.9.6-beta8_5413 )
|
||||
|
||||
## 八、WinBoLL 应用 APK 版本号命名规则
|
||||
### ☆ Stage 渠道:
|
||||
#### V<应用开发环境编号><应用功能变更号><应用调试阶段号> (示例: APPBase_15.7.0 )
|
||||
### ☆ Beta 渠道:
|
||||
#### V<应用开发环境编号><应用功能变更号><应用调试阶段号>-beta<调试编译计数>_<调试编译时间(分钟+秒钟)> (示例: APPBase_15.9.6-beta8_5413 )
|
||||
|
||||
44
build.gradle
@@ -1,6 +1,15 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
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://clojars.org/repo/" }
|
||||
maven { url "https://jitpack.io" }
|
||||
mavenCentral()
|
||||
google()
|
||||
|
||||
mavenLocal {
|
||||
// 设置本地Maven仓库路径
|
||||
url 'file:///sdcard/.m2/repository/'
|
||||
@@ -11,19 +20,6 @@ buildscript {
|
||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
||||
// "WinBoLL Snapshot"
|
||||
maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" }
|
||||
|
||||
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://clojars.org/repo/" }
|
||||
maven { url "https://jitpack.io" }
|
||||
mavenCentral()
|
||||
google()
|
||||
//println "mavenLocal : ==========="
|
||||
//println mavenLocal().url
|
||||
//println "mavenLocal : ==========="
|
||||
//mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
// 适配MIUI12
|
||||
@@ -35,6 +31,15 @@ buildscript {
|
||||
|
||||
allprojects {
|
||||
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://clojars.org/repo/" }
|
||||
maven { url "https://jitpack.io" }
|
||||
mavenCentral()
|
||||
google()
|
||||
|
||||
mavenLocal {
|
||||
// 设置本地Maven仓库路径
|
||||
url 'file:///sdcard/.m2/repository/'
|
||||
@@ -45,19 +50,6 @@ allprojects {
|
||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
||||
// "WinBoLL Snapshot"
|
||||
maven { url "https://nexus.winboll.cc/repository/maven-snapshots/" }
|
||||
|
||||
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://clojars.org/repo/" }
|
||||
maven { url "https://jitpack.io" }
|
||||
mavenCentral()
|
||||
google()
|
||||
//println "mavenLocal : ==========="
|
||||
//println mavenLocal().url
|
||||
//println "mavenLocal : ==========="
|
||||
//mavenLocal()
|
||||
}
|
||||
ext {
|
||||
// 定义全局变量,常用于版本管理
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# WinBoLL
|
||||
# ColorPickerDialogEx
|
||||
[](https://jitpack.io/#ZhanGSKen/ColorPickerDialogEx)
|
||||
|
||||
#### 介绍
|
||||
WinBoLL 应用编译功能临时调试项目
|
||||
WinBoLL ColorPickerDialogEx 调试版类库。
|
||||
|
||||
#### 软件架构
|
||||
适配安卓应用 [AIDE Pro] 的 Gradle 编译结构。
|
||||
@@ -10,12 +11,10 @@ WinBoLL 应用编译功能临时调试项目
|
||||
|
||||
#### Gradle 编译说明
|
||||
调试版编译命令 :gradle assembleBetaDebug
|
||||
阶段版编译命令 :bash .winboll/bashPublishAPKAddTag.sh debugtemp
|
||||
阶段版编译命令 :bash .winboll/bashPublishAPKAddTag.sh colorpickerdialogex
|
||||
阶段版类库发布命令 :git pull &&bash .winboll/bashPublishLIBAddTag.sh libcolorpickerdialogex
|
||||
|
||||
#### 使用说明
|
||||
3. Termux应用配置:
|
||||
- 已安装Termux(包名 com.termux );
|
||||
- 执行 echo "allow-external-apps = true" > ~/.termux/termux.properties
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
@@ -23,7 +23,7 @@ android {
|
||||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "cc.winboll.studio.debugtemp"
|
||||
applicationId "cc.winboll.studio.colorpickerdialogex"
|
||||
minSdkVersion 23
|
||||
// 适配MIUI12
|
||||
targetSdkVersion 30
|
||||
@@ -50,8 +50,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
api 'com.google.code.gson:gson:2.10.1'
|
||||
api project(':libcolorpickerdialogex')
|
||||
|
||||
// 下拉控件
|
||||
api 'com.baoyz.pullrefreshlayout:library:1.2.0'
|
||||
@@ -108,12 +107,12 @@ dependencies {
|
||||
implementation 'com.termux:termux-shared:0.118.0'
|
||||
|
||||
// WinBoLL库 nexus.winboll.cc 地址
|
||||
api 'cc.winboll.studio:libaes:15.15.2'
|
||||
api 'cc.winboll.studio:libappbase:15.15.11'
|
||||
api 'cc.winboll.studio:libaes:15.15.9'
|
||||
api 'cc.winboll.studio:libappbase:15.15.21'
|
||||
|
||||
// WinBoLL备用库 jitpack.io 地址
|
||||
//api 'com.github.ZhanGSKen:AES:aes-v15.15.7'
|
||||
//api 'com.github.ZhanGSKen:APPBase:appbase-v15.15.4'
|
||||
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
8
colorpickerdialogex/build.properties
Normal file
@@ -0,0 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sat May 02 21:13:04 HKT 2026
|
||||
stageCount=1
|
||||
libraryProject=libcolorpickerdialogex
|
||||
baseVersion=15.0
|
||||
publishVersion=15.0.0
|
||||
buildCount=0
|
||||
baseBetaVersion=15.0.1
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">DebugTemp☆</string>
|
||||
<string name="app_name">ColorPickerDialogEx ©</string>
|
||||
|
||||
</resources>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="cc.winboll.studio.debugtemp">
|
||||
package="cc.winboll.studio.colorpickerdialogex">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -32,6 +32,9 @@
|
||||
|
||||
<activity android:name=".GlobalApplication$CrashActivity"/>
|
||||
|
||||
<activity android:name=".AboutActivity"
|
||||
android:exported="true"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,50 @@
|
||||
package cc.winboll.studio.colorpickerdialogex;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Toolbar;
|
||||
import cc.winboll.studio.colorpickerdialogex.R;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.models.APPInfo;
|
||||
import cc.winboll.studio.libappbase.views.AboutView;
|
||||
|
||||
/**
|
||||
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
|
||||
* @Date 2026/01/11 12:55
|
||||
* @Describe AboutActivity
|
||||
*/
|
||||
public class AboutActivity extends Activity {
|
||||
|
||||
public static final String TAG = "AboutActivity";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setActionBar(toolbar);
|
||||
|
||||
AboutView aboutView = findViewById(R.id.aboutview);
|
||||
aboutView.setAPPInfo(genDefaultAppInfo());
|
||||
}
|
||||
|
||||
private APPInfo genDefaultAppInfo() {
|
||||
LogUtils.d(TAG, "genDefaultAppInfo() 调用");
|
||||
String branchName = "colorpickerdialogex";
|
||||
APPInfo appInfo = new APPInfo();
|
||||
appInfo.setAppName("ColorPickerDialogEx");
|
||||
appInfo.setAppIcon(R.drawable.ic_winboll);
|
||||
appInfo.setAppDescription(getString(R.string.app_description));
|
||||
appInfo.setAppGitName("ColorPickerDialogEx");
|
||||
appInfo.setAppGitOwner("ZhanGSKen");
|
||||
appInfo.setAppGitAPPBranch(branchName);
|
||||
appInfo.setAppGitAPPSubProjectFolder(branchName);
|
||||
appInfo.setAppHomePage("https://www.winboll.cc/apks/index.php?project=ColorPickerDialogEx");
|
||||
appInfo.setAppAPKName("ColorPickerDialogEx");
|
||||
appInfo.setAppAPKFolderName("ColorPickerDialogEx");
|
||||
LogUtils.d(TAG, "genDefaultAppInfo: 应用信息已生成");
|
||||
return appInfo;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cc.winboll.studio.debugtemp;
|
||||
package cc.winboll.studio.colorpickerdialogex;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
@@ -48,6 +48,10 @@ public class App extends GlobalApplication {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
// 如果应用不在调试状态,就根据编译类型设置调试状态
|
||||
if (isDebugging() != true) {
|
||||
setIsDebugging(BuildConfig.DEBUG);
|
||||
}
|
||||
|
||||
// 初始化 Toast 框架
|
||||
ToastUtils.init(this);
|
||||
@@ -0,0 +1,85 @@
|
||||
package cc.winboll.studio.colorpickerdialogex;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.LibraryActivity;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.libcolorpickerdialogex.ColorPickerDialogEx;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
LogView mLogView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
mLogView = findViewById(R.id.logview);
|
||||
|
||||
ToastUtils.show("onCreate");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (App.isDebugging() == true) {
|
||||
mLogView.setVisibility(View.VISIBLE);
|
||||
mLogView.start();
|
||||
} else {
|
||||
mLogView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.menu_about) {
|
||||
startActivity(new Intent(this, AboutActivity.class));
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void onSettingBackgroundWithColorPickerDialogEx(View view) {
|
||||
ColorPickerDialogEx dlg = new ColorPickerDialogEx(this, getResources().getColor(R.color.colorPrimary));
|
||||
dlg.setOnColorChangedListener(new com.a4455jkjh.colorpicker.view.OnColorChangedListener() {
|
||||
|
||||
@Override
|
||||
public void beforeColorChanged() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onColorChanged(int color) {
|
||||
LinearLayout llMain=(LinearLayout)findViewById(R.id.ll_main);
|
||||
llMain.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterColorChanged() {
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
dlg.show();
|
||||
}
|
||||
|
||||
public void onLibraryActivity(View view) {
|
||||
startActivity(new Intent(this, LibraryActivity.class));
|
||||
}
|
||||
}
|
||||
21
colorpickerdialogex/src/main/res/layout/activity_about.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.widget.Toolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/toolbar"/>
|
||||
|
||||
<cc.winboll.studio.libappbase.views.AboutView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0"
|
||||
android:id="@+id/aboutview"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/ll_main">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -26,11 +27,17 @@
|
||||
android:layout_weight="1.0"
|
||||
android:gravity="center_vertical|center_horizontal">
|
||||
|
||||
<TextView
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="DebugTemp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||
android:text="Setting Background With ColorPickerDialogEx"
|
||||
android:onClick="onSettingBackgroundWithColorPickerDialogEx"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Open LibraryActivity"
|
||||
android:onClick="onLibraryActivity"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
8
colorpickerdialogex/src/main/res/menu/main_menu.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/menu_about"
|
||||
android:title="About"
|
||||
android:icon="@android:drawable/ic_dialog_info"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
||||
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
5
colorpickerdialogex/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">ColorPickerDialogEx</string>
|
||||
<string name="app_description">WinBoLL ColorPickerDialogEx 调试版类库调试应用。</string>
|
||||
|
||||
</resources>
|
||||
@@ -1,8 +0,0 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Mar 17 05:58:36 HKT 2026
|
||||
stageCount=51
|
||||
libraryProject=
|
||||
baseVersion=15.0
|
||||
publishVersion=15.0.50
|
||||
buildCount=0
|
||||
baseBetaVersion=15.0.51
|
||||
@@ -1,33 +0,0 @@
|
||||
package cc.winboll.studio.debugtemp;
|
||||
|
||||
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
LogView mLogView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
mLogView = findViewById(R.id.logview);
|
||||
|
||||
ToastUtils.show("onCreate");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mLogView.start();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
<resources>
|
||||
<string name="app_name">DebugTemp</string>
|
||||
|
||||
</resources>
|
||||
1
libcolorpickerdialogex/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
89
libcolorpickerdialogex/build.gradle
Normal file
@@ -0,0 +1,89 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'maven-publish'
|
||||
apply from: '../.winboll/winboll_lib_build.gradle'
|
||||
apply from: '../.winboll/winboll_lint_build.gradle'
|
||||
|
||||
android {
|
||||
// 适配MIUI12
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api 'com.google.code.gson:gson:2.10.1'
|
||||
|
||||
// 下拉控件
|
||||
api 'com.baoyz.pullrefreshlayout:library:1.2.0'
|
||||
|
||||
// SSH
|
||||
api 'com.jcraft:jsch:0.1.55'
|
||||
// Html 解析
|
||||
api 'org.jsoup:jsoup:1.13.1'
|
||||
// 二维码类库
|
||||
api 'com.google.zxing:core:3.4.1'
|
||||
api 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||
// 应用介绍页类库
|
||||
api 'io.github.medyo:android-about-page:2.0.0'
|
||||
// 网络连接类库
|
||||
api 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
// OkHttp网络请求
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.14.9'
|
||||
// FastJSON解析
|
||||
implementation 'com.alibaba:fastjson:1.2.76'
|
||||
|
||||
// AndroidX 类库
|
||||
/*api 'androidx.appcompat:appcompat:1.1.0'
|
||||
//api 'com.google.android.material:material:1.4.0'
|
||||
//api 'androidx.viewpager:viewpager:1.0.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
//api 'androidx.fragment:fragment:1.1.0'*/
|
||||
|
||||
|
||||
// 米盟
|
||||
api 'com.miui.zeus:mimo-ad-sdk:5.3.+'//请使用最新版sdk
|
||||
//注意:以下5个库必须要引入
|
||||
//implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
api 'androidx.recyclerview:recyclerview:1.0.0'
|
||||
api 'com.google.code.gson:gson:2.8.5'
|
||||
api 'com.github.bumptech.glide:glide:4.9.0'
|
||||
//annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
|
||||
|
||||
implementation "androidx.annotation:annotation:1.3.0"
|
||||
implementation "androidx.core:core:1.6.0"
|
||||
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
|
||||
implementation "androidx.preference:preference:1.1.1"
|
||||
implementation "androidx.viewpager:viewpager:1.0.0"
|
||||
implementation "com.google.android.material:material:1.4.0"
|
||||
implementation "com.google.guava:guava:24.1-jre"
|
||||
/*
|
||||
implementation "io.noties.markwon:core:$markwonVersion"
|
||||
implementation "io.noties.markwon:ext-strikethrough:$markwonVersion"
|
||||
implementation "io.noties.markwon:linkify:$markwonVersion"
|
||||
implementation "io.noties.markwon:recycler:$markwonVersion"
|
||||
*/
|
||||
implementation 'com.termux:terminal-emulator:0.118.0'
|
||||
implementation 'com.termux:terminal-view:0.118.0'
|
||||
implementation 'com.termux:termux-shared:0.118.0'
|
||||
|
||||
// WinBoLL库 nexus.winboll.cc 地址
|
||||
api 'cc.winboll.studio:libaes:15.15.2'
|
||||
api 'cc.winboll.studio:libappbase:15.15.11'
|
||||
|
||||
// WinBoLL备用库 jitpack.io 地址
|
||||
//api 'com.github.ZhanGSKen:AES:aes-v15.15.7'
|
||||
//api 'com.github.ZhanGSKen:APPBase:appbase-v15.15.4'
|
||||
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
8
libcolorpickerdialogex/build.properties
Normal file
@@ -0,0 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sat May 02 21:13:04 HKT 2026
|
||||
stageCount=1
|
||||
libraryProject=libcolorpickerdialogex
|
||||
baseVersion=15.0
|
||||
publishVersion=15.0.0
|
||||
buildCount=0
|
||||
baseBetaVersion=15.0.1
|
||||
17
libcolorpickerdialogex/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/tools/adt-bundle-windows-x86_64-20131030/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
13
libcolorpickerdialogex/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="cc.winboll.studio.libcolorpickerdialogex" >
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name="cc.winboll.studio.LibraryActivity"
|
||||
android:label="@string/lib_name" >
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package cc.winboll.studio;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import cc.winboll.studio.libcolorpickerdialogex.R;
|
||||
|
||||
public class LibraryActivity extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.library);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package cc.winboll.studio.libcolorpickerdialogex;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import com.a4455jkjh.colorpicker.ColorPickerDialog;
|
||||
import com.a4455jkjh.colorpicker.view.ColorPickerLayout;
|
||||
import com.a4455jkjh.colorpicker.view.OnColorChangedListener;
|
||||
import java.lang.CharSequence;
|
||||
import java.lang.Object;
|
||||
|
||||
/**
|
||||
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
|
||||
* @Date 2026/05/02 15:14
|
||||
*/
|
||||
public class ColorPickerDialogEx extends com.a4455jkjh.colorpicker.ColorPickerDialog {
|
||||
|
||||
public static final String TAG = "ColorPickerDialog";
|
||||
|
||||
public ColorPickerDialogEx(Context context, int p) {
|
||||
super(context, p);
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
}
|
||||
|
||||
public void onClick(DialogInterface dialogInterface, int p) {
|
||||
super.onClick(dialogInterface, p);
|
||||
}
|
||||
|
||||
public ColorPickerDialog setOnColorChangedListener(OnColorChangedListener onColorChangedListener) {
|
||||
return super.setOnColorChangedListener(onColorChangedListener);
|
||||
}
|
||||
|
||||
public ColorPickerDialog setTitle(int p) {
|
||||
return super.setTitle(p);
|
||||
}
|
||||
|
||||
public ColorPickerDialog setTitle(CharSequence charSequence) {
|
||||
return super.setTitle(charSequence);
|
||||
}
|
||||
|
||||
public void show() {
|
||||
super.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 19 KiB |
11
libcolorpickerdialogex/src/main/res/layout/library.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:text="@string/text_libraryactivity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="AppTheme" parent="@android:style/Theme.Material.Light">
|
||||
</style>
|
||||
</resources>
|
||||
8
libcolorpickerdialogex/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="lib_name">libdebugtemp</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="text_libraryactivity">LibraryActivity</string>
|
||||
|
||||
</resources>
|
||||
5
libcolorpickerdialogex/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
|
||||
</style>
|
||||
</resources>
|
||||
@@ -30,6 +30,11 @@
|
||||
//include ':libaes'
|
||||
//rootProject.name = "aes"
|
||||
|
||||
// ColorPickerDialogEx 项目编译设置
|
||||
//include ':colorpickerdialogex'
|
||||
//include ':libcolorpickerdialogex'
|
||||
//rootProject.name = "colorpickerdialogex"
|
||||
|
||||
// Contacts 项目编译设置
|
||||
//include ':contacts'
|
||||
//rootProject.name = "contacts"
|
||||
@@ -77,7 +82,3 @@
|
||||
// RegExpUtils 项目编译设置
|
||||
//include ':regexputils'
|
||||
//rootProject.name = "regexputils"
|
||||
|
||||
// DebugTemp 项目编译设置
|
||||
//include ':debugtemp'
|
||||
//rootProject.name = "debugtemp"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sun Mar 15 11:48:40 HKT 2026
|
||||
stageCount=26
|
||||
#Thu Apr 30 14:58:25 CST 2026
|
||||
stageCount=27
|
||||
libraryProject=
|
||||
baseVersion=15.11
|
||||
publishVersion=15.11.25
|
||||
buildCount=0
|
||||
baseBetaVersion=15.11.26
|
||||
publishVersion=15.11.26
|
||||
buildCount=11
|
||||
baseBetaVersion=15.11.27
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="cc.winboll.studio.winboll"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:sharedUserId="com.termux">
|
||||
package="cc.winboll.studio.winboll"
|
||||
android:sharedUserId="com.termux">
|
||||
|
||||
<!-- 拥有完全的网络访问权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
@@ -13,11 +13,15 @@
|
||||
|
||||
<!-- 对正在运行的应用重新排序 -->
|
||||
<uses-permission android:name="android.permission.REORDER_TASKS"/>
|
||||
<!-- Android 11+ 查询已安装应用权限 -->
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission" />
|
||||
<!-- 可选:兼容低版本系统 -->
|
||||
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
|
||||
|
||||
<!-- 计算应用存储空间 -->
|
||||
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE"/>
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission"/>
|
||||
|
||||
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -289,17 +293,39 @@
|
||||
|
||||
<activity android:name="cc.winboll.studio.winboll.activities.WXPayActivity"/>
|
||||
|
||||
<activity android:name="cc.winboll.studio.winboll.activities.PatternLockActivity"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="cc.winboll.studio.winboll.activities.PatternLockActivity.ACTION_OPEN_PATTERN"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<activity android:name="cc.winboll.studio.winboll.unittest.TermuxEnvTestActivity"/>
|
||||
|
||||
<activity
|
||||
android:name=".termux.NfcTermuxBridgeActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="cc.winboll.nfc.ACTION_EXEC_TERMUX" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".termux.NfcTermuxBridgeActivity"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="cc.winboll.studio.winboll.termux.NfcTermuxBridgeActivity.ACTION_BUILD"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<activity android:name="cc.winboll.studio.winboll.applications.MyTermuxActivity"
|
||||
android:label="@string/my_termux_activity"
|
||||
android:exported="true"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
@@ -15,6 +15,7 @@ import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.winboll.R;
|
||||
import cc.winboll.studio.winboll.activities.AboutActivity;
|
||||
import cc.winboll.studio.winboll.activities.SettingsActivity;
|
||||
import cc.winboll.studio.winboll.applications.MyTermuxActivity;
|
||||
import cc.winboll.studio.winboll.fragments.BrowserFragment;
|
||||
import cc.winboll.studio.winboll.unittest.TermuxEnvTestActivity;
|
||||
import java.util.ArrayList;
|
||||
@@ -155,6 +156,10 @@ public class MainActivity extends DrawerFragmentActivity {
|
||||
Intent intent = new Intent(getApplicationContext(), AboutActivity.class);
|
||||
|
||||
WinBoLLActivityManager.getInstance().startWinBoLLActivity(getApplicationContext(), intent, AboutActivity.class);
|
||||
} else if (nItemId == R.id.item_mytermux) {
|
||||
Intent intent = new Intent(getApplicationContext(), MyTermuxActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
} else if (nItemId == R.id.item_termux_env_test) {
|
||||
Intent intent = new Intent(getApplicationContext(), TermuxEnvTestActivity.class);
|
||||
|
||||
|
||||
@@ -0,0 +1,295 @@
|
||||
package cc.winboll.studio.winboll.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
import cc.winboll.studio.winboll.R;
|
||||
|
||||
public class PatternLockActivity extends BaseWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "PatternLockActivity";
|
||||
|
||||
private static final int DOT_RADIUS = 8;
|
||||
private static final int PATTERN_ERROR_DURATION = 1500;
|
||||
|
||||
private static final String PREFS_NAME = "pattern_lock_prefs";
|
||||
static final String KEY_LOCK_PATTERN = "lock_pattern";
|
||||
static final String KEY_ERROR_STATE = "error_state";
|
||||
private static final String KEY_ERROR_REPEAT_PATTERN = "error_repeat_pattern";
|
||||
|
||||
private boolean mIsInErrorState;
|
||||
private boolean mNeedRestart;
|
||||
private Handler mHandler;
|
||||
|
||||
private FrameLayout mContainer;
|
||||
private PatternView mPatternView;
|
||||
|
||||
public PatternLockActivity() {
|
||||
mHandler = new Handler(Looper.getMainLooper());
|
||||
}
|
||||
|
||||
PatternLockActivity(Context context) {
|
||||
mHandler = new Handler(Looper.getMainLooper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
AESThemeUtil.applyAppTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_pattern_lock);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setSubtitle(TAG);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
toolbar.setNavigationOnClickListener(v -> finish());
|
||||
|
||||
mContainer = findViewById(R.id.container);
|
||||
mPatternView = new PatternView(this);
|
||||
mContainer.addView(mPatternView);
|
||||
mPatternView.invalidate();
|
||||
|
||||
mNeedRestart = false;
|
||||
boolean isEnoughPoints = savedInstanceIsEnoughPoints();
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mIsInErrorState = savedInstanceState.getBoolean(KEY_ERROR_STATE, false);
|
||||
mNeedRestart = savedInstanceState.getBoolean(KEY_ERROR_REPEAT_PATTERN, false);
|
||||
}
|
||||
|
||||
if (mIsInErrorState) {
|
||||
mPatternView.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
boolean savedInstanceIsEnoughPoints() {
|
||||
int count = 0;
|
||||
if (mPatternView != null) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (mPatternView.mDotState[i] == 1) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count >= 4 || count == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
if (mIsInErrorState) {
|
||||
outState.putBoolean(KEY_ERROR_STATE, mIsInErrorState);
|
||||
}
|
||||
if (mNeedRestart) {
|
||||
outState.putBoolean(KEY_ERROR_REPEAT_PATTERN, mNeedRestart);
|
||||
}
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
private void showErrorState() {
|
||||
mIsInErrorState = true;
|
||||
invalidatePattern();
|
||||
mHandler.postDelayed(() -> {
|
||||
mIsInErrorState = false;
|
||||
SharedPreferences prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
|
||||
prefs.edit().putBoolean(KEY_ERROR_STATE, false).apply();
|
||||
invalidatePattern();
|
||||
if (mPatternView != null) mPatternView.invalidate();
|
||||
}, PATTERN_ERROR_DURATION);
|
||||
}
|
||||
|
||||
private void clearErrorState() {
|
||||
mIsInErrorState = false;
|
||||
SharedPreferences prefs = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
|
||||
prefs.edit().putBoolean(KEY_ERROR_STATE, false).apply();
|
||||
invalidatePattern();
|
||||
if (mPatternView != null) mPatternView.invalidate();
|
||||
}
|
||||
|
||||
private void showErrorToast() {
|
||||
android.widget.Toast.makeText(this, "图案点数不足,请重新绘制",
|
||||
android.widget.Toast.LENGTH_SHORT).show();
|
||||
mNeedRestart = true;
|
||||
}
|
||||
|
||||
private void showSuccessDialog() {
|
||||
android.app.AlertDialog alertDialog = new android.app.AlertDialog.Builder(this)
|
||||
.setTitle("设置成功")
|
||||
.setMessage("图案密码已设置成功")
|
||||
.setPositiveButton("确定", (dialog, which) -> finish())
|
||||
.setCancelable(false)
|
||||
.create();
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
void finishWithRestart() {
|
||||
finish();
|
||||
}
|
||||
|
||||
private void invalidatePattern() {
|
||||
if (mPatternView != null) {
|
||||
mPatternView.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
class PatternView extends FrameLayout {
|
||||
int mPatternSize = 0;
|
||||
int MAX_DOT_COUNT = 9;
|
||||
int[] mDotX = new int[MAX_DOT_COUNT];
|
||||
int[] mDotY = new int[MAX_DOT_COUNT];
|
||||
int[] mDotState = new int[MAX_DOT_COUNT];
|
||||
Bitmap mDotBitmap;
|
||||
Paint mPaintConnector;
|
||||
Paint mPaintErrorBackground;
|
||||
int mDotCount = 0;
|
||||
|
||||
PatternView(Context context) {
|
||||
super(context);
|
||||
setBackgroundColor(Color.WHITE);
|
||||
for (int i = 0; i < MAX_DOT_COUNT; i++) {
|
||||
mDotX[i] = -1;
|
||||
mDotY[i] = -1;
|
||||
mDotState[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
if (w == 0 || h == 0) return;
|
||||
mPatternSize = w > h ? h : w;
|
||||
int grid = 3;
|
||||
int cell = mPatternSize / grid;
|
||||
|
||||
for (int i = 0; i < MAX_DOT_COUNT; i++) {
|
||||
mDotX[i] = (i % grid) * cell + cell / 2 - cell / 24;
|
||||
mDotY[i] = (i / grid) * cell + cell / 2 - cell / 24;
|
||||
mDotState[i] = 0;
|
||||
}
|
||||
|
||||
if (mDotBitmap == null) {
|
||||
mDotBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.dot_darkgreen_dark);
|
||||
}
|
||||
if (mPaintConnector == null) {
|
||||
mPaintConnector = new Paint(Paint.FILTER_BITMAP_FLAG);
|
||||
mPaintConnector.setColor(-0xFF006400);
|
||||
}
|
||||
if (mPaintErrorBackground == null) {
|
||||
mPaintErrorBackground = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mPaintErrorBackground.setColor(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (mDotCount > 0) return false;
|
||||
|
||||
switch (event.getActionMasked()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
invalidate();
|
||||
return true;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
float x = event.getX();
|
||||
float y = event.getY();
|
||||
|
||||
for (int i = 0; i < MAX_DOT_COUNT; i++) {
|
||||
int dx = (int) Math.abs(x - mDotX[i]);
|
||||
int dy = (int) Math.abs(y - mDotY[i]);
|
||||
if (dx <= DOT_RADIUS && dy <= DOT_RADIUS && mDotState[i] == 0) {
|
||||
mDotState[i] = 1;
|
||||
mDotCount++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < mDotCount - 1; i++) {
|
||||
int a = -1, b = -1;
|
||||
for (int k = 0; k < MAX_DOT_COUNT; k++) {
|
||||
if (mDotState[k] == 1) {
|
||||
if (a < 0) a = k;
|
||||
else b = k;
|
||||
}
|
||||
}
|
||||
if (a >= 0 && b >= 0) {
|
||||
a = Math.min(a, b);
|
||||
b = Math.max(a, b);
|
||||
}
|
||||
if (mDotState[a] == 1 && mDotState[b] == 1) {
|
||||
int dx = mDotX[b] - mDotX[a];
|
||||
int dy = mDotY[b] - mDotY[a];
|
||||
if ((Math.abs(dx) <= 1 && Math.abs(dy) <= 1) ||
|
||||
(Math.abs(dx) <= 2 && Math.abs(dy) <= 1)) {
|
||||
if (mDotState[b] == 1) {
|
||||
for (int k = a + 1; k < b; k++) {
|
||||
if (mDotState[k] == 0) {
|
||||
mDotState[k] = 1;
|
||||
}
|
||||
}
|
||||
mDotCount += (b - a - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
invalidate();
|
||||
return true;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
if (mDotCount < 4) {
|
||||
showErrorState();
|
||||
showErrorToast();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas) {
|
||||
if (mPatternSize == 0) return;
|
||||
|
||||
int activeCount = 0;
|
||||
for (int i = 0; i < MAX_DOT_COUNT; i++) {
|
||||
if (mDotState[i] == 1) activeCount++;
|
||||
}
|
||||
|
||||
if (activeCount == 0) {
|
||||
mPaintErrorBackground.setAlpha(50);
|
||||
} else {
|
||||
mPaintErrorBackground.setAlpha(mIsInErrorState ? 80 : 60);
|
||||
}
|
||||
|
||||
canvas.clipRect(0, 0, mPatternSize * 80 / 100, mPatternSize * 80 / 100);
|
||||
|
||||
canvas.drawRect(0, 0, mPatternSize, mPatternSize, mPaintErrorBackground);
|
||||
|
||||
if (mDotBitmap != null) {
|
||||
for (int i = 0; i < MAX_DOT_COUNT; i++) {
|
||||
if (mDotState[i] == 1) {
|
||||
canvas.drawBitmap(mDotBitmap, mDotX[i], mDotY[i], mPaintConnector);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package cc.winboll.studio.winboll.applications;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.winboll.R;
|
||||
import cc.winboll.studio.winboll.termux.TermuxCommandExecutor;
|
||||
|
||||
public class MyTermuxActivity extends AppCompatActivity {
|
||||
|
||||
public static final String TAG = "MyTermuxActivity";
|
||||
|
||||
private Toolbar mToolbar;
|
||||
private Button mTermuxButton;
|
||||
private Button mTermuxWorkSpacesButton;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_my_termux);
|
||||
|
||||
// 初始化工具栏
|
||||
initToolbar();
|
||||
// 初始化按钮
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initToolbar() {
|
||||
mToolbar = findViewById(R.id.toolbar);
|
||||
if (mToolbar != null) {
|
||||
setSupportActionBar(mToolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogUtils.d(TAG, "点击返回按钮");
|
||||
finish();
|
||||
}
|
||||
});
|
||||
LogUtils.d(TAG, "工具栏初始化完成");
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
mTermuxButton = findViewById(R.id.btn_termux);
|
||||
if (mTermuxButton != null) {
|
||||
mTermuxButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogUtils.d(TAG, "点击 Termux 按钮");
|
||||
TermuxCommandExecutor.openTermuxBash(MyTermuxActivity.this, "cd ~");
|
||||
//TermuxCommandExecutor.openTermuxBash(MyTermuxActivity.this, "cd ~/TermuxWorkSpaces", "./TermuxWorkSpaces");
|
||||
}
|
||||
});
|
||||
LogUtils.d(TAG, "Termux 按钮初始化完成");
|
||||
}
|
||||
|
||||
mTermuxWorkSpacesButton = findViewById(R.id.btn_termuxworkspaces);
|
||||
if (mTermuxWorkSpacesButton != null) {
|
||||
mTermuxWorkSpacesButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogUtils.d(TAG, "点击 TermuxWorkSpaces 按钮");
|
||||
TermuxCommandExecutor.openTermuxBash(MyTermuxActivity.this, "cd ~/TermuxWorkSpaces", "./TermuxWorkSpaces");
|
||||
}
|
||||
});
|
||||
LogUtils.d(TAG, "TermuxWorkSpaces 按钮初始化完成");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isTermuxAvailable() {
|
||||
return TermuxCommandExecutor.isTermuxInstalled(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package cc.winboll.studio.winboll.models;
|
||||
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
|
||||
* @Date 2026/04/30 10:47
|
||||
*/
|
||||
public class TermuxButtonModel extends BaseBean {
|
||||
|
||||
public static final String TAG = "TermuxButtonModel";
|
||||
|
||||
String buttonName;
|
||||
String exeCommand;
|
||||
String workDir;
|
||||
|
||||
// 已修改:isCommit 改为规范过去式命名 isCommitted
|
||||
boolean isCommitted;
|
||||
String commitTitle;
|
||||
String commitInfo;
|
||||
|
||||
public TermuxButtonModel() {
|
||||
this.buttonName = "";
|
||||
this.exeCommand = "";
|
||||
this.workDir = "";
|
||||
// 默认初始化
|
||||
this.isCommitted = false;
|
||||
this.commitTitle = "";
|
||||
this.commitInfo = "";
|
||||
}
|
||||
|
||||
public void setButtonName(String buttonName) {
|
||||
this.buttonName = buttonName;
|
||||
}
|
||||
|
||||
public String getButtonName() {
|
||||
return buttonName;
|
||||
}
|
||||
|
||||
public void setExeCommand(String exeCommand) {
|
||||
this.exeCommand = exeCommand;
|
||||
}
|
||||
|
||||
public String getExeCommand() {
|
||||
return exeCommand;
|
||||
}
|
||||
|
||||
public void setWorkDir(String workDir) {
|
||||
this.workDir = workDir;
|
||||
}
|
||||
|
||||
public String getWorkDir() {
|
||||
return workDir;
|
||||
}
|
||||
|
||||
// ========== 已修改 对应 isCommitted 完整 Get & Set ==========
|
||||
public boolean isCommitted() {
|
||||
return isCommitted;
|
||||
}
|
||||
|
||||
public void setCommitted(boolean committed) {
|
||||
isCommitted = committed;
|
||||
}
|
||||
|
||||
public String getCommitTitle() {
|
||||
return commitTitle;
|
||||
}
|
||||
|
||||
public void setCommitTitle(String commitTitle) {
|
||||
this.commitTitle = commitTitle;
|
||||
}
|
||||
|
||||
public String getCommitInfo() {
|
||||
return commitInfo;
|
||||
}
|
||||
|
||||
public void setCommitInfo(String commitInfo) {
|
||||
this.commitInfo = commitInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return TermuxButtonModel.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("buttonName").value(getButtonName());
|
||||
jsonWriter.name("exeCommand").value(getExeCommand());
|
||||
jsonWriter.name("workDir").value(getWorkDir());
|
||||
|
||||
// JSON写入同步修改
|
||||
jsonWriter.name("isCommitted").value(isCommitted());
|
||||
jsonWriter.name("commitTitle").value(getCommitTitle());
|
||||
jsonWriter.name("commitInfo").value(getCommitInfo());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) {
|
||||
return true;
|
||||
} else {
|
||||
if (name.equals("buttonName")) {
|
||||
setButtonName(jsonReader.nextString());
|
||||
} else if (name.equals("exeCommand")) {
|
||||
setExeCommand(jsonReader.nextString());
|
||||
} else if (name.equals("workDir")) {
|
||||
setWorkDir(jsonReader.nextString());
|
||||
}
|
||||
// JSON解析字段同步修改
|
||||
else if (name.equals("isCommitted")) {
|
||||
setCommitted(jsonReader.nextBoolean());
|
||||
} else if (name.equals("commitTitle")) {
|
||||
setCommitTitle(jsonReader.nextString());
|
||||
} else if (name.equals("commitInfo")) {
|
||||
setCommitInfo(jsonReader.nextString());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
String name = jsonReader.nextName();
|
||||
if (!initObjectsFromJsonReader(jsonReader, name)) {
|
||||
jsonReader.skipValue();
|
||||
}
|
||||
}
|
||||
jsonReader.endObject();
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* 源码说明与描述:
|
||||
* NFC 与 Termux 桥接活动,用于接收外部应用(包调用)传递的 JSON 指令并执行 Termux 脚本命令。
|
||||
* 支持 ACTION_BUILD(后台执行)与 ACTION_BUILD_VIEW(终端窗口唤起)两种动作。
|
||||
*
|
||||
* 作者:豆包&ZhanGSKen<zhangsken@qq.com>
|
||||
* 创建时间:2025-03-15 14:00:00
|
||||
* 最后编辑时间:2026-03-16 10:00:00
|
||||
*/
|
||||
package cc.winboll.studio.winboll.termux;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -6,99 +15,227 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.winboll.models.NfcTermuxCmd;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class NfcTermuxBridgeActivity extends Activity {
|
||||
|
||||
private static final String TAG = "NfcTermuxBridge";
|
||||
// ========================= 常量与静态属性 =========================
|
||||
public static final String TAG = "NfcTermuxBridgeActivity";
|
||||
|
||||
// 外部应用调用时使用的 Action 常量
|
||||
public static final String ACTION_BUILD = "cc.winboll.studio.winboll.termux.NfcTermuxBridgeActivity.ACTION_BUILD";
|
||||
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
// ========================= 生命周期方法 =========================
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
handleNfcIntent(getIntent());
|
||||
LogUtils.d(TAG, "onCreate() 调用,savedInstanceState: " + (savedInstanceState != null ? "非空" : "空"));
|
||||
dispatchIntent(getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
handleNfcIntent(intent);
|
||||
LogUtils.d(TAG, "onNewIntent() 调用,intent: " + (intent != null ? intent.toString() : "null"));
|
||||
if (intent != null) {
|
||||
LogUtils.d(TAG, "onNewIntent() action: " + intent.getAction());
|
||||
LogUtils.d(TAG, "onNewIntent() data: " + intent.getDataString());
|
||||
LogUtils.d(TAG, "onNewIntent() extras: " + intent.getExtras());
|
||||
LogUtils.d(TAG, "onNewIntent() flags: " + intent.getFlags());
|
||||
LogUtils.d(TAG, "onNewIntent() component: " + intent.getComponent());
|
||||
} else {
|
||||
LogUtils.w(TAG, "onNewIntent() intent is null");
|
||||
}
|
||||
dispatchIntent(intent);
|
||||
}
|
||||
|
||||
// ========================= 统一 Intent 分发(合并去重) =========================
|
||||
/**
|
||||
* 处理 NFC 传递的 JSON 指令
|
||||
* 统一分发 Intent,根据 Action 路由到不同业务逻辑
|
||||
* @param intent 外部传入的 Intent
|
||||
*/
|
||||
private void handleNfcIntent(Intent intent) {
|
||||
if (intent == null) return;
|
||||
private void dispatchIntent(Intent intent) {
|
||||
LogUtils.d(TAG, "dispatchIntent() 分发 intent");
|
||||
if (intent == null) {
|
||||
LogUtils.w(TAG, "dispatchIntent() intent is null");
|
||||
return;
|
||||
}
|
||||
|
||||
String action = intent.getAction();
|
||||
if (ACTION_BUILD.equals(action)) {
|
||||
ToastUtils.show("ACTION_BUILD 命中");
|
||||
onOpenTermuxProjectBuild(intent);
|
||||
} else {
|
||||
LogUtils.w(TAG, "dispatchIntent() 未知 Action: " + action);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
// ========================= 核心业务方法 =========================
|
||||
/**
|
||||
* 处理 ACTION_BUILD 动作:后台执行 NFC 指令
|
||||
*/
|
||||
// private void handleNfcIntent(Intent intent) {
|
||||
// LogUtils.d(TAG, "handleNfcIntent() 调用");
|
||||
// if (intent == null) {
|
||||
// LogUtils.w(TAG, "handleNfcIntent() intent 为空");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// String json = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
// LogUtils.d(TAG, "handleNfcIntent() json: " + json);
|
||||
//
|
||||
// if (json == null || json.isEmpty()) {
|
||||
// LogUtils.e(TAG, "handleNfcIntent() 指令为空");
|
||||
// showToast("指令为空");
|
||||
// finish();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// NfcTermuxCmd cmd = GSON.fromJson(json, NfcTermuxCmd.class);
|
||||
// LogUtils.d(TAG, "handleNfcIntent() cmd: " + cmd);
|
||||
//
|
||||
// if (cmd.script == null || cmd.script.isEmpty()) {
|
||||
// LogUtils.e(TAG, "handleNfcIntent() script 为空");
|
||||
// showToast("script 不能为空");
|
||||
// finish();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// //String scriptPath = "/data/data/com.termux/files/home/TermuxWorkSpaces/BashShells/AutoNFC/" + cmd.script;
|
||||
// String scriptPath = "/data/data/com.termux/files/home/TermuxWorkSpaces/BashShells/AutoNFC/" + "BuildWinBoLLProject.sh";
|
||||
// LogUtils.d(TAG, "handleNfcIntent() 脚本路径: " + scriptPath);
|
||||
//
|
||||
// boolean success = TermuxCommandExecutor.executeCommand(
|
||||
// this, scriptPath, cmd.args, cmd.workDir, cmd.background, cmd.resultDir
|
||||
// );
|
||||
// LogUtils.d(TAG, "handleNfcIntent() 执行结果: " + success);
|
||||
//
|
||||
// if (success) {
|
||||
// showToast("指令已发送: " + cmd.script);
|
||||
// LogUtils.i(TAG, "执行成功: " + scriptPath);
|
||||
// } else {
|
||||
// showToast("指令发送失败");
|
||||
// LogUtils.e(TAG, "执行失败");
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// LogUtils.e(TAG, "handleNfcIntent() 异常: " + e.getMessage(), e);
|
||||
// showToast("解析失败");
|
||||
// } finally {
|
||||
// finish();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 处理 ACTION_BUILD_VIEW 动作:唤起 Termux 窗口执行命令
|
||||
*/
|
||||
public void onOpenTermuxProjectBuild(Intent intent) {
|
||||
LogUtils.d(TAG, "onOpenTermuxProjectBuildView() 调用");
|
||||
if (intent == null) {
|
||||
LogUtils.w(TAG, "onOpenTermuxProjectBuildView() intent 为空");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
String json = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
LogUtils.d(TAG, "onOpenTermuxProjectBuildView() json: " + json);
|
||||
|
||||
// 1. 发布版逻辑:正常接收 NFC 传入的 JSON
|
||||
if (json == null || json.isEmpty()) {
|
||||
LogUtils.e(TAG, "NFC 指令为空");
|
||||
LogUtils.e(TAG, "onOpenTermuxProjectBuildView() 指令为空");
|
||||
showToast("指令为空");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
LogUtils.d(TAG, "接收 JSON:" + json);
|
||||
|
||||
// 2. 解析指令
|
||||
NfcTermuxCmd cmd = GSON.fromJson(json, NfcTermuxCmd.class);
|
||||
LogUtils.d(TAG, "onOpenTermuxProjectBuildView() cmd: " + cmd);
|
||||
|
||||
if (cmd.script == null || cmd.script.isEmpty()) {
|
||||
LogUtils.e(TAG, "script 不能为空");
|
||||
LogUtils.e(TAG, "onOpenTermuxProjectBuildView() script 为空");
|
||||
showToast("script 不能为空");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 拼接脚本路径
|
||||
String scriptPath = "/data/data/com.termux/files/home/TermuxWorkSpaces/BashShells/AutoNFC/" + cmd.script;
|
||||
StringBuilder targetCmd = new StringBuilder();
|
||||
String nfcScriptFolder = "/data/data/com.termux/files/home/TermuxWorkSpaces/BashShells/AutoNFC/";
|
||||
targetCmd.append("cd " + nfcScriptFolder + " && ");
|
||||
//targetCmd.append("stdbuf -o0 -e0 -i0 bash ").append(cmd.script).append(" ");
|
||||
targetCmd.append("stdbuf -o0 -e0 -i0 bash ").append("BuildWinBoLLProject.sh").append(" ");
|
||||
if (cmd.args != null) {
|
||||
for (String arg : cmd.args) {
|
||||
targetCmd.append(arg).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 执行 Termux 命令
|
||||
boolean success = TermuxCommandExecutor.executeCommand(
|
||||
this,
|
||||
scriptPath,
|
||||
cmd.args,
|
||||
cmd.workDir,
|
||||
cmd.background,
|
||||
cmd.resultDir
|
||||
);
|
||||
LogUtils.d(TAG, "onOpenTermuxProjectBuildView() 命令: " + targetCmd);
|
||||
boolean cmdSuccess = TermuxCommandExecutor.executeTerminalCommand(this, targetCmd.toString());
|
||||
LogUtils.d(TAG, "onOpenTermuxProjectBuildView() 执行结果: " + cmdSuccess);
|
||||
|
||||
// 5. 结果反馈
|
||||
if (success) {
|
||||
Toast.makeText(this, "指令已发送:" + cmd.script, Toast.LENGTH_SHORT).show();
|
||||
LogUtils.i(TAG, "执行成功:" + scriptPath);
|
||||
if (cmdSuccess) {
|
||||
showToast("指令已发送: " + cmd.script);
|
||||
} else {
|
||||
Toast.makeText(this, "指令发送失败", Toast.LENGTH_SHORT).show();
|
||||
LogUtils.e(TAG, "执行失败");
|
||||
showToast("指令发送失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(TAG, "处理异常:" + e.getMessage(), e);
|
||||
Toast.makeText(this, "解析失败", Toast.LENGTH_SHORT).show();
|
||||
LogUtils.e(TAG, "onOpenTermuxProjectBuildView() 异常: " + e.getMessage(), e);
|
||||
showToast("解析失败");
|
||||
} finally {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================
|
||||
// 公共静态测试函数:外部可直接调用注入测试 JSON
|
||||
// ===========================================================
|
||||
// ========================= 公共静态测试方法 =========================
|
||||
/**
|
||||
* 内部测试方法:发送 ACTION_BUILD 指令
|
||||
*/
|
||||
public static void testCommand(Context context) {
|
||||
LogUtils.d(TAG, "testCommand()");
|
||||
try {
|
||||
// 测试用指令
|
||||
String testJson = "{\"script\":\"BuildWinBoLLProject.sh\",\"args\":[\"WinBoLL_Demo\"],\"workDir\":null,\"background\":true,\"resultDir\":null}";
|
||||
|
||||
Intent testIntent = new Intent(context, NfcTermuxBridgeActivity.class);
|
||||
testIntent.putExtra(Intent.EXTRA_TEXT, testJson);
|
||||
|
||||
// 模拟跳转至自身 Activity
|
||||
context.startActivity(testIntent);
|
||||
|
||||
String testJson = "{\"script\":\"BuildWinBoLLProject.sh\",\"args\":[\"DebugTemp\"],\"workDir\":null,\"background\":true,\"resultDir\":null}";
|
||||
Intent intent = new Intent(context, NfcTermuxBridgeActivity.class);
|
||||
intent.setAction(ACTION_BUILD); // 指定 Action
|
||||
intent.putExtra(Intent.EXTRA_TEXT, testJson);
|
||||
context.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(TAG, "测试指令注入失败:" + e.getMessage());
|
||||
LogUtils.e(TAG, "testCommand() 失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部测试方法:发送 ACTION_BUILD_VIEW 指令
|
||||
*/
|
||||
// public static void testViewCommand(Context context) {
|
||||
// LogUtils.d(TAG, "testViewCommand()");
|
||||
// try {
|
||||
// String testJson = "{\"script\":\"BuildWinBoLLProjectView.sh\",\"args\":[\"DebugTemp\"],\"workDir\":null,\"background\":true,\"resultDir\":null}";
|
||||
// Intent intent = new Intent(context, NfcTermuxBridgeActivity.class);
|
||||
// intent.setAction(ACTION_BUILD_VIEW); // 指定 Action
|
||||
// intent.putExtra(Intent.EXTRA_TEXT, testJson);
|
||||
// context.startActivity(intent);
|
||||
// } catch (Exception e) {
|
||||
// LogUtils.e(TAG, "testViewCommand() 失败: " + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
// ========================= 工具方法 =========================
|
||||
/**
|
||||
* 统一显示 Toast,确保在主线程调用
|
||||
*/
|
||||
private void showToast(final String message) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(NfcTermuxBridgeActivity.this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ public class TermuxCommandExecutor {
|
||||
// Termux RunCommandService 完整类名(包名+类名)
|
||||
private static final String TERMUX_RUN_CMD_SERVICE_CLASS = "com.termux.app.RunCommandService";
|
||||
private static final String TERMUX_RUN_CMD_ACTION = TermuxConstants.TERMUX_APP.RUN_COMMAND_SERVICE.ACTION_RUN_COMMAND;
|
||||
private static final String TERMUX_HOME_PATH = "/data/data/com.termux/files/home";
|
||||
|
||||
/**
|
||||
* 执行 Termux 命令(核心方法)
|
||||
@@ -114,7 +115,7 @@ public class TermuxCommandExecutor {
|
||||
context,
|
||||
"/data/data/com.termux/files/usr/bin/bash", // Termux 默认 bash 路径(正确)
|
||||
args,
|
||||
"/data/data/com.termux/files/home", // 默认工作目录
|
||||
TERMUX_HOME_PATH, // 默认工作目录
|
||||
false, // 终端会话执行(可见)
|
||||
null // 不输出到文件
|
||||
);
|
||||
@@ -173,5 +174,49 @@ public class TermuxCommandExecutor {
|
||||
LogUtils.d(TAG, "外部应用调用权限提示:" + tip);
|
||||
return tip;
|
||||
}
|
||||
|
||||
public static boolean openTermuxBash(Context context, String command) {
|
||||
return openTermuxBash(context, command, "~");
|
||||
}
|
||||
|
||||
public static boolean openTermuxBash(Context context, String command, String workDir) {
|
||||
LogUtils.d(TAG, "openTermuxBash() 按钮点击,执行Gradle命令(实时输出)");
|
||||
|
||||
// 1. 校验Termux是否安装
|
||||
if (!TermuxCommandExecutor.isTermuxInstalled(context)) {
|
||||
LogUtils.e(TAG, "openTermuxBash() 错误:未安装Termux应用");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 2. 定义核心路径(确保路径与Termux中一致)
|
||||
String projectPath = TERMUX_HOME_PATH;
|
||||
if (workDir.startsWith("~") || workDir.startsWith(".")) {
|
||||
projectPath = TERMUX_HOME_PATH + "/" + workDir.substring(1);
|
||||
}
|
||||
|
||||
// 3. 构造命令(核心:用stdbuf禁用缓冲,实现实时输出)
|
||||
String targetCmd = "";
|
||||
// 步骤1:进入项目目录(不存在则创建)
|
||||
targetCmd += "cd " + projectPath + " && ";
|
||||
// 步骤2:加载环境变量
|
||||
targetCmd += "source ~/.bashrc && ";
|
||||
// 步骤3:显式配置PATH
|
||||
targetCmd += "export PATH=/data/data/com.termux/files/usr/bin:$PATH && ";
|
||||
// 步骤4:用stdbuf禁用stdout/stderr缓冲(关键!),执行Gradle命令
|
||||
// -o0:stdout无缓冲;-e0:stderr无缓冲;-i0:stdin无缓冲
|
||||
//targetCmd += "stdbuf -o0 -e0 -i0 " + gradleFullPath + " task --all | grep assemble && ";
|
||||
//targetCmd += "stdbuf -o0 -e0 -i0 " + gradleFullPath + " -Pandroid.aapt2FromMavenOverride=/data/data/com.termux/files/home/android-sdk/build-tools/34.0.4/aapt2 assembleBetaDebug && ";
|
||||
targetCmd += "stdbuf -o0 -e0 -i0 bash && ";
|
||||
// 步骤5:执行成功提示
|
||||
targetCmd += "echo '\n✅ 命令执行完成!' && echo '\n📌 当前目录:" + projectPath + "' && read -p '按回车键关闭终端...'";
|
||||
|
||||
|
||||
// 4. 执行命令(终端会话模式,唤起Termux窗口)
|
||||
boolean cmdSuccess = TermuxCommandExecutor.executeTerminalCommand(context, targetCmd);
|
||||
if (!cmdSuccess) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ public class TermuxEnvTestActivity extends BaseWinBoLLActivity {
|
||||
|
||||
// 常量属性(置顶排列)
|
||||
public static final String TAG = "TermuxEnvTestActivity";
|
||||
private static final String TERMUX_HOME_PATH = "/sdcard/WinBoLLStudio";
|
||||
private static final String CMD_RESULT_FILE = TERMUX_HOME_PATH + "/.authcenter_cmd_result.tmp";
|
||||
private static final String TERMUX_HOME_PATH = "/data/data/com.termux/files/home/TermuxWorkSpaces";
|
||||
private static final String CMD_RESULT_FILE = TERMUX_HOME_PATH + "/CMD_RESULT_FILE.log";
|
||||
|
||||
// 成员属性(常量后排列)
|
||||
private Toolbar mToolbar;
|
||||
@@ -158,7 +158,7 @@ public class TermuxEnvTestActivity extends BaseWinBoLLActivity {
|
||||
/**
|
||||
* 测试执行Gradle命令(实时输出版,唤起Termux窗口)
|
||||
*/
|
||||
public void onTestTermuxCMD(View view) {
|
||||
public void onTestTermuxGradleBuildCMD(View view) {
|
||||
LogUtils.d(TAG, "onTestTermuxCMD() 按钮点击,执行Gradle命令(实时输出)");
|
||||
tvMessage.append("\n【测试:执行Gradle命令(实时输出)】\n");
|
||||
|
||||
@@ -171,7 +171,7 @@ public class TermuxEnvTestActivity extends BaseWinBoLLActivity {
|
||||
|
||||
// 2. 定义核心路径(确保路径与Termux中一致)
|
||||
String gradleFullPath = "/data/data/com.termux/files/home/gradle/gradle-7.5.1/bin/gradle";
|
||||
String projectPath = TERMUX_HOME_PATH + "/Sources/WinBoLL"; // 项目目录
|
||||
String projectPath = TERMUX_HOME_PATH + "/Sources/DebugTemp"; // 项目目录
|
||||
|
||||
// 3. 构造命令(核心:用stdbuf禁用缓冲,实现实时输出)
|
||||
String targetCmd = "";
|
||||
@@ -218,9 +218,14 @@ public class TermuxEnvTestActivity extends BaseWinBoLLActivity {
|
||||
}
|
||||
|
||||
public void onTestWinBoLLProjectBuild(View view) {
|
||||
ToastUtils.show("onOpenTermuxBash");
|
||||
ToastUtils.show("onTestWinBoLLProjectBuild");
|
||||
NfcTermuxBridgeActivity.testCommand(this);
|
||||
}
|
||||
|
||||
// public void onTestWinBoLLProjectBuildView(View view) {
|
||||
// ToastUtils.show("onTestWinBoLLProjectBuildView");
|
||||
// NfcTermuxBridgeActivity.testViewCommand(this);
|
||||
// }
|
||||
|
||||
public void onOpenTermuxBash(View view) {
|
||||
LogUtils.d(TAG, "onTestTermuxCMD() 按钮点击,执行Gradle命令(实时输出)");
|
||||
@@ -235,7 +240,7 @@ public class TermuxEnvTestActivity extends BaseWinBoLLActivity {
|
||||
|
||||
// 2. 定义核心路径(确保路径与Termux中一致)
|
||||
String gradleFullPath = "/data/data/com.termux/files/home/gradle/gradle-7.5.1/bin/gradle";
|
||||
String projectPath = TERMUX_HOME_PATH + "/Sources/WinBoLL"; // 项目目录
|
||||
String projectPath = TERMUX_HOME_PATH + "/"; // 项目目录
|
||||
|
||||
// 3. 构造命令(核心:用stdbuf禁用缓冲,实现实时输出)
|
||||
String targetCmd = "";
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
package cc.winboll.studio.winboll.views;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.winboll.models.TermuxButtonModel;
|
||||
|
||||
/**
|
||||
* 自定义Termux功能按钮控件
|
||||
* 绑定TermuxButtonModel实体数据,拦截点击事件做确认弹窗逻辑判断
|
||||
* isCommitted为true直接执行点击事件,为false弹出确认对话框二次确认
|
||||
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
|
||||
* @CreateTime 2026/04/30 10:57:00
|
||||
* @EditTime 2026/04/30 13:52:15
|
||||
*/
|
||||
public class TermuxButton extends Button {
|
||||
|
||||
public static final String TAG = "TermuxButton";
|
||||
|
||||
/** 绑定按钮对应数据实体 */
|
||||
private TermuxButtonModel buttonModel;
|
||||
/** 保存外部设置的原始点击监听 */
|
||||
private OnClickListener originClickListener;
|
||||
|
||||
//==================== 构造方法 ====================
|
||||
/**
|
||||
* 代码动态创建控件构造
|
||||
* @param context 上下文
|
||||
*/
|
||||
public TermuxButton(Context context) {
|
||||
super(context);
|
||||
LogUtils.d(TAG, "TermuxButton 无参构造执行,上下文:" + context);
|
||||
initView(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* XML布局引用控件基础构造
|
||||
* @param context 上下文
|
||||
* @param attrs XML属性集
|
||||
*/
|
||||
public TermuxButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
LogUtils.d(TAG, "TermuxButton XML构造执行");
|
||||
initView(attrs, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* XML布局带自定义属性构造
|
||||
* @param context 上下文
|
||||
* @param attrs XML属性集
|
||||
* @param defStyleAttr 默认样式属性
|
||||
*/
|
||||
public TermuxButton(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
LogUtils.d(TAG, "TermuxButton 带样式属性构造执行");
|
||||
initView(attrs, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 高版本Android完整全参构造
|
||||
* @param context 上下文
|
||||
* @param attrs XML属性集
|
||||
* @param defStyleAttr 默认样式属性
|
||||
* @param defStyleRes 默认样式资源
|
||||
*/
|
||||
public TermuxButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
LogUtils.d(TAG, "TermuxButton 全参构造执行");
|
||||
initView(attrs, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接传入Model初始化控件构造
|
||||
* @param context 上下文
|
||||
* @param model 按钮数据实体
|
||||
*/
|
||||
public TermuxButton(Context context, TermuxButtonModel model) {
|
||||
super(context);
|
||||
LogUtils.d(TAG, "TermuxButton Model入参构造执行");
|
||||
initView(null, model);
|
||||
}
|
||||
|
||||
//==================== 核心初始化 ====================
|
||||
/**
|
||||
* 控件统一初始化方法
|
||||
* @param attrs XML属性集合
|
||||
* @param model 绑定数据实体
|
||||
*/
|
||||
private void initView(AttributeSet attrs, TermuxButtonModel model) {
|
||||
this.buttonModel = model;
|
||||
|
||||
// 按钮基础默认配置
|
||||
setClickable(true);
|
||||
setFocusable(true);
|
||||
|
||||
// 解析XML布局自定义属性
|
||||
if (attrs != null) {
|
||||
parseXmlCustomAttr(attrs);
|
||||
}
|
||||
|
||||
// 同步Model内按钮名称到控件展示文本
|
||||
refreshButtonText();
|
||||
// 绑定自定义拦截点击事件
|
||||
setCustomClickEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析XML布局属性,读取原生android:text与自定义属性赋值到Model
|
||||
* @param attrs XML属性集
|
||||
*/
|
||||
private void parseXmlCustomAttr(AttributeSet attrs) {
|
||||
if (buttonModel == null) {
|
||||
buttonModel = new TermuxButtonModel();
|
||||
LogUtils.d(TAG, "自动初始化空的TermuxButtonModel实体");
|
||||
}
|
||||
|
||||
// 读取原生android:text作为按钮名称
|
||||
String androidText = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "text");
|
||||
// 读取自定义扩展属性
|
||||
String exeCommand = attrs.getAttributeValue("http://schemas.android.com/apk/res-auto", "exeCommand");
|
||||
String workDir = attrs.getAttributeValue("http://schemas.android.com/apk/res-auto", "workDir");
|
||||
String isCommittedStr = attrs.getAttributeValue("http://schemas.android.com/apk/res-auto", "isCommitted");
|
||||
String commitTitle = attrs.getAttributeValue("http://schemas.android.com/apk/res-auto", "commitTitle");
|
||||
String commitInfo = attrs.getAttributeValue("http://schemas.android.com/apk/res-auto", "commitInfo");
|
||||
|
||||
// 属性赋值绑定
|
||||
if (androidText != null) {
|
||||
buttonModel.setButtonName(androidText);
|
||||
}
|
||||
if (exeCommand != null) {
|
||||
buttonModel.setExeCommand(exeCommand);
|
||||
}
|
||||
if (workDir != null) {
|
||||
buttonModel.setWorkDir(workDir);
|
||||
}
|
||||
if (isCommittedStr != null) {
|
||||
buttonModel.setCommitted(Boolean.parseBoolean(isCommittedStr));
|
||||
}
|
||||
if (commitTitle != null) {
|
||||
buttonModel.setCommitTitle(commitTitle);
|
||||
}
|
||||
if (commitInfo != null) {
|
||||
buttonModel.setCommitInfo(commitInfo);
|
||||
}
|
||||
|
||||
LogUtils.d(TAG, "XML属性解析完成,按钮名称:" + androidText);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步Model中buttonName,更新按钮展示文字
|
||||
*/
|
||||
private void refreshButtonText() {
|
||||
if (buttonModel != null) {
|
||||
setText(buttonModel.getButtonName());
|
||||
}
|
||||
}
|
||||
|
||||
//==================== 点击事件相关 ====================
|
||||
/**
|
||||
* 重写点击监听设置,保存外部原始点击事件
|
||||
* @param l 外部传入点击监听
|
||||
*/
|
||||
@Override
|
||||
public void setOnClickListener(OnClickListener l) {
|
||||
this.originClickListener = l;
|
||||
LogUtils.d(TAG, "保存外部原始按钮点击监听");
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义拦截按钮点击逻辑
|
||||
* isCommitted=true 直接执行原始点击事件
|
||||
* isCommitted=false 弹出确认二次弹窗
|
||||
*/
|
||||
private void setCustomClickEvent() {
|
||||
super.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (buttonModel == null) {
|
||||
LogUtils.d(TAG, "无绑定Model,直接执行原始点击事件");
|
||||
if (originClickListener != null) {
|
||||
originClickListener.onClick(view);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
boolean commitState = buttonModel.isCommitted();
|
||||
LogUtils.d(TAG, "按钮点击触发,isCommitted状态:" + commitState);
|
||||
if (commitState) {
|
||||
// 无需确认,直接执行原有点击任务
|
||||
if (originClickListener != null) {
|
||||
originClickListener.onClick(view);
|
||||
}
|
||||
} else {
|
||||
// 需要二次确认,弹出提示对话框
|
||||
showCommitDialog();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹出操作确认对话框
|
||||
* 标题:commitTitle 内容:commitInfo
|
||||
* 取消:关闭弹窗无操作 确定:执行原始点击事件
|
||||
*/
|
||||
private void showCommitDialog() {
|
||||
Context context = getContext();
|
||||
String dialogTitle = buttonModel.getCommitTitle();
|
||||
String dialogMsg = buttonModel.getCommitInfo();
|
||||
|
||||
// 空值默认兜底处理
|
||||
if (dialogTitle == null || "".equals(dialogTitle)) {
|
||||
dialogTitle = "温馨提示";
|
||||
}
|
||||
if (dialogMsg == null || "".equals(dialogMsg)) {
|
||||
dialogMsg = "确定要执行该操作吗?";
|
||||
}
|
||||
|
||||
LogUtils.d(TAG, "弹出确认对话框,标题:" + dialogTitle);
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(dialogTitle)
|
||||
.setMessage(dialogMsg)
|
||||
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
LogUtils.d(TAG, "对话框点击取消,终止操作");
|
||||
}
|
||||
})
|
||||
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
LogUtils.d(TAG, "对话框点击确定,继续执行操作");
|
||||
if (originClickListener != null) {
|
||||
originClickListener.onClick(TermuxButton.this);
|
||||
}
|
||||
}
|
||||
})
|
||||
.setCancelable(false)
|
||||
.show();
|
||||
}
|
||||
|
||||
//==================== Getter & Setter ====================
|
||||
public TermuxButtonModel getButtonModel() {
|
||||
return buttonModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置绑定按钮数据实体,自动刷新按钮展示文字
|
||||
* @param buttonModel 数据实体类
|
||||
*/
|
||||
public void setButtonModel(TermuxButtonModel buttonModel) {
|
||||
this.buttonModel = buttonModel;
|
||||
LogUtils.d(TAG, "外部设置ButtonModel,自动刷新按钮文本");
|
||||
refreshButtonText();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
8
winboll/src/main/res/drawable/dot_background.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="ring"
|
||||
android:innerRadiusRatio="3"
|
||||
android:thicknessRatio="8"
|
||||
android:useLevel="false">
|
||||
<solid android:color="#00000000"/>
|
||||
</shape>
|
||||
14
winboll/src/main/res/drawable/dot_darkgreen_dark.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<inset xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:insetLeft="2dp"
|
||||
android:insetTop="2dp"
|
||||
android:insetRight="2dp"
|
||||
android:insetBottom="2dp">
|
||||
<shape android:shape="ring"
|
||||
android:innerRadiusRatio="2"
|
||||
android:thicknessRatio="2.5"
|
||||
android:useLevel="false">
|
||||
<solid android:color="#006400"/>
|
||||
<stroke android:width="1dp" android:color="#006400"/>
|
||||
</shape>
|
||||
</inset>
|
||||
90
winboll/src/main/res/layout/activity_my_termux.xml
Normal file
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:title="@string/app_name"
|
||||
app:subtitle="@string/my_termux_activity"
|
||||
app:titleTextColor="@android:color/white"
|
||||
app:subtitleTextColor="@android:color/white"/>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<cc.winboll.studio.winboll.views.TermuxButton
|
||||
android:id="@+id/btn_termux"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Termux"
|
||||
android:textSize="18sp"
|
||||
android:padding="16dp"
|
||||
android:backgroundTint="@android:color/holo_blue_dark"
|
||||
app:exeCommand="cd ~"
|
||||
app:workDir="~"
|
||||
app:isCommitted="true"
|
||||
app:commitTitle="打开 Termux"
|
||||
app:commitInfo="打开 Termux 应用"/>
|
||||
|
||||
<cc.winboll.studio.winboll.views.TermuxButton
|
||||
android:id="@+id/btn_termuxworkspaces"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TermuxWorkSpaces"
|
||||
android:textSize="18sp"
|
||||
android:padding="16dp"
|
||||
android:backgroundTint="@android:color/holo_blue_dark"
|
||||
app:exeCommand="cd ~/TermuxWorkSpaces"
|
||||
app:workDir="~"
|
||||
app:isCommitted="false"
|
||||
app:commitTitle="打开 TermuxWorkSpaces"
|
||||
app:commitInfo="打开 Termux 应用,进入 TermuxWorkSpaces 目录。"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="+"
|
||||
android:id="@+id/btn_addtermuxbutton"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
25
winboll/src/main/res/layout/activity_pattern_lock.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/black">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:gravity="center"
|
||||
app:titleTextColor="@android:color/white"
|
||||
app:subtitleTextColor="@android:color/white"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FFFFFF"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -16,26 +16,30 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right">
|
||||
|
||||
|
||||
<Button
|
||||
android:textAllCaps="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="OpenTermuxBash"
|
||||
android:text="Open Termux Bash"
|
||||
android:onClick="onOpenTermuxBash"/>
|
||||
|
||||
<Button
|
||||
android:textAllCaps="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TestTermuxCMD"
|
||||
android:onClick="onTestTermuxCMD"/>
|
||||
android:text="Test Termux Gradle Build CMD"
|
||||
android:onClick="onTestTermuxGradleBuildCMD"/>
|
||||
|
||||
<Button
|
||||
android:textAllCaps="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TestTermuxEnv"
|
||||
android:text="Test Termux Env"
|
||||
android:onClick="onTestTermuxEnv"/>
|
||||
|
||||
|
||||
<Button
|
||||
android:textAllCaps="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Test WinBoLL Project Build"
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
android:id="@+id/item_home"
|
||||
android:title="HOME"/>
|
||||
<item
|
||||
android:id="@+id/item_mytermux"
|
||||
android:title="MyTermuxActivity"/>
|
||||
<item
|
||||
android:id="@+id/item_settings"
|
||||
android:title="Settings"/>
|
||||
<item
|
||||
|
||||
@@ -5,5 +5,13 @@
|
||||
<attr name="toolbarTitleColor" format="color" />
|
||||
<attr name="toolbarBackgroundColor" format="color" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="TermuxButton">
|
||||
<attr name="exeCommand" format="string" />
|
||||
<attr name="workDir" format="string" />
|
||||
<attr name="isCommitted" format="boolean" />
|
||||
<attr name="commitTitle" format="string" />
|
||||
<attr name="commitInfo" format="string" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -3,4 +3,5 @@
|
||||
<color name="colorPrimary">#009688</color>
|
||||
<color name="colorPrimaryDark">#00796B</color>
|
||||
<color name="colorAccent">#FF9800</color>
|
||||
<color name="pattern_lock_black">#000000</color>
|
||||
</resources>
|
||||
@@ -11,4 +11,6 @@
|
||||
<string name="cn2_switch_disabled">金抖云 X</string>
|
||||
<string name="tileservice_name">WinBoLL</string>
|
||||
<string name="toolbar_icon_description">WinBoLL APP</string>
|
||||
<string name="my_termux_activity">MyTermuxActivity</string>
|
||||
<string name="pattern_lock_title">图案密码设置</string>
|
||||
</resources>
|
||||
|
||||