├── .gitignore
├── LICENSE.txt
├── README.md
├── app
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── cc
│ │ └── fastcv
│ │ └── linenumberclock
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── cc
│ │ │ └── fastcv
│ │ │ └── linenumberclock
│ │ │ └── MainActivity.kt
│ └── res
│ │ ├── drawable
│ │ ├── ic_launcher_background.xml
│ │ └── ic_launcher_foreground.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ │ └── xml
│ │ ├── backup_rules.xml
│ │ └── data_extraction_rules.xml
│ └── test
│ └── java
│ └── cc
│ └── fastcv
│ └── linenumberclock
│ └── ExampleUnitTest.kt
├── assets
├── 1747639094216-69c3e474-c0a6-4247-bb09-272ce3e5125b.gif
└── img.png
├── build.gradle.kts
├── gradle.properties
├── gradle
├── libs.versions.toml
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── line_number_clock
├── .gitignore
├── build.gradle.kts
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── cc
│ │ └── fastcv
│ │ └── line_number_clock
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── cc
│ │ └── fastcv
│ │ └── line_number_clock
│ │ ├── AbsComponents.kt
│ │ ├── AbsNumberDrawParam.kt
│ │ ├── CircleDrawParam.kt
│ │ ├── CircleDrawer.kt
│ │ ├── ComponentsManager.kt
│ │ ├── ComponentsType.kt
│ │ ├── LineNumberClockView.kt
│ │ ├── NumberProxy.kt
│ │ ├── Numbers.kt
│ │ ├── SplitLineComponents.kt
│ │ ├── TimeComponents.kt
│ │ └── TransitionNumberDrawParam.kt
│ └── test
│ └── java
│ └── cc
│ └── fastcv
│ └── line_number_clock
│ └── ExampleUnitTest.kt
└── settings.gradle.kts
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 | /.idea/inspectionProfiles/Project_Default.xml
17 | /.idea/AndroidProjectSystem.xml
18 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LineNumberClock
2 |
3 |
4 |
5 | # 用法
6 |
7 | 添加依赖:
8 |
9 | ```
10 | implementation("cc.fastcv:line-number-clock:1.0.1")
11 | ```
12 |
13 |
14 |
15 |
16 |
17 | 在布局文件中:
18 |
19 | ````
20 |
21 |
28 |
29 |
33 |
34 |
35 | ````
36 |
37 | 这里说明一下,这个组件使用的自适应宽高比,所以需要固定的大小的话需要你自己去调整适配或者提个issue问我,还可以进行二次开发。
38 |
39 |
40 |
41 | 这样,就可以在你的app上看到效果了。
42 |
43 |
44 |
45 | 
46 |
47 |
48 | 我拉了个安卓技术讨论群,感兴趣的可以加我,我拉你进群
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.android.application)
3 | alias(libs.plugins.kotlin.android)
4 | }
5 |
6 | android {
7 | namespace = "cc.fastcv.linenumberclock"
8 | compileSdk = 34
9 |
10 | defaultConfig {
11 | applicationId = "cc.fastcv.linenumberclock"
12 | minSdk = 24
13 | targetSdk = 34
14 | versionCode = 1
15 | versionName = "1.0"
16 |
17 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18 | }
19 |
20 | buildTypes {
21 | release {
22 | isMinifyEnabled = false
23 | proguardFiles(
24 | getDefaultProguardFile("proguard-android-optimize.txt"),
25 | "proguard-rules.pro"
26 | )
27 | }
28 | }
29 | compileOptions {
30 | sourceCompatibility = JavaVersion.VERSION_11
31 | targetCompatibility = JavaVersion.VERSION_11
32 | }
33 | kotlinOptions {
34 | jvmTarget = "11"
35 | }
36 | }
37 |
38 | dependencies {
39 |
40 | implementation(libs.androidx.core.ktx)
41 | implementation(libs.androidx.appcompat)
42 | implementation(libs.material)
43 | implementation(libs.androidx.activity)
44 | implementation(libs.androidx.constraintlayout)
45 | implementation(project(":line_number_clock"))
46 | testImplementation(libs.junit)
47 | androidTestImplementation(libs.androidx.junit)
48 | androidTestImplementation(libs.androidx.espresso.core)
49 |
50 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/androidTest/java/cc/fastcv/linenumberclock/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.linenumberclock
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("cc.fastcv.linenumberclock", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/cc/fastcv/linenumberclock/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.linenumberclock
2 |
3 | import android.content.pm.ActivityInfo
4 | import android.content.res.Configuration
5 | import android.os.Bundle
6 | import androidx.activity.enableEdgeToEdge
7 | import androidx.appcompat.app.AppCompatActivity
8 | import androidx.core.view.ViewCompat
9 | import androidx.core.view.WindowInsetsCompat
10 | import cc.fastcv.line_number_clock.LineNumberClockView
11 |
12 | class MainActivity : AppCompatActivity() {
13 | private lateinit var view: LineNumberClockView
14 |
15 | override fun onCreate(savedInstanceState: Bundle?) {
16 | super.onCreate(savedInstanceState)
17 | enableEdgeToEdge()
18 | setContentView(R.layout.activity_main)
19 | ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
20 | val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
21 | v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
22 | insets
23 | }
24 | view = findViewById(R.id.view)
25 | view.setOnClickListener {
26 | val isPortrait =
27 | resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
28 | requestedOrientation = if (isPortrait) {
29 | ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
30 | } else {
31 | ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
32 | }
33 | }
34 | view.bindLifecycle(lifecycle)
35 | }
36 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF000000
4 | #FFFFFFFF
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LineNumberClock
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/test/java/cc/fastcv/linenumberclock/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.linenumberclock
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/assets/1747639094216-69c3e474-c0a6-4247-bb09-272ce3e5125b.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/assets/1747639094216-69c3e474-c0a6-4247-bb09-272ce3e5125b.gif
--------------------------------------------------------------------------------
/assets/img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/assets/img.png
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | plugins {
3 | alias(libs.plugins.android.application) apply false
4 | alias(libs.plugins.kotlin.android) apply false
5 | alias(libs.plugins.android.library) apply false
6 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. For more details, visit
12 | # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.7.3"
3 | kotlin = "1.9.24"
4 | coreKtx = "1.10.1"
5 | junit = "4.13.2"
6 | junitVersion = "1.1.5"
7 | espressoCore = "3.5.1"
8 | appcompat = "1.6.1"
9 | material = "1.10.0"
10 | activity = "1.8.0"
11 | constraintlayout = "2.1.4"
12 |
13 | [libraries]
14 | androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
15 | junit = { group = "junit", name = "junit", version.ref = "junit" }
16 | androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
17 | androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
18 | androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
19 | material = { group = "com.google.android.material", name = "material", version.ref = "material" }
20 | androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
21 | androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
22 |
23 | [plugins]
24 | android-application = { id = "com.android.application", version.ref = "agp" }
25 | kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
26 | android-library = { id = "com.android.library", version.ref = "agp" }
27 |
28 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri May 16 14:07:15 CST 2025
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/line_number_clock/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/line_number_clock/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.android.library)
3 | alias(libs.plugins.kotlin.android)
4 | id("maven-publish")
5 | id("signing")
6 | id("tech.yanand.maven-central-publish") version ("1.3.0")
7 | }
8 |
9 | android {
10 | namespace = "cc.fastcv.line_number_clock"
11 | compileSdk = 34
12 |
13 | defaultConfig {
14 | minSdk = 24
15 |
16 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
17 | consumerProguardFiles("consumer-rules.pro")
18 | }
19 |
20 | buildTypes {
21 | release {
22 | isMinifyEnabled = false
23 | proguardFiles(
24 | getDefaultProguardFile("proguard-android-optimize.txt"),
25 | "proguard-rules.pro"
26 | )
27 | }
28 | }
29 | compileOptions {
30 | sourceCompatibility = JavaVersion.VERSION_11
31 | targetCompatibility = JavaVersion.VERSION_11
32 | }
33 | kotlinOptions {
34 | jvmTarget = "11"
35 | }
36 | }
37 |
38 | dependencies {
39 |
40 | implementation(libs.androidx.core.ktx)
41 | implementation(libs.androidx.appcompat)
42 | implementation(libs.material)
43 | testImplementation(libs.junit)
44 | androidTestImplementation(libs.androidx.junit)
45 | androidTestImplementation(libs.androidx.espresso.core)
46 | }
47 |
48 | publishing {
49 | publications {
50 | create("mavenJava") {
51 | afterEvaluate { artifact(tasks.getByName("bundleReleaseAar")) }
52 | groupId = "cc.fastcv"
53 | artifactId = "line-number-clock"
54 | version = "1.0.1"
55 |
56 | pom {
57 | name = "LineNumberClock"
58 | description = "line number clock"
59 | url = "https://github.com/fastcv-cc/LineNumberClock"
60 | licenses {
61 | license {
62 | name = "The Apache License, Version 2.0"
63 | url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
64 | }
65 | }
66 | developers {
67 | developer {
68 | name = "pisto"
69 | email = "sayhigerry@gmail.com"
70 | }
71 | }
72 | scm {
73 | url = "https://github.com/fastcv-cc/LineNumberClock"
74 | connection = "scm:git:git://github.com/fastcv-cc/LineNumberClock.git"
75 | developerConnection =
76 | "scm:git:ssh://git@github.com:fastcv-cc/LineNumberClock.git"
77 | }
78 | }
79 |
80 | }
81 | }
82 |
83 | repositories {
84 | }
85 | }
86 |
87 |
88 | signing {
89 | sign(publishing.publications)
90 | }
91 |
92 | mavenCentral {
93 | authToken = rootProject.properties["authTokenValue"] as String
94 | // 上传是否应该自动发布。如果您希望手动执行此操作,请使用 'USER_MANAGED'。
95 | // 该属性是可选的,默认为 'AUTOMATIC'。
96 | publishingType = "AUTOMATIC"
97 | // 当发布类型为 'AUTOMATIC' 时,状态API获取 'PUBLISHING' 或 'PUBLISHED' 状态的最大等待时间
98 | // 或者当发布类型为 'USER_MANAGED' 时,获取 'VALIDATED' 状态。
99 | // 该属性是可选的,默认为60秒。
100 | maxWait = 60
101 | }
--------------------------------------------------------------------------------
/line_number_clock/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fastcv-cc/LineNumberClock/30f878f969fbbdcca56b728ea4b7a9af83641b76/line_number_clock/consumer-rules.pro
--------------------------------------------------------------------------------
/line_number_clock/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/line_number_clock/src/androidTest/java/cc/fastcv/line_number_clock/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("cc.fastcv.line_number_clock.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/line_number_clock/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/line_number_clock/src/main/java/cc/fastcv/line_number_clock/AbsComponents.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | import android.graphics.Canvas
4 |
5 | abstract class AbsComponents {
6 |
7 | abstract val type: ComponentsType
8 |
9 | abstract fun draw(canvas: Canvas)
10 |
11 | }
--------------------------------------------------------------------------------
/line_number_clock/src/main/java/cc/fastcv/line_number_clock/AbsNumberDrawParam.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | /**
4 | * 数字绘制参数
5 | * 指代每个数据默认的绘制参数
6 | * 每个数字由6个圆点组成
7 | */
8 | abstract class AbsNumberDrawParam {
9 | abstract val params: Array
10 | }
--------------------------------------------------------------------------------
/line_number_clock/src/main/java/cc/fastcv/line_number_clock/CircleDrawParam.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | /**
4 | * 圆绘制参数
5 | * angle: -180 ~ 180
6 | * alpha: 0 ~ 255
7 | */
8 | data class CircleDrawParam(
9 | var line1Angle: Float,
10 | var line1Alpha: Int,
11 | var line2Angle: Float,
12 | var line2Alpha: Int
13 | ) {
14 | //参数变更差计算
15 | fun transition(newParam: CircleDrawParam, progress: Float): CircleDrawParam {
16 | val tempLine1Angle: Float = line1Angle + (newParam.line1Angle - line1Angle) * progress
17 | val tempLine1Alpha: Int =
18 | (line1Alpha + (newParam.line1Alpha - line1Alpha) * progress).toInt()
19 | val tempLine2Angle: Float = line2Angle + (newParam.line2Angle - line2Angle) * progress
20 | val tempLine2Alpha: Int =
21 | (line2Alpha + (newParam.line2Alpha - line2Alpha) * progress).toInt()
22 | return CircleDrawParam(tempLine1Angle, tempLine1Alpha, tempLine2Angle, tempLine2Alpha)
23 | }
24 | }
--------------------------------------------------------------------------------
/line_number_clock/src/main/java/cc/fastcv/line_number_clock/CircleDrawer.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | import android.graphics.Canvas
4 | import android.graphics.Color
5 | import android.graphics.Paint
6 |
7 | //一个圆单元参数
8 | class CircleDrawer {
9 |
10 | var x: Float = 0.0f
11 | var y: Float = 0.0f
12 | var radius: Float = 0.0f
13 | var paint: Paint? = null
14 |
15 |
16 | //绘制基础圆
17 | fun drawBaseCircle(canvas: Canvas) {
18 | paint?.let {
19 | //画圆
20 | //TODO 定义颜色
21 | it.color = Color.parseColor("#F4EBEB")
22 | canvas.drawCircle(x, y, radius, it)
23 | //画小白点
24 | it.color = Color.WHITE
25 | canvas.drawCircle(x, y, it.strokeWidth / 2, it)
26 | }
27 | }
28 |
29 | //绘制圆中心点
30 | fun drawBlackPoint(canvas: Canvas) {
31 | paint?.let {
32 | //画小黑点
33 | it.color = Color.BLACK
34 | canvas.drawCircle(x, y, it.strokeWidth / 2, it)
35 | }
36 | }
37 |
38 | //通过绘制参数绘制线段
39 | fun drawByCircleDrawParam(
40 | canvas: Canvas,
41 | param: CircleDrawParam
42 | ) {
43 | paint?.let {
44 | //画小黑点
45 | it.color = Color.BLACK
46 | it.alpha = param.line1Alpha
47 | canvas.drawCircle(x, y, it.strokeWidth / 2, it)
48 | //画线1
49 | canvas.save()
50 | canvas.translate(x, y)
51 | canvas.rotate(param.line1Angle)
52 | it.alpha = param.line1Alpha
53 | canvas.drawLine(0f, 0f, radius, 0f, it)
54 | canvas.restore()
55 | canvas.save()
56 | canvas.translate(x, y)
57 | canvas.rotate(param.line2Angle)
58 | it.alpha = param.line2Alpha
59 | canvas.drawLine(0f, 0f, radius, 0f, it)
60 | canvas.restore()
61 | }
62 | }
63 |
64 | }
--------------------------------------------------------------------------------
/line_number_clock/src/main/java/cc/fastcv/line_number_clock/ComponentsManager.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | import android.content.Context
4 | import android.graphics.Canvas
5 | import android.graphics.Color
6 | import android.graphics.Paint
7 | import android.icu.util.Calendar
8 | import android.util.AttributeSet
9 | import android.util.TypedValue
10 |
11 | class ComponentsManager {
12 |
13 | //小圆半径
14 | private var radius = 0f
15 |
16 | //圆之间的间距
17 | private var circleMargin = 0f
18 |
19 | //原点半径
20 | private var pointRadius = 0f
21 |
22 | //宽高比
23 | private var aspectRatio = 0f
24 |
25 | //使用的宽高
26 | private var useWidth = 0f
27 | private var useHeight = 0f
28 |
29 | //小圆的二维数组
30 | private val circleArray = Array(3) {
31 | return@Array Array(14) {
32 | CircleDrawer()
33 | }
34 | }
35 |
36 | //画线的画笔
37 | private val paint = Paint().apply {
38 | setColor(Color.BLACK)
39 | style = Paint.Style.FILL
40 | }
41 |
42 | private lateinit var hourComponents: TimeComponents
43 | private lateinit var split1Components: SplitLineComponents
44 | private lateinit var minuteComponents: TimeComponents
45 | private lateinit var split2Components: SplitLineComponents
46 | private lateinit var secondComponents: TimeComponents
47 |
48 | fun initConfigureInfo(context: Context, attrs: AttributeSet?) {
49 | radius = dp2px(context, 20)
50 | circleMargin = dp2px(context, 4)
51 | pointRadius = dp2px(context, 2)
52 | paint.strokeWidth = circleMargin
53 | aspectRatio =
54 | (14 * radius * 2 + circleMargin * 15) * 1.0f / (3 * radius * 2 + circleMargin * 4)
55 | }
56 |
57 | fun initComponents(w: Int, h: Int) {
58 | val realAspectRatio = w * 1.0f / h
59 | if (realAspectRatio > aspectRatio) {
60 | //以高为基准
61 | useHeight = h * 1.0f
62 | useWidth = useHeight * aspectRatio
63 | } else {
64 | //以宽为基准
65 | useWidth = w * 1.0f
66 | useHeight = useWidth / aspectRatio
67 | }
68 | //重新计算圆半径
69 | radius = (useWidth - circleMargin * 15) / 14 / 2
70 | //以画布左上角为原点计算小圆的分布和分组
71 | countCirclePosition()
72 | }
73 |
74 | fun draw(canvas: Canvas, progress: Int) {
75 | val calendar: Calendar = Calendar.getInstance()
76 | val hour = calendar[Calendar.HOUR_OF_DAY]
77 | val minute = calendar[Calendar.MINUTE]
78 | val second = calendar[Calendar.SECOND]
79 | val drawProgress = (progress + 1) * 1f / 1000
80 | hourComponents.setNumberAndProgress(hour,drawProgress)
81 | minuteComponents.setNumberAndProgress(minute,drawProgress)
82 | secondComponents.setNumberAndProgress(second,drawProgress)
83 | drawComponents(canvas)
84 | }
85 |
86 | private fun drawComponents(canvas: Canvas) {
87 | hourComponents.draw(canvas)
88 | split1Components.draw(canvas)
89 | minuteComponents.draw(canvas)
90 | split2Components.draw(canvas)
91 | secondComponents.draw(canvas)
92 | }
93 |
94 | private fun countCirclePosition() {
95 | //根据属性计算所有圆的位置
96 | initAllCircleParamArray()
97 | initHourComponents()
98 | initSplit1Components()
99 | initMinuteComponents()
100 | initSplit2Components()
101 | initSecondComponents()
102 | }
103 |
104 | private fun initSecondComponents() {
105 | secondComponents = TimeComponents(
106 | arrayOf(
107 | arrayOf(
108 | circleArray[0][10], circleArray[0][11], circleArray[0][12], circleArray[0][13]
109 | ),
110 | arrayOf(
111 | circleArray[1][10], circleArray[1][11], circleArray[1][12], circleArray[1][13]
112 | ),
113 | arrayOf(
114 | circleArray[2][10], circleArray[2][11], circleArray[2][12], circleArray[2][13]
115 | ),
116 | )
117 | )
118 | }
119 |
120 | private fun initSplit2Components() {
121 | split2Components = SplitLineComponents(
122 | arrayOf(
123 | circleArray[0][9],
124 | circleArray[1][9],
125 | circleArray[2][9],
126 | )
127 | )
128 | }
129 |
130 | private fun initMinuteComponents() {
131 | minuteComponents = TimeComponents(
132 | arrayOf(
133 | arrayOf(circleArray[0][5], circleArray[0][6], circleArray[0][7], circleArray[0][8]),
134 | arrayOf(circleArray[1][5], circleArray[1][6], circleArray[1][7], circleArray[1][8]),
135 | arrayOf(circleArray[2][5], circleArray[2][6], circleArray[2][7], circleArray[2][8]),
136 | )
137 | )
138 | }
139 |
140 | private fun initSplit1Components() {
141 | split1Components = SplitLineComponents(
142 | arrayOf(
143 | circleArray[0][4],
144 | circleArray[1][4],
145 | circleArray[2][4],
146 | )
147 | )
148 | }
149 |
150 | private fun initHourComponents() {
151 | hourComponents = TimeComponents(
152 | arrayOf(
153 | arrayOf(circleArray[0][0], circleArray[0][1], circleArray[0][2], circleArray[0][3]),
154 | arrayOf(circleArray[1][0], circleArray[1][1], circleArray[1][2], circleArray[1][3]),
155 | arrayOf(circleArray[2][0], circleArray[2][1], circleArray[2][2], circleArray[2][3]),
156 | )
157 | )
158 | }
159 |
160 | private fun initAllCircleParamArray() {
161 | var positionY: Float
162 | var positionX: Float
163 | for (i in 0 until 3) {
164 | positionY = (i + 1) * circleMargin + (1 + 2 * i) * radius * 1.0f
165 | for (i1 in 0 until 14) {
166 | positionX = (i1 + 1) * circleMargin + (1 + 2 * i1) * radius * 1.0f
167 | circleArray[i][i1].x = positionX
168 | circleArray[i][i1].y = positionY
169 | circleArray[i][i1].radius = radius
170 | circleArray[i][i1].paint = paint
171 | }
172 | }
173 | }
174 |
175 | private fun dp2px(context: Context, dpValue: Int): Float {
176 | return TypedValue.applyDimension(
177 | TypedValue.COMPLEX_UNIT_SP, dpValue.toFloat(), context.resources.displayMetrics
178 | )
179 | }
180 | }
--------------------------------------------------------------------------------
/line_number_clock/src/main/java/cc/fastcv/line_number_clock/ComponentsType.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | /**
4 | * 数字时钟组件类型
5 | * 这里格局ui效果分为两个类型:
6 | * - 时间组件
7 | * - 分割线组件
8 | */
9 | enum class ComponentsType {
10 | COMPONENTS_TYPE_TIME, COMPONENTS_SPLIT_LINE
11 | }
--------------------------------------------------------------------------------
/line_number_clock/src/main/java/cc/fastcv/line_number_clock/LineNumberClockView.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | import android.animation.ValueAnimator
4 | import android.content.Context
5 | import android.graphics.Canvas
6 | import android.os.Handler
7 | import android.os.Looper
8 | import android.util.AttributeSet
9 | import android.util.Log
10 | import android.view.View
11 | import androidx.lifecycle.DefaultLifecycleObserver
12 | import androidx.lifecycle.Lifecycle
13 | import androidx.lifecycle.LifecycleOwner
14 |
15 | class LineNumberClockView @JvmOverloads constructor(context: Context,attrs: AttributeSet? = null, defStyleAttr: Int = 0) : View(context, attrs, defStyleAttr), DefaultLifecycleObserver {
16 |
17 | private val manager = ComponentsManager()
18 |
19 | init {
20 | manager.initConfigureInfo(context, attrs)
21 | }
22 |
23 | override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
24 | super.onSizeChanged(w, h, oldw, oldh)
25 | //计算最小宽高值
26 | manager.initComponents(w, h)
27 | }
28 |
29 | private var progress = 999
30 |
31 | private val handler = Handler(Looper.getMainLooper())
32 |
33 | private val showRunnable = Runnable {
34 | Log.d("LineNumberClockView", "System.currentTimeMillis() : ${System.currentTimeMillis()}")
35 | showInAnim()
36 | showNext()
37 | }
38 |
39 | private fun showNext() {
40 | handler.postDelayed(showRunnable, 1000L - System.currentTimeMillis() % 1000L)
41 | }
42 |
43 | fun bindLifecycle(lifecycle: Lifecycle) {
44 | lifecycle.addObserver(this)
45 | }
46 |
47 | private fun showInAnim() {
48 | progress = 0
49 | val anim = ValueAnimator.ofInt(0, 999).apply {
50 | addUpdateListener {
51 | progress = it.animatedValue as Int
52 | invalidate()
53 | }
54 | duration = 650L
55 | }
56 | anim.start()
57 | }
58 |
59 | override fun onResume(owner: LifecycleOwner) {
60 | super.onResume(owner)
61 | postDelayed(showRunnable, 1000L - System.currentTimeMillis() % 1000L)
62 | }
63 |
64 | override fun onStop(owner: LifecycleOwner) {
65 | super.onStop(owner)
66 | handler.removeCallbacks(showRunnable)
67 | }
68 |
69 | override fun onDraw(canvas: Canvas) {
70 | super.onDraw(canvas)
71 | manager.draw(canvas, progress)
72 | }
73 | }
--------------------------------------------------------------------------------
/line_number_clock/src/main/java/cc/fastcv/line_number_clock/NumberProxy.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | import android.graphics.Canvas
4 |
5 | /**
6 | * 指的是数字时钟中的一个数字单位
7 | * 从设计图中可以看出 一个数字单位 由6个圆点组成
8 | * 然后需要具体数字的绘制参数
9 | * @param array 传入的6个圆点信息数组
10 | * @param number 当前数字图形(绘制)参数
11 | */
12 | class NumberProxy(
13 | private val array: Array>,
14 | private val number: AbsNumberDrawParam
15 | ) {
16 |
17 | //绘制数字
18 | fun draw(canvas: Canvas) {
19 | for ((index, minimalUhrCircles) in array.withIndex()) {
20 | for ((index1, minimalUhrCircle) in minimalUhrCircles.withIndex()) {
21 | minimalUhrCircle.drawBaseCircle(canvas)
22 | minimalUhrCircle.drawByCircleDrawParam(canvas, number.params[index * 2 + index1])
23 | }
24 | }
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/line_number_clock/src/main/java/cc/fastcv/line_number_clock/Numbers.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | class Number0 : AbsNumberDrawParam() {
4 | override val params = arrayOf(
5 | CircleDrawParam(0f, (1f * 255).toInt(), 90f, (1f * 255).toInt()),
6 | CircleDrawParam(90f, (1f * 255).toInt(), 180f, (1f * 255).toInt()),
7 | CircleDrawParam(90f, (1f * 255).toInt(), -90f, (1f * 255).toInt()),
8 | CircleDrawParam(90f, (1f * 255).toInt(), -90f, (1f * 255).toInt()),
9 | CircleDrawParam(0f, (1f * 255).toInt(), -90f, (1f * 255).toInt()),
10 | CircleDrawParam(180f, (1f * 255).toInt(), -90f, (1f * 255).toInt())
11 | )
12 | }
13 |
14 | class Number1 : AbsNumberDrawParam() {
15 | override val params = arrayOf(
16 | CircleDrawParam(-90f, (0f * 255).toInt(),-90f, (0f * 255).toInt()),
17 | CircleDrawParam(90f, (1f * 255).toInt(),135f, (1f * 255).toInt()),
18 | CircleDrawParam(-90f, (0f * 255).toInt(),-90f, (0f * 255).toInt()),
19 | CircleDrawParam(90f, (1f * 255).toInt(),-90f, (1f * 255).toInt()),
20 | CircleDrawParam(-90f, (0f * 255).toInt(),-90f, (0f * 255).toInt()),
21 | CircleDrawParam(-90f, (0f * 255).toInt(),-90f, (1f * 255).toInt())
22 | )
23 | }
24 |
25 | class Number2 : AbsNumberDrawParam() {
26 | override val params = arrayOf(
27 | CircleDrawParam(0f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
28 | CircleDrawParam(90f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
29 | CircleDrawParam(0f, (1f * 255).toInt(),90f, (1f * 255).toInt()),
30 | CircleDrawParam(-90f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
31 | CircleDrawParam(-90f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
32 | CircleDrawParam(180f, (1f * 255).toInt(),180f, (1f * 255).toInt())
33 | )
34 | }
35 |
36 | class Number3 : AbsNumberDrawParam() {
37 | override val params = arrayOf(
38 | CircleDrawParam(0f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
39 | CircleDrawParam(90f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
40 | CircleDrawParam(0f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
41 | CircleDrawParam(-90f, (1f * 255).toInt(),90f, (1f * 255).toInt()),
42 | CircleDrawParam(0f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
43 | CircleDrawParam(180f, (1f * 255).toInt(),-90f, (1f * 255).toInt())
44 | )
45 | }
46 |
47 | class Number4 : AbsNumberDrawParam() {
48 | override val params = arrayOf(
49 | CircleDrawParam(90f, (1f * 255).toInt(),90f, (1f * 255).toInt()),
50 | CircleDrawParam( 90f, (1f * 255).toInt(),90f, (1f * 255).toInt()),
51 | CircleDrawParam( -90f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
52 | CircleDrawParam( 90f, (1f * 255).toInt(),-90f, (1f * 255).toInt()),
53 | CircleDrawParam( -90f, (0f * 255).toInt(),-90f, (0f * 255).toInt()),
54 | CircleDrawParam( -90f, (1f * 255).toInt(),-90f, (1f * 255).toInt()),
55 | )
56 | }
57 |
58 | class Number5 : AbsNumberDrawParam() {
59 | override val params = arrayOf(
60 | CircleDrawParam( 0f, (1f * 255).toInt(),90f, (1f * 255).toInt()),
61 | CircleDrawParam( 180f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
62 | CircleDrawParam( -90f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
63 | CircleDrawParam( 90f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
64 | CircleDrawParam( 0f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
65 | CircleDrawParam( -90f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
66 | )
67 | }
68 |
69 | class Number6 : AbsNumberDrawParam() {
70 | override val params = arrayOf(
71 | CircleDrawParam( 0f, (1f * 255).toInt(),90f, (1f * 255).toInt()),
72 | CircleDrawParam( 180f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
73 | CircleDrawParam( 90f, (1f * 255).toInt(),-90f, (1f * 255).toInt()),
74 | CircleDrawParam( 90f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
75 | CircleDrawParam( -90f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
76 | CircleDrawParam( -90f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
77 | )
78 | }
79 |
80 | class Number7 : AbsNumberDrawParam() {
81 | override val params = arrayOf(
82 | CircleDrawParam( 0f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
83 | CircleDrawParam( 90f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
84 | CircleDrawParam( -90f, (0f * 255).toInt(),-90f, (0f * 255).toInt()),
85 | CircleDrawParam( 90f, (1f * 255).toInt(),-90f, (1f * 255).toInt()),
86 | CircleDrawParam( -90f, (0f * 255).toInt(),-90f, (0f * 255).toInt()),
87 | CircleDrawParam( -90f, (1f * 255).toInt(),-90f, (1f * 255).toInt()),
88 | )
89 | }
90 |
91 | class Number8 : AbsNumberDrawParam() {
92 | override val params = arrayOf(
93 | CircleDrawParam( 0f, (1f * 255).toInt(),90f, (1f * 255).toInt()),
94 | CircleDrawParam( 90f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
95 | CircleDrawParam( 0f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
96 | CircleDrawParam( 180f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
97 | CircleDrawParam( -90f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
98 | CircleDrawParam( -90f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
99 | )
100 | }
101 |
102 | class Number9 : AbsNumberDrawParam() {
103 | override val params = arrayOf(
104 | CircleDrawParam( 0f, (1f * 255).toInt(),90f, (1f * 255).toInt()),
105 | CircleDrawParam( 90f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
106 | CircleDrawParam( 0f, (1f * 255).toInt(),-90f, (1f * 255).toInt()),
107 | CircleDrawParam( 90f, (1f * 255).toInt(),-90f, (1f * 255).toInt()),
108 | CircleDrawParam( 0f, (1f * 255).toInt(),0f, (1f * 255).toInt()),
109 | CircleDrawParam( -90f, (1f * 255).toInt(),180f, (1f * 255).toInt()),
110 | )
111 | }
--------------------------------------------------------------------------------
/line_number_clock/src/main/java/cc/fastcv/line_number_clock/SplitLineComponents.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | import android.graphics.Canvas
4 |
5 | /**
6 | * 数字分割线 由3个圆点组成
7 | */
8 | class SplitLineComponents(
9 | private val array: Array,
10 | ) : AbsComponents() {
11 |
12 | override fun draw(canvas: Canvas) {
13 | for ((index, circle) in array.withIndex()) {
14 | circle.drawBaseCircle(canvas)
15 | if (index == 1) {
16 | circle.drawBlackPoint(canvas)
17 | }
18 | }
19 | }
20 |
21 | override val type: ComponentsType
22 | get() = ComponentsType.COMPONENTS_SPLIT_LINE
23 |
24 | }
--------------------------------------------------------------------------------
/line_number_clock/src/main/java/cc/fastcv/line_number_clock/TimeComponents.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | import android.graphics.Canvas
4 | import android.util.Log
5 |
6 | class TimeComponents(private val array: Array>) :
7 | AbsComponents() {
8 | override val type: ComponentsType
9 | get() = ComponentsType.COMPONENTS_TYPE_TIME
10 |
11 | private var lastLeftNumber: AbsNumberDrawParam? = null
12 | private var newLeftNumber: AbsNumberDrawParam? = null
13 | private var lastRightNumber: AbsNumberDrawParam? = null
14 | private var newRightNumber: AbsNumberDrawParam? = null
15 | private var drawProgress:Float = 0f
16 |
17 | fun setNumberAndProgress(number: Int, process: Float) {
18 | newLeftNumber = transformNumber(number / 10)
19 | newRightNumber = transformNumber(number % 10)
20 | drawProgress = process
21 | }
22 |
23 | override fun draw(canvas: Canvas) {
24 | if (drawProgress == 1f) {
25 | lastLeftNumber = newLeftNumber
26 | lastRightNumber = newRightNumber
27 | }
28 | val leftTempNumber: AbsNumberDrawParam =
29 | lastLeftNumber!!.transition(newLeftNumber!!, drawProgress)
30 | val rightTempNumber: AbsNumberDrawParam =
31 | lastRightNumber!!.transition(newRightNumber!!, drawProgress)
32 | val leftNumber = NumberProxy(
33 | arrayOf(
34 | arrayOf(array[0][0], array[0][1]),
35 | arrayOf(array[1][0], array[1][1]),
36 | arrayOf(array[2][0], array[2][1]),
37 | ), leftTempNumber
38 | )
39 | leftNumber.draw(canvas)
40 | val rightNumber = NumberProxy(
41 | arrayOf(
42 | arrayOf(array[0][2], array[0][3]),
43 | arrayOf(array[1][2], array[1][3]),
44 | arrayOf(array[2][2], array[2][3]),
45 | ), rightTempNumber
46 | )
47 | rightNumber.draw(canvas)
48 | }
49 |
50 | private fun transformNumber(i: Int): AbsNumberDrawParam? {
51 | return when (i) {
52 | 0 -> Number0()
53 | 1 -> Number1()
54 | 2 -> Number2()
55 | 3 -> Number3()
56 | 4 -> Number4()
57 | 5 -> Number5()
58 | 6 -> Number6()
59 | 7 -> Number7()
60 | 8 -> Number8()
61 | 9 -> Number9()
62 | else -> null
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/line_number_clock/src/main/java/cc/fastcv/line_number_clock/TransitionNumberDrawParam.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | /**
4 | * 过渡数字绘制参数
5 | */
6 | class TransitionNumberDrawParam(override val params: Array) : AbsNumberDrawParam()
7 |
8 | //计算过渡数字绘制参数
9 | fun AbsNumberDrawParam.transition(newNumber: AbsNumberDrawParam, progress: Float): AbsNumberDrawParam {
10 | val circleDrawParam0 = this.params[0].transition(newNumber.params[0],progress)
11 | val circleDrawParam1 = this.params[1].transition(newNumber.params[1],progress)
12 | val circleDrawParam2 = this.params[2].transition(newNumber.params[2],progress)
13 | val circleDrawParam3 = this.params[3].transition(newNumber.params[3],progress)
14 | val circleDrawParam4 = this.params[4].transition(newNumber.params[4],progress)
15 | val circleDrawParam5 = this.params[5].transition(newNumber.params[5],progress)
16 | return TransitionNumberDrawParam(
17 | arrayOf(
18 | circleDrawParam0,
19 | circleDrawParam1,
20 | circleDrawParam2,
21 | circleDrawParam3,
22 | circleDrawParam4,
23 | circleDrawParam5,
24 | )
25 | )
26 | }
--------------------------------------------------------------------------------
/line_number_clock/src/test/java/cc/fastcv/line_number_clock/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package cc.fastcv.line_number_clock
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google {
4 | content {
5 | includeGroupByRegex("com\\.android.*")
6 | includeGroupByRegex("com\\.google.*")
7 | includeGroupByRegex("androidx.*")
8 | }
9 | }
10 | mavenCentral()
11 | gradlePluginPortal()
12 | }
13 | }
14 | dependencyResolutionManagement {
15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | rootProject.name = "LineNumberClock"
23 | include(":app")
24 | include(":line_number_clock")
25 |
--------------------------------------------------------------------------------