111 |
112 |
113 |
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 |
--------------------------------------------------------------------------------