├── sample
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── layout
│ │ │ │ └── activity_main.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── java
│ │ │ └── mx
│ │ │ │ └── jesusmartinoza
│ │ │ │ └── sweetpassword
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── mx
│ │ │ └── jesusmartinoza
│ │ │ └── sweetpassword
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── mx
│ │ └── jesusmartinoza
│ │ └── sweetpassword
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── sweet-password
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ └── attrs.xml
│ │ │ └── layout
│ │ │ │ └── sweet_password.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── mx
│ │ │ └── jesusmartinoza
│ │ │ └── widget
│ │ │ ├── EyeViewAnimation.java
│ │ │ ├── EyeView.java
│ │ │ └── SweetPassword.java
│ ├── test
│ │ └── java
│ │ │ └── mx
│ │ │ └── jesusmartinoza
│ │ │ └── widget
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── mx
│ │ └── jesusmartinoza
│ │ └── widget
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── screenshots
└── preview.gif
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── README.md
└── gradlew
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sweet-password/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':sweet-password'
2 |
--------------------------------------------------------------------------------
/screenshots/preview.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesusmartinoza/Sweet-Password/HEAD/screenshots/preview.gif
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SweetPassword
3 |
4 |
--------------------------------------------------------------------------------
/sweet-password/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | library
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesusmartinoza/Sweet-Password/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesusmartinoza/Sweet-Password/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesusmartinoza/Sweet-Password/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesusmartinoza/Sweet-Password/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesusmartinoza/Sweet-Password/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sweet-password/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesusmartinoza/Sweet-Password/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesusmartinoza/Sweet-Password/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesusmartinoza/Sweet-Password/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesusmartinoza/Sweet-Password/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesusmartinoza/Sweet-Password/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jesusmartinoza/Sweet-Password/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .idea
3 | .gradle
4 | /local.properties
5 | /.idea/workspace.xml
6 | /.idea/libraries
7 | .DS_Store
8 | /build
9 | /captures
10 | .externalNativeBuild
11 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Mar 10 13:32:14 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sweet-password/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sweet-password/src/test/java/mx/jesusmartinoza/widget/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package mx.jesusmartinoza.widget;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/sample/src/test/java/mx/jesusmartinoza/sweetpassword/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package mx.jesusmartinoza.sweetpassword;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/sample/src/main/java/mx/jesusmartinoza/sweetpassword/MainActivity.java:
--------------------------------------------------------------------------------
1 | package mx.jesusmartinoza.sweetpassword;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.animation.BounceInterpolator;
6 |
7 | import mx.jesusmartinoza.widget.SweetPassword;
8 |
9 | public class MainActivity extends AppCompatActivity {
10 |
11 | private SweetPassword spInterpolator;
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_main);
17 |
18 | spInterpolator = findViewById(R.id.sp_interpolator);
19 |
20 | spInterpolator.setInterpolator(new BounceInterpolator());
21 | spInterpolator.setAnimDuration(700);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/sweet-password/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/sweet-password/src/androidTest/java/mx/jesusmartinoza/widget/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package mx.jesusmartinoza.widget;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("mx.jesusmartinoza.library.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/sample/src/androidTest/java/mx/jesusmartinoza/sweetpassword/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package mx.jesusmartinoza.sweetpassword;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("mx.jesusmartinoza.sweetpassword", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | defaultConfig {
6 | applicationId "mx.jesusmartinoza.sweetpassword"
7 | minSdkVersion 16
8 | targetSdkVersion 26
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'com.android.support:appcompat-v7:26.1.0'
24 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
25 | testImplementation 'junit:junit:4.12'
26 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
28 | compile project(':sweet-password')
29 | }
30 |
--------------------------------------------------------------------------------
/sweet-password/src/main/res/layout/sweet_password.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
9 |
10 |
15 |
16 |
17 |
18 |
28 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
22 |
23 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/sweet-password/src/main/java/mx/jesusmartinoza/widget/EyeViewAnimation.java:
--------------------------------------------------------------------------------
1 | package mx.jesusmartinoza.widget;
2 |
3 | import android.view.animation.Animation;
4 | import android.view.animation.Transformation;
5 |
6 | /**
7 | * Created by jesusmartinoza on 10/03/18.
8 | */
9 |
10 | public class EyeViewAnimation extends Animation {
11 |
12 | private EyeView eyeView;
13 | private boolean eyeOpen;
14 |
15 | /**
16 | * Set Eye Closed Ratio to 0 (Opened eye)
17 | * @param eyeView
18 | */
19 | public EyeViewAnimation(EyeView eyeView) {
20 | this.eyeView = eyeView;
21 | eyeOpen = false;
22 | }
23 |
24 | /**
25 | * Apply {interpolatedTime} to eyeView's EOR
26 | * @param interpolatedTime
27 | * @param transformation
28 | */
29 | @Override
30 | protected void applyTransformation(float interpolatedTime, Transformation transformation) {
31 | if(eyeOpen)
32 | eyeView.setECR(interpolatedTime);
33 | else
34 | eyeView.setECR(1.0f - interpolatedTime);
35 |
36 | eyeView.requestLayout();
37 | }
38 |
39 | /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
40 | G E T T E R S & S E T T E R S
41 | =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
42 | /**
43 | * When true the eye will open
44 | * @param eyeOpen
45 | */
46 | public void setEyeOpen(boolean eyeOpen) {
47 | this.eyeOpen = eyeOpen;
48 | }
49 | }
--------------------------------------------------------------------------------
/sweet-password/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 | bintrayRepo = 'maven'
5 | bintrayName = 'sweet-password'
6 |
7 | publishedGroupId = 'mx.jesusmartinoza'
8 | libraryName = 'Sweet Password'
9 | artifact = 'sweet-password'
10 |
11 | libraryDescription = 'A customizable EditText with a switchable eye which shows or hides the password'
12 |
13 | siteUrl = 'https://github.com/jesusmartinoza/Sweet-Password'
14 | gitUrl = 'https://github.com/jesusmartinoza/Sweet-Password.git'
15 |
16 | libraryVersion = '0.2'
17 |
18 | developerId = 'jesusmartinoza'
19 | developerName = 'Jesús Alberto Martínez Mendoza'
20 | developerEmail = 'jesusmartinoza@gmail.com'
21 |
22 | licenseName = 'MIT'
23 | licenseUrl = 'https://opensource.org/licenses/MIT'
24 | allLicenses = ["MIT"]
25 | }
26 |
27 | android {
28 | compileSdkVersion 26
29 |
30 | defaultConfig {
31 | minSdkVersion 16
32 | targetSdkVersion 2
33 | versionCode 2
34 | versionName "0.2"
35 |
36 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
37 |
38 | }
39 |
40 | buildTypes {
41 | release {
42 | minifyEnabled false
43 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
44 | }
45 | }
46 |
47 | }
48 |
49 | dependencies {
50 | implementation fileTree(dir: 'libs', include: ['*.jar'])
51 |
52 | implementation 'com.android.support:appcompat-v7:26.1.0'
53 | implementation 'com.android.support:design:26.1.0'
54 |
55 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
56 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
57 | }
58 |
59 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
60 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Sweet Password
2 | [](http://hits.dwyl.io/jesusmartinoza/Sweet-Password)
3 | 
4 | [](https://lbesson.mit-license.org/)
5 |
6 | A customizable password component for Android
7 |
8 | 
9 |
10 | ## Setup
11 | *Gradle*
12 | ```
13 | repositories {
14 | jCenter()
15 | }
16 |
17 | dependencies {
18 | compile 'mx.jesusmartinoza:sweet-password:0.2'
19 | }
20 | ```
21 |
22 | ## Usage
23 | ```
24 |
27 | ```
28 |
29 | ## Available attributes
30 | All attributes are optional
31 | ```
32 |
40 | ```
41 |
42 | | Attribute | Description | Default |
43 | | ------------- |-------------|-------------|
44 | | `eye_color` | Sets color border of the eye | Theme color accent |
45 | | `iris_color` | Sets iris color | Theme color accent |
46 | | `anim_duration` | Time to open/close the eye | 280ms |
47 | | `password_hint` | Hint for edit text | _Password_ |
48 |
49 | ## Set interpolator and animation duration
50 | By default the interpolator is `DecelerateInterpolator` but you can change by anyone you want
51 |
52 | ```
53 | SweetPassword sweetPassword = findViewById(R.id.my_sweetpassword);
54 |
55 | sweetPassword.setInterpolator(new BounceInterpolator());
56 | sweetPassword.setAnimDuration(700);
57 | ```
58 |
59 | ## License
60 | ```
61 | The MIT License (MIT)
62 |
63 | Copyright (c) 2018 Jesús Alberto Martínez Mendoza(@jesusmartinoza)
64 |
65 | Permission is hereby granted, free of charge, to any person obtaining a copy
66 | of this software and associated documentation files (the "Software"), to deal
67 | in the Software without restriction, including without limitation the rights
68 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
69 | copies of the Software, and to permit persons to whom the Software is
70 | furnished to do so, subject to the following conditions:
71 |
72 | The above copyright notice and this permission notice shall be included in all
73 | copies or substantial portions of the Software.
74 |
75 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
76 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
77 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
78 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
79 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
80 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
81 | SOFTWARE.
82 |
83 | ```
84 |
--------------------------------------------------------------------------------
/sweet-password/src/main/java/mx/jesusmartinoza/widget/EyeView.java:
--------------------------------------------------------------------------------
1 | package mx.jesusmartinoza.widget;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.Path;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 |
10 | /**
11 | * Created by jesusmartinoza on 10/03/18.
12 | */
13 |
14 | public class EyeView extends View {
15 |
16 | // UI
17 | private Paint paint;
18 | private Path lashline;
19 | private Path waterLine;
20 |
21 | // Draw stuff
22 | private float eyeHeight;
23 | private float irisRadius;
24 | private float initialY;
25 | private float anchorX; // Anchor for control points of paths
26 | private float ECR; // Eye Closed Ratio
27 | private int irisColor;
28 | private int eyeColor;
29 |
30 | /**
31 | * Mandatory constructor
32 | * @param context Context
33 | */
34 | public EyeView(Context context) {
35 | super(context);
36 | init();
37 | }
38 |
39 | /**
40 | * Mandatory constructor
41 | * @param context Context
42 | */
43 | public EyeView(Context context, AttributeSet attrs) {
44 | super(context, attrs);
45 | init();
46 | }
47 |
48 | /**
49 | * Mandatory constructor
50 | * @param context Context
51 | */
52 | public EyeView(Context context, AttributeSet attrs, int defStyle) {
53 | super(context, attrs, defStyle);
54 | init();
55 | }
56 |
57 | /**
58 | * Init component with a closed eye. And set some constant data of {paint}
59 | */
60 | private void init(){
61 | float dp = getResources().getDisplayMetrics().density;
62 | paint = new Paint();
63 | ECR = 1.0f;
64 | anchorX = 5f * dp;
65 | initialY = 8f * dp;
66 | eyeHeight = 19f * dp;
67 | irisRadius = 4f * dp;
68 |
69 | paint.setAntiAlias(true);
70 | paint.setStrokeWidth(2 * dp);
71 | }
72 |
73 | /**
74 | * First draw lash line and waterline using the same color.
75 | *
76 | * A bezier curve with a dynamic control points is used to achieve
77 | * the open/close animation of eye.
78 | *
79 | * To draw we are using a Bezier curve, reference:
80 | * http://blogs.sitepointstatic.com/examples/tech/canvas-curves/bezier-curve.html
81 | *
82 | * TODO: Preallocate and reuse paths
83 | * @param canvas Canvas
84 | */
85 | @Override
86 | protected void onDraw(Canvas canvas) {
87 | super.onDraw(canvas);
88 | lashline = new Path();
89 | waterLine = new Path();
90 |
91 | paint.setColor(eyeColor);
92 | paint.setStyle(Paint.Style.STROKE);
93 |
94 | // Lashline
95 | lashline.moveTo(anchorX, canvas.getHeight() / 2);
96 | lashline.cubicTo(canvas.getWidth() / 2 - anchorX, initialY + eyeHeight * ECR,
97 | canvas.getWidth() / 2 + anchorX,
98 | initialY + eyeHeight * ECR, canvas.getWidth() - anchorX, canvas.getHeight() / 2);
99 | canvas.drawPath(lashline, paint);
100 |
101 | // Waterline
102 | waterLine.moveTo(anchorX, canvas.getHeight() / 2);
103 | waterLine.cubicTo(canvas.getWidth() / 2 - anchorX,canvas.getHeight() - initialY,
104 | canvas.getWidth() / 2 + anchorX,
105 | canvas.getHeight() - initialY, canvas.getWidth() - anchorX, canvas.getHeight() / 2);
106 | canvas.drawPath(waterLine, paint);
107 |
108 | // Iris
109 | // start draw only when eye is half open
110 | if(ECR < 0.5) {
111 | paint.setColor(irisColor);
112 | paint.setStyle(Paint.Style.FILL);
113 | canvas.drawCircle(canvas.getWidth() / 2, canvas.getHeight() / 2, irisRadius * (1.0f - ECR), paint);
114 | }
115 | }
116 |
117 | /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
118 | G E T T E R S & S E T T E R S
119 | =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
120 | /**
121 | * Set Eye Closed Ratio.
122 | * 0.0 - Fully opened eye
123 | * 1.0 - Closed eye
124 | * @param eyeClosedRatio new Eye Closed Ratio
125 | */
126 | public void setECR(float eyeClosedRatio) {
127 | ECR = eyeClosedRatio;
128 | }
129 |
130 | /**
131 | * Set iris color
132 | * @param color new color
133 | */
134 | public void setIrisColor(int color) {
135 | irisColor = color;
136 | }
137 |
138 | /**
139 | * Set border color of eye
140 | * @param color new color
141 | */
142 | public void setEyeColor(int color) {
143 | eyeColor = color;
144 | }
145 | }
--------------------------------------------------------------------------------
/sweet-password/src/main/java/mx/jesusmartinoza/widget/SweetPassword.java:
--------------------------------------------------------------------------------
1 | package mx.jesusmartinoza.widget;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.support.design.widget.TextInputLayout;
6 | import android.text.InputType;
7 | import android.util.AttributeSet;
8 | import android.util.TypedValue;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.animation.DecelerateInterpolator;
12 | import android.view.animation.Interpolator;
13 | import android.widget.EditText;
14 | import android.widget.RelativeLayout;
15 |
16 | /**
17 | * Created by jesusmartinoza on 10/03/18.
18 | */
19 | public class SweetPassword extends RelativeLayout {
20 |
21 | // UI
22 | private EditText editText;
23 | private EyeView eyeView;
24 | private TextInputLayout textInputLayout;
25 |
26 | // Animation
27 | private boolean showing;
28 | private EyeViewAnimation animation;
29 | private Interpolator interpolator;
30 |
31 | /**
32 | * Mandatory constructor for View
33 | * @param context Context
34 | */
35 | public SweetPassword(Context context) {
36 | super(context);
37 | initComponent();
38 | }
39 |
40 | /**
41 | * After init components set default values from attributes
42 | * @param context Context
43 | */
44 | public SweetPassword(Context context, AttributeSet attrs) {
45 | super(context, attrs);
46 | initComponent();
47 |
48 | TypedArray a = getContext().obtainStyledAttributes(attrs,
49 | R.styleable.SweetPassword);
50 |
51 | animation.setDuration(a.getInteger(R.styleable.SweetPassword_anim_duration, 280));
52 | eyeView.setIrisColor(a.getColor(R.styleable.SweetPassword_iris_color, fetchAccentColor()));
53 | eyeView.setEyeColor(a.getColor(R.styleable.SweetPassword_eye_color, fetchAccentColor()));
54 |
55 | // OK, I need some optional sugar :P
56 | String hint = a.getString(R.styleable.SweetPassword_password_hint);
57 | textInputLayout.setHint(hint.isEmpty() ? "Password" : hint);
58 |
59 | a.recycle();
60 | }
61 |
62 | /**
63 | * Inflate view, instantiate components and set {eyeview} click listener
64 | */
65 | private void initComponent() {
66 | String infService = Context.LAYOUT_INFLATER_SERVICE;
67 | LayoutInflater li =
68 | (LayoutInflater)getContext().getSystemService(infService);
69 | li.inflate(R.layout.sweet_password, this, true);
70 |
71 | showing = false;
72 | editText = findViewById(R.id.edit_text);
73 | eyeView = findViewById(R.id.eye_view);
74 | textInputLayout = findViewById(R.id.text_input_layout);
75 | interpolator = new DecelerateInterpolator();
76 | animation = new EyeViewAnimation(eyeView);
77 |
78 | eyeView.setOnClickListener(new OnClickListener() {
79 | @Override
80 | public void onClick(View view) {
81 | animation.setEyeOpen(showing);
82 | animation.setInterpolator(interpolator);
83 |
84 | eyeView.startAnimation(animation);
85 | showing = !showing;
86 |
87 | togglePasswordVisibility();
88 | }
89 | });
90 | }
91 |
92 | /**
93 | * Toggle EditText password visibility.
94 | */
95 | public void togglePasswordVisibility() {
96 | if (showing) {
97 | editText.setInputType(InputType.TYPE_CLASS_TEXT);
98 | } else {
99 | editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
100 | }
101 | }
102 |
103 | /**
104 | * Fetch accent color from project
105 | * @return
106 | */
107 | private int fetchAccentColor() {
108 | TypedValue typedValue = new TypedValue();
109 |
110 | TypedArray a = getContext().obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent });
111 | int color = a.getColor(0, 0);
112 |
113 | a.recycle();
114 |
115 | return color;
116 | }
117 |
118 | /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
119 | G E T T E R S & S E T T E R S
120 | =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
121 | /**
122 | * Set animation duration
123 | * @param durationMillis
124 | */
125 | public void setAnimDuration(int durationMillis) {
126 | animation.setDuration(durationMillis);
127 | }
128 |
129 | /**
130 | * Set iris color
131 | * @param color new color
132 | */
133 | public void setIrisColor(int color) {
134 | eyeView.setIrisColor(color);
135 | }
136 |
137 | /**
138 | * Set border color of eye
139 | * @param color new color
140 | */
141 | public void setEyeColor(int color) {
142 | eyeView.setEyeColor(color);
143 | }
144 |
145 | /**
146 | * Set interpolator for eye animation
147 | * @param interpolator
148 | */
149 | public void setInterpolator(Interpolator interpolator) {
150 | this.interpolator = interpolator;
151 | }
152 |
153 | /**
154 | * Get content of edit text
155 | * @return
156 | */
157 | public String getPassword() {
158 | return editText.getText().toString();
159 | }
160 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------