Skip to content

Commit 4d562ec

Browse files
committed
示例文档,国际化
1 parent a56742e commit 4d562ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+690
-1041
lines changed

CHANGELOG.md

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,76 @@
11
# Changelog
22

3-
本文件记录 CountTimeProgressView 的所有重要版本变更。
3+
This file records notable CountTimeProgressView changes.
44

55
## [2.0.0] - 2026-04-15
66

7-
### Bug 修复
8-
- 修复 `CLOCK` 模式下 `minute >= 10` 时错误拼接 `hour` 的格式化 Bug
9-
- 修复 `startAngle` getter/setter 语义不一致(用户设 0 读回 270 的问题)
10-
- 修复 `titleCenterText` SECOND 模式下的空指针崩溃风险
11-
- 修复 `DEFAULT_COUNT_TIME` 5ms 修正为 5000ms
12-
- 修复 Demo 中 `setBackgroundColor()` 误调用(应为 `backgroundColorCenter`
7+
### Bug Fixes
8+
- Fixed `CLOCK` formatting when `minute >= 10` incorrectly appended `hour`
9+
- Fixed inconsistent `startAngle` getter/setter semantics
10+
- Fixed a possible `titleCenterText` null crash in SECOND mode
11+
- Changed `DEFAULT_COUNT_TIME` from 5ms to 5000ms
12+
- Fixed the demo `setBackgroundColor()` call; it now uses `backgroundColorCenter`
1313

14-
### 新增功能
15-
- 暂停 / 恢复 / 重置动画:`pauseCountTimeAnimation()``resumeCountTimeAnimation()``resetCountTimeAnimation()`
16-
- 进度 getter/setter`progress` 属性(0f..1f
17-
- 进度变化回调:`addOnProgressChangedListener { progress, remainingMillis -> }`
18-
- 自定义文本格式化器:`textFormatter = { millis -> "..." }`
19-
- 进度条端点样式:`strokeCap`BUTT / ROUND / SQUARE),支持 XML 配置
20-
- 动画插值器配置:`interpolator` 属性
21-
- 渐变色进度条:`gradientStartColor` / `gradientEndColor`,支持 XML 配置
22-
- XML 属性扩展:`autoStart``finishedText``showCenterText``strokeCap`
23-
- `onMeasure` 支持 `wrap_content`(默认尺寸 84dp
24-
- SavedState 支持(屏幕旋转保持进度)
25-
- 无障碍支持(AccessibilityNodeInfo
26-
- 显式单位 API:`setBorderWidthPx()``setMarkBallWidthPx()``setTitleCenterTextSizePx()`
27-
- 公开 `remainingTime` `isPaused` 属性
28-
- Jetpack Compose 适配工具类 `CountTimeProgressViewCompose`
14+
### Features
15+
- Pause / resume / reset APIs: `pauseCountTimeAnimation()`, `resumeCountTimeAnimation()`, `resetCountTimeAnimation()`
16+
- `progress` getter/setter in the 0f..1f range
17+
- Progress callback: `addOnProgressChangedListener { progress, remainingMillis -> }`
18+
- Custom text formatter: `textFormatter = { millis -> "..." }`
19+
- Progress stroke cap: `strokeCap` (BUTT / ROUND / SQUARE), with XML support
20+
- Configurable animation interpolator via `interpolator`
21+
- Gradient progress stroke via `gradientStartColor` / `gradientEndColor`, with XML support
22+
- XML attributes: `autoStart`, `finishedText`, `showCenterText`, `strokeCap`
23+
- `wrap_content` support in `onMeasure` with an 84dp default size
24+
- SavedState support for restoring progress after configuration changes
25+
- Accessibility support via AccessibilityNodeInfo
26+
- Explicit pixel APIs: `setBorderWidthPx()`, `setMarkBallWidthPx()`, `setTitleCenterTextSizePx()`
27+
- Public `remainingTime` and `isPaused` properties
28+
- `CountTimeProgressViewCompose` helper for Compose AndroidView usage
2929

30-
### 代码质量
31-
- 设置 `LinearInterpolator` 为默认插值器
32-
- 删除库中所有 `Log.e` 调用
33-
- 移除冗余 `mContext` 字段
34-
- 移除 `attr != null` 死代码分支
35-
- `calcRadius()` 改为 `private`
36-
- `TextStyle` 添加 `@IntDef` 类型安全注解
37-
- `OnEndListener` 标记 `@Deprecated`,新增 `OnCountdownEndListener` + `setOnClickCallback`
38-
- `onDetachedFromWindow` 不再清空 listener
39-
- 重构 `onDraw` 为多个独立绘制方法
40-
- 性能:文本缓存、`postInvalidateOnAnimation()` 替代 `invalidate()`
30+
### Code Quality
31+
- Set `LinearInterpolator` as the default interpolator
32+
- Removed all `Log.e` calls from the library
33+
- Removed the redundant `mContext` field
34+
- Removed the dead `attr != null` branch
35+
- Made `calcRadius()` private
36+
- Added `@IntDef` type safety for `TextStyle`
37+
- Deprecated `OnEndListener` and added `OnCountdownEndListener` + `setOnClickCallback`
38+
- Stopped clearing listeners in `onDetachedFromWindow`
39+
- Split `onDraw` into focused drawing methods
40+
- Improved drawing performance with text caching and `postInvalidateOnAnimation()`
4141

42-
### 工程化
43-
- library 模块移除 AppCompat 运行时依赖(零第三方依赖)
44-
- 迁移至 AndroidX
45-
- `minSdk` 14 21`targetSdk` / `compileSdk` 34
46-
- 仓库改为 `google()` + `mavenCentral()`
47-
- `lintOptions {}` `lint {}`
48-
- `proguard-android.txt` `proguard-android-optimize.txt`
49-
- `compileSdkVersion``compileSdk``minSdkVersion` `minSdk`
50-
- `artifactId` `library` 改为 `counttimeprogressview`
51-
- SplashActivity Java 转换为 Kotlin
52-
- 布局文件 `left/right` `start/end`RTL 支持)
53-
- ScrollView 子 View 高度改为 `wrap_content`
54-
- ImageView 添加 `contentDescription`
55-
- 移除 `gradle.properties` 中硬编码的 JDK 路径
56-
- 新增 `ClockTimeFormatter` 独立工具类(便于单元测试)
57-
- 新增 `formatClockTime` 单元测试(9 个用例)
42+
### Project
43+
- Removed AppCompat runtime dependency from the library module
44+
- Migrated to AndroidX
45+
- Raised `minSdk` from 14 to 21, and `targetSdk` / `compileSdk` to 34
46+
- Switched repositories to `google()` + `mavenCentral()`
47+
- Migrated `lintOptions {}` to `lint {}`
48+
- Switched to `proguard-android-optimize.txt`
49+
- Migrated Gradle DSL names to `compileSdk` and `minSdk`
50+
- Changed `artifactId` from `library` to `counttimeprogressview`
51+
- Converted SplashActivity from Java to Kotlin
52+
- Replaced `left/right` layout attributes with `start/end` for RTL support
53+
- Changed ScrollView child height to `wrap_content`
54+
- Added ImageView `contentDescription`
55+
- Removed the hard-coded JDK path from `gradle.properties`
56+
- Added the standalone `ClockTimeFormatter` utility for unit testing
57+
- Added 9 unit tests for `formatClockTime`
5858

59-
### 文档
60-
- README / README-ZH:`compile``implementation`,修复中英文残片、默认值说明、拼写错误
61-
- 新增 CHANGELOG.md
62-
- 新增 CONTRIBUTING.md
63-
- 添加完整 KDoc 中文注释
59+
### Documentation
60+
- Updated README / README-ZH from `compile` to `implementation`
61+
- Fixed mixed-language snippets, default value notes, and typos
62+
- Added CHANGELOG.md
63+
- Added CONTRIBUTING.md
64+
- Normalized source comments and public messages to English
6465

6566
## [1.1.3] - 2017-11-11
66-
- 使用 Kotlin 重写代码
67+
- Rewrote the code in Kotlin
6768

6869
## [1.1.1] - 2017-03-27
69-
- 更新:退出时停止运行
70+
- Stopped running when exiting
7071

7172
## [1.1.0] - 2017-02-07
72-
- 更新:支持顺时针动画
73+
- Added clockwise animation support
7374

7475
## [1.0.0] - 2016-12-20
75-
- 首次提交
76+
- Initial commit

CONTRIBUTING.md

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
# 贡献指南
1+
# Contributing Guide
22

3-
感谢你对 CountTimeProgressView 项目的关注!欢迎任何形式的贡献。
3+
Thanks for your interest in CountTimeProgressView. Contributions of all kinds are welcome.
44

5-
## 如何贡献
5+
## How to Contribute
66

7-
### 报告 Bug
7+
### Report a Bug
88

9-
1. [Issues](https://github.com/sfyc23/CountTimeProgressView/issues) 中搜索是否已有相同问题
10-
2. 如果没有,创建新 Issue,请包含:
11-
- 问题描述
12-
- 复现步骤
13-
- 期望行为 vs 实际行为
14-
- 设备信息(Android 版本、设备型号)
15-
- 相关代码片段或截图
9+
1. Search [Issues](https://github.com/sfyc23/CountTimeProgressView/issues) for an existing report.
10+
2. If no matching issue exists, create one and include:
11+
- Problem description
12+
- Steps to reproduce
13+
- Expected behavior vs actual behavior
14+
- Device information, including Android version and device model
15+
- Relevant code snippets or screenshots
1616

17-
### 提交代码
17+
### Submit Code
1818

19-
1. Fork 本项目
20-
2. 创建功能分支:`git checkout -b feature/your-feature`
21-
3. 编写代码,确保:
22-
- 遵循现有代码风格(Kotlin
23-
- 添加必要的中文注释
24-
- 新增公开 API 需添加 KDoc
25-
- 如有新功能,更新 README CHANGELOG
26-
4. 运行构建验证:`./gradlew :library:assembleDebug :library:testDebugUnitTest`
27-
5. 提交变更:`git commit -m "feat: 你的功能描述"`
28-
6. 推送并创建 Pull Request
19+
1. Fork this repository.
20+
2. Create a feature branch: `git checkout -b feature/your-feature`.
21+
3. Make your changes and ensure:
22+
- Code follows the existing Kotlin style.
23+
- Comments and public messages are written in English.
24+
- New public APIs include KDoc when needed.
25+
- New features update README and CHANGELOG as appropriate.
26+
4. Run build verification: `./gradlew :library:assembleDebug :library:testDebugUnitTest`.
27+
5. Commit changes: `git commit -m "feat: your feature description"`.
28+
6. Push your branch and open a pull request.
2929

30-
### Commit 规范
30+
### Commit Style
3131

32-
建议使用以下前缀:
33-
- `feat:` 新功能
34-
- `fix:` Bug 修复
35-
- `docs:` 文档更新
36-
- `refactor:` 重构(不改变行为)
37-
- `perf:` 性能优化
38-
- `test:` 测试相关
39-
- `chore:` 构建/工具链变更
32+
Recommended prefixes:
33+
- `feat:` new feature
34+
- `fix:` bug fix
35+
- `docs:` documentation update
36+
- `refactor:` refactor without behavior changes
37+
- `perf:` performance improvement
38+
- `test:` tests
39+
- `chore:` build or tooling change
4040

41-
## 开发环境
41+
## Development Environment
4242

43-
- Android Studio Hedgehog 或更新版本
43+
- Android Studio Hedgehog or newer
4444
- JDK 17
4545
- Gradle 7.6+
4646
- Kotlin 1.8.22+
4747

48-
## 项目结构
48+
## Project Structure
4949

50-
```
50+
```text
5151
CountTimeProgressView/
52-
├── library/ # 核心库模块(零第三方依赖)
52+
├── library/ # Core library module with no third-party runtime dependency
5353
│ └── src/main/java/com/sfyc/ctpv/
54-
│ ├── CountTimeProgressView.kt # 核心控件
55-
│ ├── CountTimeProgressViewCompose.kt # Compose 适配
56-
│ └── ClockTimeFormatter.kt # 时钟格式化工具
57-
├── app/ # 示例 App 模块
58-
└── .AI/ # 重构分析文档
54+
│ ├── CountTimeProgressView.kt # Core custom view
55+
│ ├── CountTimeProgressViewCompose.kt # Compose helper
56+
│ └── ClockTimeFormatter.kt # Clock formatting utility
57+
├── app/ # Sample app module
58+
└── .AI/ # Refactor analysis notes
5959
```
6060

61-
## 编码规范
61+
## Coding Guidelines
6262

63-
- 使用 Kotlin,避免 Java
64-
- 公开 API 添加 KDoc 注释(中文)
65-
- 属性 setter 中 dp/sp 转换需在注释中标明单位
66-
- `onDraw` 中避免创建对象
67-
- 新增 XML 属性需同步更新 `attrs.xml`
63+
- Prefer Kotlin for new code.
64+
- Add KDoc to public APIs when it clarifies usage.
65+
- Document dp/sp conversion behavior when adding public size APIs.
66+
- Avoid allocating objects in `onDraw`.
67+
- Update `attrs.xml` when adding XML attributes.
6868

69-
## 许可证
69+
## License
7070

71-
贡献的代码将遵循本项目的 [Apache License 2.0](LICENSE) 许可证。
71+
Contributed code follows this project's [Apache License 2.0](LICENSE).

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[![twitter](https://img.shields.io/badge/twitter-sfyc23-blue.svg)](https://twitter.com/sfyc23)
2-
[![微博](https://img.shields.io/badge/%E5%BE%AE%E5%8D%9A-sfyc23-blue.svg)](https://weibo.com/sfyc23)
2+
[![Weibo](https://img.shields.io/badge/Weibo-sfyc23-blue.svg)](https://weibo.com/sfyc23)
33
[![API](https://img.shields.io/badge/API-%2B21-green.svg)](https://android-arsenal.com/api?level=21)
44
[![](https://jitpack.io/v/sfyc23/CountTimeProgressView.svg)](https://jitpack.io/#sfyc23/CountTimeProgressView)
55
[![License](https://img.shields.io/badge/License-Apache%202.0-red.svg)]()
66
# CountTimeProgressView
77

88
**CountTimeProgressView** - An Android library that provides a count time circular progress view effect.
99

10-
[中文版][1]
10+
[Chinese][1]
1111

1212
## Sample
13-
![页面动图][2]
13+
![Demo animation][2]
1414

1515

1616
## Usage

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dependencies {
4545
implementation 'androidx.viewpager2:viewpager2:1.0.0'
4646
implementation 'androidx.fragment:fragment-ktx:1.6.2'
4747

48-
// RecyclerView(导航首页列表)
48+
// RecyclerView for the main navigation list
4949
implementation 'androidx.recyclerview:recyclerview:1.3.2'
5050

5151
// Jetpack Compose

app/src/main/AndroidManifest.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
android:supportsRtl="true"
99
android:theme="@style/AppTheme">
1010

11-
<!-- 闪屏页(启动入口) -->
11+
<!-- Splash entry point -->
1212
<activity
1313
android:name=".SplashActivity"
1414
android:exported="true"
@@ -19,25 +19,25 @@
1919
</intent-filter>
2020
</activity>
2121

22-
<!-- 导航首页 -->
22+
<!-- Main navigation page -->
2323
<activity android:name=".MainActivity" />
2424

25-
<!-- 传统演示页(兼容旧版) -->
25+
<!-- Classic compatibility demo -->
2626
<activity android:name=".SimpleActivity" />
2727

28-
<!-- 动画控制页 -->
28+
<!-- Animation control page -->
2929
<activity android:name=".animation.AnimationControlActivity" />
3030

31-
<!-- 场景:广告跳过 -->
31+
<!-- Ad skip scenario -->
3232
<activity android:name=".scene.adskip.AdSkipSceneActivity" />
3333

34-
<!-- 场景:验证码倒计时 -->
34+
<!-- Verification code timer scenario -->
3535
<activity android:name=".scene.verifycode.VerifyCodeSceneActivity" />
3636

37-
<!-- 场景:进度恢复 -->
37+
<!-- Progress restore scenario -->
3838
<activity android:name=".scene.resume.ResumeProgressSceneActivity" />
3939

40-
<!-- 场景:考试计时器 -->
40+
<!-- Exam timer scenario -->
4141
<activity android:name=".scene.exam.ExamTimerSceneActivity" />
4242

4343
</application>

app/src/main/java/com/sfyc/simple/MainActivity.kt

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.view.LayoutInflater
66
import android.view.View
77
import android.view.ViewGroup
88
import android.widget.TextView
9+
import androidx.annotation.StringRes
910
import androidx.appcompat.app.AppCompatActivity
1011
import androidx.recyclerview.widget.LinearLayoutManager
1112
import androidx.recyclerview.widget.RecyclerView
@@ -15,25 +16,21 @@ import com.sfyc.simple.scene.exam.ExamTimerSceneActivity
1516
import com.sfyc.simple.scene.resume.ResumeProgressSceneActivity
1617
import com.sfyc.simple.scene.verifycode.VerifyCodeSceneActivity
1718

18-
/**
19-
* 导航首页。
20-
*
21-
* 以 Material Design 3 卡片列表展示所有演示页面入口,
22-
* 点击后跳转到对应的功能演示或真实场景页面。
23-
*/
2419
class MainActivity : AppCompatActivity() {
2520

26-
/** 演示项数据类:标题 + 副标题 + 目标 Activity */
27-
data class DemoItem(val title: String, val subtitle: String, val activityClass: Class<*>)
21+
data class DemoItem(
22+
@StringRes val titleResId: Int,
23+
@StringRes val subtitleResId: Int,
24+
val activityClass: Class<*>
25+
)
2826

29-
/** 导航列表数据源 */
3027
private val items = listOf(
31-
DemoItem("动画控制", "开始 / 暂停 / 恢复 / 重置 / 实时状态", AnimationControlActivity::class.java),
32-
DemoItem("场景:广告跳过", "真实闪屏广告跳过场景", AdSkipSceneActivity::class.java),
33-
DemoItem("场景:验证码倒计时", "发送验证码后的倒计时按钮", VerifyCodeSceneActivity::class.java),
34-
DemoItem("场景:进度恢复", "从服务器剩余时间恢复 / 屏幕旋转恢复", ResumeProgressSceneActivity::class.java),
35-
DemoItem("场景:考试计时器", "长时间倒计时 + 警告 + 暂停恢复", ExamTimerSceneActivity::class.java),
36-
DemoItem("传统演示页", "原始参数面板(兼容旧版)", SimpleActivity::class.java),
28+
DemoItem(R.string.nav_animation, R.string.nav_animation_desc, AnimationControlActivity::class.java),
29+
DemoItem(R.string.nav_ad_skip, R.string.nav_ad_skip_desc, AdSkipSceneActivity::class.java),
30+
DemoItem(R.string.nav_verify_code, R.string.nav_verify_code_desc, VerifyCodeSceneActivity::class.java),
31+
DemoItem(R.string.nav_resume, R.string.nav_resume_desc, ResumeProgressSceneActivity::class.java),
32+
DemoItem(R.string.nav_exam, R.string.nav_exam_desc, ExamTimerSceneActivity::class.java),
33+
DemoItem(R.string.nav_legacy, R.string.nav_legacy_desc, SimpleActivity::class.java),
3734
)
3835

3936
override fun onCreate(savedInstanceState: Bundle?) {
@@ -47,9 +44,6 @@ class MainActivity : AppCompatActivity() {
4744
}
4845
}
4946

50-
/**
51-
* 导航列表适配器,每个 item 显示卡片标题和描述。
52-
*/
5347
class DemoAdapter(
5448
private val items: List<DemoItem>,
5549
private val onClick: (DemoItem) -> Unit
@@ -68,8 +62,8 @@ class MainActivity : AppCompatActivity() {
6862

6963
override fun onBindViewHolder(holder: VH, position: Int) {
7064
val item = items[position]
71-
holder.tvTitle.text = item.title
72-
holder.tvSubtitle.text = item.subtitle
65+
holder.tvTitle.setText(item.titleResId)
66+
holder.tvSubtitle.setText(item.subtitleResId)
7367
holder.itemView.setOnClickListener { onClick(item) }
7468
}
7569

0 commit comments

Comments
 (0)