├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── io │ │ └── github │ │ └── deweyreed │ │ └── digitalwatchview │ │ └── app │ │ ├── MainActivity.kt │ │ └── SecondActivity.kt │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ └── ic_launcher_background.xml │ ├── layout │ ├── activity_main.xml │ └── activity_second.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── image └── preview.gif ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── io │ │ └── github │ │ └── deweyreed │ │ └── digitalwatchview │ │ ├── DigitalWatchView.kt │ │ └── Utility.kt │ └── res │ ├── font │ ├── digital_7_colon.ttf │ └── digital_7_mono_nums.ttf │ └── values │ ├── attrs.xml │ ├── ids.xml │ └── public.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/java,linux,macos,gradle,kotlin,windows,android,jetbrains,jetbrains+iml,jetbrains+all,androidstudio 3 | # Edit at https://www.gitignore.io/?templates=java,linux,macos,gradle,kotlin,windows,android,jetbrains,jetbrains+iml,jetbrains+all,androidstudio 4 | 5 | ### Android ### 6 | # Built application files 7 | *.apk 8 | *.ap_ 9 | *.aab 10 | 11 | # Files for the ART/Dalvik VM 12 | *.dex 13 | 14 | # Java class files 15 | *.class 16 | 17 | # Generated files 18 | bin/ 19 | gen/ 20 | out/ 21 | 22 | # Gradle files 23 | .gradle/ 24 | build/ 25 | 26 | # Local configuration file (sdk path, etc) 27 | local.properties 28 | 29 | # Proguard folder generated by Eclipse 30 | proguard/ 31 | 32 | # Log Files 33 | *.log 34 | 35 | # Android Studio Navigation editor temp files 36 | .navigation/ 37 | 38 | # Android Studio captures folder 39 | captures/ 40 | 41 | # IntelliJ 42 | *.iml 43 | .idea/workspace.xml 44 | .idea/tasks.xml 45 | .idea/gradle.xml 46 | .idea/assetWizardSettings.xml 47 | .idea/dictionaries 48 | .idea/libraries 49 | .idea/caches 50 | 51 | # Keystore files 52 | # Uncomment the following lines if you do not want to check your keystore files in. 53 | #*.jks 54 | #*.keystore 55 | 56 | # External native build folder generated in Android Studio 2.2 and later 57 | .externalNativeBuild 58 | 59 | # Google Services (e.g. APIs or Firebase) 60 | google-services.json 61 | 62 | # Freeline 63 | freeline.py 64 | freeline/ 65 | freeline_project_description.json 66 | 67 | # fastlane 68 | fastlane/report.xml 69 | fastlane/Preview.html 70 | fastlane/screenshots 71 | fastlane/test_output 72 | fastlane/readme.md 73 | 74 | ### Android Patch ### 75 | gen-external-apklibs 76 | 77 | ### AndroidStudio ### 78 | # Covers files to be ignored for android development using Android Studio. 79 | 80 | # Built application files 81 | 82 | # Files for the ART/Dalvik VM 83 | 84 | # Java class files 85 | 86 | # Generated files 87 | 88 | # Gradle files 89 | .gradle 90 | 91 | # Signing files 92 | .signing/ 93 | 94 | # Local configuration file (sdk path, etc) 95 | 96 | # Proguard folder generated by Eclipse 97 | 98 | # Log Files 99 | 100 | # Android Studio 101 | /*/build/ 102 | /*/local.properties 103 | /*/out 104 | /*/*/build 105 | /*/*/production 106 | *.ipr 107 | *~ 108 | *.swp 109 | 110 | # Android Patch 111 | 112 | # External native build folder generated in Android Studio 2.2 and later 113 | 114 | # NDK 115 | obj/ 116 | 117 | # IntelliJ IDEA 118 | *.iws 119 | /out/ 120 | 121 | # User-specific configurations 122 | .idea/caches/ 123 | .idea/libraries/ 124 | .idea/shelf/ 125 | .idea/.name 126 | .idea/compiler.xml 127 | .idea/copyright/profiles_settings.xml 128 | .idea/encodings.xml 129 | .idea/misc.xml 130 | .idea/modules.xml 131 | .idea/scopes/scope_settings.xml 132 | .idea/vcs.xml 133 | .idea/jsLibraryMappings.xml 134 | .idea/datasources.xml 135 | .idea/dataSources.ids 136 | .idea/sqlDataSources.xml 137 | .idea/dynamic.xml 138 | .idea/uiDesigner.xml 139 | 140 | # OS-specific files 141 | .DS_Store 142 | .DS_Store? 143 | ._* 144 | .Spotlight-V100 145 | .Trashes 146 | ehthumbs.db 147 | Thumbs.db 148 | 149 | # Legacy Eclipse project files 150 | .classpath 151 | .project 152 | .cproject 153 | .settings/ 154 | 155 | # Mobile Tools for Java (J2ME) 156 | .mtj.tmp/ 157 | 158 | # Package Files # 159 | *.war 160 | *.ear 161 | 162 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) 163 | hs_err_pid* 164 | 165 | ## Plugin-specific files: 166 | 167 | # mpeltonen/sbt-idea plugin 168 | .idea_modules/ 169 | 170 | # JIRA plugin 171 | atlassian-ide-plugin.xml 172 | 173 | # Mongo Explorer plugin 174 | .idea/mongoSettings.xml 175 | 176 | # Crashlytics plugin (for Android Studio and IntelliJ) 177 | com_crashlytics_export_strings.xml 178 | crashlytics.properties 179 | crashlytics-build.properties 180 | fabric.properties 181 | 182 | ### AndroidStudio Patch ### 183 | 184 | !/gradle/wrapper/gradle-wrapper.jar 185 | 186 | ### Java ### 187 | # Compiled class file 188 | 189 | # Log file 190 | 191 | # BlueJ files 192 | *.ctxt 193 | 194 | # Mobile Tools for Java (J2ME) 195 | 196 | # Package Files # 197 | *.jar 198 | *.nar 199 | *.zip 200 | *.tar.gz 201 | *.rar 202 | 203 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 204 | 205 | ### JetBrains ### 206 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 207 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 208 | 209 | # User-specific stuff 210 | .idea/**/workspace.xml 211 | .idea/**/tasks.xml 212 | .idea/**/usage.statistics.xml 213 | .idea/**/dictionaries 214 | .idea/**/shelf 215 | 216 | # Generated files 217 | .idea/**/contentModel.xml 218 | 219 | # Sensitive or high-churn files 220 | .idea/**/dataSources/ 221 | .idea/**/dataSources.ids 222 | .idea/**/dataSources.local.xml 223 | .idea/**/sqlDataSources.xml 224 | .idea/**/dynamic.xml 225 | .idea/**/uiDesigner.xml 226 | .idea/**/dbnavigator.xml 227 | 228 | # Gradle 229 | .idea/**/gradle.xml 230 | .idea/**/libraries 231 | 232 | # Gradle and Maven with auto-import 233 | # When using Gradle or Maven with auto-import, you should exclude module files, 234 | # since they will be recreated, and may cause churn. Uncomment if using 235 | # auto-import. 236 | # .idea/modules.xml 237 | # .idea/*.iml 238 | # .idea/modules 239 | 240 | # CMake 241 | cmake-build-*/ 242 | 243 | # Mongo Explorer plugin 244 | .idea/**/mongoSettings.xml 245 | 246 | # File-based project format 247 | 248 | # IntelliJ 249 | 250 | # mpeltonen/sbt-idea plugin 251 | 252 | # JIRA plugin 253 | 254 | # Cursive Clojure plugin 255 | .idea/replstate.xml 256 | 257 | # Crashlytics plugin (for Android Studio and IntelliJ) 258 | 259 | # Editor-based Rest Client 260 | .idea/httpRequests 261 | 262 | # Android studio 3.1+ serialized cache file 263 | .idea/caches/build_file_checksums.ser 264 | 265 | ### JetBrains Patch ### 266 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 267 | 268 | # *.iml 269 | # modules.xml 270 | # .idea/misc.xml 271 | # *.ipr 272 | 273 | # Sonarlint plugin 274 | .idea/sonarlint 275 | 276 | ### JetBrains+all ### 277 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 278 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 279 | 280 | # User-specific stuff 281 | 282 | # Generated files 283 | 284 | # Sensitive or high-churn files 285 | 286 | # Gradle 287 | 288 | # Gradle and Maven with auto-import 289 | # When using Gradle or Maven with auto-import, you should exclude module files, 290 | # since they will be recreated, and may cause churn. Uncomment if using 291 | # auto-import. 292 | # .idea/modules.xml 293 | # .idea/*.iml 294 | # .idea/modules 295 | 296 | # CMake 297 | 298 | # Mongo Explorer plugin 299 | 300 | # File-based project format 301 | 302 | # IntelliJ 303 | 304 | # mpeltonen/sbt-idea plugin 305 | 306 | # JIRA plugin 307 | 308 | # Cursive Clojure plugin 309 | 310 | # Crashlytics plugin (for Android Studio and IntelliJ) 311 | 312 | # Editor-based Rest Client 313 | 314 | # Android studio 3.1+ serialized cache file 315 | 316 | ### JetBrains+all Patch ### 317 | # Ignores the whole .idea folder and all .iml files 318 | # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 319 | 320 | .idea/ 321 | 322 | # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 323 | 324 | modules.xml 325 | 326 | ### JetBrains+iml ### 327 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 328 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 329 | 330 | # User-specific stuff 331 | 332 | # Generated files 333 | 334 | # Sensitive or high-churn files 335 | 336 | # Gradle 337 | 338 | # Gradle and Maven with auto-import 339 | # When using Gradle or Maven with auto-import, you should exclude module files, 340 | # since they will be recreated, and may cause churn. Uncomment if using 341 | # auto-import. 342 | # .idea/modules.xml 343 | # .idea/*.iml 344 | # .idea/modules 345 | 346 | # CMake 347 | 348 | # Mongo Explorer plugin 349 | 350 | # File-based project format 351 | 352 | # IntelliJ 353 | 354 | # mpeltonen/sbt-idea plugin 355 | 356 | # JIRA plugin 357 | 358 | # Cursive Clojure plugin 359 | 360 | # Crashlytics plugin (for Android Studio and IntelliJ) 361 | 362 | # Editor-based Rest Client 363 | 364 | # Android studio 3.1+ serialized cache file 365 | 366 | ### JetBrains+iml Patch ### 367 | # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 368 | 369 | 370 | ### Kotlin ### 371 | # Compiled class file 372 | 373 | # Log file 374 | 375 | # BlueJ files 376 | 377 | # Mobile Tools for Java (J2ME) 378 | 379 | # Package Files # 380 | 381 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 382 | 383 | ### Linux ### 384 | 385 | # temporary files which can be created if a process still has a handle open of a deleted file 386 | .fuse_hidden* 387 | 388 | # KDE directory preferences 389 | .directory 390 | 391 | # Linux trash folder which might appear on any partition or disk 392 | .Trash-* 393 | 394 | # .nfs files are created when an open file is removed but is still being accessed 395 | .nfs* 396 | 397 | ### macOS ### 398 | # General 399 | .AppleDouble 400 | .LSOverride 401 | 402 | # Icon must end with two \r 403 | Icon 404 | 405 | # Thumbnails 406 | 407 | # Files that might appear in the root of a volume 408 | .DocumentRevisions-V100 409 | .fseventsd 410 | .TemporaryItems 411 | .VolumeIcon.icns 412 | .com.apple.timemachine.donotpresent 413 | 414 | # Directories potentially created on remote AFP share 415 | .AppleDB 416 | .AppleDesktop 417 | Network Trash Folder 418 | Temporary Items 419 | .apdisk 420 | 421 | ### Windows ### 422 | # Windows thumbnail cache files 423 | ehthumbs_vista.db 424 | 425 | # Dump file 426 | *.stackdump 427 | 428 | # Folder config file 429 | [Dd]esktop.ini 430 | 431 | # Recycle Bin used on file shares 432 | $RECYCLE.BIN/ 433 | 434 | # Windows Installer files 435 | *.cab 436 | *.msi 437 | *.msix 438 | *.msm 439 | *.msp 440 | 441 | # Windows shortcuts 442 | *.lnk 443 | 444 | ### Gradle ### 445 | /build/ 446 | 447 | # Ignore Gradle GUI config 448 | gradle-app.setting 449 | 450 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 451 | !gradle-wrapper.jar 452 | 453 | # Cache of project 454 | .gradletasknamecache 455 | 456 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 457 | # gradle/wrapper/gradle-wrapper.properties 458 | 459 | ### Gradle Patch ### 460 | **/build/ 461 | 462 | # End of https://www.gitignore.io/api/java,linux,macos,gradle,kotlin,windows,android,jetbrains,jetbrains+iml,jetbrains+all,androidstudio 463 | 464 | *.aar -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 DeweyReed 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Android Arsenal]( https://img.shields.io/badge/Android%20Arsenal-DigitalWatchView-green.svg?style=flat)]( https://android-arsenal.com/details/1/6847) 2 | [![newest version](https://jitpack.io/v/DeweyReed/DigitalWatchView.svg)](https://jitpack.io/#DeweyReed/DigitalWatchView) 3 | 4 | ## Deprecated 5 | 6 | Since [a TextView with a custom font works perfectly](https://github.com/DeweyReed/DigitalWatchView/issues/2), this library is of little use. 7 | 8 | # DigitalWatchView 9 | 10 | Just looks like your digital watch. 11 | 12 | ![preview image](https://github.com/DeweyReed/DigitalWatchView/blob/master/image/preview.gif?raw=true) 13 | 14 | ## Install 15 | 16 | Step 1. Add the JitPack repository to your build file 17 | 18 | Add it in your root build.gradle at the end of repositories: 19 | 20 | ```Groovy 21 | allprojects { 22 | repositories { 23 | ... 24 | maven { url 'https://jitpack.io' } 25 | } 26 | } 27 | ``` 28 | 29 | Step 2. Add the dependency => [![newest version](https://jitpack.io/v/DeweyReed/DigitalWatchView.svg)](https://jitpack.io/#DeweyReed/DigitalWatchView) 30 | 31 | ```Groovy 32 | dependencies { 33 | implementation 'com.github.DeweyReed:DigitalWatchView:$version' 34 | } 35 | ``` 36 | 37 | **1.0.2 is the last version using the support library.** 38 | 39 | ## Try 40 | 41 | Download a sample APK [here](https://github.com/DeweyReed/DigitalWatchView/releases/download/1.0/sample.apk) 42 | 43 | ## Usage 44 | 45 | ```Kotlin 46 | 64 | ``` 65 | 66 | ## Attributes 67 | 68 | |xml|method|type|default|meaning| 69 | |:-:|:-:|:-:|:-:|:-| 70 | |dwv_show_background|setShowBackground|boolean|false|Show a shadow background| 71 | |dwv_background_color|setBackgroundViewColorInt|(ColorInt) int|darker_gray|Background text color| 72 | |dwv_background_alpha|setBackgroundViewAlpha|float([0.0, 1.0])|1.0|Set background text alpha| 73 | |dwv_foreground_color|setForegroundViewColorInt|(ColorInt) int|holo_green_dark|Digital text color| 74 | |dwv_normal_text_size|setNormalTextSize|float|18sp|Set hours and minutes text size| 75 | |dwv_show_seconds|setShowSeconds|boolean|true|Show seconds digits| 76 | |dwv_seconds_text_size|setSecondsTextSize|float|18sp|Set seconds text size| 77 | |dwv_show_hours|setShowHours|boolean|true|Show hours digits| 78 | |dwv_show_two_digits|setShowTwoDigits|boolean|true|Use %02d format for hours digits(minutes if hours are hidden)| 79 | |dwv_hours|setHours|int|0|Set hours| 80 | |dwv_minutes|setMinutes|int|0|Set minutes| 81 | |dwv_seconds|setSeconds|int|0|Set seconds| 82 | |dwv_blink_colons|setBlinkColons|boolean|false|Blink colons like a digital watch| 83 | ||setTime|(int, int, int)||Set hours, minutes and seconds using one method| 84 | ||getHours|||Return current hours| 85 | ||getMinutes|||Return current minutes| 86 | ||getSeconds|||Return current seconds| 87 | ||Other Getters|||Every setter has its corresponding getter| 88 | 89 | ## =-= 90 | 91 | `digital_7_colon.ttf` the two colons use is a subset font of `digital_7.ttf`. It simply includes one glyph(the colon) but takes 2.89KB space. So does `digital_7_mono_nums.ttf`, ten numbers glyphs take 5.44KB space. 92 | 93 | I do care about APK size but I don't know if there is a way to reduce these two fonts size. I need help!! 94 | 95 | ## License 96 | 97 | [MIT License](https://github.com/DeweyReed/DigitalWatchView/blob/master/LICENSE) 98 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion versions.compileSdk 9 | defaultConfig { 10 | applicationId "io.github.deweyreed.digitalwatchview.app" 11 | minSdkVersion versions.minSdk 12 | targetSdkVersion versions.targetSdk 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | 28 | implementation project(':library') 29 | implementation libs.kotlin_stdlib_jdk7 30 | implementation libs.appcompat 31 | 32 | implementation 'org.adw.library:discrete-seekbar:1.0.1' 33 | //noinspection GradleDependency 34 | implementation 'com.jaredrummler:colorpicker:1.1.0' 35 | debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.2' 36 | 37 | } 38 | -------------------------------------------------------------------------------- /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 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/deweyreed/digitalwatchview/app/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package io.github.deweyreed.digitalwatchview.app 2 | 3 | import android.content.Context 4 | import android.content.Intent 5 | import android.os.Bundle 6 | import androidx.appcompat.app.AppCompatActivity 7 | import com.jaredrummler.android.colorpicker.ColorPickerDialog 8 | import com.jaredrummler.android.colorpicker.ColorPickerDialogListener 9 | import kotlinx.android.synthetic.main.activity_main.* 10 | import org.adw.library.widgets.discreteseekbar.DiscreteSeekBar 11 | 12 | class MainActivity : AppCompatActivity(), 13 | ColorPickerDialogListener, DiscreteSeekBar.OnProgressChangeListener { 14 | 15 | override fun onCreate(savedInstanceState: Bundle?) { 16 | super.onCreate(savedInstanceState) 17 | setContentView(R.layout.activity_main) 18 | 19 | setupListeners() 20 | } 21 | 22 | override fun onDialogDismissed(dialogId: Int) = Unit 23 | 24 | override fun onColorSelected(dialogId: Int, color: Int) { 25 | when (dialogId) { 26 | R.id.imageBackgroundColor -> { 27 | imageBackgroundColor.setBackgroundColor(color) 28 | digitalWatchView.setBackgroundViewColorInt(color) 29 | } 30 | R.id.imageForegroundColor -> { 31 | imageForegroundColor.setBackgroundColor(color) 32 | digitalWatchView.setForegroundViewColorInt(color) 33 | } 34 | } 35 | } 36 | 37 | override fun onProgressChanged(seekBar: DiscreteSeekBar?, value: Int, fromUser: Boolean) { 38 | if (fromUser) { 39 | when (seekBar?.id) { 40 | R.id.seekBackgroundAlpha -> digitalWatchView.setBackgroundViewAlpha(value / 100f) 41 | R.id.seekNormalTextSize -> digitalWatchView.setNormalTextSize(sp(value)) 42 | R.id.seekSecondsTextSize -> digitalWatchView.setSecondsTextSize(sp(value)) 43 | R.id.seekHours -> digitalWatchView.setHours(value) 44 | R.id.seekMinutes -> digitalWatchView.setMinutes(value) 45 | R.id.seekSeconds -> digitalWatchView.setSeconds(value) 46 | } 47 | } 48 | } 49 | 50 | override fun onStartTrackingTouch(seekBar: DiscreteSeekBar?) = Unit 51 | 52 | override fun onStopTrackingTouch(seekBar: DiscreteSeekBar?) = Unit 53 | 54 | private fun setupListeners() { 55 | checkShowBackground.setOnCheckedChangeListener { _, isChecked -> 56 | digitalWatchView.setShowBackground(isChecked) 57 | imageBackgroundColor.isEnabled = isChecked 58 | seekBackgroundAlpha.isEnabled = isChecked 59 | } 60 | checkShowHours.setOnCheckedChangeListener { _, isChecked -> 61 | digitalWatchView.setShowHours(isChecked) 62 | } 63 | checkShowTwoDigits.setOnCheckedChangeListener { _, isChecked -> 64 | digitalWatchView.setShowTwoDigits(isChecked) 65 | } 66 | checkShowSeconds.setOnCheckedChangeListener { _, isChecked -> 67 | digitalWatchView.setShowSeconds(isChecked) 68 | seekSecondsTextSize.isEnabled = isChecked 69 | } 70 | checkBlinkColons.setOnCheckedChangeListener { _, isChecked -> 71 | digitalWatchView.setBlinkColons(isChecked) 72 | } 73 | 74 | arrayOf(imageBackgroundColor, imageForegroundColor).forEach { view -> 75 | view.setOnClickListener { 76 | ColorPickerDialog.newBuilder().setDialogId(it.id).show(this@MainActivity) 77 | } 78 | } 79 | 80 | arrayOf( 81 | seekBackgroundAlpha, seekNormalTextSize, seekSecondsTextSize, 82 | seekHours, seekMinutes, seekSeconds 83 | ).forEach { 84 | it.setOnProgressChangeListener(this@MainActivity) 85 | } 86 | 87 | btnExample.setOnClickListener { 88 | startActivity(Intent(this, SecondActivity::class.java)) 89 | } 90 | } 91 | } 92 | 93 | val Context.scaledDensity: Float get() = resources.displayMetrics.scaledDensity 94 | 95 | fun Context.sp(value: Int): Float = value * scaledDensity 96 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/deweyreed/digitalwatchview/app/SecondActivity.kt: -------------------------------------------------------------------------------- 1 | package io.github.deweyreed.digitalwatchview.app 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | 6 | class SecondActivity : AppCompatActivity() { 7 | 8 | override fun onCreate(savedInstanceState: Bundle?) { 9 | super.onCreate(savedInstanceState) 10 | setContentView(R.layout.activity_second) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /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/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 17 | 18 |