├── lib ├── .gitignore ├── proguard-rules.txt ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ └── values │ │ │ └── attrs.xml │ │ └── java │ │ └── net │ │ └── frakbot │ │ └── blinktextview │ │ └── BlinkTextView.java └── build.gradle ├── sample ├── .gitignore ├── src │ └── main │ │ ├── ic_launcher-web.png │ │ ├── res │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── values │ │ │ ├── styles.xml │ │ │ ├── dimens.xml │ │ │ └── strings.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ └── layout │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── net │ │ └── frakbot │ │ └── blinktextview │ │ └── sample │ │ └── MainActivity.java ├── proguard-rules.txt └── build.gradle ├── art ├── v2.gif ├── demo.gif ├── doge.jpg ├── logo.ai ├── ic_web.png └── ic_web.psd ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle ├── gradle.properties ├── gradlew.bat ├── README.md └── gradlew /lib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /art/v2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frakbot/BlinkTextView/HEAD/art/v2.gif -------------------------------------------------------------------------------- /art/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frakbot/BlinkTextView/HEAD/art/demo.gif -------------------------------------------------------------------------------- /art/doge.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frakbot/BlinkTextView/HEAD/art/doge.jpg -------------------------------------------------------------------------------- /art/logo.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frakbot/BlinkTextView/HEAD/art/logo.ai -------------------------------------------------------------------------------- /art/ic_web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frakbot/BlinkTextView/HEAD/art/ic_web.png -------------------------------------------------------------------------------- /art/ic_web.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frakbot/BlinkTextView/HEAD/art/ic_web.psd -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frakbot/BlinkTextView/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frakbot/BlinkTextView/HEAD/sample/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frakbot/BlinkTextView/HEAD/sample/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frakbot/BlinkTextView/HEAD/sample/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frakbot/BlinkTextView/HEAD/sample/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frakbot/BlinkTextView/HEAD/sample/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | build/ 16 | .gradle/ 17 | 18 | # Project files 19 | *.iml 20 | .idea 21 | # .idea/workspace.xml 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | keystore.properties 26 | 27 | # Configuration files 28 | Config.java 29 | 30 | # Windows thumbnail db 31 | .DS_Store 32 | 33 | # Idea non-crucial project fileS 34 | *.iws 35 | 36 | # Sandbox stuff 37 | _sandbox -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Frakbot (Sebastiano Poggi and Francesco Pontillo) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | include ':lib', ':sample' 18 | -------------------------------------------------------------------------------- /lib/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the ProGuard 5 | # include property in project.properties. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} -------------------------------------------------------------------------------- /sample/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the ProGuard 5 | # include property in project.properties. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} -------------------------------------------------------------------------------- /lib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /lib/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 16dp 20 | 16dp 21 | 22 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | BlinkTextView sample 21 | <blink/> 22 | OCD mode enabled 23 | OCD mode disabled 24 | 25 | 26 | -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 21 | 64dp 22 | 23 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 21 | 22 | 31 | 32 | -------------------------------------------------------------------------------- /lib/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Frakbot (Sebastiano Poggi and Francesco Pontillo) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'android-library' 18 | 19 | android { 20 | compileSdkVersion 19 21 | buildToolsVersion "19.0.3" 22 | 23 | defaultConfig { 24 | minSdkVersion 4 25 | targetSdkVersion 19 26 | versionCode 1 27 | versionName "1.0" 28 | } 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_7 32 | targetCompatibility JavaVersion.VERSION_1_7 33 | } 34 | buildTypes { 35 | release { 36 | runProguard false 37 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 38 | } 39 | } 40 | } 41 | 42 | dependencies { 43 | compile fileTree(dir: 'libs', include: ['*.jar']) 44 | compile 'com.google.gag:gag:1.0.1' 45 | } 46 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Frakbot (Sebastiano Poggi and Francesco Pontillo) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'android' 18 | 19 | android { 20 | compileSdkVersion 19 21 | buildToolsVersion "19.0.3" 22 | 23 | defaultConfig { 24 | minSdkVersion 7 25 | targetSdkVersion 19 26 | versionCode 1 27 | versionName "1.0" 28 | } 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_7 32 | targetCompatibility JavaVersion.VERSION_1_7 33 | } 34 | buildTypes { 35 | release { 36 | runProguard false 37 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 38 | } 39 | } 40 | } 41 | 42 | dependencies { 43 | compile fileTree(dir: 'libs', include: ['*.jar']) 44 | compile 'com.android.support:appcompat-v7:19.+' 45 | compile project(':lib') 46 | } 47 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 21 | 22 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2014 Frakbot (Sebastiano Poggi and Francesco Pontillo) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | # Project-wide Gradle settings. 18 | 19 | # IDE (e.g. Android Studio) users: 20 | # Settings specified in this file will override any Gradle settings 21 | # configured through the IDE. 22 | 23 | # For more details on how to configure your build environment visit 24 | # http://www.gradle.org/docs/current/userguide/build_environment.html 25 | 26 | # Specifies the JVM arguments used for the daemon process. 27 | # The setting is particularly useful for tweaking memory settings. 28 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 29 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 30 | 31 | # When configured, Gradle will run in incubating parallel mode. 32 | # This option should only be used with decoupled projects. More details, visit 33 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 34 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /sample/src/main/java/net/frakbot/blinktextview/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Frakbot (Sebastiano Poggi and Francesco Pontillo) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.frakbot.blinktextview.sample; 18 | 19 | import android.content.Context; 20 | import android.os.Bundle; 21 | import android.support.v7.app.ActionBarActivity; 22 | import android.view.View; 23 | import android.widget.Toast; 24 | import net.frakbot.blinktextview.BlinkTextView; 25 | 26 | 27 | public class MainActivity extends ActionBarActivity { 28 | 29 | @Override 30 | protected void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.activity_main); 33 | 34 | final BlinkTextView blinkingBastard = (BlinkTextView) findViewById(R.id.what_whaat); 35 | blinkingBastard.setOnClickListener(new View.OnClickListener() { 36 | @Override 37 | public void onClick(View v) { 38 | final BlinkTextView blinkyWinky = (BlinkTextView) v; 39 | final boolean annoyPeople = !blinkyWinky.isOcdModeEnabled(); 40 | blinkyWinky.setOcdModeEnabled(annoyPeople); 41 | 42 | final Context context = v.getContext(); 43 | if (context != null) { 44 | Toast.makeText(context, 45 | annoyPeople ? getString(R.string.toast_ocd_on) : getString(R.string.toast_ocd_off), 46 | Toast.LENGTH_SHORT) 47 | .show(); 48 | } 49 | } 50 | }); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | BlinkTextView 2 | ============= 3 | 4 | ![BlinkTextView logo](sample/src/main/res/drawable-xhdpi/ic_launcher.png) 5 |         ![NEW -- Version 2.0!](art/v2.gif) 6 | 7 | ![Much update](art/doge.jpg) 8 | 9 | **A TextView that blinks, just like the good old HTML `` tag.** 10 | 11 | Because, why not? Also, this is a birthday gift. Happy Birthday, Daniele! (note: it's not Daniele's birthday anymore.) 12 | 13 | ![Demo GIF -- Everybody loves GIFs, right?](art/demo.gif) 14 | 15 | 16 | ### Usage 17 | Wait, what? Seriously? 18 | 19 | LOL ok. Clone the repo, and reference the thing: 20 | 21 | ``` groovy 22 | dependencies { 23 | compile project(':lib') 24 | } 25 | ``` 26 | 27 | I'd suggest to copy-paste the `lib` folder to your project root and maybe rename it to something like _annoyingthingy_. 28 | That's way more representative of what the lib does. 29 | 30 | 31 | ### Other awesome blinking stuff 32 | With Version 2.0 of this awesome thing you can even **blink MOAR stuff**! How, you ask? 33 | 34 | 1. Use a `` element as root in your layout XML. It _has_ to be the layout root or it won't work! 35 | 36 | ``` xml 37 | 41 | 42 | 43 | 44 | ``` 45 | 46 | 2. Treat it exactly as if it were a `FrameLayout` (it actually is) 47 | 3. ??? 48 | 4. Profit! 49 | 50 | The lovely `BlinkLayout` is here to serve! Your layout will blink at lovely 500 ms intervals. I know it's not the best 51 | blinking interval ever, and it's actually not even the 52 | [same frequency](https://github.com/frakbot/BlinkTextView/blob/master/lib/src/main/java/net/frakbot/blinktextview/BlinkTextView.java#L74)\* 53 | that `BlinkTextView` blinks at. (\*to all the grammar nazis out there: frequency is the reciprocal of the period, we 54 | know. We ran out of synonims, and it's pretty clear what we're talking about anyway) 55 | 56 | Our amazing tech allows you to use the `BlinkLayout` even without having to have the `BlinkTextView` library as a 57 | dependency. Yeah, you read that right! This works out of the box on all Android devices and **without the need for any 58 | additional dependency**! 59 | 60 | Unfortunately there are some technical limitations. OCD Mode is sadly not available on `BlinkLayout`. But we think that 61 | having _the whole layout blinking is annoying enough anyway, so it shouldn't be a big issue. 62 | 63 | By the way, yes, the `BlinkLayout` is an easter egg (we guess) in the 64 | [AOSP code](https://github.com/android/platform_frameworks_base/blob/master/core/java/android/view/LayoutInflater.java#L467)... 65 | 66 | 67 | ### What's super cool* about it 68 | We have a magnificent **OCD mode**. It will randomly change the blink period so that it's even more effective. Make 69 | each of your blinks completely unique, your users will want to "thank" you! Guaranteed. 70 | 71 | Also, **you can't change the default blinking period**. There's sound science behind it. Also, writing getters and 72 | setters is boooring. Yes, it's boring even when the IDE can generate them automatically for you. 73 | 74 | Oh, about that *, read: _annoying_. 75 | 76 | 77 | ### Demo 78 | 79 | There is no demo. No, seriously. Build it yourself. Hell, it's a blinking thing! 80 | 81 | 82 | ### License 83 | This library is... 84 | 85 | No, can't keep a straight face saying it, sorry. Let me try again. 86 | 87 | This _library_ is released under a very liberal [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html). 88 | Basically, do whatever you want with it, but don't blame us if your users/clients/loved ones/imaginary friends will 89 | want to kill you for using it. Also, be nice and put our name somewhere (so that you can blame us for it!). 90 | 91 | Usually people buries the OSS credits somewhere in their settings screen, at the bottom, under a sub item, and then you 92 | have to walk 120 steps to the East, turn around three times while saying "Cicciput!", jump, grab a portal gun, open a 93 | portal under your feet and another on that remote wall up there, touch your nose and the credits will appear behind you. 94 | 95 | That's fine with us. But I digress. 96 | 97 | 98 | ### Credits 99 | This library uses the super cool [**Google Annotations Gallery**](https://code.google.com/p/gag/), which is licensed 100 | under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html). 101 | 102 | Also, thanks to the always great Cyril Mottier for reminding us the existence of the `BlinkLayout`. 103 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /lib/src/main/java/net/frakbot/blinktextview/BlinkTextView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Frakbot (Sebastiano Poggi and Francesco Pontillo) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package net.frakbot.blinktextview; 18 | 19 | import android.content.Context; 20 | import android.content.res.TypedArray; 21 | import android.graphics.Canvas; 22 | import android.os.Handler; 23 | import android.util.AttributeSet; 24 | import android.util.Log; 25 | import android.widget.TextView; 26 | import com.google.gag.annotation.disclaimer.SafeForSpeedsNotExceeding; 27 | import com.google.gag.annotation.enforceable.CantTouchThis; 28 | import com.google.gag.annotation.remark.PleaseDontShowUpOn; 29 | import com.google.gag.annotation.remark.WTF; 30 | import com.google.gag.annotation.team.Channeling; 31 | import com.google.gag.enumeration.*; 32 | 33 | /** 34 | * Blink like it's the 90s all over again. 35 | */ 36 | public class BlinkTextView extends TextView { 37 | 38 | private static final String TAG = BlinkTextView.class.getSimpleName(); 39 | 40 | /** 41 | * The blink period. This has been scientifically calculated as the 42 | * most effective (read, annoying) blinking period during years of 43 | * testing. Since it's super effective, you won't need to be able to 44 | * change it. And you can't. It's 987 ms. Period. (pun intended) 45 | *

46 | *

The "science, bitch!" corner


47 | * Why is 987 ms so scientifically and disturbingly annoying? Why 987 48 | * and not, say, 986? Why not 988? Why do you keep asking questions? 49 | * There's an answer to at least one of those questions! 50 | *

51 | * Which unfortunately isn't why you keep asking annoying questions. 52 | * We don't know. You probably are stupid. Or a verbal sadist. If that 53 | * is even a thing. Which it may or might not be. But I digress. 54 | *

55 | * So, why 987? Well, ~500 ms would be better, but it annoys me to the 56 | * point where I don't even want to check if the app builds. So, 1 s 57 | * is more acceptable. But 1 s is too simple. Too perfect. 58 | *

59 | * Several batches of tests have shown that people with mild forms of 60 | * OCD would feel comfortable with a 1 s blink period (severe OCD 61 | * would kick in as soon as the damn thing begins to blink). 62 | *

63 | * So we trimmed a few millis at a time and checked how many people 64 | * would still OCD. Turns out, after you go below the 990 ms threshold 65 | * people begins noticing there's something wrong going on. And that 66 | * annoys them. Which is fundamental in simulating <blink/>. 67 | *

68 | * Plus, 987 is a convenient streak of adjacent keys on the keyboard. 69 | *

70 | * Ok, that is actually the whole reason. 71 | * 72 | * @see #BLINK_VARIANCE 73 | */ 74 | public static final int BLINK_PERIOD = 987; // ms 75 | 76 | /** 77 | * The blink variance multiplier. This is only used when the View 78 | * is in OCD mode. It will make your blink ever blinkier. 79 | *

80 | * Yes, by blinkier we mean more annoying. 81 | * 82 | * @see #setOcdModeEnabled(boolean) 83 | */ 84 | public static final float BLINK_VARIANCE = .8f; // multiplier 85 | 86 | protected Handler mBlinkMachine; 87 | private boolean mShouldActuallyDoAnything; 88 | private boolean mErmShouldIDraw; 89 | private Blinker mBlinkyThing; 90 | 91 | private boolean mOcdMode; 92 | 93 | public BlinkTextView(Context context) { 94 | super(context); 95 | init(null); 96 | } 97 | 98 | public BlinkTextView(Context context, AttributeSet attrs) { 99 | super(context, attrs); 100 | init(attrs); 101 | } 102 | 103 | public BlinkTextView(Context context, AttributeSet attrs, int defStyle) { 104 | super(context, attrs, defStyle); 105 | init(attrs); 106 | } 107 | 108 | @SafeForSpeedsNotExceeding(value = 42, units = SpeedUnits.TWIPS_PER_JIFFY) 109 | private void init(AttributeSet attrs) { 110 | mBlinkMachine = new Handler(); 111 | mBlinkyThing = new Blinker(); 112 | 113 | final Context context = getContext(); 114 | if (attrs != null && context != null) { 115 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BlinkTextView); 116 | 117 | final int N; 118 | if (a != null) { 119 | N = a.getIndexCount(); 120 | 121 | for (int i = 0; i < N; ++i) { 122 | int attr = a.getIndex(i); 123 | switch (attr) { 124 | case R.styleable.BlinkTextView_ocdMode: 125 | setOcdModeEnabled(a.getBoolean(attr, false)); 126 | break; 127 | } 128 | } 129 | 130 | a.recycle(); 131 | } 132 | } 133 | } 134 | 135 | @Override 136 | protected void onDraw(Canvas canvas) { 137 | if (BuildConfig.DEBUG) Log.d(TAG, "Hello this is dog."); 138 | 139 | if (!mShouldActuallyDoAnything) { 140 | Log.i(TAG, "LOL I have no idea what I'm doing"); 141 | 142 | // Lazily begin doing things. No hurry, right? 143 | mShouldActuallyDoAnything = true; 144 | youBetterBlinkNAO(); 145 | return; 146 | } 147 | 148 | if (mErmShouldIDraw || isInEditMode()) { 149 | super.onDraw(canvas); 150 | } 151 | } 152 | 153 | @Override 154 | protected void onAttachedToWindow() { 155 | super.onAttachedToWindow(); 156 | 157 | youBetterBlinkNAO(); 158 | } 159 | 160 | @Override 161 | protected void onDetachedFromWindow() { 162 | super.onDetachedFromWindow(); 163 | 164 | stahpBinkingPlease(); 165 | } 166 | 167 | @PleaseDontShowUpOn(Website.WIKIPEDIA) 168 | public void youBetterBlinkNAO() { 169 | if (!mShouldActuallyDoAnything) { 170 | return; 171 | } 172 | 173 | final int period = pissOffUsersIfNeeded(BLINK_PERIOD); 174 | mBlinkMachine.postDelayed(mBlinkyThing, period); 175 | } 176 | 177 | @CantTouchThis(Stop.HAMMERTIME) 178 | public void stahpBinkingPlease() { 179 | if (!mShouldActuallyDoAnything) { 180 | return; 181 | } 182 | 183 | noSeriouslyStahpIt(); 184 | } 185 | 186 | /** 187 | * Gets a value indicating if OCD mode is enabled. 188 | * 189 | * @return Returns ture if O.C.D mode is active or 190 | * false if othewrise. (LOL 191 | */ 192 | public boolean isOcdModeEnabled() { 193 | return mOcdMode; 194 | } 195 | 196 | /** 197 | * Enables or disables OCD mode. 198 | *

199 | * OCD mode randomly varies the blink interval to 200 | * make users appreciate even more your taste for 201 | * all things blinking. 202 | *

203 | * The blinking interval is varied at most by the 204 | * {@link #BLINK_VARIANCE} factor. 205 | * 206 | * @param ocdMode If true, the OCD mode is enabled. 207 | * If false, it's disabled. Duh! 208 | * 209 | * @see #BLINK_VARIANCE 210 | */ 211 | @Channeling(person = "Chtulu", 212 | entity = ChannelingEntity.OLD_ONE, 213 | disposition = OpinionOfHumanity.COMMITTED_TO_THE_EVENTUAL_DESTRUCTION_OF) 214 | public void setOcdModeEnabled(boolean ocdMode) { 215 | mOcdMode = ocdMode; 216 | } 217 | 218 | @WTF 219 | private void noSeriouslyStahpIt() { 220 | goHomeBlinkYoureDrunk(); 221 | } 222 | 223 | private void goHomeBlinkYoureDrunk() { 224 | mBlinkMachine.removeCallbacks(mBlinkyThing); 225 | } 226 | 227 | private int pissOffUsersIfNeeded(int baseBlinkPeriod) { 228 | if (!mOcdMode) { 229 | return baseBlinkPeriod; 230 | } 231 | 232 | int variance = (int) (baseBlinkPeriod * BLINK_VARIANCE * (Math.random() - .5f)); 233 | if (BuildConfig.DEBUG) Log.v(TAG, "Variance for this pass: " + variance); 234 | return baseBlinkPeriod + variance; 235 | } 236 | 237 | /** 238 | * Blink on you crazy diamond. 239 | */ 240 | private class Blinker implements Runnable { 241 | 242 | @Override 243 | public void run() { 244 | mErmShouldIDraw = !mErmShouldIDraw; 245 | invalidate(); 246 | 247 | // Reschedule this awesome runnable. 248 | youBetterBlinkNAO(); 249 | } 250 | } 251 | } 252 | --------------------------------------------------------------------------------