diff --git a/.gitignore b/.gitignore
index 9070562..03e9c44 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,11 @@
+# Copyright: Benjamin Weiss (keyboardsurfer) https://github.com/keyboardsurfer
+# Under CC-BY-SA V3.0 (https://creativecommons.org/licenses/by-sa/3.0/legalcode)
+
# built application files
-*.apk
-*.ap_
-*.jar
-gen-external-apklibs
+build
-# keystore
-*.keystore
+# lint files
+lint.xml
# files for the dex VM
*.dex
@@ -16,7 +16,12 @@ gen-external-apklibs
# generated files
bin/
gen/
-target/
+classes/
+build/
+gen-external-apklibs/
+
+# maven output folder
+target
# Local configuration file (sdk path, etc)
local.properties
@@ -34,8 +39,22 @@ local.properties
# OSX files
.DS_Store
-#vi swap files
+# Windows files
+Thumbs.db
+
+# vi swap files
*.swp
-# maven target
-target
+# backup files
+*.bak
+
+#gradle folder
+.gradle
+.gradletasknamecache
+
+#signing config
+signingConfigs.release
+*.keystore
+gradle.properties
+
+atlassian-ide-plugin.xml
diff --git a/LICENSE b/LICENSE
index d645695..f433b1a 100644
--- a/LICENSE
+++ b/LICENSE
@@ -175,28 +175,3 @@
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..62df15c
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,13 @@
+Crouton
+Copyright 2012 - 2014 Benjamin Weiss
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and limitations under the License
diff --git a/README.markdown b/README.markdown
index c22b6f8..5919f52 100644
--- a/README.markdown
+++ b/README.markdown
@@ -1,14 +1,27 @@
# Crouton
-
+
Context sensitive notifications for Android
+## DEPRECATION NOTICE
+
+This library has passed it's prime and is now considered deprecated.
+
+With the [Android Design Support Library](http://android-developers.blogspot.co.uk/2015/05/android-design-support-library.html)
+introducing [Snackbar](https://developer.android.com/reference/android/support/design/widget/Snackbar.html) developers get a well
+crafted pattern to use for context aware notification of users.
+
+I won't do any active development for Crouton any more.
+But I still do accept pull requests that fix bugs.
+
+So long, and thanks for all the forks.
+
## Overview
**Crouton** is a class that can be used by Android developers that feel the need for an **alternative to the Context insensitive [Toast](http://developer.android.com/reference/android/widget/Toast.html)**.
A Crouton will be displayed at the position the developer decides.
-Standard will be the of an application window.
+Standard will be the top of an application window.
You can line up multiple Croutons for display, that will be shown one after another.
You can check some features in the Crouton Demo.
@@ -20,32 +33,9 @@ You can check some features in the Crouton Demo.
If you're already using Crouton and just want to download the latest version of the library, follow [this link](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22de.keyboardsurfer.android.widget%22).
-### Changelog
-#### Current version: 1.7
-
-####[1.7](https://github.com/keyboardsurfer/Crouton/tree/1.7)
-
-- `Crouton.setOnClickListener(OnClickListener)` has been introduced.
-- Infinite display of Crouton is possible via `Style.setDuration(Style.DURATION_INFINITE)`
-- Via `Crouton.hide(Crouton)` a Crouton can be hidden.
-
-####[1.6](https://github.com/keyboardsurfer/Crouton/tree/1.6)
-
-- Crouton now can be used on any Android device with **API level 4+**.
-- Changes the package name to `de.keyboardsurfer.android.widget`
-- Adds possibility to set a custom width
-- Can now be added to any ViewGroup (@coreform)
-- Integration with TalkBack (@coreform)
-- Adds Accessibility features (@coreform)
-- Fixes bug that got Crouton out of sync with reality (@coreform)
-- New [LifecycleCallback](https://github.com/keyboardsurfer/Crouton/blob/master/library/src/de/keyboardsurfer/android/widget/crouton/LifecycleCallback.java) (@coreform)
-- initializeCroutonView was refactored, to make it easier on the eyes
-- removes redundant initialization within Style.Builder
-- documentation improvments
+## [Releases / Changelog](https://github.com/keyboardsurfer/Crouton/releases)
-#### older versions
-
-Please see the `git log`
+### Current version: 1.8.5
## Usage
@@ -53,16 +43,20 @@ The API is kept as simple as the Toast API:
Create a Crouton for any CharSequence:
- Crouton.makeText(Activity, CharSequence, [Style]).show();
+ Crouton.makeText(Activity, CharSequence, Style).show();
Create a Crouton with a String from your application's resources:
Crouton.makeText(Activity, int, Style).show();
-Further you can attach a Crouton to any view like this:
+Further you can attach a Crouton to any ViewGroup like this:
Crouton.makeText(Activity, int, Style, int).show();
+ Crouton.makeText(Activity, int, Style, ViewGroup).show();
+
+Also `Crouton.show(...)` methods are available for convenient fire and forget display of Croutons.
+
If you would like a more graphical introduction to Crouton check out [this presentation](https://speakerdeck.com/keyboardsurfer/crouton-devfest-berlin-2012).
##Important!
@@ -73,7 +67,7 @@ In your Activity.onDestroy() make sure to call
to cancel cancel all scheduled Croutons.
-This is a workaround and further description is available in #24.
+This is a workaround and further description is available in [issue #24](https://github.com/keyboardsurfer/Crouton/issues/24).
## Basic Examples
Currently you can use the three different Style attributes displayed below out of the box:
@@ -86,7 +80,7 @@ Currently you can use the three different Style attributes displayed below out o
## Extension and Modification
-The whole design of a Crouton is defined by [Style](https://github.com/keyboardsurfer/Crouton/blob/master/library/src/de/keyboardsurfer/android/widget/crouton/Style.java).
+The whole design of a Crouton is defined by [Style](https://github.com/keyboardsurfer/Crouton/blob/master/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Style.java).
You can use one of the styles Crouton ships with: **Style.ALERT**, **Style.CONFIRM** and **Style.INFO**. Or you can create your own Style.
@@ -99,21 +93,51 @@ In general you can modify
- appearance & disappearance Animation
- displayed Image
-Since [Style](https://github.com/keyboardsurfer/Crouton/blob/master/library/src/de/keyboardsurfer/android/widget/crouton/Style.java) is the general entry point for tweaking Croutons, go and see for yourself what can be done with it.
+Since [Style](https://github.com/keyboardsurfer/Crouton/blob/master/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Style.java) is the general entry point for tweaking Croutons, go and see for yourself what can be done with it.
+
+## Building
+### Gradle
+
+#### From maven central
+Add maven central to your `build.gradle`:
+
+```groovy
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+}
+
+repositories {
+ mavenCentral()
+}
+```
+
+Then declare Crouton within your dependencies:
+
+```groovy
+dependencies {
+ ...
+ compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
+ // exclusion is not necessary, but generally a good idea.
+ exclude group: 'com.google.android', module: 'support-v4'
+ }
+ ...
+}
+```
-## Maven
-### From maven central
+### Maven
-Crouton is available in the maven central repository.
+#### From maven central
-To use crouton simply add
+To use crouton within your maven build simply add
```xml
crouton
- 1.7
+ ${crouton.version}de.keyboardsurfer.android.widget
```
@@ -133,26 +157,48 @@ or
```
to the dependency.
+If you are referencing a newer version of the Android Support Library in your application, you might want to exclude Crouton's dependency like this:
+
+```xml
+
+ crouton
+ ${crouton.version}
+ de.keyboardsurfer.android.widget
+
+
+ com.android.support
+ support-v4
+
+
+
+```
+
### DIY
-The build requires Maven. Operations are very simple:
+The build requires Gradle. Operations are very simple:
-* `mvn -f library/pom.xml clean package` will build a `jar` library;
-* `mvn clean package` will build a `jar` library and the sample application `apk`;
-* `mvn -f library/pom.xml clean install` will put Crouton in your local Maven repository.
+* install [gradle](http://www.gradle.org/)
+* `gradle assemble` builds all artifacts
+* `gradle jar` builds the jar
-After putting Crouton in the repository you can add it as a dependency.
+After putting Crouton in a repository you can add it as dependency.
-```xml
-
- crouton
- 1.6
- de.keyboardsurfer.android.widget
-
+```groovy
+compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
+ exclude group: 'com.google.android', module: 'support-v4'
+}
```
+###Building and Signing
+
+In order to build and sign Crouton locally you'll need to rename `gradle.properties.sample` to `gradle.properties`.
+
## Contribution
+###Questions
+
+Questions regarding Crouton can be asked on [StackOverflow, using the crouton tag](http://stackoverflow.com/questions/tagged/crouton).
+
### Pull requests welcome
Feel free to contribute to Crouton.
@@ -162,6 +208,8 @@ Either you found a bug or have created a new and awesome feature, just create a
If you want to start to create a new feature or have any other questions regarding Crouton, [file an issue](https://github.com/keyboardsurfer/Crouton/issues/new).
I'll try to answer as soon as I find the time.
+Please note, if you're working on a pull request, make sure to use the [develop branch](https://github.com/keyboardsurfer/Crouton/tree/develop) as your base.
+
### Formatting
For contributors using Eclipse there's a formatter available at the [download section](https://github.com/downloads/keyboardsurfer/Crouton/Crouton_Eclipseformatter.xml).
@@ -176,8 +224,7 @@ If you're using IDEA, the Eclipse Formatter plugin should allow you to use the f
## Attributions
-The initial version was written by Benjamin Weiss at [Neofonie Mobile GmbH](http://mobile.neofonie.de).
-
+The initial version was written by Benjamin Weiss.
The name and the idea of [Crouton](https://github.com/keyboardsurfer/Crouton/blob/master/library/src/de/keyboardsurfer/android/widget/crouton/Crouton.java) originates in a [blog article](http://android.cyrilmottier.com/?p=773) by Cyril Mottier.
The Crouton logo has been created by [Marie Schweiz](http://marie-schweiz.de).
diff --git a/build.gradle b/build.gradle
index e69de29..0ece2ca 100644
--- a/build.gradle
+++ b/build.gradle
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2012 - 2014 Benjamin Weiss
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+subprojects {
+version = '1.8.5'
+
+ buildscript {
+ repositories {
+ mavenCentral()
+ mavenLocal()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:1.0.0'
+ classpath 'com.github.dcendents:android-maven-plugin:1.2'
+ }
+ }
+
+ repositories {
+ mavenCentral()
+ mavenLocal()
+ }
+}
+
+task wrapper(type: Wrapper) {
+ description 'Generates the gradle wrapper'
+ gradleVersion = '2.2.1'
+}
diff --git a/gradle.properties.sample b/gradle.properties.sample
new file mode 100644
index 0000000..7fdf8a0
--- /dev/null
+++ b/gradle.properties.sample
@@ -0,0 +1,33 @@
+#
+# Copyright 2012 - 2014 Benjamin Weiss
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.gradle.daemon true
+
+#android keystore data
+keyStore=keystore.keystore
+storePassword=storePass
+keyAlias=keyAlias
+keyPassword=somePass
+
+#user data for sonatype
+sonatypeUser=someUser
+sonatypePass=somePassword
+repositoryUrl=./repo
+
+#info from your pgp key
+signing.keyId=BAADF00D
+signing.password=yourPassword
+signing.secretKeyRingFile=/path/to/your/secring
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..c97a8bd
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..c002b8d
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Jan 05 19:34:24 PST 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-bin.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/library/build.gradle b/library/build.gradle
new file mode 100644
index 0000000..484cc9c
--- /dev/null
+++ b/library/build.gradle
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2012 - 2014 Benjamin Weiss
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+apply plugin: 'com.android.library'
+apply plugin: 'android-maven'
+apply plugin: 'signing'
+
+dependencies {
+ compile 'com.android.support:support-v4:21.0.3'
+}
+
+android {
+ buildToolsVersion '21.1.2'
+ compileSdkVersion 21
+ defaultConfig {
+ versionCode 10
+ versionName = project.version
+ minSdkVersion 8
+ targetSdkVersion 21
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_6
+ targetCompatibility JavaVersion.VERSION_1_6
+ }
+}
+
+group = 'de.keyboardsurfer.android.widget'
+def artifactId = 'crouton'
+
+android.libraryVariants.all { variant ->
+ def name = variant.buildType.name
+ if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
+ return; // Skip debug builds.
+ }
+ task("javadoc${variant.name.capitalize()}", type: Javadoc) {
+ description 'Generates Javadoc for $variant.name.'
+ source = variant.javaCompile.source
+ ext.androidJar = '${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar'
+ classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
+ }
+
+ task("bundleJavadoc${variant.name.capitalize()}", type: Jar) {
+ description 'Bundles Javadoc into zip for $variant.name'
+ classifier = 'javadoc'
+ from tasks["javadoc${variant.name.capitalize()}"]
+ }
+
+}
+
+task sourcesJar(type: Jar) {
+ classifier = 'sources'
+ from android.sourceSets.main.java.srcDirs
+}
+
+task jar(type: Jar) {
+ from 'build/intermediates/classes/release'
+ exclude '**/BuildConfig.class'
+ exclude '**/R.class'
+ exclude 'de/keyboardsurfer/mobile/'
+}
+
+task javadocJar(type: Jar, dependsOn: "javadocRelease") {
+ classifier = 'javadoc'
+ from 'build/docs/javadoc'
+}
+
+artifacts {
+ archives sourcesJar
+ archives javadocJar
+ archives jar
+}
+
+signing {
+ sign configurations.archives
+ sign configurations.compile
+}
+
+uploadArchives {
+ repositories {
+ mavenDeployer {
+ beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
+ repository(url: repositoryUrl) {
+ authentication(userName: sonatypeUser, password: sonatypePass)
+ }
+
+ pom.project {
+ inceptionYear '2012'
+ name 'Crouton'
+ artifactId = 'crouton'
+ packaging 'jar', 'aar'
+ description 'Context sensitive notifications for Android'
+ url 'https://github.com/keyboardsurfer/Crouton'
+
+ scm {
+ url 'scm:git@github.com:keyboardsurfer/Crouton.git'
+ connection 'scm:git@github.com:keyboardsurfer/Crouton.git'
+ developerConnection 'scm:git@github.com:keyboardsurfer/Crouton.git'
+ }
+
+ licenses {
+ license {
+ name 'The Apache Software License, Version 2.0'
+ url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ distribution 'repo'
+ }
+ }
+
+ developers {
+ developer {
+ id 'keyboardsurfer'
+ name 'Benjamin Weiss'
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/library/build.xml b/library/build.xml
deleted file mode 100644
index 2f6f323..0000000
--- a/library/build.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/library/pom.xml b/library/pom.xml
deleted file mode 100644
index 7081c7a..0000000
--- a/library/pom.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-
-
-
-
-
- 4.0.0
-
- Crouton
- Context sensitive notifications for Android
- https://github.com/keyboardsurfer/Crouton
- crouton
- de.keyboardsurfer.android.widget
- 1.7
- jar
-
-
- UTF-8
- 4.1.1.4
- 16
-
-
-
-
- keyboardsurfer
- Benjamin Weiss
-
-
-
-
-
- The Apache Software License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
- repo
-
-
-
-
- git@github.com:keyboardsurfer/Crouton.git
- scm:git:git@github.com:keyboardsurfer/Crouton.git
- scm:git:git@github.com:keyboardsurfer/Crouton.git
-
-
-
-
- android
- ${android.version}
- com.google.android
- provided
-
-
- com.google.android
- support-v4
- r11
-
-
-
-
- src
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 2.2.1
-
-
- attach-sources
-
- jar
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.9
-
-
- attach-javadocs
-
- jar
-
-
-
-
-
- com.jayway.maven.plugins.android.generation2
- android-maven-plugin
- 3.5.0
-
-
-
-
-
diff --git a/library/project.properties b/library/project.properties
deleted file mode 100644
index 63cc19b..0000000
--- a/library/project.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-
-target=android-17
-android.library=true
diff --git a/library/src/de/keyboardsurfer/android/widget/crouton/DefaultAnimationsBuilder.java b/library/src/de/keyboardsurfer/android/widget/crouton/DefaultAnimationsBuilder.java
deleted file mode 100644
index b1109c8..0000000
--- a/library/src/de/keyboardsurfer/android/widget/crouton/DefaultAnimationsBuilder.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2012 - 2013 Benjamin Weiss
- * Copyright 2012 Neofonie Mobile GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package de.keyboardsurfer.android.widget.crouton;
-
-import android.view.animation.Animation;
-import android.view.animation.TranslateAnimation;
-
-/**
- * Builds the default animations for showing and hiding a {@link Crouton}.
- */
-final class DefaultAnimationsBuilder {
- private static Animation slideInDownAnimation, slideOutUpAnimation;
-
- protected static final class SlideInDownAnimationParameters {
- private SlideInDownAnimationParameters() {
- /* no-op */
- }
-
- public static final float FROM_X_DELTA = 0;
- public static final float TO_X_DELTA = 0;
- public static final float FROM_Y_DELTA = -50;
- public static final float TO_Y_DELTA = 0;
-
- public static final long DURATION = 400;
- }
-
- protected static final class SlideOutUpAnimationParameters {
- private SlideOutUpAnimationParameters() {
- /* no-op */
- }
-
- public static final float FROM_X_DELTA = 0;
- public static final float TO_X_DELTA = 0;
- public static final float FROM_Y_DELTA = 0;
- public static final float TO_Y_DELTA = -50;
-
- public static final long DURATION = 400;
- }
-
- private DefaultAnimationsBuilder() {
- /* no-op */
- }
-
- /**
- * @return The default Animation for a showing {@link Crouton}.
- */
- public static Animation buildDefaultSlideInDownAnimation() {
- if (null == slideInDownAnimation) {
- slideInDownAnimation = new TranslateAnimation(SlideInDownAnimationParameters.FROM_X_DELTA,
- SlideInDownAnimationParameters.TO_X_DELTA,
- SlideInDownAnimationParameters.FROM_Y_DELTA, SlideInDownAnimationParameters.TO_Y_DELTA);
- slideInDownAnimation.setDuration(SlideInDownAnimationParameters.DURATION);
- }
-
- return slideInDownAnimation;
- }
-
- /**
- * @return The default Animation for a hiding {@link Crouton}.
- */
- public static Animation buildDefaultSlideOutUpAnimation() {
- if (null == slideOutUpAnimation) {
- slideOutUpAnimation = new TranslateAnimation(SlideOutUpAnimationParameters.FROM_X_DELTA,
- SlideOutUpAnimationParameters.TO_X_DELTA,
- SlideOutUpAnimationParameters.FROM_Y_DELTA, SlideOutUpAnimationParameters.TO_Y_DELTA);
- slideOutUpAnimation.setDuration(SlideOutUpAnimationParameters.DURATION);
- }
- return slideOutUpAnimation;
- }
-}
diff --git a/library/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
similarity index 81%
rename from library/AndroidManifest.xml
rename to library/src/main/AndroidManifest.xml
index 5f62e48..7b16fcb 100644
--- a/library/AndroidManifest.xml
+++ b/library/src/main/AndroidManifest.xml
@@ -1,7 +1,6 @@
+ package="de.keyboardsurfer.mobile.app.android.widget.crouton">
diff --git a/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Configuration.java b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Configuration.java
new file mode 100644
index 0000000..2943d6c
--- /dev/null
+++ b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Configuration.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2012 - 2014 Benjamin Weiss
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package de.keyboardsurfer.android.widget.crouton;
+
+/**
+ * Allows configuring a {@link Crouton}s behaviour aside from the actual view,
+ * which is defined via {@link Style}.
+ *
+ * This allows to re-use a {@link Style} while modifying parameters that only have to be applied
+ * when the {@link Crouton} is being displayed.
+ *
+ * @author chris
+ * @since 1.8
+ */
+public class Configuration {
+
+
+ /**
+ * Display a {@link Crouton} for an infinite amount of time or
+ * until {@link Crouton#cancel()} has been called.
+ */
+ public static final int DURATION_INFINITE = -1;
+ /** The default short display duration of a {@link Crouton}. */
+ public static final int DURATION_SHORT = 3000;
+ /** The default long display duration of a {@link Crouton}. */
+ public static final int DURATION_LONG = 5000;
+
+ /** The default {@link Configuration} of a {@link Crouton}. */
+ public static final Configuration DEFAULT;
+
+ static {
+ DEFAULT = new Builder().setDuration(DURATION_SHORT).build();
+ }
+
+ /** The durationInMilliseconds the {@link Crouton} will be displayed in milliseconds. */
+ final int durationInMilliseconds;
+ /** The resource id for the in animation. */
+ final int inAnimationResId;
+ /** The resource id for the out animation. */
+ final int outAnimationResId;
+
+ private Configuration(Builder builder) {
+ this.durationInMilliseconds = builder.durationInMilliseconds;
+ this.inAnimationResId = builder.inAnimationResId;
+ this.outAnimationResId = builder.outAnimationResId;
+ }
+
+ /** Creates a {@link Builder} to build a {@link Configuration} upon. */
+ public static class Builder {
+ private int durationInMilliseconds = DURATION_SHORT;
+ private int inAnimationResId = 0;
+ private int outAnimationResId = 0;
+
+ /**
+ * Set the durationInMilliseconds option of the {@link Crouton}.
+ *
+ * @param duration
+ * The durationInMilliseconds the crouton will be displayed
+ * {@link Crouton} in milliseconds.
+ *
+ * @return the {@link Builder}.
+ */
+ public Builder setDuration(final int duration) {
+ this.durationInMilliseconds = duration;
+
+ return this;
+ }
+
+ /**
+ * The resource id for the in animation.
+ *
+ * @param inAnimationResId
+ * The resource identifier for the animation that's being shown
+ * when the {@link Crouton} is going to be displayed.
+ *
+ * @return the {@link Builder}.
+ */
+ public Builder setInAnimation(final int inAnimationResId) {
+ this.inAnimationResId = inAnimationResId;
+
+ return this;
+ }
+
+ /**
+ * The resource id for the out animation
+ *
+ * @param outAnimationResId
+ * The resource identifier for the animation that's being shown
+ * when the {@link Crouton} is going to be removed.
+ *
+ * @return the {@link Builder}.
+ */
+ public Builder setOutAnimation(final int outAnimationResId) {
+ this.outAnimationResId = outAnimationResId;
+
+ return this;
+ }
+
+ /**
+ * Builds the {@link Configuration}.
+ *
+ * @return The built {@link Configuration}.
+ */
+ public Configuration build() {
+ return new Configuration(this);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Configuration{" +
+ "durationInMilliseconds=" + durationInMilliseconds +
+ ", inAnimationResId=" + inAnimationResId +
+ ", outAnimationResId=" + outAnimationResId +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/library/src/de/keyboardsurfer/android/widget/crouton/Crouton.java b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Crouton.java
similarity index 58%
rename from library/src/de/keyboardsurfer/android/widget/crouton/Crouton.java
rename to library/src/main/java/de/keyboardsurfer/android/widget/crouton/Crouton.java
index 4d9d95b..9e8b5e5 100644
--- a/library/src/de/keyboardsurfer/android/widget/crouton/Crouton.java
+++ b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Crouton.java
@@ -1,6 +1,5 @@
/*
- * Copyright 2012 - 2013 Benjamin Weiss
- * Copyright 2012 Neofonie Mobile GmbH
+ * Copyright 2012 - 2014 Benjamin Weiss
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +24,10 @@
import android.graphics.Shader;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
+import android.text.Spannable;
+import android.text.SpannableString;
import android.util.TypedValue;
+import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
@@ -47,17 +49,19 @@
*
* Important:
* Call {@link Crouton#clearCroutonsForActivity(Activity)} within
- * {@link android.app.Activity#onDestroy()} to avoid {@link Context} leaks.
+ * {@link Activity#onDestroy()} to avoid {@link Context} leaks.
*/
public final class Crouton {
+ private static final String NULL_PARAMETERS_ARE_NOT_ACCEPTED = "Null parameters are not accepted";
private static final int IMAGE_ID = 0x100;
private static final int TEXT_ID = 0x101;
private final CharSequence text;
private final Style style;
+ private Configuration configuration = null;
private final View customView;
private OnClickListener onClickListener;
-
+
private Activity activity;
private ViewGroup viewGroup;
private FrameLayout croutonView;
@@ -69,16 +73,16 @@ public final class Crouton {
* Creates the {@link Crouton}.
*
* @param activity
- * The {@link Activity} that the {@link Crouton} should be attached
- * to.
+ * The {@link Activity} that the {@link Crouton} should be attached
+ * to.
* @param text
- * The text you want to display.
+ * The text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
*/
private Crouton(Activity activity, CharSequence text, Style style) {
if ((activity == null) || (text == null) || (style == null)) {
- throw new IllegalArgumentException("Null parameters are not accepted");
+ throw new IllegalArgumentException(NULL_PARAMETERS_ARE_NOT_ACCEPTED);
}
this.activity = activity;
@@ -92,17 +96,17 @@ private Crouton(Activity activity, CharSequence text, Style style) {
* Creates the {@link Crouton}.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param text
- * The text you want to display.
+ * The text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
* @param viewGroup
- * The {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The {@link ViewGroup} that this {@link Crouton} should be added to.
*/
private Crouton(Activity activity, CharSequence text, Style style, ViewGroup viewGroup) {
if ((activity == null) || (text == null) || (style == null)) {
- throw new IllegalArgumentException("Null parameters are not accepted");
+ throw new IllegalArgumentException(NULL_PARAMETERS_ARE_NOT_ACCEPTED);
}
this.activity = activity;
@@ -116,14 +120,14 @@ private Crouton(Activity activity, CharSequence text, Style style, ViewGroup vie
* Creates the {@link Crouton}.
*
* @param activity
- * The {@link Activity} that the {@link Crouton} should be attached
- * to.
+ * The {@link Activity} that the {@link Crouton} should be attached
+ * to.
* @param customView
- * The custom {@link View} to display
+ * The custom {@link View} to display
*/
private Crouton(Activity activity, View customView) {
if ((activity == null) || (customView == null)) {
- throw new IllegalArgumentException("Null parameters are not accepted");
+ throw new IllegalArgumentException(NULL_PARAMETERS_ARE_NOT_ACCEPTED);
}
this.activity = activity;
@@ -137,15 +141,32 @@ private Crouton(Activity activity, View customView) {
* Creates the {@link Crouton}.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param customView
- * The custom {@link View} to display
+ * The custom {@link View} to display
* @param viewGroup
- * The {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The {@link ViewGroup} that this {@link Crouton} should be added to.
*/
private Crouton(Activity activity, View customView, ViewGroup viewGroup) {
+ this(activity, customView, viewGroup, Configuration.DEFAULT);
+ }
+
+ /**
+ * Creates the {@link Crouton}.
+ *
+ * @param activity
+ * The {@link Activity} that represents the context in which the Crouton should exist.
+ * @param customView
+ * The custom {@link View} to display
+ * @param viewGroup
+ * The {@link ViewGroup} that this {@link Crouton} should be added to.
+ * @param configuration
+ * The {@link Configuration} for this {@link Crouton}.
+ */
+ private Crouton(final Activity activity, final View customView, final ViewGroup viewGroup,
+ final Configuration configuration) {
if ((activity == null) || (customView == null)) {
- throw new IllegalArgumentException("Null parameters are not accepted");
+ throw new IllegalArgumentException(NULL_PARAMETERS_ARE_NOT_ACCEPTED);
}
this.activity = activity;
@@ -153,19 +174,20 @@ private Crouton(Activity activity, View customView, ViewGroup viewGroup) {
this.viewGroup = viewGroup;
this.style = new Style.Builder().build();
this.text = null;
+ this.configuration = configuration;
}
-
+
/**
* Creates a {@link Crouton} with provided text and style for a given
* activity.
*
* @param activity
- * The {@link Activity} that the {@link Crouton} should be attached
- * to.
+ * The {@link Activity} that the {@link Crouton} should be attached
+ * to.
* @param text
- * The text you want to display.
+ * The text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
*
* @return The created {@link Crouton}.
*/
@@ -178,13 +200,13 @@ public static Crouton makeText(Activity activity, CharSequence text, Style style
* activity.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param text
- * The text you want to display.
+ * The text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
* @param viewGroup
- * The {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The {@link ViewGroup} that this {@link Crouton} should be added to.
*
* @return The created {@link Crouton}.
*/
@@ -197,13 +219,13 @@ public static Crouton makeText(Activity activity, CharSequence text, Style style
* activity.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param text
- * The text you want to display.
+ * The text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
* @param viewGroupResId
- * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
*
* @return The created {@link Crouton}.
*/
@@ -217,12 +239,12 @@ public static Crouton makeText(Activity activity, CharSequence text, Style style
* activity.
*
* @param activity
- * The {@link Activity} that the {@link Crouton} should be attached
- * to.
+ * The {@link Activity} that the {@link Crouton} should be attached
+ * to.
* @param textResourceId
- * The resource id of the text you want to display.
+ * The resource id of the text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
*
* @return The created {@link Crouton}.
*/
@@ -235,13 +257,13 @@ public static Crouton makeText(Activity activity, int textResourceId, Style styl
* activity.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param textResourceId
- * The resource id of the text you want to display.
+ * The resource id of the text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
* @param viewGroup
- * The {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The {@link ViewGroup} that this {@link Crouton} should be added to.
*
* @return The created {@link Crouton}.
*/
@@ -254,19 +276,19 @@ public static Crouton makeText(Activity activity, int textResourceId, Style styl
* activity.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param textResourceId
- * The resource id of the text you want to display.
+ * The resource id of the text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
* @param viewGroupResId
- * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
*
* @return The created {@link Crouton}.
*/
public static Crouton makeText(Activity activity, int textResourceId, Style style, int viewGroupResId) {
return makeText(activity, activity.getString(textResourceId), style,
- (ViewGroup) activity.findViewById(viewGroupResId));
+ (ViewGroup) activity.findViewById(viewGroupResId));
}
@@ -275,10 +297,10 @@ public static Crouton makeText(Activity activity, int textResourceId, Style styl
* activity.
*
* @param activity
- * The {@link Activity} that the {@link Crouton} should be attached
- * to.
+ * The {@link Activity} that the {@link Crouton} should be attached
+ * to.
* @param customView
- * The custom {@link View} to display
+ * The custom {@link View} to display
*
* @return The created {@link Crouton}.
*/
@@ -291,11 +313,11 @@ public static Crouton make(Activity activity, View customView) {
* activity.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param customView
- * The custom {@link View} to display
+ * The custom {@link View} to display
* @param viewGroup
- * The {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The {@link ViewGroup} that this {@link Crouton} should be added to.
*
* @return The created {@link Crouton}.
*/
@@ -308,11 +330,11 @@ public static Crouton make(Activity activity, View customView, ViewGroup viewGro
* activity.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param customView
- * The custom {@link View} to display
+ * The custom {@link View} to display
* @param viewGroupResId
- * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
*
* @return The created {@link Crouton}.
*/
@@ -320,17 +342,37 @@ public static Crouton make(Activity activity, View customView, int viewGroupResI
return new Crouton(activity, customView, (ViewGroup) activity.findViewById(viewGroupResId));
}
+ /**
+ * Creates a {@link Crouton} with provided text-resource and style for a given
+ * activity.
+ *
+ * @param activity
+ * The {@link Activity} that represents the context in which the Crouton should exist.
+ * @param customView
+ * The custom {@link View} to display
+ * @param viewGroupResId
+ * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+ * @param configuration
+ * The configuration for this crouton.
+ *
+ * @return The created {@link Crouton}.
+ */
+ public static Crouton make(Activity activity, View customView, int viewGroupResId,
+ final Configuration configuration) {
+ return new Crouton(activity, customView, (ViewGroup) activity.findViewById(viewGroupResId), configuration);
+ }
+
/**
* Creates a {@link Crouton} with provided text and style for a given activity
* and displays it directly.
*
* @param activity
- * The {@link android.app.Activity} that the {@link Crouton} should
- * be attached to.
+ * The {@link android.app.Activity} that the {@link Crouton} should
+ * be attached to.
* @param text
- * The text you want to display.
+ * The text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
*/
public static void showText(Activity activity, CharSequence text, Style style) {
makeText(activity, text, style).show();
@@ -341,13 +383,13 @@ public static void showText(Activity activity, CharSequence text, Style style) {
* and displays it directly.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param text
- * The text you want to display.
+ * The text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
* @param viewGroup
- * The {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The {@link ViewGroup} that this {@link Crouton} should be added to.
*/
public static void showText(Activity activity, CharSequence text, Style style, ViewGroup viewGroup) {
makeText(activity, text, style, viewGroup).show();
@@ -358,28 +400,49 @@ public static void showText(Activity activity, CharSequence text, Style style, V
* and displays it directly.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param text
- * The text you want to display.
+ * The text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
* @param viewGroupResId
- * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
*/
public static void showText(Activity activity, CharSequence text, Style style, int viewGroupResId) {
makeText(activity, text, style, (ViewGroup) activity.findViewById(viewGroupResId)).show();
}
+ /**
+ * Creates a {@link Crouton} with provided text and style for a given activity
+ * and displays it directly.
+ *
+ * @param activity
+ * The {@link Activity} that represents the context in which the Crouton should exist.
+ * @param text
+ * The text you want to display.
+ * @param style
+ * The style that this {@link Crouton} should be created with.
+ * @param viewGroupResId
+ * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+ * @param configuration
+ * The configuration for this Crouton.
+ */
+ public static void showText(Activity activity, CharSequence text, Style style, int viewGroupResId,
+ final Configuration configuration) {
+ makeText(activity, text, style, (ViewGroup) activity.findViewById(viewGroupResId)).setConfiguration(configuration)
+ .show();
+ }
+
/**
* Creates a {@link Crouton} with provided text and style for a given activity
* and displays it directly.
*
* @param activity
- * The {@link android.app.Activity} that the {@link Crouton} should
- * be attached to.
+ * The {@link android.app.Activity} that the {@link Crouton} should
+ * be attached to.
* @param customView
- * The custom {@link View} to display
+ * The custom {@link View} to display
*/
public static void show(Activity activity, View customView) {
make(activity, customView).show();
@@ -390,11 +453,11 @@ public static void show(Activity activity, View customView) {
* and displays it directly.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param customView
- * The custom {@link View} to display
+ * The custom {@link View} to display
* @param viewGroup
- * The {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The {@link ViewGroup} that this {@link Crouton} should be added to.
*/
public static void show(Activity activity, View customView, ViewGroup viewGroup) {
make(activity, customView, viewGroup).show();
@@ -405,11 +468,11 @@ public static void show(Activity activity, View customView, ViewGroup viewGroup)
* and displays it directly.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param customView
- * The custom {@link View} to display
+ * The custom {@link View} to display
* @param viewGroupResId
- * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
*/
public static void show(Activity activity, View customView, int viewGroupResId) {
make(activity, customView, viewGroupResId).show();
@@ -420,12 +483,12 @@ public static void show(Activity activity, View customView, int viewGroupResId)
* activity and displays it directly.
*
* @param activity
- * The {@link Activity} that the {@link Crouton} should be attached
- * to.
+ * The {@link Activity} that the {@link Crouton} should be attached
+ * to.
* @param textResourceId
- * The resource id of the text you want to display.
+ * The resource id of the text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
*/
public static void showText(Activity activity, int textResourceId, Style style) {
showText(activity, activity.getString(textResourceId), style);
@@ -436,13 +499,13 @@ public static void showText(Activity activity, int textResourceId, Style style)
* activity and displays it directly.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param textResourceId
- * The resource id of the text you want to display.
+ * The resource id of the text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
* @param viewGroup
- * The {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The {@link ViewGroup} that this {@link Crouton} should be added to.
*/
public static void showText(Activity activity, int textResourceId, Style style, ViewGroup viewGroup) {
showText(activity, activity.getString(textResourceId), style, viewGroup);
@@ -453,13 +516,13 @@ public static void showText(Activity activity, int textResourceId, Style style,
* activity and displays it directly.
*
* @param activity
- * The {@link Activity} that represents the context in which the Crouton should exist.
+ * The {@link Activity} that represents the context in which the Crouton should exist.
* @param textResourceId
- * The resource id of the text you want to display.
+ * The resource id of the text you want to display.
* @param style
- * The style that this {@link Crouton} should be created with.
+ * The style that this {@link Crouton} should be created with.
* @param viewGroupResId
- * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
+ * The resource id of the {@link ViewGroup} that this {@link Crouton} should be added to.
*/
public static void showText(Activity activity, int textResourceId, Style style, int viewGroupResId) {
showText(activity, activity.getString(textResourceId), style, viewGroupResId);
@@ -467,10 +530,12 @@ public static void showText(Activity activity, int textResourceId, Style style,
/**
* Allows hiding of a previously displayed {@link Crouton}.
- * @param crouton The {@link Crouton} you want to hide.
+ *
+ * @param crouton
+ * The {@link Crouton} you want to hide.
*/
public static void hide(Crouton crouton) {
- Manager.getInstance().removeCrouton(crouton);
+ crouton.hide();
}
/**
@@ -486,7 +551,7 @@ public static void cancelAllCroutons() {
* croutons for the provided activity
*
* @param activity
- * - The {@link Activity} to clear the croutons for.
+ * - The {@link Activity} to clear the croutons for.
*/
public static void clearCroutonsForActivity(Activity activity) {
Manager.getInstance().clearCroutonsForActivity(activity);
@@ -510,10 +575,11 @@ public void show() {
public Animation getInAnimation() {
if ((null == this.inAnimation) && (null != this.activity)) {
- if (getStyle().inAnimationResId > 0) {
- this.inAnimation = AnimationUtils.loadAnimation(getActivity(), getStyle().inAnimationResId);
+ if (getConfiguration().inAnimationResId > 0) {
+ this.inAnimation = AnimationUtils.loadAnimation(getActivity(), getConfiguration().inAnimationResId);
} else {
- this.inAnimation = DefaultAnimationsBuilder.buildDefaultSlideInDownAnimation();
+ measureCroutonView();
+ this.inAnimation = DefaultAnimationsBuilder.buildDefaultSlideInDownAnimation(getView());
}
}
@@ -522,10 +588,10 @@ public Animation getInAnimation() {
public Animation getOutAnimation() {
if ((null == this.outAnimation) && (null != this.activity)) {
- if (getStyle().outAnimationResId > 0) {
- this.outAnimation = AnimationUtils.loadAnimation(getActivity(), getStyle().outAnimationResId);
+ if (getConfiguration().outAnimationResId > 0) {
+ this.outAnimation = AnimationUtils.loadAnimation(getActivity(), getConfiguration().outAnimationResId);
} else {
- this.outAnimation = DefaultAnimationsBuilder.buildDefaultSlideOutUpAnimation();
+ this.outAnimation = DefaultAnimationsBuilder.buildDefaultSlideOutUpAnimation(getView());
}
}
@@ -534,51 +600,105 @@ public Animation getOutAnimation() {
/**
* @param lifecycleCallback
- * Callback object for notable events in the life of a Crouton.
+ * Callback object for notable events in the life of a Crouton.
*/
public void setLifecycleCallback(LifecycleCallback lifecycleCallback) {
this.lifecycleCallback = lifecycleCallback;
}
/**
- * Convenience method to get the license text for embedding within your application.
- * @return
- * The license text.
+ * Removes this {@link Crouton}.
+ *
+ * @since 1.9
*/
- public String getLicenseText() {
- return "This application uses the Crouton library.\n\n" +
- "Copyright 2012 - 2013 Benjamin Weiss \n" +
- "Copyright 2012 Neofonie Mobile GmbH\n" +
- "\n" +
- "Licensed under the Apache License, Version 2.0 (the \"License\");\n" +
- "you may not use this file except in compliance with the License.\n" +
- "You may obtain a copy of the License at\n" +
- "\n" +
- " http://www.apache.org/licenses/LICENSE-2.0\n" +
- "\n" +
- "Unless required by applicable law or agreed to in writing, software\n" +
- "distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
- "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
- "See the License for the specific language governing permissions and\n" +
- "limitations under the License.";
+ public void hide() {
+ Manager.getInstance().removeCrouton(this);
}
/**
* Allows setting of an {@link OnClickListener} directly to a {@link Crouton} without having to use a custom view.
- * @param onClickListener The {@link OnClickListener} to set.
+ *
+ * @param onClickListener
+ * The {@link OnClickListener} to set.
+ *
* @return this {@link Crouton}.
*/
- public Crouton setOnClickListener(OnClickListener onClickListener){
+ public Crouton setOnClickListener(OnClickListener onClickListener) {
this.onClickListener = onClickListener;
return this;
}
+ /**
+ * Set the {@link Configuration} on this {@link Crouton}, prior to showing it.
+ *
+ * @param configuration
+ * a {@link Configuration} built using the {@link Configuration.Builder}.
+ *
+ * @return this {@link Crouton}.
+ */
+ public Crouton setConfiguration(final Configuration configuration) {
+ this.configuration = configuration;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return "Crouton{" +
+ "text=" + text +
+ ", style=" + style +
+ ", configuration=" + configuration +
+ ", customView=" + customView +
+ ", onClickListener=" + onClickListener +
+ ", activity=" + activity +
+ ", viewGroup=" + viewGroup +
+ ", croutonView=" + croutonView +
+ ", inAnimation=" + inAnimation +
+ ", outAnimation=" + outAnimation +
+ ", lifecycleCallback=" + lifecycleCallback +
+ '}';
+ }
+
+ /**
+ * Convenience method to get the license text for embedding within your application.
+ *
+ * @return The license text.
+ */
+ public static String getLicenseText() {
+ return "This application uses the Crouton library.\n\n" +
+ "Copyright 2012 - 2013 Benjamin Weiss \n" +
+ "\n" +
+ "Licensed under the Apache License, Version 2.0 (the \"License\");\n" +
+ "you may not use this file except in compliance with the License.\n" +
+ "You may obtain a copy of the License at\n" +
+ "\n" +
+ " http://www.apache.org/licenses/LICENSE-2.0\n" +
+ "\n" +
+ "Unless required by applicable law or agreed to in writing, software\n" +
+ "distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
+ "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
+ "See the License for the specific language governing permissions and\n" +
+ "limitations under the License.";
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ // You have reached the internal API of Crouton.
+ // If you do not plan to develop for Crouton there is nothing of interest below here.
+ //////////////////////////////////////////////////////////////////////////////////////
+
/**
* @return true if the {@link Crouton} is being displayed, else
- * false.
+ * false.
*/
boolean isShowing() {
- return (null != activity) && (null != croutonView) && (null != croutonView.getParent());
+ return (null != activity) && (isCroutonViewNotNull() || isCustomViewNotNull());
+ }
+
+ private boolean isCroutonViewNotNull() {
+ return (null != croutonView) && (null != croutonView.getParent());
+ }
+
+ private boolean isCustomViewNotNull() {
+ return (null != customView) && (null != customView.getParent());
}
/**
@@ -616,6 +736,16 @@ Style getStyle() {
return style;
}
+ /**
+ * @return this croutons configuration
+ */
+ Configuration getConfiguration() {
+ if (null == configuration) {
+ configuration = getStyle().configuration;
+ }
+ return configuration;
+ }
+
/**
* @return the activity
*/
@@ -654,6 +784,19 @@ View getView() {
return croutonView;
}
+ private void measureCroutonView() {
+ View view = getView();
+ int widthSpec;
+ if (null != viewGroup) {
+ widthSpec = View.MeasureSpec.makeMeasureSpec(viewGroup.getMeasuredWidth(), View.MeasureSpec.AT_MOST);
+ } else {
+ widthSpec = View.MeasureSpec.makeMeasureSpec(activity.getWindow().getDecorView().getMeasuredWidth(),
+ View.MeasureSpec.AT_MOST);
+ }
+
+ view.measure(widthSpec, View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
+ }
+
private void initializeCroutonView() {
Resources resources = this.activity.getResources();
@@ -667,9 +810,10 @@ private void initializeCroutonView() {
private FrameLayout initializeCroutonViewGroup(Resources resources) {
FrameLayout croutonView = new FrameLayout(this.activity);
- if(null != onClickListener)
- croutonView.setOnClickListener(onClickListener);
-
+ if (null != onClickListener) {
+ croutonView.setOnClickListener(onClickListener);
+ }
+
final int height;
if (this.style.heightDimensionResId > 0) {
height = resources.getDimensionPixelSize(this.style.heightDimensionResId);
@@ -685,10 +829,10 @@ private FrameLayout initializeCroutonViewGroup(Resources resources) {
}
croutonView.setLayoutParams(
- new FrameLayout.LayoutParams(width != 0 ? width : FrameLayout.LayoutParams.MATCH_PARENT, height));
+ new FrameLayout.LayoutParams(width != 0 ? width : FrameLayout.LayoutParams.MATCH_PARENT, height));
// set background
- if (this.style.backgroundColorValue != -1) {
+ if (this.style.backgroundColorValue != Style.NOT_SET) {
croutonView.setBackgroundColor(this.style.backgroundColorValue);
} else {
croutonView.setBackgroundColor(resources.getColor(this.style.backgroundColorResourceId));
@@ -710,7 +854,7 @@ private FrameLayout initializeCroutonViewGroup(Resources resources) {
private RelativeLayout initializeContentView(final Resources resources) {
RelativeLayout contentView = new RelativeLayout(this.activity);
contentView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT));
+ RelativeLayout.LayoutParams.MATCH_PARENT));
// set padding
int padding = this.style.paddingInPixels;
@@ -732,10 +876,19 @@ private RelativeLayout initializeContentView(final Resources resources) {
TextView text = initializeTextView(resources);
RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT);
+ RelativeLayout.LayoutParams.WRAP_CONTENT);
if (null != image) {
textParams.addRule(RelativeLayout.RIGHT_OF, image.getId());
}
+
+ if ((this.style.gravity & Gravity.CENTER) != 0) {
+ textParams.addRule(RelativeLayout.CENTER_IN_PARENT);
+ } else if ((this.style.gravity & Gravity.CENTER_VERTICAL) != 0) {
+ textParams.addRule(RelativeLayout.CENTER_VERTICAL);
+ } else if ((this.style.gravity & Gravity.CENTER_HORIZONTAL) != 0) {
+ textParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
+ }
+
contentView.addView(text, textParams);
return contentView;
}
@@ -743,12 +896,20 @@ private RelativeLayout initializeContentView(final Resources resources) {
private TextView initializeTextView(final Resources resources) {
TextView text = new TextView(this.activity);
text.setId(TEXT_ID);
- text.setText(this.text);
+ if (this.style.fontName != null) {
+ setTextWithCustomFont(text, this.style.fontName);
+ } else if (this.style.fontNameResId != 0) {
+ setTextWithCustomFont(text, resources.getString(this.style.fontNameResId));
+ } else {
+ text.setText(this.text);
+ }
text.setTypeface(Typeface.DEFAULT_BOLD);
text.setGravity(this.style.gravity);
-
+
// set the text color if set
- if (this.style.textColorResourceId != 0) {
+ if (this.style.textColorValue != Style.NOT_SET) {
+ text.setTextColor(this.style.textColorValue);
+ } else if (this.style.textColorResourceId != 0) {
text.setTextColor(resources.getColor(this.style.textColorResourceId));
}
@@ -771,6 +932,15 @@ private TextView initializeTextView(final Resources resources) {
return text;
}
+ private void setTextWithCustomFont(TextView text, String fontName) {
+ if (this.text != null) {
+ SpannableString s = new SpannableString(this.text);
+ s.setSpan(new TypefaceSpan(text.getContext(), fontName), 0, s.length(),
+ Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ text.setText(s);
+ }
+ }
+
private void initializeTextViewShadow(final Resources resources, final TextView text) {
int textShadowColor = resources.getColor(this.style.textShadowColorResId);
float textShadowRadius = this.style.textShadowRadius;
@@ -798,28 +968,13 @@ private ImageView initializeImageView() {
}
RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(
- RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT);
+ RelativeLayout.LayoutParams.WRAP_CONTENT,
+ RelativeLayout.LayoutParams.WRAP_CONTENT);
imageParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
imageParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
-
+
image.setLayoutParams(imageParams);
-
- return image;
- }
- @Override
- public String toString() {
- return "Crouton{" +
- "text=" + text +
- ", style=" + style +
- ", customView=" + customView +
- ", activity=" + activity +
- ", viewGroup=" + viewGroup +
- ", croutonView=" + croutonView +
- ", inAnimation=" + inAnimation +
- ", outAnimation=" + outAnimation +
- ", lifecycleCallback=" + lifecycleCallback +
- '}';
+ return image;
}
}
diff --git a/library/src/main/java/de/keyboardsurfer/android/widget/crouton/DefaultAnimationsBuilder.java b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/DefaultAnimationsBuilder.java
new file mode 100644
index 0000000..0e52d49
--- /dev/null
+++ b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/DefaultAnimationsBuilder.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2012 - 2014 Benjamin Weiss
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package de.keyboardsurfer.android.widget.crouton;
+
+import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.TranslateAnimation;
+
+/** Builds the default animations for showing and hiding a {@link Crouton}. */
+final class DefaultAnimationsBuilder {
+ private static final long DURATION = 400;
+ private static Animation slideInDownAnimation, slideOutUpAnimation;
+ private static int lastInAnimationHeight, lastOutAnimationHeight;
+
+ private DefaultAnimationsBuilder() {
+ /* no-op */
+ }
+
+ /**
+ * @param croutonView
+ * The croutonView which gets animated.
+ *
+ * @return The default Animation for a showing {@link Crouton}.
+ */
+ static Animation buildDefaultSlideInDownAnimation(View croutonView) {
+ if (!areLastMeasuredInAnimationHeightAndCurrentEqual(croutonView) || (null == slideInDownAnimation)) {
+ slideInDownAnimation = new TranslateAnimation(
+ 0, 0, // X: from, to
+ -croutonView.getMeasuredHeight(), 0 // Y: from, to
+ );
+ slideInDownAnimation.setDuration(DURATION);
+ setLastInAnimationHeight(croutonView.getMeasuredHeight());
+ }
+ return slideInDownAnimation;
+ }
+
+ /**
+ * @param croutonView
+ * The croutonView which gets animated.
+ *
+ * @return The default Animation for a hiding {@link Crouton}.
+ */
+ static Animation buildDefaultSlideOutUpAnimation(View croutonView) {
+ if (!areLastMeasuredOutAnimationHeightAndCurrentEqual(croutonView) || (null == slideOutUpAnimation)) {
+ slideOutUpAnimation = new TranslateAnimation(
+ 0, 0, // X: from, to
+ 0, -croutonView.getMeasuredHeight() // Y: from, to
+ );
+ slideOutUpAnimation.setDuration(DURATION);
+ setLastOutAnimationHeight(croutonView.getMeasuredHeight());
+ }
+ return slideOutUpAnimation;
+ }
+
+ private static boolean areLastMeasuredInAnimationHeightAndCurrentEqual(View croutonView) {
+ return areLastMeasuredAnimationHeightAndCurrentEqual(lastInAnimationHeight, croutonView);
+ }
+
+ private static boolean areLastMeasuredOutAnimationHeightAndCurrentEqual(View croutonView) {
+ return areLastMeasuredAnimationHeightAndCurrentEqual(lastOutAnimationHeight, croutonView);
+ }
+
+ private static boolean areLastMeasuredAnimationHeightAndCurrentEqual(int lastHeight, View croutonView) {
+ return lastHeight == croutonView.getMeasuredHeight();
+ }
+
+ private static void setLastInAnimationHeight(int lastInAnimationHeight) {
+ DefaultAnimationsBuilder.lastInAnimationHeight = lastInAnimationHeight;
+ }
+
+ private static void setLastOutAnimationHeight(int lastOutAnimationHeight) {
+ DefaultAnimationsBuilder.lastOutAnimationHeight = lastOutAnimationHeight;
+ }
+}
diff --git a/library/src/main/java/de/keyboardsurfer/android/widget/crouton/LifecycleCallback.java b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/LifecycleCallback.java
new file mode 100644
index 0000000..a55f734
--- /dev/null
+++ b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/LifecycleCallback.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2012 - 2014 Benjamin Weiss
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package de.keyboardsurfer.android.widget.crouton;
+
+/** Provides callback methods on major lifecycle events of a {@link Crouton}. */
+public interface LifecycleCallback {
+ /** Will be called when your Crouton has been displayed. */
+ public void onDisplayed();
+
+ /** Will be called when your {@link Crouton} has been removed. */
+ public void onRemoved();
+
+ //public void onCeasarDressing();
+}
diff --git a/library/src/de/keyboardsurfer/android/widget/crouton/Manager.java b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Manager.java
similarity index 58%
rename from library/src/de/keyboardsurfer/android/widget/crouton/Manager.java
rename to library/src/main/java/de/keyboardsurfer/android/widget/crouton/Manager.java
index 0d46294..bed2337 100644
--- a/library/src/de/keyboardsurfer/android/widget/crouton/Manager.java
+++ b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Manager.java
@@ -1,6 +1,5 @@
/*
- * Copyright 2012 - 2013 Benjamin Weiss
- * Copyright 2012 Neofonie Mobile GmbH
+ * Copyright 2012 - 2014 Benjamin Weiss
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,18 +16,24 @@
package de.keyboardsurfer.android.widget.crouton;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
+import android.content.res.Resources;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
-import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
+import android.view.ViewTreeObserver;
+import android.view.Window;
+import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
+import android.widget.AdapterView;
import android.widget.FrameLayout;
+import android.widget.RelativeLayout;
import java.util.Iterator;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
@@ -39,8 +44,7 @@
*/
final class Manager extends Handler {
private static final class Messages {
- private Messages() { /* no-op */
- }
+ private Messages() { /* no-op */ }
public static final int DISPLAY_CROUTON = 0xc2007;
public static final int ADD_CROUTON_TO_VIEW = 0xc20074dd;
@@ -49,7 +53,7 @@ private Messages() { /* no-op */
private static Manager INSTANCE;
- private Queue croutonQueue;
+ private final Queue croutonQueue;
private Manager() {
croutonQueue = new LinkedBlockingQueue();
@@ -70,7 +74,7 @@ static synchronized Manager getInstance() {
* Inserts a {@link Crouton} to be displayed.
*
* @param crouton
- * The {@link Crouton} to be displayed.
+ * The {@link Crouton} to be displayed.
*/
void add(Crouton crouton) {
croutonQueue.add(crouton);
@@ -105,7 +109,7 @@ private void displayCrouton() {
}
private long calculateCroutonDuration(Crouton crouton) {
- long croutonDuration = crouton.getStyle().durationInMilliseconds;
+ long croutonDuration = crouton.getConfiguration().durationInMilliseconds;
croutonDuration += crouton.getInAnimation().getDuration();
croutonDuration += crouton.getOutAnimation().getDuration();
return croutonDuration;
@@ -115,9 +119,9 @@ private long calculateCroutonDuration(Crouton crouton) {
* Sends a {@link Crouton} within a {@link Message}.
*
* @param crouton
- * The {@link Crouton} that should be sent.
+ * The {@link Crouton} that should be sent.
* @param messageId
- * The {@link Message} id.
+ * The {@link Message} id.
*/
private void sendMessage(Crouton crouton, final int messageId) {
final Message message = obtainMessage(messageId);
@@ -129,11 +133,11 @@ private void sendMessage(Crouton crouton, final int messageId) {
* Sends a {@link Crouton} within a delayed {@link Message}.
*
* @param crouton
- * The {@link Crouton} that should be sent.
+ * The {@link Crouton} that should be sent.
* @param messageId
- * The {@link Message} id.
+ * The {@link Message} id.
* @param delay
- * The delay in milliseconds.
+ * The delay in milliseconds.
*/
private void sendMessageDelayed(Crouton crouton, final int messageId, final long delay) {
Message message = obtainMessage(messageId);
@@ -149,7 +153,9 @@ private void sendMessageDelayed(Crouton crouton, final int messageId, final long
@Override
public void handleMessage(Message message) {
final Crouton crouton = (Crouton) message.obj;
-
+ if (null == crouton) {
+ return;
+ }
switch (message.what) {
case Messages.DISPLAY_CROUTON: {
displayCrouton();
@@ -180,41 +186,101 @@ public void handleMessage(Message message) {
* Adds a {@link Crouton} to the {@link ViewParent} of it's {@link Activity}.
*
* @param crouton
- * The {@link Crouton} that should be added.
+ * The {@link Crouton} that should be added.
*/
- private void addCroutonToView(Crouton crouton) {
+ private void addCroutonToView(final Crouton crouton) {
// don't add if it is already showing
if (crouton.isShowing()) {
return;
}
- View croutonView = crouton.getView();
+ final View croutonView = crouton.getView();
if (null == croutonView.getParent()) {
ViewGroup.LayoutParams params = croutonView.getLayoutParams();
if (null == params) {
- params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ params =
+ new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
- // display Crouton in ViewGroup is it has been supplied
+ // display Crouton in ViewGroup if it has been supplied
if (null != crouton.getViewGroup()) {
- // TODO implement add to last position feature (need to align with how this will be requested for activity)
- if (crouton.getViewGroup() instanceof FrameLayout) {
- crouton.getViewGroup().addView(croutonView, params);
+ final ViewGroup croutonViewGroup = crouton.getViewGroup();
+ if (shouldAddViewWithoutPosition(croutonViewGroup)) {
+ croutonViewGroup.addView(croutonView, params);
} else {
- crouton.getViewGroup().addView(croutonView, 0, params);
+ croutonViewGroup.addView(croutonView, 0, params);
}
} else {
Activity activity = crouton.getActivity();
if (null == activity || activity.isFinishing()) {
return;
}
+ handleTranslucentActionBar((ViewGroup.MarginLayoutParams) params, activity);
+ handleActionBarOverlay((ViewGroup.MarginLayoutParams) params, activity);
+
activity.addContentView(croutonView, params);
}
}
- croutonView.startAnimation(crouton.getInAnimation());
- announceForAccessibilityCompat(crouton.getActivity(), crouton.getText());
- if (Style.DURATION_INFINITE != crouton.getStyle().durationInMilliseconds) {
- sendMessageDelayed(crouton, Messages.REMOVE_CROUTON,
- crouton.getStyle().durationInMilliseconds + crouton.getInAnimation().getDuration());
+
+ croutonView.requestLayout(); // This is needed so the animation can use the measured with/height
+ ViewTreeObserver observer = croutonView.getViewTreeObserver();
+ if (null != observer) {
+ observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ @TargetApi(16)
+ public void onGlobalLayout() {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
+ croutonView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
+ } else {
+ croutonView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+ }
+
+ if(crouton.getInAnimation() != null) {
+ croutonView.startAnimation(crouton.getInAnimation());
+ announceForAccessibilityCompat(crouton.getActivity(), crouton.getText());
+ if (Configuration.DURATION_INFINITE != crouton.getConfiguration().durationInMilliseconds) {
+ sendMessageDelayed(crouton, Messages.REMOVE_CROUTON,
+ crouton.getConfiguration().durationInMilliseconds + crouton.getInAnimation().getDuration());
+ }
+ }
+ }
+ });
+ }
+ }
+
+ private boolean shouldAddViewWithoutPosition(ViewGroup croutonViewGroup) {
+ return croutonViewGroup instanceof FrameLayout || croutonViewGroup instanceof AdapterView ||
+ croutonViewGroup instanceof RelativeLayout;
+ }
+
+ @TargetApi(19)
+ private void handleTranslucentActionBar(ViewGroup.MarginLayoutParams params, Activity activity) {
+ // Translucent status is only available as of Android 4.4 Kit Kat.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ final int flags = activity.getWindow().getAttributes().flags;
+ final int translucentStatusFlag = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
+ if ((flags & translucentStatusFlag) == translucentStatusFlag) {
+ setActionBarMargin(params, activity);
+ }
+ }
+ }
+
+ @TargetApi(11)
+ private void handleActionBarOverlay(ViewGroup.MarginLayoutParams params, Activity activity) {
+ // ActionBar overlay is only available as of Android 3.0 Honeycomb.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ final boolean flags = activity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
+ if (flags) {
+ setActionBarMargin(params, activity);
+ }
+ }
+ }
+
+ private void setActionBarMargin(ViewGroup.MarginLayoutParams params, Activity activity) {
+ final int actionBarContainerId = Resources.getSystem().getIdentifier("action_bar_container", "id", "android");
+ final View actionBarContainer = activity.findViewById(actionBarContainerId);
+ // The action bar is present: the app is using a Holo theme.
+ if (null != actionBarContainer) {
+ params.topMargin = actionBarContainer.getBottom();
}
}
@@ -223,10 +289,15 @@ private void addCroutonToView(Crouton crouton) {
* durationInMilliseconds.
*
* @param crouton
- * The {@link Crouton} added to a {@link ViewGroup} and should be
- * removed.
+ * The {@link Crouton} added to a {@link ViewGroup} and should be
+ * removed.
*/
protected void removeCrouton(Crouton crouton) {
+ // If the crouton hasn't been displayed yet a `Crouton.hide()` will fail to hide
+ // it since the DISPLAY message might still be in the queue. Remove all messages
+ // for this crouton.
+ removeAllMessagesForCrouton(crouton);
+
View croutonView = crouton.getView();
ViewGroup croutonParentView = (ViewGroup) croutonView.getParent();
@@ -258,7 +329,7 @@ protected void removeCrouton(Crouton crouton) {
* displayed.
*
* @param crouton
- * The {@link Crouton} that should be removed.
+ * The {@link Crouton} that should be removed.
*/
void removeCroutonImmediately(Crouton crouton) {
// if Crouton has already been displayed then it may not be in the queue (because it was popped).
@@ -273,25 +344,21 @@ void removeCroutonImmediately(Crouton crouton) {
removeAllMessagesForCrouton(crouton);
}
// remove any matching croutons from queue
- if (null != croutonQueue) {
- final Iterator croutonIterator = croutonQueue.iterator();
- while (croutonIterator.hasNext()) {
- final Crouton c = croutonIterator.next();
- if (c.equals(crouton) && (null != c.getActivity())) {
- // remove the crouton from the content view
- if (crouton.isShowing()) {
- ((ViewGroup) c.getView().getParent()).removeView(c.getView());
- }
+ final Iterator croutonIterator = croutonQueue.iterator();
+ while (croutonIterator.hasNext()) {
+ final Crouton c = croutonIterator.next();
+ if (c.equals(crouton) && (null != c.getActivity())) {
+ // remove the crouton from the content view
+ removeCroutonFromViewParent(crouton);
- // remove any messages pending for the crouton
- removeAllMessagesForCrouton(c);
+ // remove any messages pending for the crouton
+ removeAllMessagesForCrouton(c);
- // remove the crouton from the queue
- croutonIterator.remove();
+ // remove the crouton from the queue
+ croutonIterator.remove();
- // we have found our crouton so just break
- break;
- }
+ // we have found our crouton so just break
+ break;
}
}
}
@@ -302,16 +369,12 @@ void removeCroutonImmediately(Crouton crouton) {
void clearCroutonQueue() {
removeAllMessages();
- if (null != croutonQueue) {
- // remove any views that may already have been added to the activity's
- // content view
- for (Crouton crouton : croutonQueue) {
- if (crouton.isShowing()) {
- ((ViewGroup) crouton.getView().getParent()).removeView(crouton.getView());
- }
- }
- croutonQueue.clear();
+ // remove any views that may already have been added to the activity's
+ // content view
+ for (Crouton crouton : croutonQueue) {
+ removeCroutonFromViewParent(crouton);
}
+ croutonQueue.clear();
}
/**
@@ -319,21 +382,26 @@ void clearCroutonQueue() {
* crouton from {@link Activity}s content view immediately.
*/
void clearCroutonsForActivity(Activity activity) {
- if (null != croutonQueue) {
- Iterator croutonIterator = croutonQueue.iterator();
- while (croutonIterator.hasNext()) {
- Crouton crouton = croutonIterator.next();
- if ((null != crouton.getActivity()) && crouton.getActivity().equals(activity)) {
- // remove the crouton from the content view
- if (crouton.isShowing()) {
- ((ViewGroup) crouton.getView().getParent()).removeView(crouton.getView());
- }
+ Iterator croutonIterator = croutonQueue.iterator();
+ while (croutonIterator.hasNext()) {
+ Crouton crouton = croutonIterator.next();
+ if ((null != crouton.getActivity()) && crouton.getActivity().equals(activity)) {
+ // remove the crouton from the content view
+ removeCroutonFromViewParent(crouton);
- removeAllMessagesForCrouton(crouton);
+ removeAllMessagesForCrouton(crouton);
- // remove the crouton from the queue
- croutonIterator.remove();
- }
+ // remove the crouton from the queue
+ croutonIterator.remove();
+ }
+ }
+ }
+
+ private void removeCroutonFromViewParent(Crouton crouton) {
+ if (crouton.isShowing()) {
+ ViewGroup parent = (ViewGroup) crouton.getView().getParent();
+ if (null != parent) {
+ parent.removeView(crouton.getView());
}
}
}
@@ -365,15 +433,17 @@ private void removeAllMessagesForCrouton(Crouton crouton) {
* via https://github.com/coreform/android-formidable-validation
*
* @param context
- * Used to get {@link AccessibilityManager}
+ * Used to get {@link AccessibilityManager}
* @param text
- * The text to announce.
+ * The text to announce.
*/
public static void announceForAccessibilityCompat(Context context, CharSequence text) {
if (Build.VERSION.SDK_INT >= 4) {
- AccessibilityManager accessibilityManager = (AccessibilityManager) context.getSystemService(
- Context.ACCESSIBILITY_SERVICE);
- if (!accessibilityManager.isEnabled()) {
+ AccessibilityManager accessibilityManager = null;
+ if (null != context) {
+ accessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
+ }
+ if (null == accessibilityManager || !accessibilityManager.isEnabled()) {
return;
}
@@ -384,7 +454,7 @@ public static void announceForAccessibilityCompat(Context context, CharSequence
if (Build.VERSION.SDK_INT < 16) {
eventType = AccessibilityEvent.TYPE_VIEW_FOCUSED;
} else {
- eventType = AccessibilityEventCompat.TYPE_ANNOUNCEMENT;
+ eventType = AccessibilityEvent.TYPE_ANNOUNCEMENT;
}
// Construct an accessibility event with the minimum recommended
@@ -400,4 +470,11 @@ public static void announceForAccessibilityCompat(Context context, CharSequence
accessibilityManager.sendAccessibilityEvent(event);
}
}
+
+ @Override
+ public String toString() {
+ return "Manager{" +
+ "croutonQueue=" + croutonQueue +
+ '}';
+ }
}
diff --git a/library/src/de/keyboardsurfer/android/widget/crouton/Style.java b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Style.java
similarity index 55%
rename from library/src/de/keyboardsurfer/android/widget/crouton/Style.java
rename to library/src/main/java/de/keyboardsurfer/android/widget/crouton/Style.java
index 28f2ada..dca9453 100644
--- a/library/src/de/keyboardsurfer/android/widget/crouton/Style.java
+++ b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Style.java
@@ -1,6 +1,5 @@
/*
- * Copyright 2012 - 2013 Benjamin Weiss
- * Copyright 2012 Neofonie Mobile GmbH
+ * Copyright 2012 - 2014 Benjamin Weiss
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,49 +22,39 @@
import android.widget.ImageView;
-/**
- * The style for a {@link Crouton}.
- */
-
+/** The style for a {@link Crouton}. */
public class Style {
+
+ public static final int NOT_SET = -1;
- /**
- * Display a {@link Crouton} for an infinite amount of time or
- * until {@link de.keyboardsurfer.android.widget.crouton.Crouton#cancel()} has been called.
- */
- public static final int DURATION_INFINITE = -1;
+ public static final int holoRedLight = 0xffff4444;
+ public static final int holoGreenLight = 0xff99cc00;
+ public static final int holoBlueLight = 0xff33b5e5;
- /**
- * Default style for alerting the user.
- */
+ /** Default style for alerting the user. */
public static final Style ALERT;
- /**
- * Default style for confirming an action.
- */
+ /** Default style for confirming an action. */
public static final Style CONFIRM;
- /**
- * Default style for general information.
- */
+ /** Default style for general information. */
public static final Style INFO;
- public static final int holoRedLight = 0xffff4444;
- public static final int holoGreenLight = 0xff99cc00;
- public static final int holoBlueLight = 0xff33b5e5;
-
static {
- ALERT = new Builder().setDuration(5000).setBackgroundColorValue(holoRedLight).setHeight(LayoutParams.WRAP_CONTENT)
+ ALERT = new Builder()
+ .setBackgroundColorValue(holoRedLight)
+ .build();
+ CONFIRM = new Builder()
+ .setBackgroundColorValue(holoGreenLight)
.build();
- CONFIRM = new Builder().setDuration(3000).setBackgroundColorValue(holoGreenLight).setHeight(
- LayoutParams.WRAP_CONTENT).build();
- INFO = new Builder().setDuration(3000).setBackgroundColorValue(holoBlueLight).setHeight(LayoutParams.WRAP_CONTENT)
+ INFO = new Builder()
+ .setBackgroundColorValue(holoBlueLight)
.build();
}
/**
- * The durationInMilliseconds the {@link Crouton} will be displayed in
- * milliseconds.
+ * The {@link Configuration} for this {@link Style}.
+ * It can be overridden via {@link Crouton#setConfiguration(Configuration)}.
*/
- final int durationInMilliseconds;
+ final Configuration configuration;
/**
* The resource id of the backgroundResourceId.
@@ -84,13 +73,11 @@ public class Style {
/**
* The backgroundColorResourceValue's e.g. 0xffff4444;
*
- * -1 for no value.
+ * NOT_SET for no value.
*/
final int backgroundColorValue;
- /**
- * Whether we should isTileEnabled the backgroundResourceId or not.
- */
+ /** Whether we should isTileEnabled the backgroundResourceId or not. */
final boolean isTileEnabled;
/**
@@ -101,44 +88,34 @@ public class Style {
final int textColorResourceId;
/**
- * The height of the {@link Crouton} in pixels.
+ * The textColorResourceValue's e.g. 0xffff4444;
+ *
+ * NOT_SET for no value.
*/
+ final int textColorValue;
+
+ /** The height of the {@link Crouton} in pixels. */
final int heightInPixels;
- /**
- * Resource ID for the height of the {@link Crouton}.
- */
+ /** Resource ID for the height of the {@link Crouton}. */
final int heightDimensionResId;
-
- /**
- * The width of the {@link Crouton} in pixels.
- */
+
+ /** The width of the {@link Crouton} in pixels. */
final int widthInPixels;
-
- /**
- * Resource ID for the width of the {@link Crouton}.
- */
+
+ /** Resource ID for the width of the {@link Crouton}. */
final int widthDimensionResId;
- /**
- * The text's gravity as provided by {@link Gravity}.
- */
+ /** The text's gravity as provided by {@link Gravity}. */
final int gravity;
- /**
- * An additional image to display in the {@link Crouton}.
- */
+ /** An additional image to display in the {@link Crouton}. */
final Drawable imageDrawable;
- /**
- * An additional image to display in the {@link Crouton}.
- */
+ /** An additional image to display in the {@link Crouton}. */
final int imageResId;
- /**
- * The {@link ImageView.ScaleType} for the image to display in the
- * {@link Crouton}.
- */
+ /** The {@link ImageView.ScaleType} for the image to display in the {@link Crouton}. */
final ImageView.ScaleType imageScaleType;
/**
@@ -148,57 +125,40 @@ public class Style {
*/
final int textSize;
- /**
- * The text shadow color's resource id
- */
+ /** The text shadow color's resource id */
final int textShadowColorResId;
- /**
- * The text shadow radius
- */
+ /** The text shadow radius */
final float textShadowRadius;
- /**
- * The text shadow vertical offset
- */
+ /** The text shadow vertical offset */
final float textShadowDy;
- /**
- * The text shadow horizontal offset
- */
+ /** The text shadow horizontal offset */
final float textShadowDx;
- /**
- * The text appearance resource id for the text.
- */
+ /** The text appearance resource id for the text. */
final int textAppearanceResId;
- /**
- * The resource id for the in animation
- */
- final int inAnimationResId;
-
- /**
- * The resource id for the out animation
- */
- final int outAnimationResId;
-
- /**
- * The padding for the crouton view content in pixels
- */
+ /** The padding for the crouton view content in pixels */
final int paddingInPixels;
- /**
- * The resource id for the padding for the view content
- */
+ /** The resource id for the padding for the view content */
final int paddingDimensionResId;
+ /** The file path and font name for the view content */
+ final String fontName;
+
+ /** The file path and font name resource id for the view content */
+ final int fontNameResId;
+
private Style(final Builder builder) {
- this.durationInMilliseconds = builder.durationInMilliseconds;
+ this.configuration = builder.configuration;
this.backgroundColorResourceId = builder.backgroundColorResourceId;
this.backgroundDrawableResourceId = builder.backgroundDrawableResourceId;
this.isTileEnabled = builder.isTileEnabled;
this.textColorResourceId = builder.textColorResourceId;
+ this.textColorValue = builder.textColorValue;
this.heightInPixels = builder.heightInPixels;
this.heightDimensionResId = builder.heightDimensionResId;
this.widthInPixels = builder.widthInPixels;
@@ -211,25 +171,24 @@ private Style(final Builder builder) {
this.textShadowDx = builder.textShadowDx;
this.textShadowDy = builder.textShadowDy;
this.textAppearanceResId = builder.textAppearanceResId;
- this.inAnimationResId = builder.inAnimationResId;
- this.outAnimationResId = builder.outAnimationResId;
this.imageResId = builder.imageResId;
this.imageScaleType = builder.imageScaleType;
this.paddingInPixels = builder.paddingInPixels;
this.paddingDimensionResId = builder.paddingDimensionResId;
this.backgroundColorValue = builder.backgroundColorValue;
+ this.fontName = builder.fontName;
+ this.fontNameResId = builder.fontNameResId;
}
- /**
- * Builder for the {@link Style} object.
- */
+ /** Builder for the {@link Style} object. */
public static class Builder {
- private int durationInMilliseconds;
+ private Configuration configuration;
private int backgroundColorValue;
private int backgroundColorResourceId;
private int backgroundDrawableResourceId;
private boolean isTileEnabled;
private int textColorResourceId;
+ private int textColorValue;
private int heightInPixels;
private int heightDimensionResId;
private int widthInPixels;
@@ -242,42 +201,76 @@ public static class Builder {
private float textShadowDx;
private float textShadowDy;
private int textAppearanceResId;
- private int inAnimationResId;
- private int outAnimationResId;
private int imageResId;
private ImageView.ScaleType imageScaleType;
private int paddingInPixels;
private int paddingDimensionResId;
+ private String fontName;
+ private int fontNameResId;
+ /** Creates a {@link Builder} to build a {@link Style} upon. */
public Builder() {
- durationInMilliseconds = 3000;
+ configuration = Configuration.DEFAULT;
paddingInPixels = 10;
backgroundColorResourceId = android.R.color.holo_blue_light;
backgroundDrawableResourceId = 0;
- backgroundColorValue = -1;
+ backgroundColorValue = NOT_SET;
isTileEnabled = false;
textColorResourceId = android.R.color.white;
+ textColorValue = NOT_SET;
heightInPixels = LayoutParams.WRAP_CONTENT;
widthInPixels = LayoutParams.MATCH_PARENT;
gravity = Gravity.CENTER;
imageDrawable = null;
- inAnimationResId = 0;
- outAnimationResId = 0;
imageResId = 0;
imageScaleType = ImageView.ScaleType.FIT_XY;
+ fontName = null;
+ fontNameResId = 0;
}
/**
- * Set the durationInMilliseconds option of the {@link Crouton}.
+ * Creates a {@link Builder} to build a {@link Style} upon.
+ *
+ * @param baseStyle
+ * The base {@link Style} to use for this {@link Style}.
+ */
+ public Builder(final Style baseStyle) {
+ configuration = baseStyle.configuration;
+ backgroundColorValue = baseStyle.backgroundColorValue;
+ backgroundColorResourceId = baseStyle.backgroundColorResourceId;
+ backgroundDrawableResourceId = baseStyle.backgroundDrawableResourceId;
+ isTileEnabled = baseStyle.isTileEnabled;
+ textColorResourceId = baseStyle.textColorResourceId;
+ textColorValue = baseStyle.textColorValue;
+ heightInPixels = baseStyle.heightInPixels;
+ heightDimensionResId = baseStyle.heightDimensionResId;
+ widthInPixels = baseStyle.widthInPixels;
+ widthDimensionResId = baseStyle.widthDimensionResId;
+ gravity = baseStyle.gravity;
+ imageDrawable = baseStyle.imageDrawable;
+ textSize = baseStyle.textSize;
+ textShadowColorResId = baseStyle.textShadowColorResId;
+ textShadowRadius = baseStyle.textShadowRadius;
+ textShadowDx = baseStyle.textShadowDx;
+ textShadowDy = baseStyle.textShadowDy;
+ textAppearanceResId = baseStyle.textAppearanceResId;
+ imageResId = baseStyle.imageResId;
+ imageScaleType = baseStyle.imageScaleType;
+ paddingInPixels = baseStyle.paddingInPixels;
+ paddingDimensionResId = baseStyle.paddingDimensionResId;
+ fontName = baseStyle.fontName;
+ fontNameResId = baseStyle.fontNameResId;
+ }
+ /**
+ * Set the {@link Configuration} option of the {@link Crouton}.
+ *
+ * @param configuration
+ * The {@link Configuration}.
*
- * @param duration
- * The durationInMilliseconds the crouton will be displayed
- * {@link Crouton} in milliseconds.
* @return the {@link Builder}.
*/
- public Builder setDuration(int duration) {
- this.durationInMilliseconds = duration;
-
+ public Builder setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
return this;
}
@@ -285,7 +278,8 @@ public Builder setDuration(int duration) {
* Set the backgroundColorResourceId option of the {@link Crouton}.
*
* @param backgroundColorResourceId
- * The backgroundColorResourceId's resource id.
+ * The backgroundColorResourceId's resource id.
+ *
* @return the {@link Builder}.
*/
public Builder setBackgroundColor(int backgroundColorResourceId) {
@@ -298,7 +292,8 @@ public Builder setBackgroundColor(int backgroundColorResourceId) {
* Set the backgroundColorResourceValue option of the {@link Crouton}.
*
* @param backgroundColorValue
- * The backgroundColorResourceValue's e.g. 0xffff4444;
+ * The backgroundColorResourceValue's e.g. 0xffff4444;
+ *
* @return the {@link Builder}.
*/
public Builder setBackgroundColorValue(int backgroundColorValue) {
@@ -310,7 +305,8 @@ public Builder setBackgroundColorValue(int backgroundColorValue) {
* Set the backgroundDrawableResourceId option for the {@link Crouton}.
*
* @param backgroundDrawableResourceId
- * Resource ID of a backgroundDrawableResourceId image drawable.
+ * Resource ID of a backgroundDrawableResourceId image drawable.
+ *
* @return the {@link Builder}.
*/
public Builder setBackgroundDrawable(int backgroundDrawableResourceId) {
@@ -323,9 +319,10 @@ public Builder setBackgroundDrawable(int backgroundDrawableResourceId) {
* Set the heightInPixels option for the {@link Crouton}.
*
* @param height
- * The height of the {@link Crouton} in pixel. Can also be
- * {@link LayoutParams#MATCH_PARENT} or
- * {@link LayoutParams#WRAP_CONTENT}.
+ * The height of the {@link Crouton} in pixel. Can also be
+ * {@link LayoutParams#MATCH_PARENT} or
+ * {@link LayoutParams#WRAP_CONTENT}.
+ *
* @return the {@link Builder}.
*/
public Builder setHeight(int height) {
@@ -338,7 +335,8 @@ public Builder setHeight(int height) {
* Set the resource id for the height option for the {@link Crouton}.
*
* @param heightDimensionResId
- * Resource ID of a dimension for the height of the {@link Crouton}.
+ * Resource ID of a dimension for the height of the {@link Crouton}.
+ *
* @return the {@link Builder}.
*/
public Builder setHeightDimensionResId(int heightDimensionResId) {
@@ -351,9 +349,10 @@ public Builder setHeightDimensionResId(int heightDimensionResId) {
* Set the widthInPixels option for the {@link Crouton}.
*
* @param width
- * The width of the {@link Crouton} in pixel. Can also be
- * {@link LayoutParams#MATCH_PARENT} or
- * {@link LayoutParams#WRAP_CONTENT}.
+ * The width of the {@link Crouton} in pixel. Can also be
+ * {@link LayoutParams#MATCH_PARENT} or
+ * {@link LayoutParams#WRAP_CONTENT}.
+ *
* @return the {@link Builder}.
*/
public Builder setWidth(int width) {
@@ -366,7 +365,8 @@ public Builder setWidth(int width) {
* Set the resource id for the width option for the {@link Crouton}.
*
* @param widthDimensionResId
- * Resource ID of a dimension for the width of the {@link Crouton}.
+ * Resource ID of a dimension for the width of the {@link Crouton}.
+ *
* @return the {@link Builder}.
*/
public Builder setWidthDimensionResId(int widthDimensionResId) {
@@ -379,8 +379,9 @@ public Builder setWidthDimensionResId(int widthDimensionResId) {
* Set the isTileEnabled option for the {@link Crouton}.
*
* @param isTileEnabled
- * true if you want the backgroundResourceId to be
- * tiled, else false.
+ * true if you want the backgroundResourceId to be
+ * tiled, else false.
+ *
* @return the {@link Builder}.
*/
public Builder setTileEnabled(boolean isTileEnabled) {
@@ -393,7 +394,8 @@ public Builder setTileEnabled(boolean isTileEnabled) {
* Set the textColorResourceId option for the {@link Crouton}.
*
* @param textColor
- * The resource id of the text colorResourceId.
+ * The resource id of the text colorResourceId.
+ *
* @return the {@link Builder}.
*/
public Builder setTextColor(int textColor) {
@@ -402,11 +404,25 @@ public Builder setTextColor(int textColor) {
return this;
}
+ /**
+ * Set the textColorResourceValue option of the {@link Crouton}.
+ *
+ * @param textColorValue
+ * The textColorResourceValue's e.g. 0xffff4444;
+ *
+ * @return the {@link Builder}.
+ */
+ public Builder setTextColorValue(int textColorValue) {
+ this.textColorValue = textColorValue;
+ return this;
+ }
+
/**
* Set the gravity option for the {@link Crouton}.
*
* @param gravity
- * The text's gravity as provided by {@link Gravity}.
+ * The text's gravity as provided by {@link Gravity}.
+ *
* @return the {@link Builder}.
*/
public Builder setGravity(int gravity) {
@@ -419,7 +435,8 @@ public Builder setGravity(int gravity) {
* Set the image option for the {@link Crouton}.
*
* @param imageDrawable
- * An additional image to display in the {@link Crouton}.
+ * An additional image to display in the {@link Crouton}.
+ *
* @return the {@link Builder}.
*/
public Builder setImageDrawable(Drawable imageDrawable) {
@@ -432,7 +449,8 @@ public Builder setImageDrawable(Drawable imageDrawable) {
* Set the image resource option for the {@link Crouton}.
*
* @param imageResId
- * An additional image to display in the {@link Crouton}.
+ * An additional image to display in the {@link Crouton}.
+ *
* @return the {@link Builder}.
*/
public Builder setImageResource(int imageResId) {
@@ -441,99 +459,106 @@ public Builder setImageResource(int imageResId) {
return this;
}
- /**
- * The text size in sp
- */
+ /** The text size in sp. */
public Builder setTextSize(int textSize) {
this.textSize = textSize;
return this;
}
- /**
- * The text shadow color's resource id
- */
+ /** The text shadow color resource id. */
public Builder setTextShadowColor(int textShadowColorResId) {
this.textShadowColorResId = textShadowColorResId;
return this;
}
- /**
- * The text shadow radius
- */
+ /** The text shadow radius. */
public Builder setTextShadowRadius(float textShadowRadius) {
this.textShadowRadius = textShadowRadius;
return this;
}
- /**
- * The text shadow horizontal offset
- */
+ /** The text shadow horizontal offset. */
public Builder setTextShadowDx(float textShadowDx) {
this.textShadowDx = textShadowDx;
return this;
}
- /**
- * The text shadow vertical offset
- */
+ /** The text shadow vertical offset. */
public Builder setTextShadowDy(float textShadowDy) {
this.textShadowDy = textShadowDy;
return this;
}
- /**
- * The text appearance resource id for the text.
- */
+ /** The text appearance resource id for the text. */
public Builder setTextAppearance(int textAppearanceResId) {
this.textAppearanceResId = textAppearanceResId;
return this;
}
- /**
- * The resource id for the in animation
- */
- public Builder setInAnimation(int inAnimationResId) {
- this.inAnimationResId = inAnimationResId;
- return this;
- }
-
- /**
- * The resource id for the out animation
- */
- public Builder setOutAnimation(int outAnimationResId) {
- this.outAnimationResId = outAnimationResId;
- return this;
- }
-
- /**
- * The {@link android.widget.ImageView.ScaleType} for the image
- */
+ /** The {@link android.widget.ImageView.ScaleType} for the image. */
public Builder setImageScaleType(ImageView.ScaleType imageScaleType) {
this.imageScaleType = imageScaleType;
return this;
}
- /**
- * The padding for the crouton view's content in pixels
- */
+ /** The padding for the crouton view's content in pixels. */
public Builder setPaddingInPixels(int padding) {
this.paddingInPixels = padding;
return this;
}
- /**
- * The resource id for the padding for the crouton view's content
- */
+ /** The resource id for the padding for the crouton view's content. */
public Builder setPaddingDimensionResId(int paddingResId) {
this.paddingDimensionResId = paddingResId;
return this;
}
- /**
- * @return a configured {@link Style} object.
- */
+ /** The file path and name of the font for the crouton view's content. */
+ public Builder setFontName(String fontName) {
+ this.fontName = fontName;
+ return this;
+ }
+
+ /** The resource id for the file path and name of the font for the crouton view's content. */
+ public Builder setFontNameResId(int fontNameResId) {
+ this.fontNameResId = fontNameResId;
+ return this;
+ }
+
+ /** @return a configured {@link Style} object. */
public Style build() {
return new Style(this);
}
}
+
+ @Override
+ public String toString() {
+ return "Style{" +
+ "configuration=" + configuration +
+ ", backgroundColorResourceId=" + backgroundColorResourceId +
+ ", backgroundDrawableResourceId=" + backgroundDrawableResourceId +
+ ", backgroundColorValue=" + backgroundColorValue +
+ ", isTileEnabled=" + isTileEnabled +
+ ", textColorResourceId=" + textColorResourceId +
+ ", textColorValue=" + textColorValue +
+ ", heightInPixels=" + heightInPixels +
+ ", heightDimensionResId=" + heightDimensionResId +
+ ", widthInPixels=" + widthInPixels +
+ ", widthDimensionResId=" + widthDimensionResId +
+ ", gravity=" + gravity +
+ ", imageDrawable=" + imageDrawable +
+ ", imageResId=" + imageResId +
+ ", imageScaleType=" + imageScaleType +
+ ", textSize=" + textSize +
+ ", textShadowColorResId=" + textShadowColorResId +
+ ", textShadowRadius=" + textShadowRadius +
+ ", textShadowDy=" + textShadowDy +
+ ", textShadowDx=" + textShadowDx +
+ ", textAppearanceResId=" + textAppearanceResId +
+ ", paddingInPixels=" + paddingInPixels +
+ ", paddingDimensionResId=" + paddingDimensionResId +
+ ", fontName=" + fontName +
+ ", fontNameResId=" + fontNameResId +
+ '}';
+ }
}
diff --git a/library/src/main/java/de/keyboardsurfer/android/widget/crouton/TypefaceSpan.java b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/TypefaceSpan.java
new file mode 100644
index 0000000..6adb00f
--- /dev/null
+++ b/library/src/main/java/de/keyboardsurfer/android/widget/crouton/TypefaceSpan.java
@@ -0,0 +1,59 @@
+
+/*
+ * Copyright 2012 - 2014 Benjamin Weiss
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package de.keyboardsurfer.android.widget.crouton;
+
+import android.content.Context;
+import android.graphics.Typeface;
+import android.support.v4.util.LruCache;
+import android.text.TextPaint;
+import android.text.style.MetricAffectingSpan;
+
+/**
+ * Style a spannable with a custom {@link Typeface}.
+ */
+public class TypefaceSpan extends MetricAffectingSpan {
+ /** An LruCache for previously loaded typefaces. */
+ private static LruCache sTypefaceCache = new LruCache(5);
+
+ private Typeface mTypeface;
+
+ /**
+ * Load the {@link Typeface} and apply to a spannable.
+ */
+ public TypefaceSpan(Context context, String typefaceName) {
+ mTypeface = sTypefaceCache.get(typefaceName);
+
+ if (mTypeface == null) {
+ mTypeface = Typeface.createFromAsset(context.getApplicationContext()
+ .getAssets(), String.format("%s", typefaceName));
+
+ // Cache the loaded Typeface
+ sTypefaceCache.put(typefaceName, mTypeface);
+ }
+ }
+
+ @Override
+ public void updateMeasureState(TextPaint p) {
+ p.setTypeface(mTypeface);
+ }
+
+ @Override
+ public void updateDrawState(TextPaint tp) {
+ tp.setTypeface(mTypeface);
+ }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 06782ea..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,102 +0,0 @@
-
-
-
-
-
- 4.0.0
-
- Crouton Parent
- crouton-parent
- 1.7
- de.keyboardsurfer.android.widget
- pom
-
-
-
- keyboardsurfer
- Benjamin Weiss
-
-
-
-
-
- The Apache Software License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
- repo
-
-
-
-
- git@github.com:keyboardsurfer/Crouton.git
- scm:git:git@github.com:keyboardsurfer/Crouton.git
- scm:git:git@github.com:keyboardsurfer/Crouton.git
-
-
-
- library
- sample
-
-
-
- UTF-8
- 4.1.1.4
- 16
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 2.5.1
-
- 1.6
- 1.6
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 2.2
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.9
-
-
- com.jayway.maven.plugins.android.generation2
- android-maven-plugin
- 3.4.1
- true
-
-
- ${android.version.platform}
-
- true
- true
-
-
-
-
-
-
-
diff --git a/sample/build.gradle b/sample/build.gradle
index 5015d42..a08ec0c 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -1,46 +1,71 @@
+/*
+ * Copyright 2012 - 2014 Benjamin Weiss
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+apply plugin: 'com.android.application'
+
buildscript {
- repositories {
- mavenCentral()
- // To use a development snapshot version of the plugin, add the
- // Sonatype Snapshots repository.
- maven {
- url "https://oss.sonatype.org/content/repositories/snapshots"
- }
- }
-
- dependencies {
- classpath 'org.gradle.api.plugins:gradle-android-plugin:1.2.1'
- }
+ repositories {
+ maven {
+ url 'https://github.com/dahlgren/vpi-aar/raw/master'
+ }
+ }
}
-apply plugin: 'android'
-
repositories {
- mavenCentral()
+ maven {
+ url 'https://github.com/dahlgren/vpi-aar/raw/master'
+ }
}
-// Sets the package version
-version = "1.0.0"
-
-// Signing configuration, valid for all builds (1)
-androidSignAndAlign {
- keyStore = "path/to/my/keystore"
- keyAlias = "my-key-alias"
- keyStorePassword = "mystorepass"
- keyAliasPassword = "myaliaspass"
+dependencies {
+ compile project(':crouton-library')
+ compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
+ compile 'com.android.support:support-v4:21.0.3'
+ compile('com.viewpagerindicator:library:2.4.2-SNAPSHOT@aar') {
+ exclude group: 'com.google.android', module: 'support-v4'
+ }
}
-// Configure the filtering of resources with properties from the Gradle's project scope (2)
-processResources {
- expand (project.properties)
-}
+android {
+ buildToolsVersion '20.0.0'
+ compileSdkVersion 19
-// Configure a dedicated debug build (3)
-task configureDebug << {
- jar.classifier = "debug"
-}
+ defaultConfig {
+ versionCode 15
+ versionName = project.version
+ minSdkVersion 8
+ targetSdkVersion 19
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_6
+ targetCompatibility JavaVersion.VERSION_1_6
+ }
+
+ signingConfigs {
+ release {}
+ }
+ buildTypes {
+ release {
+ signingConfig signingConfigs.release
-// Configure a dedicated release build (4)
-task configureRelease << {
- proguard.enabled = true
+ signingConfig.storeFile = file(keyStore)
+ signingConfig.storePassword = storePassword
+ signingConfig.keyAlias = keyAlias
+ signingConfig.keyPassword = keyPassword
+ }
+ }
}
diff --git a/sample/build.xml b/sample/build.xml
deleted file mode 100644
index 57b8ac2..0000000
--- a/sample/build.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/sample/pom.xml b/sample/pom.xml
deleted file mode 100644
index 1ae49ac..0000000
--- a/sample/pom.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
- 4.0.0
-
- Crouton Demo
- de.keyboardsurfer.app.demo.crouton
- 1.7
- de.keyboardsurfer.app.demo.crouton
- apk
-
-
-
- keyboardsurfer
- Benjamin Weiss
-
-
-
-
-
- The Apache Software License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
- repo
-
-
-
-
- git@github.com:keyboardsurfer/Crouton.git
- scm:git:git@github.com:keyboardsurfer/Crouton.git
- scm:git:git@github.com:keyboardsurfer/Crouton.git
-
-
-
-
- UTF-8
- 1.7
- 4.1.1.4
- 16
-
-
-
-
- android
- ${android.version}
- com.google.android
- provided
-
-
-
- crouton
- ${crouton.version}
- de.keyboardsurfer.android.widget
-
-
-
- crouton
- ${crouton.version}
- de.keyboardsurfer.android.widget
- javadoc
-
-
-
- crouton
- ${crouton.version}
- de.keyboardsurfer.android.widget
- sources
-
-
-
- com.actionbarsherlock
- actionbarsherlock
- 4.2.0
- apklib
-
-
-
- com.viewpagerindicator
- library
- 2.4.1
- apklib
-
-
-
-
-
- src
-
-
-
- com.jayway.maven.plugins.android.generation2
- android-maven-plugin
- 3.4.1
- true
-
-
- ${android.version.platform}
-
- true
- true
-
-
-
-
-
-
diff --git a/sample/project.properties b/sample/project.properties
index fd62fb2..e2d4d7f 100644
--- a/sample/project.properties
+++ b/sample/project.properties
@@ -11,7 +11,5 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-16
-android.library.reference.1=../library
-android.library.reference.2=gen-external-apklibs/com.actionbarsherlock_actionbarsherlock_4.2.0
-android.library.reference.3=gen-external-apklibs/com.viewpagerindicator_library_2.4.1
+target=android-19
+android.library.reference.1=../library
\ No newline at end of file
diff --git a/sample/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
similarity index 88%
rename from sample/AndroidManifest.xml
rename to sample/src/main/AndroidManifest.xml
index 5521ce3..b80020b 100644
--- a/sample/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -1,6 +1,6 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/res/layout/crouton_demo.xml b/sample/src/main/res/layout/crouton_demo.xml
similarity index 93%
rename from sample/res/layout/crouton_demo.xml
rename to sample/src/main/res/layout/crouton_demo.xml
index 66a7e97..64831e7 100644
--- a/sample/res/layout/crouton_demo.xml
+++ b/sample/src/main/res/layout/crouton_demo.xml
@@ -1,5 +1,7 @@
-
@@ -33,4 +33,4 @@
android:layout_height="match_parent"
android:id="@+id/crouton_pager" />
-
\ No newline at end of file
+
diff --git a/sample/res/values/dimens.xml b/sample/src/main/res/values/dimens.xml
similarity index 94%
rename from sample/res/values/dimens.xml
rename to sample/src/main/res/values/dimens.xml
index 5490ca2..d5dcee1 100644
--- a/sample/res/values/dimens.xml
+++ b/sample/src/main/res/values/dimens.xml
@@ -1,7 +1,7 @@