├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── encodings.xml ├── runConfigurations.xml └── vcs.xml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── art ├── takt.gif └── takt.png ├── build.gradle ├── example ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── jp │ │ └── wasabeef │ │ └── example │ │ └── takt │ │ ├── MainActivity.kt │ │ └── SampleApplication.kt │ └── res │ ├── layout │ ├── activity_main.xml │ └── stage.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ └── values │ ├── strings.xml │ └── styles.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── signingConfigs ├── debug.gradle ├── debug.keystore ├── release.gradle └── release.keystore ├── takt-no-op ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── jp │ └── wasabeef │ └── takt │ ├── Audience.java │ ├── LifecycleListener.java │ ├── Seat.java │ └── Takt.java └── takt ├── build.gradle └── src └── main ├── AndroidManifest.xml ├── java └── jp │ └── wasabeef │ └── takt │ ├── Audience.java │ ├── LifecycleListener.java │ ├── Metronome.java │ ├── Seat.java │ └── Takt.java └── res └── layout └── stage.xml /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | indent_size = 2 3 | max_line_length = off 4 | insert_final_newline = true 5 | 6 | [*.{kt, kts}] 7 | kotlin_imports_layout = ascii 8 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: wasabeef # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Future Task 2 | 3 | ## What is the motivation? 4 | 5 | ## What kind of solution can be considered? 6 | 7 | ## What do you want to discuss? 8 | 9 | *Please add relevant labels* 10 | 11 | ----- 12 | 13 | # Bug Reporting 14 | 15 | ## Steps to Reproduce 16 | 17 | ## Actual Results (include screenshots) 18 | 19 | ## Expected Results (include screenshots) 20 | 21 | ## URL 22 | 23 | ## OS details 24 | 25 | - Device: 26 | - OS: 27 | 28 | *Please add relevant labels* 29 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## What does this change? 2 | 3 | ## What is the value of this and can you measure success? 4 | 5 | ## Screenshots 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac OS 2 | .DS_store 3 | 4 | # Built application files 5 | *.apk 6 | *.ap_ 7 | 8 | # Files for the ART/Dalvik VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | 14 | # Generated files 15 | bin/ 16 | gen/ 17 | out/ 18 | 19 | # Gradle files 20 | .gradle/ 21 | build/ 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | 26 | # Proguard folder generated by Eclipse 27 | proguard/ 28 | 29 | # Log Files 30 | *.log 31 | 32 | # Android Studio Navigation editor temp files 33 | .navigation/ 34 | 35 | # Android Studio captures folder 36 | captures/ 37 | 38 | # IntelliJ 39 | *.iml 40 | .idea/workspace.xml 41 | .idea/tasks.xml 42 | .idea/gradle.xml 43 | .idea/assetWizardSettings.xml 44 | .idea/dictionaries 45 | .idea/libraries 46 | .idea/caches 47 | .idea/misc.xml 48 | .idea/modules.xml 49 | .idea/navEditor.xml 50 | .idea/markdown* 51 | .idea/jarRepositories.xml 52 | .idea/inspectionProfiles/Project_Default.xml 53 | .idea/compiler.xml 54 | projectFilesBackup/ 55 | 56 | # Keystore files 57 | # Uncomment the following line if you do not want to check your keystore files in. 58 | #*.jks 59 | 60 | # External native build folder generated in Android Studio 2.2 and later 61 | .externalNativeBuild 62 | 63 | # Google Services (e.g. APIs or Firebase) 64 | google-services.json 65 | 66 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | xmlns:android 17 | 18 | ^$ 19 | 20 | 21 | 22 |
23 |
24 | 25 | 26 | 27 | xmlns:.* 28 | 29 | ^$ 30 | 31 | 32 | BY_NAME 33 | 34 |
35 |
36 | 37 | 38 | 39 | .*:id 40 | 41 | http://schemas.android.com/apk/res/android 42 | 43 | 44 | 45 |
46 |
47 | 48 | 49 | 50 | .*:name 51 | 52 | http://schemas.android.com/apk/res/android 53 | 54 | 55 | 56 |
57 |
58 | 59 | 60 | 61 | name 62 | 63 | ^$ 64 | 65 | 66 | 67 |
68 |
69 | 70 | 71 | 72 | style 73 | 74 | ^$ 75 | 76 | 77 | 78 |
79 |
80 | 81 | 82 | 83 | .* 84 | 85 | ^$ 86 | 87 | 88 | BY_NAME 89 | 90 |
91 |
92 | 93 | 94 | 95 | .* 96 | 97 | http://schemas.android.com/apk/res/android 98 | 99 | 100 | ANDROID_ATTRIBUTE_ORDER 101 | 102 |
103 |
104 | 105 | 106 | 107 | .* 108 | 109 | .* 110 | 111 | 112 | BY_NAME 113 | 114 |
115 |
116 |
117 |
118 | 119 | 121 |
122 |
-------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Change Log 2 | ========== 3 | 4 | Version 2.1.1 *(2021-03-10)* 5 | ---------------------------- 6 | 7 | - Uploaded to Maven Central. 8 | 9 | 10 | Version 2.1.0 *(2020-09-15)* 11 | ---------------------------- 12 | 13 | Update: 14 | - Kotlin 1.3.41 -> 1.3.72 15 | - Compile & Target SDK Version 28 -> 30 16 | 17 | Feature: 18 | - [#20](https://github.com/wasabeef/Takt/pull/20) Added No-op artifact by [beigirad](https://github.com/beigirad) 19 | 20 | Version 2.0.1 *(2019-08-09)* 21 | ---------------------------- 22 | 23 | Update: 24 | - Kotlin 1.3.0 -> 1.3.41 25 | - Build tools 3.4.0-alpha04 -> 3.6.0-alpha05 26 | - Appcompat 1.0.2 -> 1.1.0-rc01 27 | 28 | Version 2.0.0 *(2018-11-19)* 29 | ---------------------------- 30 | 31 | Update: 32 | - Migrate to AndroidX 33 | - Remove novoda-bintray-plugin 34 | 35 | Version 1.0.5 *(2017-06-28)* 36 | ---------------------------- 37 | 38 | Update: 39 | - Compile & Target SDK Version 25 -> 26 40 | - Build Tools 25.0.2 -> 26.0.0-rc2 41 | - Support Library 25.3.0 -> 25.4.0 42 | 43 | Fix: 44 | - Use TYPE_APPLICATION_OVERLAY on Android 8.0 (O) 45 | 46 | 47 | Version 1.0.4 *(2017-03-21)* 48 | ---------------------------- 49 | 50 | Update: 51 | - Compile & Target SDK Version 23 -> 25 52 | - Build Tools 24.0.2 -> 25.0.2 53 | - Support Library 23.4.0 -> 25.3.0 54 | 55 | Version 1.0.3 *(2016-08-03)* 56 | ---------------------------- 57 | 58 | Update: 59 | - Build Tools 23.0.1 -> 24.0.2 60 | - Support Library 23.0.1 -> 23.4.0 61 | 62 | Version 1.0.2 *(2015-12-01)* 63 | ---------------------------- 64 | 65 | bug fix. 66 | 67 | Version 1.0.1 *(2015-09-10)* 68 | ---------------------------- 69 | 70 | add alpha. 71 | 72 | Version 1.0.0 *(2015-09-9)* 73 | ---------------------------- 74 | 75 | Please enjoy. 76 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 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 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-takt-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/2468) 2 | [![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) 3 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/jp.wasabeef/takt/badge.svg)](https://search.maven.org/artifact/jp.wasabeef/takt) 4 | 5 | `Takt` is `Android` library for measuring the `FPS` using [`Choreographer`](http://developer.android.com/intl/ja/reference/android/view/Choreographer.html). 6 | 7 | ![Takt](art/takt.png) 8 | 9 | Screenshot 10 | --- 11 | 12 | 13 | 14 | How do I use it? 15 | --- 16 | 17 | ### Setup 18 | 19 | ##### Dependencies 20 | ```groovy 21 | repositories { 22 | mavenCentral() 23 | } 24 | 25 | dependencies { 26 | releaseImplementation 'jp.wasabeef:takt-no-op:2.1.1' 27 | debugImplementation 'jp.wasabeef:takt:2.1.1' 28 | } 29 | ``` 30 | 31 | 32 | ### Functions 33 | 34 | There is a simple initialization step which occurs in your Application class: 35 | **Simple** 36 | ```java 37 | class MyApplication : Application() { 38 | override fun onCreate() { 39 | super.onCreate() 40 | Takt.stock(this) 41 | } 42 | } 43 | ``` 44 | 45 | **Options** 46 | 47 | - `seat(Seat seat)` is a position 48 | - `interval(int ms)` is a interval 49 | - `color(int color)` is a text color. 50 | - `size(int size)` is a text size 51 | - `alpha(float alpha)` is a text alpha 52 | - `listener(Audience audience)` is a Listener 53 | - `useCustomControl` to manually start/stop Takt (disabled by default) 54 | - `showOverlaySetting` to enable/disable showing system overlay setting (enabled by default) 55 | 56 | ```kotlin 57 | Takt.stock(this) 58 | .seat(Seat.BOTTOM_RIGHT) 59 | .interval(250) 60 | .color(Color.WHITE) 61 | .size(14f) 62 | .alpha(.5f) 63 | .listener { fps -> 64 | Log.d("Excellent!", fps.toString() + " fps") 65 | 66 | // Logcat 67 | // jp.wasabeef.example.takt D/Excellent!﹕ 59.28853754940712 fps 68 | // jp.wasabeef.example.takt D/Excellent!﹕ 59.523809523809526 fps 69 | // jp.wasabeef.example.takt D/Excellent!﹕ 59.05511811023622 fps 70 | // jp.wasabeef.example.takt D/Excellent!﹕ 55.33596837944664 fps 71 | // jp.wasabeef.example.takt D/Excellent!﹕ 59.523809523809526 fps 72 | } 73 | ``` 74 | 75 | **Position** 76 | 77 | ```java 78 | Takt.stock(this) 79 | .seat(Seat.RIGHT_CENTER) 80 | 81 | /** 82 | * TOP_RIGHT, 83 | * TOP_LEFT, 84 | * TOP_CENTER, 85 | * 86 | * CENTER, 87 | * RIGHT_CENTER, 88 | * LEFT_CENTER, 89 | * 90 | * BOTTOM_RIGHT, 91 | * BOTTOM_LEFT, 92 | * BOTTOM_CENTER 93 | */ 94 | ``` 95 | 96 | **Hide fps label** 97 | 98 | ```java 99 | Takt.stock(this) 100 | .hide() 101 | .listener { fps -> Log.d("Excellent!", fps.toString() + " fps") } 102 | ``` 103 | 104 | Requirements 105 | -------------- 106 | Android 4.1+ (using the [`Choreographer`](http://developer.android.com/intl/ja/reference/android/view/Choreographer.html)) 107 | 108 | Developed By 109 | ------- 110 | Daichi Furiya (Wasabeef) - 111 | 112 | 113 | Follow me on Twitter 115 | 116 | 117 | License 118 | ------- 119 | 120 | Copyright (C) 2020 Wasabeef 121 | 122 | Licensed under the Apache License, Version 2.0 (the "License"); 123 | you may not use this file except in compliance with the License. 124 | You may obtain a copy of the License at 125 | 126 | http://www.apache.org/licenses/LICENSE-2.0 127 | 128 | Unless required by applicable law or agreed to in writing, software 129 | distributed under the License is distributed on an "AS IS" BASIS, 130 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131 | See the License for the specific language governing permissions and 132 | limitations under the License. 133 | -------------------------------------------------------------------------------- /art/takt.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/Takt/dd3eb554b0c256218b49741455e391f8e4462ca6/art/takt.gif -------------------------------------------------------------------------------- /art/takt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/Takt/dd3eb554b0c256218b49741455e391f8e4462ca6/art/takt.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.3.72' 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:4.2.0-beta05' 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | 13 | // TODO: Close JCenter on May 1st https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/ 14 | // classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5' 15 | // classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | google() 22 | jcenter() 23 | } 24 | tasks.withType(Javadoc) { 25 | enabled = false 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /example/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-kapt' 4 | 5 | android { 6 | compileSdkVersion COMPILE_SDK_VERSION as int 7 | 8 | defaultConfig { 9 | minSdkVersion MIN_SDK_VERSION as int 10 | targetSdkVersion TARGET_SDK_VERSION as int 11 | versionCode VERSION_CODE as int 12 | versionName VERSION_NAME 13 | } 14 | 15 | // SigningConfigs 16 | apply from: '../signingConfigs/debug.gradle', to: android 17 | apply from: '../signingConfigs/release.gradle', to: android 18 | 19 | buildTypes { 20 | debug { 21 | debuggable true 22 | zipAlignEnabled true 23 | signingConfig signingConfigs.debug 24 | } 25 | release { 26 | debuggable false 27 | zipAlignEnabled true 28 | minifyEnabled true 29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 30 | shrinkResources true 31 | signingConfig signingConfigs.release 32 | } 33 | } 34 | } 35 | 36 | repositories { 37 | // maven { url = "https://oss.sonatype.org/content/repositories/snapshots"} 38 | } 39 | 40 | dependencies { 41 | debugImplementation project(':takt') 42 | releaseImplementation project(':takt-no-op') 43 | // debugImplementation 'jp.wasabeef:takt:2.1.1' 44 | // releaseImplementation 'jp.wasabeef:takt-no-op:2.1.1' 45 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 46 | implementation "androidx.appcompat:appcompat:1.2.0" 47 | } 48 | -------------------------------------------------------------------------------- /example/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /example/src/main/java/jp/wasabeef/example/takt/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.example.takt 2 | 3 | import android.os.Bundle 4 | 5 | import androidx.appcompat.app.AppCompatActivity 6 | import jp.wasabeef.takt.Takt 7 | 8 | /** 9 | * Copyright (C) 2020 Wasabeef 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | class MainActivity : AppCompatActivity() { 25 | 26 | override fun onCreate(savedInstanceState: Bundle?) { 27 | super.onCreate(savedInstanceState) 28 | setContentView(R.layout.activity_main) 29 | } 30 | 31 | override fun onStart() { 32 | super.onStart() 33 | Takt.play() 34 | } 35 | 36 | override fun onStop() { 37 | super.onStop() 38 | Takt.finish() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /example/src/main/java/jp/wasabeef/example/takt/SampleApplication.kt: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.example.takt 2 | 3 | import android.app.Application 4 | import android.graphics.Color 5 | import android.util.Log 6 | import jp.wasabeef.takt.Seat 7 | import jp.wasabeef.takt.Takt 8 | 9 | /** 10 | * Copyright (C) 2020 Wasabeef 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | class SampleApplication : Application() { 26 | 27 | override fun onCreate() { 28 | super.onCreate() 29 | Takt.stock(this) 30 | .seat(Seat.TOP_RIGHT) 31 | .interval(250) 32 | .color(Color.WHITE) 33 | .size(24f) 34 | .alpha(.5f) 35 | .listener { fps -> Log.d("Excellent!", fps.toString() + " fps") } 36 | .useCustomControl() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /example/src/main/res/layout/stage.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /example/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/Takt/dd3eb554b0c256218b49741455e391f8e4462ca6/example/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/Takt/dd3eb554b0c256218b49741455e391f8e4462ca6/example/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/Takt/dd3eb554b0c256218b49741455e391f8e4462ca6/example/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/Takt/dd3eb554b0c256218b49741455e391f8e4462ca6/example/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Takt 3 | Hello world! 4 | 5 | -------------------------------------------------------------------------------- /example/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2048m 2 | org.gradle.parallel=true 3 | org.gradle.daemon=true 4 | org.gradle.configureondemand=true 5 | org.gradle.caching=true 6 | android.enableBuildCache=true 7 | android.useAndroidX=true 8 | android.enableJetifier=false 9 | kotlin.code.style=official 10 | 11 | VERSION_NAME=2.1.1 12 | VERSION_CODE=211 13 | GROUP=jp.wasabeef 14 | COMPILE_SDK_VERSION=30 15 | TARGET_SDK_VERSION=30 16 | MIN_SDK_VERSION=21 17 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/Takt/dd3eb554b0c256218b49741455e391f8e4462ca6/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':example', ':takt', ':takt-no-op' 2 | -------------------------------------------------------------------------------- /signingConfigs/debug.gradle: -------------------------------------------------------------------------------- 1 | signingConfigs { 2 | debug { 3 | storeFile file("debug.keystore") 4 | storePassword "android" 5 | keyAlias "androiddebugkey" 6 | keyPassword "android" 7 | } 8 | } 9 | 10 | // $ keytool -v -list -keystore 11 | // Certificate fingerprints: 12 | // MD5: 28:22:7C:A4:B9:2F:6E:C7:D5:58:62:48:EB:7E:82:C3 13 | // SHA1: 94:25:A9:50:9C:0E:AE:AA:00:37:5E:D6:71:E3:BC:ED:17:E5:0C:A3 14 | // SHA256: 04:92:39:09:3D:1C:B6:16:BE:55:58:A3:5F:3B:BB:CB:0B:E7:F1:DA:AA:26:C5:2D:BD:2F:44:CF:AE:47:CF:87 15 | -------------------------------------------------------------------------------- /signingConfigs/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/Takt/dd3eb554b0c256218b49741455e391f8e4462ca6/signingConfigs/debug.keystore -------------------------------------------------------------------------------- /signingConfigs/release.gradle: -------------------------------------------------------------------------------- 1 | signingConfigs { 2 | release { 3 | storeFile file("release.keystore") 4 | storePassword "takttakt" 5 | keyAlias "dummy" 6 | keyPassword "takttakt" 7 | } 8 | } 9 | 10 | // $ keytool -v -list -keystore 11 | // Certificate fingerprints: 12 | // MD5: E8:AB:EB:87:91:DA:8C:C1:0B:15:5C:0F:55:17:66:83 13 | // SHA1: 6C:EA:F9:AA:87:9E:4E:7F:98:EF:DE:EA:95:91:B5:82:82:F2:E7:61 14 | // SHA256: 2A:E7:56:DF:EB:4E:A6:F6:52:A3:9D:6B:50:BE:10:E8:40:4A:DA:0A:7C:76:58:1F:FD:A6:50:05:0B:D1:68:3D 15 | -------------------------------------------------------------------------------- /signingConfigs/release.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/Takt/dd3eb554b0c256218b49741455e391f8e4462ca6/signingConfigs/release.keystore -------------------------------------------------------------------------------- /takt-no-op/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion COMPILE_SDK_VERSION as int 5 | 6 | defaultConfig { 7 | minSdkVersion MIN_SDK_VERSION as int 8 | targetSdkVersion TARGET_SDK_VERSION as int 9 | } 10 | } 11 | 12 | ext { 13 | bintrayRepo = 'maven' 14 | bintrayName = 'takt-no-op' 15 | bintrayUserOrg = 'wasabeef' 16 | publishedGroupId = 'jp.wasabeef' 17 | libraryName = 'takt' 18 | artifact = 'takt-no-op' 19 | libraryDescription = 'Android libraries for measuring the FPS' 20 | siteUrl = 'https://github.com/wasabeef/Takt' 21 | gitUrl = 'https://github.com/wasabeef/Takt.git' 22 | issueUrl = 'https://github.com/wasabeef/Takt/issues' 23 | libraryVersion = VERSION_NAME 24 | developerId = 'wasabeef' 25 | developerName = 'Wasabeef' 26 | developerEmail = 'dadadada.chop@gmail.com' 27 | licenseName = 'The Apache Software License, Version 2.0' 28 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 29 | allLicenses = ["Apache-2.0"] 30 | } 31 | 32 | // TODO: Close JCenter on May 1st https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/ 33 | // apply from: 'https://gist.githubusercontent.com/wasabeef/cf14805bee509baf7461974582f17d26/raw/bintray-v1.gradle' 34 | // apply from: 'https://gist.githubusercontent.com/wasabeef/cf14805bee509baf7461974582f17d26/raw/install-v1.gradle' 35 | 36 | apply from: 'https://gist.githubusercontent.com/wasabeef/2f2ae8d97b429e7d967128125dc47854/raw/maven-central-v1.gradle' 37 | -------------------------------------------------------------------------------- /takt-no-op/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /takt-no-op/src/main/java/jp/wasabeef/takt/Audience.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.takt; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 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 | * http://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 | public interface Audience { 20 | void heartbeat(double fps); 21 | } 22 | -------------------------------------------------------------------------------- /takt-no-op/src/main/java/jp/wasabeef/takt/LifecycleListener.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.takt; 2 | 3 | import android.app.Activity; 4 | import android.app.Application; 5 | import android.os.Bundle; 6 | 7 | /** 8 | * @author aleien on 21.10.18. 9 | */ 10 | public class LifecycleListener implements Application.ActivityLifecycleCallbacks { 11 | 12 | public LifecycleListener(LifecycleCallbackListener listener) { 13 | } 14 | 15 | public interface LifecycleCallbackListener { 16 | void onAppForeground(); 17 | 18 | void onAppBackground(); 19 | } 20 | 21 | @Override 22 | public void onActivityStarted(Activity activity) { 23 | } 24 | 25 | @Override 26 | public void onActivityStopped(Activity activity) { 27 | } 28 | 29 | @Override 30 | public void onActivityCreated(Activity activity, Bundle savedInstanceState) { 31 | } 32 | 33 | @Override 34 | public void onActivityResumed(Activity activity) { 35 | } 36 | 37 | @Override 38 | public void onActivityPaused(Activity activity) { 39 | } 40 | 41 | @Override 42 | public void onActivitySaveInstanceState(Activity activity, Bundle outState) { 43 | } 44 | 45 | @Override 46 | public void onActivityDestroyed(Activity activity) { 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /takt-no-op/src/main/java/jp/wasabeef/takt/Seat.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.takt; 2 | 3 | import android.view.Gravity; 4 | 5 | /** 6 | * Copyright (C) 2020 Wasabeef 7 | *

8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | *

12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | *

14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | public enum Seat { 22 | TOP_RIGHT(Gravity.TOP | Gravity.END), 23 | TOP_LEFT(Gravity.TOP | Gravity.START), 24 | TOP_CENTER(Gravity.TOP | Gravity.CENTER_HORIZONTAL), 25 | 26 | RIGHT_CENTER(Gravity.END | Gravity.CENTER_VERTICAL), 27 | LEFT_CENTER(Gravity.START | Gravity.CENTER_VERTICAL), 28 | CENTER(Gravity.CENTER), 29 | 30 | BOTTOM_RIGHT(Gravity.BOTTOM | Gravity.END), 31 | BOTTOM_LEFT(Gravity.BOTTOM | Gravity.START), 32 | BOTTOM_CENTER(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL); 33 | 34 | private final int gravity; 35 | 36 | Seat(int gravity) { 37 | this.gravity = gravity; 38 | } 39 | 40 | public int getGravity() { 41 | return gravity; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /takt-no-op/src/main/java/jp/wasabeef/takt/Takt.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.takt; 2 | 3 | import android.app.Application; 4 | 5 | /** 6 | * Copyright (C) 2020 Wasabeef 7 | *

8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | *

12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | *

14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | public class Takt { 22 | 23 | private final static Program program = new Program(); 24 | 25 | private Takt() { 26 | } 27 | 28 | public static Program stock(Application application) { 29 | return program.prepare(application); 30 | } 31 | 32 | public static void play() { 33 | } 34 | 35 | public static void finish() { 36 | } 37 | 38 | public static class Program implements LifecycleListener.LifecycleCallbackListener { 39 | public Program() { 40 | } 41 | 42 | private Program prepare(Application application) { 43 | return this; 44 | } 45 | 46 | @Override 47 | public void onAppForeground() { 48 | } 49 | 50 | @Override 51 | public void onAppBackground() { 52 | } 53 | 54 | public void play() { 55 | } 56 | 57 | public void stop() { 58 | } 59 | 60 | public Program color(int color) { 61 | return this; 62 | } 63 | 64 | public Program size(float size) { 65 | return this; 66 | } 67 | 68 | public Program useCustomControl() { 69 | return this; 70 | } 71 | 72 | public Program alpha(float alpha) { 73 | return this; 74 | } 75 | 76 | public Program interval(int ms) { 77 | return this; 78 | } 79 | 80 | public Program listener(Audience audience) { 81 | return this; 82 | } 83 | 84 | public Program hide() { 85 | return this; 86 | } 87 | 88 | public Program seat(Seat seat) { 89 | return this; 90 | } 91 | 92 | public Program showOverlaySetting(boolean enable) { 93 | return this; 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /takt/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion COMPILE_SDK_VERSION as int 5 | 6 | defaultConfig { 7 | minSdkVersion MIN_SDK_VERSION as int 8 | targetSdkVersion TARGET_SDK_VERSION as int 9 | } 10 | } 11 | 12 | ext { 13 | bintrayRepo = 'maven' 14 | bintrayName = 'takt' 15 | bintrayUserOrg = 'wasabeef' 16 | publishedGroupId = 'jp.wasabeef' 17 | libraryName = 'takt' 18 | artifact = 'takt' 19 | libraryDescription = 'Android libraries for measuring the FPS' 20 | siteUrl = 'https://github.com/wasabeef/Takt' 21 | gitUrl = 'https://github.com/wasabeef/Takt.git' 22 | issueUrl = 'https://github.com/wasabeef/Takt/issues' 23 | libraryVersion = VERSION_NAME 24 | developerId = 'wasabeef' 25 | developerName = 'Wasabeef' 26 | developerEmail = 'dadadada.chop@gmail.com' 27 | licenseName = 'The Apache Software License, Version 2.0' 28 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 29 | allLicenses = ["Apache-2.0"] 30 | } 31 | 32 | // TODO: Close JCenter on May 1st https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/ 33 | // apply from: 'https://gist.githubusercontent.com/wasabeef/cf14805bee509baf7461974582f17d26/raw/bintray-v1.gradle' 34 | // apply from: 'https://gist.githubusercontent.com/wasabeef/cf14805bee509baf7461974582f17d26/raw/install-v1.gradle' 35 | 36 | apply from: 'https://gist.githubusercontent.com/wasabeef/2f2ae8d97b429e7d967128125dc47854/raw/maven-central-v1.gradle' 37 | -------------------------------------------------------------------------------- /takt/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /takt/src/main/java/jp/wasabeef/takt/Audience.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.takt; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 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 | * http://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 | public interface Audience { 20 | void heartbeat(double fps); 21 | } 22 | -------------------------------------------------------------------------------- /takt/src/main/java/jp/wasabeef/takt/LifecycleListener.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.takt; 2 | 3 | import android.app.Activity; 4 | import android.app.Application; 5 | import android.os.Bundle; 6 | 7 | /** 8 | * Copyright (C) 2020 Wasabeef 9 | *

10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | *

14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | *

16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | public class LifecycleListener implements Application.ActivityLifecycleCallbacks { 24 | private int startedActivityCounter = 0; 25 | private final LifecycleCallbackListener listener; 26 | 27 | public LifecycleListener(LifecycleCallbackListener listener) { 28 | this.listener = listener; 29 | } 30 | 31 | public interface LifecycleCallbackListener { 32 | void onAppForeground(); 33 | 34 | void onAppBackground(); 35 | } 36 | 37 | @Override 38 | public void onActivityStarted(Activity activity) { 39 | synchronized (this) { 40 | startedActivityCounter++; 41 | if (startedActivityCounter == 1 && listener != null) { 42 | listener.onAppForeground(); 43 | } 44 | } 45 | } 46 | 47 | @Override 48 | public void onActivityStopped(Activity activity) { 49 | synchronized (this) { 50 | startedActivityCounter--; 51 | if (startedActivityCounter == 0 && listener != null) { 52 | listener.onAppBackground(); 53 | } 54 | } 55 | } 56 | 57 | @Override 58 | public void onActivityCreated(Activity activity, Bundle savedInstanceState) { 59 | } 60 | 61 | @Override 62 | public void onActivityResumed(Activity activity) { 63 | } 64 | 65 | @Override 66 | public void onActivityPaused(Activity activity) { 67 | } 68 | 69 | @Override 70 | public void onActivitySaveInstanceState(Activity activity, Bundle outState) { 71 | } 72 | 73 | @Override 74 | public void onActivityDestroyed(Activity activity) { 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /takt/src/main/java/jp/wasabeef/takt/Metronome.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.takt; 2 | 3 | import android.view.Choreographer; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.concurrent.TimeUnit; 8 | 9 | /** 10 | * Copyright (C) 2020 Wasabeef 11 | *

12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | *

16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | *

18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | class Metronome implements Choreographer.FrameCallback { 26 | 27 | private final Choreographer choreographer; 28 | 29 | private long frameStartTime = 0; 30 | private int framesRendered = 0; 31 | 32 | private final List listeners = new ArrayList<>(); 33 | private int interval = 500; 34 | 35 | public Metronome() { 36 | choreographer = Choreographer.getInstance(); 37 | } 38 | 39 | public void start() { 40 | choreographer.postFrameCallback(this); 41 | } 42 | 43 | public void stop() { 44 | frameStartTime = 0; 45 | framesRendered = 0; 46 | choreographer.removeFrameCallback(this); 47 | } 48 | 49 | public void addListener(Audience l) { 50 | listeners.add(l); 51 | } 52 | 53 | public void setInterval(int interval) { 54 | this.interval = interval; 55 | } 56 | 57 | @Override 58 | public void doFrame(long frameTimeNanos) { 59 | long currentTimeMillis = TimeUnit.NANOSECONDS.toMillis(frameTimeNanos); 60 | 61 | if (frameStartTime > 0) { 62 | // take the span in milliseconds 63 | final long timeSpan = currentTimeMillis - frameStartTime; 64 | framesRendered++; 65 | 66 | if (timeSpan > interval) { 67 | final double fps = framesRendered * 1000 / (double) timeSpan; 68 | 69 | frameStartTime = currentTimeMillis; 70 | framesRendered = 0; 71 | 72 | for (Audience audience : listeners) { 73 | audience.heartbeat(fps); 74 | } 75 | } 76 | } else { 77 | frameStartTime = currentTimeMillis; 78 | } 79 | 80 | choreographer.postFrameCallback(this); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /takt/src/main/java/jp/wasabeef/takt/Seat.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.takt; 2 | 3 | import android.view.Gravity; 4 | 5 | /** 6 | * Copyright (C) 2020 Wasabeef 7 | *

8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | *

12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | *

14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | public enum Seat { 22 | TOP_RIGHT(Gravity.TOP | Gravity.END), 23 | TOP_LEFT(Gravity.TOP | Gravity.START), 24 | TOP_CENTER(Gravity.TOP | Gravity.CENTER_HORIZONTAL), 25 | 26 | RIGHT_CENTER(Gravity.END | Gravity.CENTER_VERTICAL), 27 | LEFT_CENTER(Gravity.START | Gravity.CENTER_VERTICAL), 28 | CENTER(Gravity.CENTER), 29 | 30 | BOTTOM_RIGHT(Gravity.BOTTOM | Gravity.END), 31 | BOTTOM_LEFT(Gravity.BOTTOM | Gravity.START), 32 | BOTTOM_CENTER(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL); 33 | 34 | private final int gravity; 35 | 36 | Seat(int gravity) { 37 | this.gravity = gravity; 38 | } 39 | 40 | public int getGravity() { 41 | return gravity; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /takt/src/main/java/jp/wasabeef/takt/Takt.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.takt; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.graphics.PixelFormat; 7 | import android.net.Uri; 8 | import android.os.Build; 9 | import android.provider.Settings; 10 | import android.util.Log; 11 | import android.view.LayoutInflater; 12 | import android.view.View; 13 | import android.view.WindowManager; 14 | import android.view.WindowManager.LayoutParams; 15 | import android.widget.RelativeLayout; 16 | import android.widget.TextView; 17 | 18 | import java.text.DecimalFormat; 19 | 20 | /** 21 | * Copyright (C) 2020 Wasabeef 22 | *

23 | * Licensed under the Apache License, Version 2.0 (the "License"); 24 | * you may not use this file except in compliance with the License. 25 | * You may obtain a copy of the License at 26 | *

27 | * http://www.apache.org/licenses/LICENSE-2.0 28 | *

29 | * Unless required by applicable law or agreed to in writing, software 30 | * distributed under the License is distributed on an "AS IS" BASIS, 31 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 32 | * See the License for the specific language governing permissions and 33 | * limitations under the License. 34 | */ 35 | 36 | public class Takt { 37 | 38 | private final static Program program = new Program(); 39 | 40 | private Takt() { 41 | } 42 | 43 | public static Program stock(Application application) { 44 | return program.prepare(application); 45 | } 46 | 47 | public static void play() { 48 | program.play(); 49 | } 50 | 51 | public static void finish() { 52 | program.stop(); 53 | } 54 | 55 | public static class Program implements LifecycleListener.LifecycleCallbackListener { 56 | private Metronome metronome; 57 | private boolean show = true; 58 | private boolean isPlaying = false; 59 | private boolean showSetting = true; 60 | private boolean customControl = false; 61 | 62 | private Application app; 63 | private WindowManager wm; 64 | private View stageView; 65 | private TextView fpsText; 66 | private LayoutParams params; 67 | 68 | private final DecimalFormat decimal = new DecimalFormat("#.0' fps'"); 69 | 70 | public Program() { 71 | } 72 | 73 | private Program prepare(Application application) { 74 | metronome = new Metronome(); 75 | params = new LayoutParams(); 76 | params.width = LayoutParams.WRAP_CONTENT; 77 | params.height = LayoutParams.WRAP_CONTENT; 78 | application.registerActivityLifecycleCallbacks(new LifecycleListener(this)); 79 | 80 | if (isOverlayApiDeprecated()) { 81 | params.type = LayoutParams.TYPE_APPLICATION_OVERLAY; 82 | } else { 83 | params.type = LayoutParams.TYPE_TOAST; 84 | } 85 | params.flags = LayoutParams.FLAG_KEEP_SCREEN_ON | LayoutParams.FLAG_NOT_FOCUSABLE 86 | | LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_NOT_TOUCHABLE; 87 | params.format = PixelFormat.TRANSLUCENT; 88 | params.gravity = Seat.BOTTOM_RIGHT.getGravity(); 89 | params.x = 10; 90 | 91 | app = application; 92 | wm = (WindowManager) application.getSystemService(Context.WINDOW_SERVICE); 93 | LayoutInflater inflater = LayoutInflater.from(app); 94 | stageView = inflater.inflate(R.layout.stage, new RelativeLayout(app)); 95 | fpsText = stageView.findViewById(R.id.takt_fps); 96 | 97 | listener(fps -> { 98 | if (fpsText != null) { 99 | fpsText.setText(decimal.format(fps)); 100 | } 101 | }); 102 | 103 | return this; 104 | } 105 | 106 | @Override 107 | public void onAppForeground() { 108 | if (!customControl) play(); 109 | } 110 | 111 | @Override 112 | public void onAppBackground() { 113 | if (!customControl) stop(); 114 | } 115 | 116 | public void play() { 117 | if (!hasOverlayPermission()) { 118 | if (showSetting) { 119 | startOverlaySettingActivity(); 120 | } else { 121 | Log.w("takt", "Application has no Overlay permission"); 122 | } 123 | return; 124 | } 125 | 126 | metronome.start(); 127 | 128 | if (show && !isPlaying) { 129 | wm.addView(stageView, params); 130 | isPlaying = true; 131 | } 132 | } 133 | 134 | public void stop() { 135 | metronome.stop(); 136 | 137 | if (show && isPlaying) { 138 | wm.removeView(stageView); 139 | isPlaying = false; 140 | } 141 | } 142 | 143 | public Program color(int color) { 144 | fpsText.setTextColor(color); 145 | return this; 146 | } 147 | 148 | public Program size(float size) { 149 | fpsText.setTextSize(size); 150 | return this; 151 | } 152 | 153 | public Program useCustomControl() { 154 | customControl = true; 155 | return this; 156 | } 157 | 158 | /* 159 | * alpha from = 0.0, to = 1.0 160 | */ 161 | public Program alpha(float alpha) { 162 | fpsText.setAlpha(alpha); 163 | return this; 164 | } 165 | 166 | public Program interval(int ms) { 167 | metronome.setInterval(ms); 168 | return this; 169 | } 170 | 171 | public Program listener(Audience audience) { 172 | metronome.addListener(audience); 173 | return this; 174 | } 175 | 176 | public Program hide() { 177 | show = false; 178 | return this; 179 | } 180 | 181 | public Program seat(Seat seat) { 182 | params.gravity = seat.getGravity(); 183 | return this; 184 | } 185 | 186 | public Program showOverlaySetting(boolean enable) { 187 | showSetting = enable; 188 | return this; 189 | } 190 | 191 | private boolean isOverlayApiDeprecated() { 192 | return Build.VERSION.SDK_INT >= 26; 193 | } 194 | 195 | private boolean hasOverlayPermission() { 196 | return Build.VERSION.SDK_INT < 23 || Settings.canDrawOverlays(app); 197 | } 198 | 199 | private void startOverlaySettingActivity() { 200 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 201 | app.startActivity(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, 202 | Uri.parse("package:" + app.getPackageName())).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); 203 | } 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /takt/src/main/res/layout/stage.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | --------------------------------------------------------------------------------