├── settings.gradle
├── gradle.properties
├── app
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ ├── drawable
│ │ │ ├── logo_big.png
│ │ │ ├── custom_img.jpg
│ │ │ └── ic_launcher_background.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
│ │ ├── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ └── layout
│ │ │ └── sample_activity.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── cazaea
│ │ └── sweetalert
│ │ └── sample
│ │ └── SampleActivity.java
├── .gitignore
├── proguard-rules.pro
└── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── library
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── res
│ │ ├── values
│ │ │ ├── dimen.xml
│ │ │ ├── strings.xml
│ │ │ ├── attrs.xml
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ ├── drawable
│ │ │ ├── dialog_background.xml
│ │ │ ├── error_circle.xml
│ │ │ ├── success_bow.xml
│ │ │ ├── warning_circle.xml
│ │ │ ├── success_circle.xml
│ │ │ ├── red_button_background.xml
│ │ │ ├── blue_button_background.xml
│ │ │ ├── gray_button_background.xml
│ │ │ ├── warning_sigh.xml
│ │ │ └── error_center_x.xml
│ │ ├── anim
│ │ │ ├── success_bow_roate.xml
│ │ │ ├── success_mask_layout.xml
│ │ │ ├── modal_out.xml
│ │ │ ├── error_frame_in.xml
│ │ │ ├── error_x_in.xml
│ │ │ └── modal_in.xml
│ │ └── layout
│ │ │ └── alert_dialog.xml
│ │ └── java
│ │ └── com
│ │ └── cazaea
│ │ └── sweetalert
│ │ ├── OptAnimationLoader.java
│ │ ├── ProgressHelper.java
│ │ ├── SuccessTickView.java
│ │ ├── Rotate3dAnimation.java
│ │ └── SweetAlertDialog.java
├── .gitignore
├── proguard-rules.pro
└── build.gradle
├── .idea
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
└── misc.xml
├── .gitignore
├── gradlew.bat
├── gradlew
├── README.zh.md
└── README.md
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/gradle.properties
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | sweet-alert-dialog
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logo_big.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/drawable/logo_big.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/custom_img.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/drawable/custom_img.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cazaea/SweetAlertDialog/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/library/src/main/res/values/dimen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 290dp
4 | 3dp
5 | 34dp
6 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/dialog_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Nov 17 16:27:54 CST 2017
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 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 | Here\'s a message!
4 | OK
5 | Cancel
6 | Loading...
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/error_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/success_bow.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/warning_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/success_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/anim/success_bow_roate.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/library/src/main/res/anim/success_mask_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
18 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/red_button_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/blue_button_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/gray_button_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/library/src/main/res/anim/modal_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
14 |
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/libraries
39 |
40 | # Keystore files
41 | *.jks
42 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/libraries
39 |
40 | # Keystore files
41 | *.jks
42 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/libraries
39 |
40 | # Keystore files
41 | *.jks
42 |
--------------------------------------------------------------------------------
/library/src/main/res/anim/error_frame_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
12 |
13 |
20 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/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 |
--------------------------------------------------------------------------------
/library/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 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/warning_sigh.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 | -
17 |
18 |
19 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/library/src/main/res/anim/error_x_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
12 |
13 |
22 |
23 |
32 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 |
6 | defaultConfig {
7 | applicationId "com.cazaea.sweetalert.sample"
8 | minSdkVersion 19
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 |
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | implementation fileTree(include: ['*.jar'], dir: 'libs')
25 | implementation 'com.android.support:appcompat-v7:26.1.0'
26 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
27 | testImplementation 'junit:junit:4.12'
28 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
29 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
30 | // 加入依赖
31 | implementation project(path: ':library')
32 | }
33 |
--------------------------------------------------------------------------------
/library/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #00000000
4 | #FFFFFF
5 | #FFFFFF
6 | #D0D0D0
7 | #B6B6B6
8 | #AEDEF4
9 | #96BFD2
10 | #DD6B55
11 | #CD5B55
12 | #F27474
13 | #A5DC86
14 | #33A5DC86
15 | #F8BB86
16 | #575757
17 | #ff37474f
18 | #ff263238
19 | #ff21272b
20 | #ff80cbc4
21 | #ff009688
22 |
--------------------------------------------------------------------------------
/library/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
15 |
24 |
--------------------------------------------------------------------------------
/library/src/main/res/anim/modal_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
10 |
11 |
19 |
20 |
29 |
30 |
39 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/error_center_x.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
19 | -
20 |
25 |
26 |
27 |
28 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 |
4 | android {
5 | compileSdkVersion 26
6 |
7 | defaultConfig {
8 | minSdkVersion 9
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 |
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 |
21 | /**
22 | * 以下为配置library注释在打包jar后保留
23 | */
24 | // 打包源码jar
25 | task sourcesJar(type: Jar) {
26 | from android.sourceSets.main.java.srcDirs
27 | classifier = 'sources'
28 | }
29 | task javadoc(type: Javadoc) {
30 | failOnError false
31 | source = android.sourceSets.main.java.sourceFiles
32 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
33 | classpath += configurations.compile
34 | }
35 | // 打包文档jar
36 | task javadocJar(type: Jar, dependsOn: javadoc) {
37 | classifier = 'javadoc'
38 | from javadoc.destinationDir
39 | }
40 | artifacts {
41 | archives sourcesJar
42 | archives javadocJar
43 | }
44 |
45 | }
46 |
47 | dependencies {
48 | implementation fileTree(dir: 'libs', include: ['*.jar'])
49 | // 加入自己的依赖包
50 | implementation 'com.github.cazaea:materialish-progress:1.0.2'
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | 1.8
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/library/src/main/java/com/cazaea/sweetalert/OptAnimationLoader.java:
--------------------------------------------------------------------------------
1 | package com.cazaea.sweetalert;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.content.res.XmlResourceParser;
6 | import android.util.AttributeSet;
7 | import android.util.Xml;
8 | import android.view.animation.*;
9 | import org.xmlpull.v1.XmlPullParser;
10 | import org.xmlpull.v1.XmlPullParserException;
11 |
12 | import java.io.IOException;
13 |
14 | public class OptAnimationLoader {
15 |
16 | public static Animation loadAnimation(Context context, int id)
17 | throws Resources.NotFoundException {
18 |
19 | XmlResourceParser parser = null;
20 | try {
21 | parser = context.getResources().getAnimation(id);
22 | return createAnimationFromXml(context, parser);
23 | } catch (XmlPullParserException ex) {
24 | Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" +
25 | Integer.toHexString(id));
26 | rnf.initCause(ex);
27 | throw rnf;
28 | } catch (IOException ex) {
29 | Resources.NotFoundException rnf = new Resources.NotFoundException("Can't load animation resource ID #0x" +
30 | Integer.toHexString(id));
31 | rnf.initCause(ex);
32 | throw rnf;
33 | } finally {
34 | if (parser != null) parser.close();
35 | }
36 | }
37 |
38 | private static Animation createAnimationFromXml(Context c, XmlPullParser parser)
39 | throws XmlPullParserException, IOException {
40 |
41 | return createAnimationFromXml(c, parser, null, Xml.asAttributeSet(parser));
42 | }
43 |
44 | private static Animation createAnimationFromXml(Context c, XmlPullParser parser,
45 | AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException {
46 |
47 | Animation anim = null;
48 |
49 | // Make sure we are on a start tag.
50 | int type;
51 | int depth = parser.getDepth();
52 |
53 | while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
54 | && type != XmlPullParser.END_DOCUMENT) {
55 |
56 | if (type != XmlPullParser.START_TAG) {
57 | continue;
58 | }
59 |
60 | String name = parser.getName();
61 |
62 | if (name.equals("set")) {
63 | anim = new AnimationSet(c, attrs);
64 | createAnimationFromXml(c, parser, (AnimationSet)anim, attrs);
65 | } else if (name.equals("alpha")) {
66 | anim = new AlphaAnimation(c, attrs);
67 | } else if (name.equals("scale")) {
68 | anim = new ScaleAnimation(c, attrs);
69 | } else if (name.equals("rotate")) {
70 | anim = new RotateAnimation(c, attrs);
71 | } else if (name.equals("translate")) {
72 | anim = new TranslateAnimation(c, attrs);
73 | } else {
74 | try {
75 | anim = (Animation) Class.forName(name).getConstructor(Context.class, AttributeSet.class).newInstance(c, attrs);
76 | } catch (Exception te) {
77 | throw new RuntimeException("Unknown animation name: " + parser.getName() + " error:" + te.getMessage());
78 | }
79 | }
80 |
81 | if (parent != null) {
82 | parent.addAnimation(anim);
83 | }
84 | }
85 |
86 | return anim;
87 |
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/library/src/main/java/com/cazaea/sweetalert/ProgressHelper.java:
--------------------------------------------------------------------------------
1 | package com.cazaea.sweetalert;
2 |
3 | import android.content.Context;
4 |
5 | import com.cazaea.materialishprogress.ProgressWheel;
6 |
7 | public class ProgressHelper {
8 | private ProgressWheel mProgressWheel;
9 | private boolean mToSpin;
10 | private float mSpinSpeed;
11 | private int mBarWidth;
12 | private int mBarColor;
13 | private int mRimWidth;
14 | private int mRimColor;
15 | private boolean mIsInstantProgress;
16 | private float mProgressVal;
17 | private int mCircleRadius;
18 |
19 | public ProgressHelper(Context ctx) {
20 | mToSpin = true;
21 | mSpinSpeed = 0.75f;
22 | mBarWidth = ctx.getResources().getDimensionPixelSize(R.dimen.common_circle_width) + 1;
23 | mBarColor = ctx.getResources().getColor(R.color.success_stroke_color);
24 | mRimWidth = 0;
25 | mRimColor = 0x00000000;
26 | mIsInstantProgress = false;
27 | mProgressVal = -1;
28 | mCircleRadius = ctx.getResources().getDimensionPixelOffset(R.dimen.progress_circle_radius);
29 | }
30 |
31 | public ProgressWheel getProgressWheel () {
32 | return mProgressWheel;
33 | }
34 |
35 | public void setProgressWheel (ProgressWheel progressWheel) {
36 | mProgressWheel = progressWheel;
37 | updatePropsIfNeed();
38 | }
39 |
40 | private void updatePropsIfNeed () {
41 | if (mProgressWheel != null) {
42 | if (!mToSpin && mProgressWheel.isSpinning()) {
43 | mProgressWheel.stopSpinning();
44 | } else if (mToSpin && !mProgressWheel.isSpinning()) {
45 | mProgressWheel.spin();
46 | }
47 | if (mSpinSpeed != mProgressWheel.getSpinSpeed()) {
48 | mProgressWheel.setSpinSpeed(mSpinSpeed);
49 | }
50 | if (mBarWidth != mProgressWheel.getBarWidth()) {
51 | mProgressWheel.setBarWidth(mBarWidth);
52 | }
53 | if (mBarColor != mProgressWheel.getBarColor()) {
54 | mProgressWheel.setBarColor(mBarColor);
55 | }
56 | if (mRimWidth != mProgressWheel.getRimWidth()) {
57 | mProgressWheel.setRimWidth(mRimWidth);
58 | }
59 | if (mRimColor != mProgressWheel.getRimColor()) {
60 | mProgressWheel.setRimColor(mRimColor);
61 | }
62 | if (mProgressVal != mProgressWheel.getProgress()) {
63 | if (mIsInstantProgress) {
64 | mProgressWheel.setInstantProgress(mProgressVal);
65 | } else {
66 | mProgressWheel.setProgress(mProgressVal);
67 | }
68 | }
69 | if (mCircleRadius != mProgressWheel.getCircleRadius()) {
70 | mProgressWheel.setCircleRadius(mCircleRadius);
71 | }
72 | }
73 | }
74 |
75 | public void resetCount() {
76 | if (mProgressWheel != null) {
77 | mProgressWheel.resetCount();
78 | }
79 | }
80 |
81 | public boolean isSpinning() {
82 | return mToSpin;
83 | }
84 |
85 | public void spin() {
86 | mToSpin = true;
87 | updatePropsIfNeed();
88 | }
89 |
90 | public void stopSpinning() {
91 | mToSpin = false;
92 | updatePropsIfNeed();
93 | }
94 |
95 | public float getProgress() {
96 | return mProgressVal;
97 | }
98 |
99 | public void setProgress(float progress) {
100 | mIsInstantProgress = false;
101 | mProgressVal = progress;
102 | updatePropsIfNeed();
103 | }
104 |
105 | public void setInstantProgress(float progress) {
106 | mProgressVal = progress;
107 | mIsInstantProgress = true;
108 | updatePropsIfNeed();
109 | }
110 |
111 | public int getCircleRadius() {
112 | return mCircleRadius;
113 | }
114 |
115 | /**
116 | * @param circleRadius units using pixel
117 | * **/
118 | public void setCircleRadius(int circleRadius) {
119 | mCircleRadius = circleRadius;
120 | updatePropsIfNeed();
121 | }
122 |
123 | public int getBarWidth() {
124 | return mBarWidth;
125 | }
126 |
127 | public void setBarWidth(int barWidth) {
128 | mBarWidth = barWidth;
129 | updatePropsIfNeed();
130 | }
131 |
132 | public int getBarColor() {
133 | return mBarColor;
134 | }
135 |
136 | public void setBarColor(int barColor) {
137 | mBarColor = barColor;
138 | updatePropsIfNeed();
139 | }
140 |
141 | public int getRimWidth() {
142 | return mRimWidth;
143 | }
144 |
145 | public void setRimWidth(int rimWidth) {
146 | mRimWidth = rimWidth;
147 | updatePropsIfNeed();
148 | }
149 |
150 | public int getRimColor() {
151 | return mRimColor;
152 | }
153 |
154 | public void setRimColor(int rimColor) {
155 | mRimColor = rimColor;
156 | updatePropsIfNeed();
157 | }
158 |
159 | public float getSpinSpeed() {
160 | return mSpinSpeed;
161 | }
162 |
163 | public void setSpinSpeed(float spinSpeed) {
164 | mSpinSpeed = spinSpeed;
165 | updatePropsIfNeed();
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/library/src/main/java/com/cazaea/sweetalert/SuccessTickView.java:
--------------------------------------------------------------------------------
1 | package com.cazaea.sweetalert;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.RectF;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 | import android.view.animation.Animation;
10 | import android.view.animation.Transformation;
11 |
12 | public class SuccessTickView extends View {
13 | private float mDensity = -1;
14 | private Paint mPaint;
15 | private final float CONST_RADIUS = dip2px(1.2f);
16 | private final float CONST_RECT_WEIGHT = dip2px(3);
17 | private final float CONST_LEFT_RECT_W = dip2px(15);
18 | private final float CONST_RIGHT_RECT_W = dip2px(25);
19 | private final float MIN_LEFT_RECT_W = dip2px(3.3f);
20 | private final float MAX_RIGHT_RECT_W = CONST_RIGHT_RECT_W + dip2px(6.7f);
21 |
22 | private float mMaxLeftRectWidth;
23 | private float mLeftRectWidth;
24 | private float mRightRectWidth;
25 | private boolean mLeftRectGrowMode;
26 |
27 | public SuccessTickView(Context context) {
28 | super(context);
29 | init();
30 | }
31 |
32 | public SuccessTickView(Context context, AttributeSet attrs){
33 | super(context,attrs);
34 | init();
35 | }
36 |
37 | private void init () {
38 | mPaint = new Paint();
39 | mPaint.setColor(getResources().getColor(R.color.success_stroke_color));
40 | mLeftRectWidth = CONST_LEFT_RECT_W;
41 | mRightRectWidth = CONST_RIGHT_RECT_W;
42 | mLeftRectGrowMode = false;
43 | }
44 |
45 | @Override
46 | public void draw(Canvas canvas) {
47 | super.draw(canvas);
48 | int totalW = getWidth();
49 | int totalH = getHeight();
50 | // rotate canvas first
51 | canvas.rotate(45, totalW / 2, totalH / 2);
52 |
53 | totalW /= 1.2;
54 | totalH /= 1.4;
55 | mMaxLeftRectWidth = (totalW + CONST_LEFT_RECT_W) / 2 + CONST_RECT_WEIGHT - 1;
56 |
57 | RectF leftRect = new RectF();
58 | if (mLeftRectGrowMode) {
59 | leftRect.left = 0;
60 | leftRect.right = leftRect.left + mLeftRectWidth;
61 | leftRect.top = (totalH + CONST_RIGHT_RECT_W) / 2;
62 | leftRect.bottom = leftRect.top + CONST_RECT_WEIGHT;
63 | } else {
64 | leftRect.right = (totalW + CONST_LEFT_RECT_W) / 2 + CONST_RECT_WEIGHT - 1;
65 | leftRect.left = leftRect.right - mLeftRectWidth;
66 | leftRect.top = (totalH + CONST_RIGHT_RECT_W) / 2;
67 | leftRect.bottom = leftRect.top + CONST_RECT_WEIGHT;
68 | }
69 |
70 | canvas.drawRoundRect(leftRect, CONST_RADIUS, CONST_RADIUS, mPaint);
71 |
72 | RectF rightRect = new RectF();
73 | rightRect.bottom = (totalH + CONST_RIGHT_RECT_W) / 2 + CONST_RECT_WEIGHT - 1;
74 | rightRect.left = (totalW + CONST_LEFT_RECT_W) / 2;
75 | rightRect.right = rightRect.left + CONST_RECT_WEIGHT;
76 | rightRect.top = rightRect.bottom - mRightRectWidth;
77 | canvas.drawRoundRect(rightRect, CONST_RADIUS, CONST_RADIUS, mPaint);
78 | }
79 |
80 | public float dip2px(float dpValue) {
81 | if(mDensity == -1) {
82 | mDensity = getResources().getDisplayMetrics().density;
83 | }
84 | return dpValue * mDensity + 0.5f;
85 | }
86 |
87 | public void startTickAnim () {
88 | // hide tick
89 | mLeftRectWidth = 0;
90 | mRightRectWidth = 0;
91 | invalidate();
92 | Animation tickAnim = new Animation() {
93 | @Override
94 | protected void applyTransformation(float interpolatedTime, Transformation t) {
95 | super.applyTransformation(interpolatedTime, t);
96 | if (0.54 < interpolatedTime && 0.7 >= interpolatedTime) { // grow left and right rect to right
97 | mLeftRectGrowMode = true;
98 | mLeftRectWidth = mMaxLeftRectWidth * ((interpolatedTime - 0.54f) / 0.16f);
99 | if (0.65 < interpolatedTime) {
100 | mRightRectWidth = MAX_RIGHT_RECT_W * ((interpolatedTime - 0.65f) / 0.19f);
101 | }
102 | invalidate();
103 | } else if (0.7 < interpolatedTime && 0.84 >= interpolatedTime) { // shorten left rect from right, still grow right rect
104 | mLeftRectGrowMode = false;
105 | mLeftRectWidth = mMaxLeftRectWidth * (1 - ((interpolatedTime - 0.7f) / 0.14f));
106 | mLeftRectWidth = mLeftRectWidth < MIN_LEFT_RECT_W ? MIN_LEFT_RECT_W : mLeftRectWidth;
107 | mRightRectWidth = MAX_RIGHT_RECT_W * ((interpolatedTime - 0.65f) / 0.19f);
108 | invalidate();
109 | } else if (0.84 < interpolatedTime && 1 >= interpolatedTime) { // restore left rect width, shorten right rect to const
110 | mLeftRectGrowMode = false;
111 | mLeftRectWidth = MIN_LEFT_RECT_W + (CONST_LEFT_RECT_W - MIN_LEFT_RECT_W) * ((interpolatedTime - 0.84f) / 0.16f);
112 | mRightRectWidth = CONST_RIGHT_RECT_W + (MAX_RIGHT_RECT_W - CONST_RIGHT_RECT_W) * (1 - ((interpolatedTime - 0.84f) / 0.16f));
113 | invalidate();
114 | }
115 | }
116 | };
117 | tickAnim.setDuration(750);
118 | tickAnim.setStartOffset(100);
119 | startAnimation(tickAnim);
120 | }
121 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/library/src/main/java/com/cazaea/sweetalert/Rotate3dAnimation.java:
--------------------------------------------------------------------------------
1 | package com.cazaea.sweetalert;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Camera;
6 | import android.graphics.Matrix;
7 | import android.util.AttributeSet;
8 | import android.util.TypedValue;
9 | import android.view.animation.Animation;
10 | import android.view.animation.Transformation;
11 |
12 | public class Rotate3dAnimation extends Animation {
13 | private int mPivotXType = ABSOLUTE;
14 | private int mPivotYType = ABSOLUTE;
15 | private float mPivotXValue = 0.0f;
16 | private float mPivotYValue = 0.0f;
17 |
18 | private float mFromDegrees;
19 | private float mToDegrees;
20 | private float mPivotX;
21 | private float mPivotY;
22 | private Camera mCamera;
23 | private int mRollType;
24 |
25 | public static final int ROLL_BY_X = 0;
26 | public static final int ROLL_BY_Y = 1;
27 | public static final int ROLL_BY_Z = 2;
28 |
29 | protected static class Description {
30 | public int type;
31 | public float value;
32 | }
33 |
34 | Description parseValue(TypedValue value) {
35 | Description d = new Description();
36 | if (value == null) {
37 | d.type = ABSOLUTE;
38 | d.value = 0;
39 | } else {
40 | if (value.type == TypedValue.TYPE_FRACTION) {
41 | d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) ==
42 | TypedValue.COMPLEX_UNIT_FRACTION_PARENT ?
43 | RELATIVE_TO_PARENT : RELATIVE_TO_SELF;
44 | d.value = TypedValue.complexToFloat(value.data);
45 | return d;
46 | } else if (value.type == TypedValue.TYPE_FLOAT) {
47 | d.type = ABSOLUTE;
48 | d.value = value.getFloat();
49 | return d;
50 | } else if (value.type >= TypedValue.TYPE_FIRST_INT &&
51 | value.type <= TypedValue.TYPE_LAST_INT) {
52 | d.type = ABSOLUTE;
53 | d.value = value.data;
54 | return d;
55 | }
56 | }
57 |
58 | d.type = ABSOLUTE;
59 | d.value = 0.0f;
60 |
61 | return d;
62 | }
63 |
64 | public Rotate3dAnimation (Context context, AttributeSet attrs) {
65 | super(context, attrs);
66 |
67 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Rotate3dAnimation);
68 |
69 | mFromDegrees = a.getFloat(R.styleable.Rotate3dAnimation_fromDeg, 0.0f);
70 | mToDegrees = a.getFloat(R.styleable.Rotate3dAnimation_toDeg, 0.0f);
71 | mRollType = a.getInt(R.styleable.Rotate3dAnimation_rollType, ROLL_BY_X);
72 | Description d = parseValue(a.peekValue(R.styleable.Rotate3dAnimation_pivotX));
73 | mPivotXType = d.type;
74 | mPivotXValue = d.value;
75 |
76 | d = parseValue(a.peekValue(R.styleable.Rotate3dAnimation_pivotY));
77 | mPivotYType = d.type;
78 | mPivotYValue = d.value;
79 |
80 | a.recycle();
81 |
82 | initializePivotPoint();
83 | }
84 |
85 | public Rotate3dAnimation (int rollType, float fromDegrees, float toDegrees) {
86 | mRollType = rollType;
87 | mFromDegrees = fromDegrees;
88 | mToDegrees = toDegrees;
89 | mPivotX = 0.0f;
90 | mPivotY = 0.0f;
91 | }
92 |
93 | public Rotate3dAnimation (int rollType, float fromDegrees, float toDegrees, float pivotX, float pivotY) {
94 | mRollType = rollType;
95 | mFromDegrees = fromDegrees;
96 | mToDegrees = toDegrees;
97 |
98 | mPivotXType = ABSOLUTE;
99 | mPivotYType = ABSOLUTE;
100 | mPivotXValue = pivotX;
101 | mPivotYValue = pivotY;
102 | initializePivotPoint();
103 | }
104 |
105 | public Rotate3dAnimation (int rollType, float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) {
106 | mRollType = rollType;
107 | mFromDegrees = fromDegrees;
108 | mToDegrees = toDegrees;
109 |
110 | mPivotXValue = pivotXValue;
111 | mPivotXType = pivotXType;
112 | mPivotYValue = pivotYValue;
113 | mPivotYType = pivotYType;
114 | initializePivotPoint();
115 | }
116 |
117 | private void initializePivotPoint() {
118 | if (mPivotXType == ABSOLUTE) {
119 | mPivotX = mPivotXValue;
120 | }
121 | if (mPivotYType == ABSOLUTE) {
122 | mPivotY = mPivotYValue;
123 | }
124 | }
125 |
126 | @Override
127 | public void initialize(int width, int height, int parentWidth, int parentHeight) {
128 | super.initialize(width, height, parentWidth, parentHeight);
129 | mCamera = new Camera();
130 | mPivotX = resolveSize(mPivotXType, mPivotXValue, width, parentWidth);
131 | mPivotY = resolveSize(mPivotYType, mPivotYValue, height, parentHeight);
132 | }
133 |
134 | @Override
135 | protected void applyTransformation(float interpolatedTime, Transformation t) {
136 | final float fromDegrees = mFromDegrees;
137 | float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
138 |
139 | final Matrix matrix = t.getMatrix();
140 |
141 | mCamera.save();
142 | switch (mRollType) {
143 | case ROLL_BY_X:
144 | mCamera.rotateX(degrees);
145 | break;
146 | case ROLL_BY_Y:
147 | mCamera.rotateY(degrees);
148 | break;
149 | case ROLL_BY_Z:
150 | mCamera.rotateZ(degrees);
151 | break;
152 | }
153 | mCamera.getMatrix(matrix);
154 | mCamera.restore();
155 |
156 | matrix.preTranslate(-mPivotX, -mPivotY);
157 | matrix.postTranslate(mPivotX, mPivotY);
158 | }
159 | }
--------------------------------------------------------------------------------
/library/src/main/res/layout/alert_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
21 |
22 |
28 |
29 |
33 |
34 |
41 |
42 |
43 |
44 |
50 |
51 |
55 |
56 |
63 |
64 |
71 |
72 |
76 |
77 |
81 |
82 |
83 |
84 |
90 |
91 |
95 |
96 |
102 |
103 |
104 |
112 |
113 |
119 |
120 |
121 |
130 |
131 |
141 |
142 |
147 |
148 |
155 |
156 |
161 |
162 |
--------------------------------------------------------------------------------
/app/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 |
--------------------------------------------------------------------------------
/README.zh.md:
--------------------------------------------------------------------------------
1 | Sweet Alert Dialog
2 | ===================
3 | Android版的SweetAlert,清新文艺,快意灵动的甜心弹框
4 |
5 | [](https://996.icu)
6 | [](https://github.com/996icu/996.ICU/blob/master/LICENSE)
7 | [](https://android-arsenal.com/details/1/1065)
8 |
9 | [English Version](https://github.com/cazaea/SweetAlertDialog/blob/master/README.md)
10 |
11 | 灵感来源于JS版[SweetAlert](http://tristanedwards.me/sweetalert)
12 |
13 | [Demo下载](https://github.com/pedant/sweet-alert-dialog/releases/download/v1.1/sweet-alert-sample-v1.1.apk)
14 |
15 | ## 运行示意图
16 | 
17 |
18 | ## 安装
19 | 使用SweetAlertDialog最简单的办法就是像下面这样添加项目依赖。
20 |
21 | **Gradle**(Module)
22 |
23 | ```
24 | dependencies {
25 | compile 'com.github.cazaea:sweet-alert-dialog:1.0.0'
26 | }
27 | ```
28 |
29 | **Gradle**(Project)
30 |
31 | ```
32 | allprojects {
33 | repositories {
34 | ...
35 | maven { url 'https://jitpack.io' }
36 | ...
37 | }
38 | }
39 | ```
40 |
41 | ## 如何开始
42 | 显示Material进度样式
43 |
44 | SweetAlertDialog pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE);
45 | pDialog.getProgressHelper().setBarColor(Color.parseColor("#A5DC86"));
46 | pDialog.setTitleText("Loading");
47 | pDialog.setCancelable(false);
48 | pDialog.show();
49 |
50 | 
51 |
52 | 你可以通过 *SweetAlertDialog.getProgressHelper()* 调用materialish-progress中下面这些方法,来动态改变进度条的样式
53 |
54 | - resetCount()
55 | - isSpinning()
56 | - spin()
57 | - stopSpinning()
58 | - getProgress()
59 | - setProgress(float progress)
60 | - setInstantProgress(float progress)
61 | - getCircleRadius()
62 | - setCircleRadius(int circleRadius)
63 | - getBarWidth()
64 | - setBarWidth(int barWidth)
65 | - getBarColor()
66 | - setBarColor(int barColor)
67 | - getRimWidth()
68 | - setRimWidth(int rimWidth)
69 | - getRimColor()
70 | - setRimColor(int rimColor)
71 | - getSpinSpeed()
72 | - setSpinSpeed(float spinSpeed)
73 |
74 | 感谢[materialish-progress](https://github.com/pnikosis/materialish-progress)项目以及[@pedant](https://github.com/pedant)的原始项目。
75 |
76 | 更多关于进度条的用法,请参见样例代码。
77 |
78 | 只显示标题:
79 |
80 | new SweetAlertDialog(this)
81 | .setTitleText("Here's a message!")
82 | .setConfirmText("确定") // 如果不设置确定按钮属性,确定按钮将不显示,便于弹出后自动消失
83 | .show();
84 |
85 | 显示标题和内容:
86 |
87 | new SweetAlertDialog(this)
88 | .setTitleText("Here's a message!")
89 | .setContentText("It's pretty, isn't it?")
90 | .setConfirmText("确定")
91 | .show();
92 |
93 | 显示异常样式:
94 |
95 | new SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE)
96 | .setTitleText("Oops...")
97 | .setContentText("Something went wrong!")
98 | .setConfirmText("确定")
99 | .show();
100 |
101 | 显示警告样式:
102 |
103 | new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
104 | .setTitleText("Are you sure?")
105 | .setContentText("Won't be able to recover this file!")
106 | .setConfirmText("Yes,delete it!")
107 | .show();
108 |
109 | 显示成功完成样式:
110 |
111 | new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
112 | .setTitleText("Good job!")
113 | .setContentText("You clicked the button!")
114 | .setConfirmText("确定")
115 | .show();
116 |
117 | 自定义头部图像:
118 |
119 | new SweetAlertDialog(this, SweetAlertDialog.CUSTOM_IMAGE_TYPE)
120 | .setTitleText("Sweet!")
121 | .setContentText("Here's a custom image.")
122 | .setCustomImage(R.drawable.custom_img)
123 | .setConfirmText("确定")
124 | .show();
125 |
126 | 确认事件绑定:
127 |
128 | new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
129 | .setTitleText("Are you sure?")
130 | .setContentText("Won't be able to recover this file!")
131 | .setConfirmText("Yes,delete it!")
132 | .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
133 | @Override
134 | public void onClick(SweetAlertDialog sDialog) {
135 | sDialog.dismissWithAnimation();
136 | }
137 | })
138 | .show();
139 |
140 | 显示取消按钮及事件绑定:
141 |
142 | new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
143 | .setTitleText("Are you sure?")
144 | .setContentText("Won't be able to recover this file!")
145 | .setCancelText("No,cancel plx!")
146 | .setConfirmText("Yes,delete it!")
147 | .showCancelButton(true)
148 | .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {
149 | @Override
150 | public void onClick(SweetAlertDialog sDialog) {
151 | sDialog.cancel();
152 | }
153 | })
154 | .show();
155 |
156 | 确认后**切换**对话框样式:
157 |
158 | new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
159 | .setTitleText("Are you sure?")
160 | .setContentText("Won't be able to recover this file!")
161 | .setConfirmText("Yes,delete it!")
162 | .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
163 | @Override
164 | public void onClick(SweetAlertDialog sDialog) {
165 | sDialog
166 | .setTitleText("Deleted!")
167 | .setContentText("Your imaginary file has been deleted!")
168 | .setConfirmText("OK")
169 | .setConfirmClickListener(null)
170 | .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
171 | }
172 | })
173 | .show();
174 |
175 | [更多Android原创技术分享见: cazaea.com](https://cazaea.com)
176 |
177 | ## 反 996 许可证
178 |
179 | 反996许可证版本1.0
180 |
181 | 版权所有(c)2017 Cazaea(https://cazaea.com)
182 |
183 | 在符合下列条件的情况下,特此免费向任何得到本授权作品的副本(包括源代码、文件和/或相关内容,以下
184 | 统称为“授权作品”)的个人和法人实体授权:被授权个人或法人实体有权以任何目的处置授权作品,包括但
185 | 不限于使用、复制,修改,衍生利用、散布,发布和再许可:
186 |
187 | 1. 个人或法人实体必须在许可作品的每个再散布或衍生副本上包含以上版权声明和本许可证,不得自行修
188 | 改。
189 | 2. 个人或法人实体必须严格遵守与个人实际所在地或个人出生地或归化地、或法人实体注册地或经营地
190 | (以较严格者为准)的司法管辖区所有适用的与劳动和就业相关法律、法规、规则和标准。如果该司法管辖
191 | 区没有此类法律、法规、规章和标准或其法律、法规、规章和标准不可执行,则个人或法人实体必须遵守国
192 | 际劳工标准的核心公约。
193 | 3. 个人或法人不得以任何方式诱导或强迫其全职或兼职员工或其独立承包人以口头或书面形式同意直接或
194 | 间接限制、削弱或放弃其所拥有的,受相关与劳动和就业有关的法律、法规、规则和标准保护的权利或补救
195 | 措施,无论该等书面或口头协议是否被该司法管辖区的法律所承认,该等个人或法人实体也不得以任何方法
196 | 限制其雇员或独立承包人向版权持有人或监督许可证合规情况的有关当局报告或投诉上述违反许可证的行为
197 | 的权利。
198 |
199 | 该授权作品是"按原样"提供,不做任何明示或暗示的保证,包括但不限于对适销性、特定用途适用性和非侵
200 | 权性的保证。在任何情况下,无论是在合同诉讼、侵权诉讼或其他诉讼中,版权持有人均不承担因本软件或
201 | 本软件的使用或其他交易而产生、引起或与之相关的任何索赔、损害或其他责任。
202 |
203 |
204 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/sample_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
21 |
22 |
32 |
33 |
40 |
41 |
51 |
52 |
59 |
60 |
71 |
72 |
79 |
80 |
91 |
92 |
99 |
100 |
111 |
112 |
119 |
120 |
121 |
132 |
133 |
140 |
141 |
152 |
153 |
160 |
161 |
172 |
173 |
180 |
181 |
182 |
183 |
184 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # The original project(sweet-alert-dialog) is updated
2 |
3 | Original project address:[https://github.com/pedant/sweet-alert-dialog](https://github.com/pedant/sweet-alert-dialog)
4 |
5 | Sweet Alert Dialog
6 | ===================
7 | SweetAlert for Android, a beautiful and clever alert dialog
8 |
9 | [](https://996.icu)
10 | [](https://github.com/996icu/996.ICU/blob/master/LICENSE)
11 | [](https://android-arsenal.com/details/1/1065)
12 |
13 | [中文版](https://github.com/cazaea/SweetAlertDialog/blob/master/README.zh.md)
14 |
15 | [Demo Download](https://github.com/pedant/sweet-alert-dialog/releases/download/v1.1/sweet-alert-sample-v1.1.apk)
16 |
17 | ## ScreenShot
18 | 
19 |
20 | ## Setup
21 | The simplest way to use SweetAlertDialog is to add the library as aar dependency to your build.
22 |
23 | **Gradle**(Module)
24 |
25 | ```
26 | dependencies {
27 | compile 'com.github.cazaea:sweet-alert-dialog:1.0.0'
28 | }
29 | ```
30 |
31 | **Gradle**(Project)
32 |
33 | ```
34 | allprojects {
35 | repositories {
36 | ...
37 | maven { url 'https://jitpack.io' }
38 | ...
39 | }
40 | }
41 | ```
42 |
43 |
44 | ## Usage
45 |
46 | show material progress
47 |
48 | ```
49 | SweetAlertDialog pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE);
50 | pDialog.getProgressHelper().setBarColor(Color.parseColor("#A5DC86"));
51 | pDialog.setTitleText("Loading");
52 | pDialog.setCancelable(false);
53 | pDialog.show();
54 | ```
55 |
56 | 
57 |
58 | You can customize progress bar dynamically with materialish-progress methods via **SweetAlertDialog.getProgressHelper()**:
59 |
60 | - resetCount()
61 | - isSpinning()
62 | - spin()
63 | - stopSpinning()
64 | - getProgress()
65 | - setProgress(float progress)
66 | - setInstantProgress(float progress)
67 | - getCircleRadius()
68 | - setCircleRadius(int circleRadius)
69 | - getBarWidth()
70 | - setBarWidth(int barWidth)
71 | - getBarColor()
72 | - setBarColor(int barColor)
73 | - getRimWidth()
74 | - setRimWidth(int rimWidth)
75 | - getRimColor()
76 | - setRimColor(int rimColor)
77 | - getSpinSpeed()
78 | - setSpinSpeed(float spinSpeed)
79 |
80 | thanks to the project [materialish-progress](https://github.com/pnikosis/materialish-progress) and [@pedant](https://github.com/pedant) participation.
81 |
82 | more usages about progress, please see the sample.
83 |
84 | A basic message:
85 |
86 | new SweetAlertDialog(this)
87 | .setTitleText("Here's a message!")
88 | .setConfirmText("OK") // Do not set the property, do not show the button
89 | .show();
90 |
91 | A title with a text under:
92 |
93 | new SweetAlertDialog(this)
94 | .setTitleText("Here's a message!")
95 | .setContentText("It's pretty, isn't it?")
96 | .setConfirmText("OK")
97 | .show();
98 |
99 | A error message:
100 |
101 | new SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE)
102 | .setTitleText("Oops...")
103 | .setContentText("Something went wrong!")
104 | .setConfirmText("OK")
105 | .show();
106 |
107 | A warning message:
108 |
109 | new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
110 | .setTitleText("Are you sure?")
111 | .setContentText("Won't be able to recover this file!")
112 | .setConfirmText("Yes,delete it!")
113 | .show();
114 |
115 | A success message:
116 |
117 | new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
118 | .setTitleText("Good job!")
119 | .setContentText("You clicked the button!")
120 | .show();
121 |
122 | A message with a custom icon:
123 |
124 | new SweetAlertDialog(this, SweetAlertDialog.CUSTOM_IMAGE_TYPE)
125 | .setTitleText("Sweet!")
126 | .setContentText("Here's a custom image.")
127 | .setCustomImage(R.drawable.custom_img)
128 | .show();
129 |
130 | Bind the listener to confirm button:
131 |
132 | new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
133 | .setTitleText("Are you sure?")
134 | .setContentText("Won't be able to recover this file!")
135 | .setConfirmText("Yes,delete it!")
136 | .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
137 | @Override
138 | public void onClick(SweetAlertDialog sDialog) {
139 | sDialog.dismissWithAnimation();
140 | }
141 | })
142 | .show();
143 |
144 | Show the cancel button and bind listener to it:
145 |
146 | new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
147 | .setTitleText("Are you sure?")
148 | .setContentText("Won't be able to recover this file!")
149 | .setCancelText("No,cancel plx!")
150 | .setConfirmText("Yes,delete it!")
151 | .showCancelButton(true)
152 | .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {
153 | @Override
154 | public void onClick(SweetAlertDialog sDialog) {
155 | sDialog.cancel();
156 | }
157 | })
158 | .show();
159 |
160 | **Change** the dialog style upon confirming:
161 |
162 | new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
163 | .setTitleText("Are you sure?")
164 | .setContentText("Won't be able to recover this file!")
165 | .setConfirmText("Yes,delete it!")
166 | .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
167 | @Override
168 | public void onClick(SweetAlertDialog sDialog) {
169 | sDialog
170 | .setTitleText("Deleted!")
171 | .setContentText("Your imaginary file has been deleted!")
172 | .setConfirmText("OK")
173 | .setConfirmClickListener(null)
174 | .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
175 | }
176 | })
177 | .show();
178 |
179 | [more android tech shares: cazaea.com](http://www.cazaea.com)
180 |
181 | ## License
182 |
183 | Anti 996 License Version 1.0 (Draft)
184 |
185 | Copyright (c) 2017 Cazaea(http://cazaea.com)
186 |
187 | Permission is hereby granted to any individual or legal entity
188 | obtaining a copy of this licensed work (including the source code,
189 | documentation and/or related items, hereinafter collectively referred
190 | to as the "licensed work"), free of charge, to deal with the licensed
191 | work for any purpose, including without limitation, the rights to use,
192 | reproduce, modify, prepare derivative works of, distribute, publish
193 | and sublicense the licensed work, subject to the following conditions:
194 |
195 | 1. The individual or the legal entity must conspicuously display,
196 | without modification, this License and the notice on each redistributed
197 | or derivative copy of the Licensed Work.
198 |
199 | 2. The individual or the legal entity must strictly comply with all
200 | applicable laws, regulations, rules and standards of the jurisdiction
201 | relating to labor and employment where the individual is physically
202 | located or where the individual was born or naturalized; or where the
203 | legal entity is registered or is operating (whichever is stricter). In
204 | case that the jurisdiction has no such laws, regulations, rules and
205 | standards or its laws, regulations, rules and standards are
206 | unenforceable, the individual or the legal entity are required to
207 | comply with Core International Labor Standards.
208 |
209 | 3. The individual or the legal entity shall not induce or force its
210 | employee(s), whether full-time or part-time, or its independent
211 | contractor(s), in any methods, to agree in oral or written form, to
212 | directly or indirectly restrict, weaken or relinquish his or her
213 | rights or remedies under such laws, regulations, rules and standards
214 | relating to labor and employment as mentioned above, no matter whether
215 | such written or oral agreement are enforceable under the laws of the
216 | said jurisdiction, nor shall such individual or the legal entity
217 | limit, in any methods, the rights of its employee(s) or independent
218 | contractor(s) from reporting or complaining to the copyright holder or
219 | relevant authorities monitoring the compliance of the license about
220 | its violation(s) of the said license.
221 |
222 | THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
223 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
224 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
225 | IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM,
226 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
227 | OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION WITH THE
228 | LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK.
229 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cazaea/sweetalert/sample/SampleActivity.java:
--------------------------------------------------------------------------------
1 | package com.cazaea.sweetalert.sample;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.os.CountDownTimer;
6 | import android.os.Handler;
7 | import android.view.View;
8 | import android.widget.Switch;
9 |
10 | import com.cazaea.sweetalert.SweetAlertDialog;
11 |
12 | public class SampleActivity extends Activity implements View.OnClickListener {
13 |
14 | private int i = -1;
15 |
16 | @Override
17 | public void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.sample_activity);
20 | findViewById(R.id.basic_test).setOnClickListener(this);
21 | findViewById(R.id.under_text_test).setOnClickListener(this);
22 | findViewById(R.id.error_text_test).setOnClickListener(this);
23 | findViewById(R.id.success_text_test).setOnClickListener(this);
24 | findViewById(R.id.warning_confirm_test).setOnClickListener(this);
25 | findViewById(R.id.warning_cancel_test).setOnClickListener(this);
26 | findViewById(R.id.custom_img_test).setOnClickListener(this);
27 | findViewById(R.id.progress_dialog).setOnClickListener(this);
28 | }
29 |
30 | @Override
31 | public void onClick(View v) {
32 | switch (v.getId()) {
33 | case R.id.basic_test:
34 | // default title "Here's a message!"
35 | SweetAlertDialog sd = new SweetAlertDialog(this);
36 | sd.setCancelable(true);
37 | sd.setCanceledOnTouchOutside(true);
38 | sd.setConfirmText("OK");
39 | sd.show();
40 | break;
41 | case R.id.under_text_test:
42 | new SweetAlertDialog(this)
43 | .setContentText("It's pretty, isn't it?")
44 | .setConfirmText("OK")
45 | .show();
46 | break;
47 | case R.id.error_text_test:
48 | new SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE)
49 | .setTitleText("Oops...")
50 | .setContentText("Something went wrong!")
51 | .setConfirmText("OK")
52 | .show();
53 | break;
54 | case R.id.success_text_test:
55 | final SweetAlertDialog successDialog = new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
56 | .setTitleText("Good job!")
57 | .setContentText("You clicked the button!");
58 | successDialog.show();
59 | new Handler().postDelayed(new Runnable() {
60 | @Override
61 | public void run() {
62 | if (successDialog.isShowing()) {
63 | successDialog.dismiss();
64 | }
65 | }
66 | }, 1500);
67 | break;
68 | case R.id.warning_confirm_test:
69 | new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
70 | .setTitleText("Are you sure?")
71 | .setContentText("Won't be able to recover this file!")
72 | .setConfirmText("Yes,delete it!")
73 | .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
74 | @Override
75 | public void onClick(SweetAlertDialog sDialog) {
76 | // reuse previous dialog instance
77 | sDialog.setTitleText("Deleted!")
78 | .setContentText("Your imaginary file has been deleted!")
79 | .setConfirmText("OK")
80 | .setConfirmClickListener(null)
81 | .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
82 | }
83 | })
84 | .show();
85 | break;
86 | case R.id.warning_cancel_test:
87 | new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
88 | .setTitleText("Are you sure?")
89 | .setContentText("Won't be able to recover this file!")
90 | .setCancelText("No,cancel plx!")
91 | .setConfirmText("Yes,delete it!")
92 | .showCancelButton(true)
93 | .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {
94 | @Override
95 | public void onClick(SweetAlertDialog sDialog) {
96 | // reuse previous dialog instance, keep widget user state, reset them if you need
97 | sDialog.setTitleText("Cancelled!")
98 | .setContentText("Your imaginary file is safe :)")
99 | .setConfirmText("OK")
100 | .showCancelButton(false)
101 | .setCancelClickListener(null)
102 | .setConfirmClickListener(null)
103 | .changeAlertType(SweetAlertDialog.ERROR_TYPE);
104 |
105 | // or you can new a SweetAlertDialog to show
106 | /* sDialog.dismiss();
107 | new SweetAlertDialog(SampleActivity.this, SweetAlertDialog.ERROR_TYPE)
108 | .setTitleText("Cancelled!")
109 | .setContentText("Your imaginary file is safe :)")
110 | .setConfirmText("OK")
111 | .show();*/
112 | }
113 | })
114 | .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
115 | @Override
116 | public void onClick(SweetAlertDialog sDialog) {
117 | sDialog.setTitleText("Deleted!")
118 | .setContentText("Your imaginary file has been deleted!")
119 | .setConfirmText("OK")
120 | .showCancelButton(false)
121 | .setCancelClickListener(null)
122 | .setConfirmClickListener(null)
123 | .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
124 | }
125 | })
126 | .show();
127 | break;
128 | case R.id.custom_img_test:
129 | new SweetAlertDialog(this, SweetAlertDialog.CUSTOM_IMAGE_TYPE)
130 | .setTitleText("Sweet!")
131 | .setContentText("Here's a custom image.")
132 | .setCustomImage(R.drawable.custom_img)
133 | .setConfirmText("OK")
134 | .show();
135 | break;
136 | case R.id.progress_dialog:
137 | final SweetAlertDialog pDialog = new SweetAlertDialog(this, SweetAlertDialog.PROGRESS_TYPE)
138 | .setTitleText("Loading");
139 | pDialog.show();
140 | pDialog.setCancelable(false);
141 | new CountDownTimer(800 * 3, 800) {
142 | public void onTick(long millisUntilFinished) {
143 | // you can change the progress bar color by ProgressHelper every 800 millis
144 | i++;
145 | switch (i) {
146 | case 0:
147 | pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.blue_btn_bg_color));
148 | break;
149 | case 1:
150 | pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.material_deep_teal_50));
151 | break;
152 | case 2:
153 | pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.success_stroke_color));
154 | break;
155 | case 3:
156 | pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.material_deep_teal_20));
157 | break;
158 | case 4:
159 | pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.material_blue_grey_80));
160 | break;
161 | case 5:
162 | pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.warning_stroke_color));
163 | break;
164 | case 6:
165 | pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.success_stroke_color));
166 | break;
167 | }
168 | }
169 |
170 | public void onFinish() {
171 | i = -1;
172 | pDialog.setTitleText("Success!")
173 | .setConfirmText("OK")
174 | .changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
175 | }
176 | }.start();
177 | break;
178 | }
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/library/src/main/java/com/cazaea/sweetalert/SweetAlertDialog.java:
--------------------------------------------------------------------------------
1 | package com.cazaea.sweetalert;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.graphics.drawable.Drawable;
6 | import android.os.Build;
7 | import android.os.Bundle;
8 | import android.view.View;
9 | import android.view.WindowManager;
10 | import android.view.animation.AlphaAnimation;
11 | import android.view.animation.Animation;
12 | import android.view.animation.AnimationSet;
13 | import android.view.animation.Transformation;
14 | import android.widget.Button;
15 | import android.widget.FrameLayout;
16 | import android.widget.ImageView;
17 | import android.widget.TextView;
18 |
19 | import com.cazaea.materialishprogress.ProgressWheel;
20 |
21 | import java.util.List;
22 |
23 | public class SweetAlertDialog extends Dialog implements View.OnClickListener {
24 | private View mDialogView;
25 | private AnimationSet mModalInAnim;
26 | private AnimationSet mModalOutAnim;
27 | private Animation mOverlayOutAnim;
28 | private Animation mErrorInAnim;
29 | private AnimationSet mErrorXInAnim;
30 | private AnimationSet mSuccessLayoutAnimSet;
31 | private Animation mSuccessBowAnim;
32 | private TextView mTitleTextView;
33 | private TextView mContentTextView;
34 | private String mTitleText;
35 | private String mContentText;
36 | private boolean mShowCancel;
37 | private boolean mShowConfirm;
38 | private boolean mShowContent;
39 | private String mCancelText;
40 | private String mConfirmText;
41 | private int mAlertType;
42 | private FrameLayout mErrorFrame;
43 | private FrameLayout mSuccessFrame;
44 | private FrameLayout mProgressFrame;
45 | private SuccessTickView mSuccessTick;
46 | private ImageView mErrorX;
47 | private View mSuccessLeftMask;
48 | private View mSuccessRightMask;
49 | private Drawable mCustomImgDrawable;
50 | private ImageView mCustomImage;
51 | private Button mConfirmButton;
52 | private Button mCancelButton;
53 | private ProgressHelper mProgressHelper;
54 | private FrameLayout mWarningFrame;
55 | private OnSweetClickListener mCancelClickListener;
56 | private OnSweetClickListener mConfirmClickListener;
57 | private boolean mCloseFromCancel;
58 |
59 | public static final int NORMAL_TYPE = 0;
60 | public static final int ERROR_TYPE = 1;
61 | public static final int SUCCESS_TYPE = 2;
62 | public static final int WARNING_TYPE = 3;
63 | public static final int CUSTOM_IMAGE_TYPE = 4;
64 | public static final int PROGRESS_TYPE = 5;
65 |
66 | public static interface OnSweetClickListener {
67 | public void onClick(SweetAlertDialog sweetAlertDialog);
68 | }
69 |
70 | public SweetAlertDialog(Context context) {
71 | this(context, NORMAL_TYPE);
72 | }
73 |
74 | public SweetAlertDialog(Context context, int alertType) {
75 | super(context, R.style.alert_dialog);
76 | setCancelable(true);
77 | setCanceledOnTouchOutside(false);
78 | mProgressHelper = new ProgressHelper(context);
79 | mAlertType = alertType;
80 | mErrorInAnim = OptAnimationLoader.loadAnimation(getContext(), R.anim.error_frame_in);
81 | mErrorXInAnim = (AnimationSet)OptAnimationLoader.loadAnimation(getContext(), R.anim.error_x_in);
82 | // 2.3.x system don't support alpha-animation on layer-list drawable
83 | // remove it from animation set
84 | if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
85 | List childAnims = mErrorXInAnim.getAnimations();
86 | int idx = 0;
87 | for (;idx < childAnims.size();idx++) {
88 | if (childAnims.get(idx) instanceof AlphaAnimation) {
89 | break;
90 | }
91 | }
92 | if (idx < childAnims.size()) {
93 | childAnims.remove(idx);
94 | }
95 | }
96 | mSuccessBowAnim = OptAnimationLoader.loadAnimation(getContext(), R.anim.success_bow_roate);
97 | mSuccessLayoutAnimSet = (AnimationSet)OptAnimationLoader.loadAnimation(getContext(), R.anim.success_mask_layout);
98 | mModalInAnim = (AnimationSet) OptAnimationLoader.loadAnimation(getContext(), R.anim.modal_in);
99 | mModalOutAnim = (AnimationSet) OptAnimationLoader.loadAnimation(getContext(), R.anim.modal_out);
100 | mModalOutAnim.setAnimationListener(new Animation.AnimationListener() {
101 | @Override
102 | public void onAnimationStart(Animation animation) {
103 |
104 | }
105 |
106 | @Override
107 | public void onAnimationEnd(Animation animation) {
108 | mDialogView.setVisibility(View.GONE);
109 | mDialogView.post(new Runnable() {
110 | @Override
111 | public void run() {
112 | if (mCloseFromCancel) {
113 | SweetAlertDialog.super.cancel();
114 | } else {
115 | SweetAlertDialog.super.dismiss();
116 | }
117 | }
118 | });
119 | }
120 |
121 | @Override
122 | public void onAnimationRepeat(Animation animation) {
123 |
124 | }
125 | });
126 | // dialog overlay fade out
127 | mOverlayOutAnim = new Animation() {
128 | @Override
129 | protected void applyTransformation(float interpolatedTime, Transformation t) {
130 | WindowManager.LayoutParams wlp = getWindow().getAttributes();
131 | wlp.alpha = 1 - interpolatedTime;
132 | getWindow().setAttributes(wlp);
133 | }
134 | };
135 | mOverlayOutAnim.setDuration(120);
136 | }
137 |
138 | protected void onCreate(Bundle savedInstanceState) {
139 | super.onCreate(savedInstanceState);
140 | setContentView(R.layout.alert_dialog);
141 |
142 | mDialogView = getWindow().getDecorView().findViewById(android.R.id.content);
143 | mTitleTextView = (TextView)findViewById(R.id.title_text);
144 | mContentTextView = (TextView)findViewById(R.id.content_text);
145 | mErrorFrame = (FrameLayout)findViewById(R.id.error_frame);
146 | mErrorX = (ImageView)mErrorFrame.findViewById(R.id.error_x);
147 | mSuccessFrame = (FrameLayout)findViewById(R.id.success_frame);
148 | mProgressFrame = (FrameLayout)findViewById(R.id.progress_dialog);
149 | mSuccessTick = (SuccessTickView)mSuccessFrame.findViewById(R.id.success_tick);
150 | mSuccessLeftMask = mSuccessFrame.findViewById(R.id.mask_left);
151 | mSuccessRightMask = mSuccessFrame.findViewById(R.id.mask_right);
152 | mCustomImage = (ImageView)findViewById(R.id.custom_image);
153 | mWarningFrame = (FrameLayout)findViewById(R.id.warning_frame);
154 | mConfirmButton = (Button)findViewById(R.id.confirm_button);
155 | mCancelButton = (Button)findViewById(R.id.cancel_button);
156 | mProgressHelper.setProgressWheel((ProgressWheel)findViewById(R.id.progressWheel));
157 | mConfirmButton.setOnClickListener(this);
158 | mCancelButton.setOnClickListener(this);
159 |
160 | setTitleText(mTitleText);
161 | setContentText(mContentText);
162 | setCancelText(mCancelText);
163 | setConfirmText(mConfirmText);
164 | changeAlertType(mAlertType, true);
165 |
166 | }
167 |
168 | private void restore () {
169 | mCustomImage.setVisibility(View.GONE);
170 | mErrorFrame.setVisibility(View.GONE);
171 | mSuccessFrame.setVisibility(View.GONE);
172 | mWarningFrame.setVisibility(View.GONE);
173 | mProgressFrame.setVisibility(View.GONE);
174 | mConfirmButton.setVisibility(View.VISIBLE);
175 |
176 | mConfirmButton.setBackgroundResource(R.drawable.blue_button_background);
177 | mErrorFrame.clearAnimation();
178 | mErrorX.clearAnimation();
179 | mSuccessTick.clearAnimation();
180 | mSuccessLeftMask.clearAnimation();
181 | mSuccessRightMask.clearAnimation();
182 | }
183 |
184 | private void playAnimation () {
185 | if (mAlertType == ERROR_TYPE) {
186 | mErrorFrame.startAnimation(mErrorInAnim);
187 | mErrorX.startAnimation(mErrorXInAnim);
188 | } else if (mAlertType == SUCCESS_TYPE) {
189 | mSuccessTick.startTickAnim();
190 | mSuccessRightMask.startAnimation(mSuccessBowAnim);
191 | }
192 | }
193 |
194 | private void changeAlertType(int alertType, boolean fromCreate) {
195 | mAlertType = alertType;
196 | // call after created views
197 | if (mDialogView != null) {
198 | if (!fromCreate) {
199 | // restore all of views state before switching alert type
200 | restore();
201 | }
202 | switch (mAlertType) {
203 | case ERROR_TYPE:
204 | mErrorFrame.setVisibility(View.VISIBLE);
205 | break;
206 | case SUCCESS_TYPE:
207 | mSuccessFrame.setVisibility(View.VISIBLE);
208 | // initial rotate layout of success mask
209 | mSuccessLeftMask.startAnimation(mSuccessLayoutAnimSet.getAnimations().get(0));
210 | mSuccessRightMask.startAnimation(mSuccessLayoutAnimSet.getAnimations().get(1));
211 | break;
212 | case WARNING_TYPE:
213 | mConfirmButton.setBackgroundResource(R.drawable.red_button_background);
214 | mWarningFrame.setVisibility(View.VISIBLE);
215 | break;
216 | case CUSTOM_IMAGE_TYPE:
217 | setCustomImage(mCustomImgDrawable);
218 | break;
219 | case PROGRESS_TYPE:
220 | mProgressFrame.setVisibility(View.VISIBLE);
221 | mConfirmButton.setVisibility(View.GONE);
222 | break;
223 | }
224 | if (!fromCreate) {
225 | playAnimation();
226 | }
227 | }
228 | }
229 |
230 | public int getAlerType () {
231 | return mAlertType;
232 | }
233 |
234 | public void changeAlertType(int alertType) {
235 | changeAlertType(alertType, false);
236 | }
237 |
238 |
239 | public String getTitleText () {
240 | return mTitleText;
241 | }
242 |
243 | public SweetAlertDialog setTitleText (String text) {
244 | mTitleText = text;
245 | if (mTitleTextView != null && mTitleText != null) {
246 | mTitleTextView.setText(mTitleText);
247 | }
248 | return this;
249 | }
250 |
251 | public SweetAlertDialog setCustomImage (Drawable drawable) {
252 | mCustomImgDrawable = drawable;
253 | if (mCustomImage != null && mCustomImgDrawable != null) {
254 | mCustomImage.setVisibility(View.VISIBLE);
255 | mCustomImage.setImageDrawable(mCustomImgDrawable);
256 | }
257 | return this;
258 | }
259 |
260 | public SweetAlertDialog setCustomImage (int resourceId) {
261 | return setCustomImage(getContext().getResources().getDrawable(resourceId));
262 | }
263 |
264 | public String getContentText () {
265 | return mContentText;
266 | }
267 |
268 | public SweetAlertDialog setContentText (String text) {
269 | mContentText = text;
270 | if (mContentTextView != null && mContentText != null) {
271 | showContentText(true);
272 | mContentTextView.setText(mContentText);
273 | }
274 | return this;
275 | }
276 |
277 | public SweetAlertDialog showCancelButton (boolean isShow) {
278 | mShowCancel = isShow;
279 | if (mCancelButton != null) {
280 | mCancelButton.setVisibility(mShowCancel ? View.VISIBLE : View.GONE);
281 | }
282 | return this;
283 | }
284 |
285 | public SweetAlertDialog showConfirmButton (boolean isShow) {
286 | mShowConfirm = isShow;
287 | if (mConfirmButton != null) {
288 | mConfirmButton.setVisibility(mShowConfirm ? View.VISIBLE : View.GONE);
289 | }
290 | return this;
291 | }
292 |
293 | public SweetAlertDialog showContentText (boolean isShow) {
294 | mShowContent = isShow;
295 | if (mContentTextView != null) {
296 | mContentTextView.setVisibility(mShowContent ? View.VISIBLE : View.GONE);
297 | }
298 | return this;
299 | }
300 |
301 | public String getCancelText () {
302 | return mCancelText;
303 | }
304 |
305 | public SweetAlertDialog setCancelText (String text) {
306 | mCancelText = text;
307 | if (mCancelButton != null && mCancelText != null) {
308 | showCancelButton(true);
309 | mCancelButton.setText(mCancelText);
310 | }
311 | return this;
312 | }
313 |
314 | public String getConfirmText () {
315 | return mConfirmText;
316 | }
317 |
318 | public SweetAlertDialog setConfirmText (String text) {
319 | mConfirmText = text;
320 | if (mConfirmButton != null && mConfirmText != null) {
321 | showConfirmButton(true);
322 | mConfirmButton.setText(mConfirmText);
323 | }
324 | return this;
325 | }
326 |
327 | public SweetAlertDialog setCancelClickListener (OnSweetClickListener listener) {
328 | mCancelClickListener = listener;
329 | return this;
330 | }
331 |
332 | public SweetAlertDialog setConfirmClickListener (OnSweetClickListener listener) {
333 | mConfirmClickListener = listener;
334 | return this;
335 | }
336 |
337 | protected void onStart() {
338 | mDialogView.startAnimation(mModalInAnim);
339 | playAnimation();
340 | }
341 |
342 | /**
343 | * The real Dialog.cancel() will be invoked async-ly after the animation finishes.
344 | */
345 | @Override
346 | public void cancel() {
347 | dismissWithAnimation(true);
348 | }
349 |
350 | /**
351 | * The real Dialog.dismiss() will be invoked async-ly after the animation finishes.
352 | */
353 | public void dismissWithAnimation() {
354 | dismissWithAnimation(false);
355 | }
356 |
357 | private void dismissWithAnimation(boolean fromCancel) {
358 | mCloseFromCancel = fromCancel;
359 | mConfirmButton.startAnimation(mOverlayOutAnim);
360 | mDialogView.startAnimation(mModalOutAnim);
361 | }
362 |
363 | @Override
364 | public void onClick(View v) {
365 | if (v.getId() == R.id.cancel_button) {
366 | if (mCancelClickListener != null) {
367 | mCancelClickListener.onClick(SweetAlertDialog.this);
368 | } else {
369 | dismissWithAnimation();
370 | }
371 | } else if (v.getId() == R.id.confirm_button) {
372 | if (mConfirmClickListener != null) {
373 | mConfirmClickListener.onClick(SweetAlertDialog.this);
374 | } else {
375 | dismissWithAnimation();
376 | }
377 | }
378 | }
379 |
380 | public ProgressHelper getProgressHelper () {
381 | return mProgressHelper;
382 | }
383 | }
--------------------------------------------------------------------------------