diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7bdfe81
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,51 @@
+# Built application files
+*.apk
+*.ap_
+
+# Files for the ART/Dalvik VM
+*.dex
+
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+
+# Gradle files
+.gradle/
+build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
+*.log
+
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# Intellij
+*.iml
+.idea/
+
+# Keystore files
+*.jks
+
+# External native build folder generated in Android Studio 2.2 and later
+.externalNativeBuild
+
+# Google Services (e.g. APIs or Firebase)
+google-services.json
+
+# Freeline
+freeline.py
+freeline/
+freeline_project_description.json
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..e698e83
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1,2 @@
+/build
+*.iml
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..1313735
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,30 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.3"
+ defaultConfig {
+ applicationId "com.jsheng.safedialogfragment.sample"
+ minSdkVersion 16
+ targetSdkVersion 25
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ compile 'com.android.support:appcompat-v7:25.3.1'
+ compile 'com.android.support.constraint:constraint-layout:1.0.2'
+ testCompile 'junit:junit:4.12'
+}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..dec2a29
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,25 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in D:\Android\sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/app/src/androidTest/java/com/jsheng/safedialogfragment/sample/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/jsheng/safedialogfragment/sample/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..dc0b5bb
--- /dev/null
+++ b/app/src/androidTest/java/com/jsheng/safedialogfragment/sample/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.jsheng.safedialogfragment.sample;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumentation test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.jsheng.safedialogfragment.sample", appContext.getPackageName());
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..be8993b
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/jsheng/safedialogfragment/sample/MainActivity.java b/app/src/main/java/com/jsheng/safedialogfragment/sample/MainActivity.java
new file mode 100644
index 0000000..79d816a
--- /dev/null
+++ b/app/src/main/java/com/jsheng/safedialogfragment/sample/MainActivity.java
@@ -0,0 +1,13 @@
+package com.jsheng.safedialogfragment.sample;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+
+public class MainActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..aeee4b3
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..cde69bc
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000..9a078e3
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c133a0c
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000..efc028a
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..bfa42f0
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..3af2608
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..324e72c
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..9bec2e6
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..aee44e1
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..34947cd
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/values-v19/dimens.xml b/app/src/main/res/values-v19/dimens.xml
new file mode 100644
index 0000000..54283dd
--- /dev/null
+++ b/app/src/main/res/values-v19/dimens.xml
@@ -0,0 +1,4 @@
+
+
+ 25dp
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..2a12c47
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #3F51B5
+ #303F9F
+ #FF4081
+
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..9d7d63d
--- /dev/null
+++ b/app/src/main/res/values/dimens.xml
@@ -0,0 +1,4 @@
+
+
+ 0dp
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..3994512
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ SafeDialogFragment
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..d39d37b
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/app/src/test/java/com/jsheng/safedialogfragment/sample/ExampleUnitTest.java b/app/src/test/java/com/jsheng/safedialogfragment/sample/ExampleUnitTest.java
new file mode 100644
index 0000000..573b7f1
--- /dev/null
+++ b/app/src/test/java/com/jsheng/safedialogfragment/sample/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.jsheng.safedialogfragment.sample;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..684d23a
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,25 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:2.3.3'
+ // https://jitpack.io/docs/ANDROID/
+ classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..3530b01
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,17 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..13372ae
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..eb38d30
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Jul 25 17:23:56 CST 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..9d82f78
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/library/.gitignore b/library/.gitignore
new file mode 100644
index 0000000..e698e83
--- /dev/null
+++ b/library/.gitignore
@@ -0,0 +1,2 @@
+/build
+*.iml
diff --git a/library/build.gradle b/library/build.gradle
new file mode 100644
index 0000000..b224cc9
--- /dev/null
+++ b/library/build.gradle
@@ -0,0 +1,62 @@
+apply plugin: 'com.android.library'
+apply plugin: 'com.github.dcendents.android-maven'
+
+group='com.github.flztsj'
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.3"
+
+ defaultConfig {
+ minSdkVersion 16
+ targetSdkVersion 25
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ // 指定编码
+ tasks.withType(JavaCompile) {
+ options.encoding = "UTF-8"
+ }
+
+ // 打包源码
+ task sourcesJar(type: Jar) {
+ from android.sourceSets.main.java.srcDirs
+ classifier = 'sources'
+ }
+
+// task javadoc(type: Javadoc) {
+// failOnError false
+// source = android.sourceSets.main.java.sourceFiles
+// classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+// classpath += configurations.compile
+// }
+
+// // 制作文档(Javadoc)
+// task javadocJar(type: Jar, dependsOn: javadoc) {
+// classifier = 'javadoc'
+// from javadoc.destinationDir
+// }
+
+ artifacts {
+ archives sourcesJar
+// archives javadocJar
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ compile 'com.android.support:appcompat-v7:25.3.1'
+ testCompile 'junit:junit:4.12'
+}
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
new file mode 100644
index 0000000..dec2a29
--- /dev/null
+++ b/library/proguard-rules.pro
@@ -0,0 +1,25 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in D:\Android\sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/library/src/androidTest/java/android/support/v4/app/ExampleInstrumentedTest.java b/library/src/androidTest/java/android/support/v4/app/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..3eeaa7f
--- /dev/null
+++ b/library/src/androidTest/java/android/support/v4/app/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package android.support.v4.app;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumentation test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("android.support.v4.app.test", appContext.getPackageName());
+ }
+}
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..4cfd2e8
--- /dev/null
+++ b/library/src/main/AndroidManifest.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
diff --git a/library/src/main/java/android/support/v4/app/SafeDialogFragment.java b/library/src/main/java/android/support/v4/app/SafeDialogFragment.java
new file mode 100644
index 0000000..00d15e0
--- /dev/null
+++ b/library/src/main/java/android/support/v4/app/SafeDialogFragment.java
@@ -0,0 +1,539 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.app;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.support.annotation.IntDef;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.RestrictTo;
+import android.support.annotation.StyleRes;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import static android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP;
+
+/**
+ * Static library support version of the framework's {@link android.app.DialogFragment}.
+ * Used to write apps that run on platforms prior to Android 3.0. When running
+ * on Android 3.0 or above, this implementation is still used; it does not try
+ * to switch to the framework's implementation. See the framework SDK
+ * documentation for a class overview.
+ */
+public class SafeDialogFragment extends Fragment
+ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener {
+
+ /** @hide */
+ @RestrictTo(LIBRARY_GROUP)
+ @IntDef({STYLE_NORMAL, STYLE_NO_TITLE, STYLE_NO_FRAME, STYLE_NO_INPUT})
+ @Retention(RetentionPolicy.SOURCE)
+ private @interface DialogStyle {}
+
+ /**
+ * Style for {@link #setStyle(int, int)}: a basic,
+ * normal dialog.
+ */
+ public static final int STYLE_NORMAL = 0;
+
+ /**
+ * Style for {@link #setStyle(int, int)}: don't include
+ * a title area.
+ */
+ public static final int STYLE_NO_TITLE = 1;
+
+ /**
+ * Style for {@link #setStyle(int, int)}: don't draw
+ * any frame at all; the view hierarchy returned by {@link #onCreateView}
+ * is entirely responsible for drawing the dialog.
+ */
+ public static final int STYLE_NO_FRAME = 2;
+
+ /**
+ * Style for {@link #setStyle(int, int)}: like
+ * {@link #STYLE_NO_FRAME}, but also disables all input to the dialog.
+ * The user can not touch it, and its window will not receive input focus.
+ */
+ public static final int STYLE_NO_INPUT = 3;
+
+ private static final String SAVED_DIALOG_STATE_TAG = "android:savedDialogState";
+ private static final String SAVED_STYLE = "android:style";
+ private static final String SAVED_THEME = "android:theme";
+ private static final String SAVED_CANCELABLE = "android:cancelable";
+ private static final String SAVED_SHOWS_DIALOG = "android:showsDialog";
+ private static final String SAVED_BACK_STACK_ID = "android:backStackId";
+
+ int mStyle = STYLE_NORMAL;
+ int mTheme = 0;
+ boolean mCancelable = true;
+ boolean mShowsDialog = true;
+ int mBackStackId = -1;
+
+ Dialog mDialog;
+ boolean mViewDestroyed;
+ boolean mDismissed;
+ boolean mShownByMe;
+
+ public SafeDialogFragment() {
+ }
+
+ /**
+ * Call to customize the basic appearance and behavior of the
+ * fragment's dialog. This can be used for some common dialog behaviors,
+ * taking care of selecting flags, theme, and other options for you. The
+ * same effect can be achieve by manually setting Dialog and Window
+ * attributes yourself. Calling this after the fragment's Dialog is
+ * created will have no effect.
+ *
+ * @param style Selects a standard style: may be {@link #STYLE_NORMAL},
+ * {@link #STYLE_NO_TITLE}, {@link #STYLE_NO_FRAME}, or
+ * {@link #STYLE_NO_INPUT}.
+ * @param theme Optional custom theme. If 0, an appropriate theme (based
+ * on the style) will be selected for you.
+ */
+ public void setStyle(@DialogStyle int style, @StyleRes int theme) {
+ mStyle = style;
+ if (mStyle == STYLE_NO_FRAME || mStyle == STYLE_NO_INPUT) {
+ mTheme = android.R.style.Theme_Panel;
+ }
+ if (theme != 0) {
+ mTheme = theme;
+ }
+ }
+
+ /**
+ * Display the dialog, adding the fragment to the given FragmentManager. This
+ * is a convenience for explicitly creating a transaction, adding the
+ * fragment to it with the given tag, and committing it. This does
+ * not add the transaction to the back stack. When the fragment
+ * is dismissed, a new transaction will be executed to remove it from
+ * the activity.
+ * @param manager The FragmentManager this fragment will be added to.
+ * @param tag The tag for this fragment, as per
+ * {@link FragmentTransaction#add(Fragment, String) FragmentTransaction.add}.
+ */
+ public void show(FragmentManager manager, String tag) {
+ mDismissed = false;
+ mShownByMe = true;
+ FragmentTransaction ft = manager.beginTransaction();
+ ft.add(this, tag);
+ ft.commit();
+ }
+
+ /**
+ * add by jun.sheng
+ */
+ public void showNow(FragmentManager manager, String tag) {
+ mDismissed = false;
+ mShownByMe = true;
+ FragmentTransaction ft = manager.beginTransaction();
+ ft.add(this, tag);
+ ft.commitNow();
+ }
+
+ /**
+ * add by jun.sheng
+ */
+ public void showAllowingStateLoss(FragmentManager manager, String tag) {
+ mDismissed = false;
+ mShownByMe = true;
+ FragmentTransaction ft = manager.beginTransaction();
+ ft.add(this, tag);
+ ft.commitAllowingStateLoss();
+ }
+
+ /**
+ * add by jun.sheng
+ */
+ public void showNowAllowingStateLoss(FragmentManager manager, String tag) {
+ mDismissed = false;
+ mShownByMe = true;
+ FragmentTransaction ft = manager.beginTransaction();
+ ft.add(this, tag);
+ ft.commitNowAllowingStateLoss();
+ }
+
+ /**
+ * Display the dialog, adding the fragment using an existing transaction
+ * and then committing the transaction.
+ * @param transaction An existing transaction in which to add the fragment.
+ * @param tag The tag for this fragment, as per
+ * {@link FragmentTransaction#add(Fragment, String) FragmentTransaction.add}.
+ * @return Returns the identifier of the committed transaction, as per
+ * {@link FragmentTransaction#commit() FragmentTransaction.commit()}.
+ */
+ public int show(FragmentTransaction transaction, String tag) {
+ mDismissed = false;
+ mShownByMe = true;
+ transaction.add(this, tag);
+ mViewDestroyed = false;
+ mBackStackId = transaction.commit();
+ return mBackStackId;
+ }
+
+ /**
+ * add by jun.sheng
+ */
+ public int showAllowingStateLoss(FragmentTransaction transaction, String tag) {
+ mDismissed = false;
+ mShownByMe = true;
+ transaction.add(this, tag);
+ mViewDestroyed = false;
+ mBackStackId = transaction.commitAllowingStateLoss();
+ return mBackStackId;
+ }
+
+ /**
+ * Dismiss the fragment and its dialog. If the fragment was added to the
+ * back stack, all back stack state up to and including this entry will
+ * be popped. Otherwise, a new transaction will be committed to remove
+ * the fragment.
+ */
+ public void dismiss() {
+ dismissInternal(false, false);
+ }
+
+ /**
+ * add by jun.sheng
+ */
+ public void dismissNow() {
+ dismissInternal(false, true);
+ }
+
+ /**
+ * Version of {@link #dismiss()} that uses
+ * {@link FragmentTransaction#commitAllowingStateLoss()
+ * FragmentTransaction.commitAllowingStateLoss()}. See linked
+ * documentation for further details.
+ */
+ public void dismissAllowingStateLoss() {
+ dismissInternal(true, false);
+ }
+
+ /**
+ * add by jun.sheng
+ */
+ public void dismissNowAllowingStateLoss() {
+ dismissInternal(true, true);
+ }
+
+ void dismissInternal(boolean allowStateLoss, boolean now) {
+ if (mDismissed) {
+ return;
+ }
+ mDismissed = true;
+ mShownByMe = false;
+ if (mDialog != null) {
+ mDialog.dismiss();
+ mDialog = null;
+ }
+ mViewDestroyed = true;
+ if (mBackStackId >= 0) {
+ getFragmentManager().popBackStack(mBackStackId,
+ FragmentManager.POP_BACK_STACK_INCLUSIVE);
+ mBackStackId = -1;
+ } else {
+ FragmentTransaction ft = getFragmentManager().beginTransaction();
+ ft.remove(this);
+ if (allowStateLoss) {
+ if (now) {
+ ft.commitNowAllowingStateLoss();
+ } else {
+ ft.commitAllowingStateLoss();
+ }
+ } else {
+ if (now) {
+ ft.commitAllowingStateLoss();
+ } else {
+ ft.commit();
+ }
+ }
+ }
+ }
+
+ public Dialog getDialog() {
+ return mDialog;
+ }
+
+ @StyleRes
+ public int getTheme() {
+ return mTheme;
+ }
+
+ /**
+ * Control whether the shown Dialog is cancelable. Use this instead of
+ * directly calling {@link Dialog#setCancelable(boolean)
+ * Dialog.setCancelable(boolean)}, because android.support.v4.app.SafeDialogFragment needs to change
+ * its behavior based on this.
+ *
+ * @param cancelable If true, the dialog is cancelable. The default
+ * is true.
+ */
+ public void setCancelable(boolean cancelable) {
+ mCancelable = cancelable;
+ if (mDialog != null) mDialog.setCancelable(cancelable);
+ }
+
+ /**
+ * Return the current value of {@link #setCancelable(boolean)}.
+ */
+ public boolean isCancelable() {
+ return mCancelable;
+ }
+
+ /**
+ * Controls whether this fragment should be shown in a dialog. If not
+ * set, no Dialog will be created in {@link #onActivityCreated(Bundle)},
+ * and the fragment's view hierarchy will thus not be added to it. This
+ * allows you to instead use it as a normal fragment (embedded inside of
+ * its activity).
+ *
+ *
This is normally set for you based on whether the fragment is
+ * associated with a container view ID passed to
+ * {@link FragmentTransaction#add(int, Fragment) FragmentTransaction.add(int, Fragment)}.
+ * If the fragment was added with a container, setShowsDialog will be
+ * initialized to false; otherwise, it will be true.
+ *
+ * @param showsDialog If true, the fragment will be displayed in a Dialog.
+ * If false, no Dialog will be created and the fragment's view hierarchy
+ * left undisturbed.
+ */
+ public void setShowsDialog(boolean showsDialog) {
+ mShowsDialog = showsDialog;
+ }
+
+ /**
+ * Return the current value of {@link #setShowsDialog(boolean)}.
+ */
+ public boolean getShowsDialog() {
+ return mShowsDialog;
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ if (!mShownByMe) {
+ // If not explicitly shown through our API, take this as an
+ // indication that the dialog is no longer dismissed.
+ mDismissed = false;
+ }
+ }
+
+ @Override
+ public void onDetach() {
+ super.onDetach();
+ if (!mShownByMe && !mDismissed) {
+ // The fragment was not shown by a direct call here, it is not
+ // dismissed, and now it is being detached... well, okay, thou
+ // art now dismissed. Have fun.
+ mDismissed = true;
+ }
+ }
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mShowsDialog = mContainerId == 0;
+
+ if (savedInstanceState != null) {
+ mStyle = savedInstanceState.getInt(SAVED_STYLE, STYLE_NORMAL);
+ mTheme = savedInstanceState.getInt(SAVED_THEME, 0);
+ mCancelable = savedInstanceState.getBoolean(SAVED_CANCELABLE, true);
+ mShowsDialog = savedInstanceState.getBoolean(SAVED_SHOWS_DIALOG, mShowsDialog);
+ mBackStackId = savedInstanceState.getInt(SAVED_BACK_STACK_ID, -1);
+ }
+ }
+
+ /** @hide */
+ @RestrictTo(LIBRARY_GROUP)
+ @Override
+ public LayoutInflater getLayoutInflater(Bundle savedInstanceState) {
+ if (!mShowsDialog) {
+ return super.getLayoutInflater(savedInstanceState);
+ }
+
+ mDialog = onCreateDialog(savedInstanceState);
+
+ if (mDialog != null) {
+ setupDialog(mDialog, mStyle);
+
+ return (LayoutInflater) mDialog.getContext().getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ }
+ return (LayoutInflater) mHost.getContext().getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+ /** @hide */
+ @RestrictTo(LIBRARY_GROUP)
+ public void setupDialog(Dialog dialog, int style) {
+ switch (style) {
+ case STYLE_NO_INPUT:
+ dialog.getWindow().addFlags(
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
+ WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
+ // fall through...
+ case STYLE_NO_FRAME:
+ case STYLE_NO_TITLE:
+ dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
+ }
+ }
+
+ /**
+ * Override to build your own custom Dialog container. This is typically
+ * used to show an AlertDialog instead of a generic Dialog; when doing so,
+ * {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)} does not need
+ * to be implemented since the AlertDialog takes care of its own content.
+ *
+ *
This method will be called after {@link #onCreate(Bundle)} and
+ * before {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}. The
+ * default implementation simply instantiates and returns a {@link Dialog}
+ * class.
+ *
+ *
Note: android.support.v4.app.SafeDialogFragment own the {@link Dialog#setOnCancelListener
+ * Dialog.setOnCancelListener} and {@link Dialog#setOnDismissListener
+ * Dialog.setOnDismissListener} callbacks. You must not set them yourself.
+ * To find out about these events, override {@link #onCancel(DialogInterface)}
+ * and {@link #onDismiss(DialogInterface)}.
+ *
+ * @param savedInstanceState The last saved instance state of the Fragment,
+ * or null if this is a freshly created Fragment.
+ *
+ * @return Return a new Dialog instance to be displayed by the Fragment.
+ */
+ @NonNull
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ return new Dialog(getActivity(), getTheme());
+ }
+
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ }
+
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ if (!mViewDestroyed) {
+ // Note: we need to use allowStateLoss, because the dialog
+ // dispatches this asynchronously so we can receive the call
+ // after the activity is paused. Worst case, when the user comes
+ // back to the activity they see the dialog again.
+ dismissInternal(true, false);
+ }
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ if (!mShowsDialog) {
+ return;
+ }
+
+ View view = getView();
+ if (view != null) {
+ if (view.getParent() != null) {
+ throw new IllegalStateException(
+ "android.support.v4.app.SafeDialogFragment can not be attached to a container view");
+ }
+ mDialog.setContentView(view);
+ }
+ final Activity activity = getActivity();
+ if (activity != null) {
+ mDialog.setOwnerActivity(activity);
+ }
+ mDialog.setCancelable(mCancelable);
+ mDialog.setOnCancelListener(this);
+ mDialog.setOnDismissListener(this);
+ if (savedInstanceState != null) {
+ Bundle dialogState = savedInstanceState.getBundle(SAVED_DIALOG_STATE_TAG);
+ if (dialogState != null) {
+ mDialog.onRestoreInstanceState(dialogState);
+ }
+ }
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ if (mDialog != null) {
+ mViewDestroyed = false;
+ mDialog.show();
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ if (mDialog != null) {
+ Bundle dialogState = mDialog.onSaveInstanceState();
+ if (dialogState != null) {
+ outState.putBundle(SAVED_DIALOG_STATE_TAG, dialogState);
+ }
+ }
+ if (mStyle != STYLE_NORMAL) {
+ outState.putInt(SAVED_STYLE, mStyle);
+ }
+ if (mTheme != 0) {
+ outState.putInt(SAVED_THEME, mTheme);
+ }
+ if (!mCancelable) {
+ outState.putBoolean(SAVED_CANCELABLE, mCancelable);
+ }
+ if (!mShowsDialog) {
+ outState.putBoolean(SAVED_SHOWS_DIALOG, mShowsDialog);
+ }
+ if (mBackStackId != -1) {
+ outState.putInt(SAVED_BACK_STACK_ID, mBackStackId);
+ }
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ if (mDialog != null) {
+ mDialog.hide();
+ }
+ }
+
+ /**
+ * Remove dialog.
+ */
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ if (mDialog != null) {
+ // Set removed here because this dismissal is just to hide
+ // the dialog -- we don't want this to cause the fragment to
+ // actually be removed.
+ mViewDestroyed = true;
+ mDialog.dismiss();
+ mDialog = null;
+ }
+ }
+}
+
diff --git a/library/src/test/java/android/support/v4/app/ExampleUnitTest.java b/library/src/test/java/android/support/v4/app/ExampleUnitTest.java
new file mode 100644
index 0000000..93ffa9a
--- /dev/null
+++ b/library/src/test/java/android/support/v4/app/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package android.support.v4.app;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..85b59a4
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':app', ':library'