├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── hei123
│ │ │ │ └── permissiondog
│ │ │ │ ├── ScreenShot
│ │ │ │ ├── never_get_permission.jpg
│ │ │ │ ├── request_multi_permission.jpg
│ │ │ │ ├── request_single_permission.jpg
│ │ │ │ └── failed_to_get_multi_permission.jpg
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── PermissionDog
│ │ │ │ └── PermissionDog.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── hei123
│ │ │ └── permissiondog
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── hei123
│ │ └── permissiondog
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── .idea
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── gradlew
└── README.md
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | PermissionDog
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hei12138/PermissionDog/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hei12138/PermissionDog/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hei12138/PermissionDog/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hei12138/PermissionDog/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hei12138/PermissionDog/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hei12138/PermissionDog/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/hei123/permissiondog/ScreenShot/never_get_permission.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hei12138/PermissionDog/HEAD/app/src/main/java/com/example/hei123/permissiondog/ScreenShot/never_get_permission.jpg
--------------------------------------------------------------------------------
/app/src/main/java/com/example/hei123/permissiondog/ScreenShot/request_multi_permission.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hei12138/PermissionDog/HEAD/app/src/main/java/com/example/hei123/permissiondog/ScreenShot/request_multi_permission.jpg
--------------------------------------------------------------------------------
/app/src/main/java/com/example/hei123/permissiondog/ScreenShot/request_single_permission.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hei12138/PermissionDog/HEAD/app/src/main/java/com/example/hei123/permissiondog/ScreenShot/request_single_permission.jpg
--------------------------------------------------------------------------------
/app/src/main/java/com/example/hei123/permissiondog/ScreenShot/failed_to_get_multi_permission.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hei12138/PermissionDog/HEAD/app/src/main/java/com/example/hei123/permissiondog/ScreenShot/failed_to_get_multi_permission.jpg
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/hei123/permissiondog/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.hei123.permissiondog;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
15 |
16 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\hei123\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/hei123/permissiondog/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.hei123.permissiondog;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.hei123.permissiondog", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
15 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.0"
6 | defaultConfig {
7 | applicationId "com.example.hei123.permissiondog"
8 | minSdkVersion 23
9 | targetSdkVersion 24
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:24.2.1'
28 | testCompile 'junit:junit:4.12'
29 | compile 'com.android.support:design:24.0.0'
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
13 |
14 |
19 |
24 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.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 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | Android API 24 Platform
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PermissionDog
2 | 权限狗 权限申请
3 | 最近在一家公司实习,项目中需要用到适配安卓6.0以上的系统,我本来是想用其他人已经写好的权限申请框架来实现的,但是发现跟我的需求有点小区别,所以就自己写了一个
4 |
5 | 这个权限申请的帮助类很小,只有一个java文件,复制到你的项目中就可以直接使用
6 |
7 | 没想到什么好名字 既然有权限,那就叫权限狗吧
8 | #使用截图
9 | 
10 |
请求单个权限
11 | 
12 |
请求多个权限
13 | 
14 |
请求多个权限失败
15 | 
16 |
请求多个权限时有权限勾选了不再提醒
17 | ##特性
18 |
19 | 1:支持单个和多个权限的申请
20 |
21 | 2:单个支持三个回调:允许,拒绝,勾中不再显示框并拒绝
22 |
23 | 3:多个权限回调时返回允许,拒绝,勾中不再显示框并拒绝的权限列表
24 | ##使用
25 |
26 | ###1.在你需要申请权限的Activity中重写onRequestPermissionsResult
27 | ```java
28 | @Override
29 | public void onRequestPermissionsResult(int requestCode,
30 | @NonNull String[] permissions,
31 | @NonNull int[] grantResults) {
32 | PermissionDog.getInstance().notifyPermissionsChanged(MainActivity.this, requestCode, permissions, grantResults);
33 | }
34 | ```
35 |
36 | ###2.在你需要申请权限的地方初始去添加一下代码
37 |
38 | ####请求单个权限
39 | ```java
40 | private void requestSinglePermission() {
41 | PermissionDog.getInstance().SetAction(new PermissionDog.PermissionDogAction() {
42 | @Override
43 | public void never() {
44 | super.never();
45 | //已经勾选了不再提醒
46 | Toast.makeText(MainActivity.this, "已经拒绝权限,请前往设置开启", Toast.LENGTH_SHORT).show();
47 | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
48 | Uri uri = Uri.fromParts("package", getPackageName(), null);
49 | intent.setData(uri);
50 | startActivityForResult(intent, REQUEST_PERMISSION_SETTING);
51 | }
52 |
53 | @Override
54 | public void denied() {
55 | super.denied();
56 | //未获取到权限
57 | Toast.makeText(MainActivity.this, "未获取到了单个权限", Toast.LENGTH_SHORT).show();
58 |
59 | }
60 |
61 | @Override
62 | public void grant() {
63 | super.grant();
64 | //获取到了权限
65 | Toast.makeText(MainActivity.this, "获取到了单个权限", Toast.LENGTH_SHORT).show();
66 |
67 | }
68 | });
69 | PermissionDog.getInstance().requestSinglePermissions(MainActivity.this, singlePermission);
70 | }
71 | ```
72 | ####请求多个权限
73 | ```java
74 | private void requestMultiPermission() {
75 | PermissionDog.getInstance().SetAction(new PermissionDog.PermissionDogAction() {
76 | @Override
77 | public void allallow() {
78 | super.allallow();
79 | //在此设置权限全部被允许后的操作
80 | Toast.makeText(MainActivity.this, "多个权限全部被允许", Toast.LENGTH_SHORT).show();
81 |
82 | }
83 |
84 | @Override
85 | public void multi(String[] granteds, String[] denieds, String[] nevershows) {
86 | if (nevershows.length != 0) {
87 | new AlertDialog.Builder(MainActivity.this, R.style.DialogTheme).setTitle("Permission")
88 | .setMessage("PermissionDog需要摄像头和拨打电话的权限")
89 | .setPositiveButton("前往设置", new DialogInterface.OnClickListener() {
90 | @Override
91 | public void onClick(DialogInterface dialog, int which) {
92 | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
93 | Uri uri = Uri.fromParts("package", getPackageName(), null);
94 | intent.setData(uri);
95 | startActivityForResult(intent, REQUEST_PERMISSION_SETTING);
96 | }
97 | }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
98 | @Override
99 | public void onClick(DialogInterface dialog, int which) {
100 | //有权限被勾选了不再提醒
101 | Toast.makeText(MainActivity.this, "有权限被勾选了不再提醒", Toast.LENGTH_SHORT).show();
102 | }
103 | }).create().show();
104 | } else {
105 | if (denieds.length != 0) {
106 | new AlertDialog.Builder(MainActivity.this, R.style.DialogTheme).setTitle("Permission")
107 | .setMessage("PermissionDog需要读写空间和拨打电话的权限")
108 | .setPositiveButton("获取", new DialogInterface.OnClickListener() {
109 | @Override
110 | public void onClick(DialogInterface dialog, int which) {
111 | PermissionDog.getInstance().requestMultiPermissions(MainActivity.this, multiPermission);
112 | }
113 | }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
114 | @Override
115 | public void onClick(DialogInterface dialog, int which) {
116 | Toast.makeText(MainActivity.this, "未获取到必要的权限", Toast.LENGTH_SHORT).show();
117 | }
118 | }).create().show();
119 | } else {
120 | //在此设置权限全部被允许后的操作
121 | Toast.makeText(MainActivity.this, "多个权限全部被允许", Toast.LENGTH_SHORT).show();
122 | }
123 | }
124 | }
125 | });
126 |
127 | PermissionDog.getInstance().requestMultiPermissions(MainActivity.this, multiPermission);
128 |
129 | }
130 | ```
131 | ###3.运行
132 |
133 | ##解释:
134 |
135 | 申请单个权限时重写never,denied,grant三个方法
136 | 申请多个权限时重写allallow,multi两个方法
137 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/hei123/permissiondog/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.hei123.permissiondog;
2 |
3 |
4 | import android.Manifest;
5 | import android.app.Activity;
6 |
7 | import android.content.DialogInterface;
8 | import android.content.Intent;
9 | import android.net.Uri;
10 | import android.provider.Settings;
11 | import android.support.annotation.NonNull;
12 |
13 | import android.os.Bundle;
14 | import android.support.v7.app.AlertDialog;
15 | import android.util.Log;
16 | import android.view.View;
17 | import android.widget.Toast;
18 |
19 | import com.example.hei123.permissiondog.PermissionDog.PermissionDog;
20 |
21 | public class MainActivity extends Activity {
22 |
23 | String[] multiPermission = new String[]{Manifest.permission.CAMERA,
24 | Manifest.permission.CALL_PHONE};
25 | String singlePermission = Manifest.permission.WRITE_EXTERNAL_STORAGE;
26 | private final int REQUEST_PERMISSION_SETTING = 0x001;
27 |
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_main);
32 | View btn_single = findViewById(R.id.btn_single);
33 | View btn_multi = findViewById(R.id.btn_multi);
34 | btn_single.setOnClickListener(new View.OnClickListener() {
35 | @Override
36 | public void onClick(View v) {
37 | requestSinglePermission();
38 | }
39 | });
40 | btn_multi.setOnClickListener(new View.OnClickListener() {
41 | @Override
42 | public void onClick(View v) {
43 | requestMultiPermission();
44 | }
45 | });
46 | }
47 |
48 | /**
49 | * 请求单个权限
50 | */
51 | private void requestSinglePermission() {
52 | PermissionDog.getInstance().SetAction(new PermissionDog.PermissionDogAction() {
53 | @Override
54 | public void never() {
55 | super.never();
56 | //已经勾选了不再提醒
57 | Toast.makeText(MainActivity.this, "已经拒绝权限,请前往设置开启", Toast.LENGTH_SHORT).show();
58 | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
59 | Uri uri = Uri.fromParts("package", getPackageName(), null);
60 | intent.setData(uri);
61 | startActivityForResult(intent, REQUEST_PERMISSION_SETTING);
62 | }
63 |
64 | @Override
65 | public void denied() {
66 | super.denied();
67 | //未获取到权限
68 | Toast.makeText(MainActivity.this, "未获取到了单个权限", Toast.LENGTH_SHORT).show();
69 |
70 | }
71 |
72 | @Override
73 | public void grant() {
74 | super.grant();
75 | //获取到了权限
76 | Toast.makeText(MainActivity.this, "获取到了单个权限", Toast.LENGTH_SHORT).show();
77 |
78 | }
79 | });
80 | PermissionDog.getInstance().requestSinglePermissions(MainActivity.this, singlePermission);
81 | }
82 |
83 | /**
84 | * 请求多个权限
85 | */
86 | private void requestMultiPermission() {
87 | PermissionDog.getInstance().SetAction(new PermissionDog.PermissionDogAction() {
88 | @Override
89 | public void allallow() {
90 | super.allallow();
91 | //在此设置权限全部被允许后的操作
92 | Toast.makeText(MainActivity.this, "多个权限全部被允许", Toast.LENGTH_SHORT).show();
93 |
94 | }
95 |
96 | @Override
97 | public void multi(String[] granteds, String[] denieds, String[] nevershows) {
98 | if (nevershows.length != 0) {
99 | new AlertDialog.Builder(MainActivity.this, R.style.DialogTheme).setTitle("Permission")
100 | .setMessage("PermissionDog需要摄像头和拨打电话的权限")
101 | .setPositiveButton("前往设置", new DialogInterface.OnClickListener() {
102 | @Override
103 | public void onClick(DialogInterface dialog, int which) {
104 | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
105 | Uri uri = Uri.fromParts("package", getPackageName(), null);
106 | intent.setData(uri);
107 | startActivityForResult(intent, REQUEST_PERMISSION_SETTING);
108 | }
109 | }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
110 | @Override
111 | public void onClick(DialogInterface dialog, int which) {
112 | //有权限被勾选了不再提醒
113 | Toast.makeText(MainActivity.this, "有权限被勾选了不再提醒", Toast.LENGTH_SHORT).show();
114 | }
115 | }).create().show();
116 | } else {
117 | if (denieds.length != 0) {
118 | new AlertDialog.Builder(MainActivity.this, R.style.DialogTheme).setTitle("Permission")
119 | .setMessage("PermissionDog需要读写空间和拨打电话的权限")
120 | .setPositiveButton("获取", new DialogInterface.OnClickListener() {
121 | @Override
122 | public void onClick(DialogInterface dialog, int which) {
123 | PermissionDog.getInstance().requestMultiPermissions(MainActivity.this, multiPermission);
124 | }
125 | }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
126 | @Override
127 | public void onClick(DialogInterface dialog, int which) {
128 | Toast.makeText(MainActivity.this, "未获取到必要的权限", Toast.LENGTH_SHORT).show();
129 | }
130 | }).create().show();
131 | } else {
132 | //在此设置权限全部被允许后的操作
133 | Toast.makeText(MainActivity.this, "多个权限全部被允许", Toast.LENGTH_SHORT).show();
134 | }
135 | }
136 | }
137 | });
138 |
139 | PermissionDog.getInstance().requestMultiPermissions(MainActivity.this, multiPermission);
140 |
141 | }
142 |
143 |
144 | //重写权限申请的回调
145 | @Override
146 | public void onRequestPermissionsResult(int requestCode,
147 | @NonNull String[] permissions,
148 | @NonNull int[] grantResults) {
149 | PermissionDog.getInstance().notifyPermissionsChanged(MainActivity.this, requestCode, permissions, grantResults);
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/hei123/permissiondog/PermissionDog/PermissionDog.java:
--------------------------------------------------------------------------------
1 | package com.example.hei123.permissiondog.PermissionDog;
2 |
3 | import android.app.Activity;
4 | import android.content.pm.PackageManager;
5 | import android.os.Build;
6 | import android.support.annotation.NonNull;
7 | import android.support.annotation.Nullable;
8 | import android.support.v4.app.Fragment;
9 |
10 | import java.lang.ref.WeakReference;
11 | import java.security.Permissions;
12 | import java.util.ArrayList;
13 | import java.util.jar.Manifest;
14 |
15 | /**
16 | * lishencai
17 | * connect to hei12138@outlook.com
18 | * Created by hei123 on 11/17/2016.
19 | * CopyRight @hei123
20 | * 修改或复制请保留此版权信息
21 | */
22 |
23 | public class PermissionDog {
24 |
25 | /**
26 | * 被拒绝的权限数组
27 | */
28 | private ArrayList Denieds;
29 | /**
30 | * 勾选了不再展示的数组
31 | */
32 | private ArrayList NeverShow;
33 | /**
34 | * 已获取权限的数组
35 | */
36 | private ArrayList Granteds;
37 | private WeakReference mAction;
38 | private static PermissionDog mPermissionDog;
39 |
40 | /**
41 | * 构造函数直接传Action
42 | */
43 | private PermissionDog() {
44 | }
45 |
46 |
47 | public static PermissionDog getInstance() {
48 | if (mPermissionDog == null) {
49 | mPermissionDog = new PermissionDog();
50 | }
51 | return mPermissionDog;
52 | }
53 |
54 |
55 | public void SetAction(PermissionDogAction action){
56 | this.mAction=new WeakReference(action);
57 | }
58 |
59 | /**
60 | * 申请单个权限
61 | *
62 | * @param activity
63 | * @param permission 权限
64 | */
65 | public void requestSinglePermissions(Activity activity, String permission) {
66 | String[] permissions = new String[]{permission};
67 | int isGrant = activity.checkCallingOrSelfPermission(permission);
68 | if (isGrant == PackageManager.PERMISSION_GRANTED) {
69 | PermissionDogAction permissionDogAction = mAction.get();
70 | if (permissionDogAction != null)
71 | permissionDogAction.grant();
72 | return;
73 | }
74 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
75 | activity.requestPermissions(permissions, 0);
76 | }
77 |
78 | public void requestSinglePermissions(Fragment fragment,String permission){
79 | String[] permissions = new String[]{permission};
80 | int isGrant = fragment.getActivity().checkCallingOrSelfPermission(permission);
81 | if (isGrant == PackageManager.PERMISSION_GRANTED) {
82 | PermissionDogAction permissionDogAction = mAction.get();
83 | if (permissionDogAction != null)
84 | permissionDogAction.grant();
85 | return;
86 | }
87 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
88 | fragment.requestPermissions(permissions, 0);
89 | }
90 |
91 |
92 | /**
93 | * 申请多个权限
94 | *
95 | * @param activity
96 | * @param permissions 权限数组
97 | */
98 | public void requestMultiPermissions(Activity activity, @NonNull String[] permissions) {
99 | ArrayList deniedPermission = new ArrayList();
100 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
101 | for (String permission : permissions) {
102 | int isGrant = activity.checkCallingOrSelfPermission(permission);
103 | if (isGrant == PackageManager.PERMISSION_DENIED) {
104 | //没有获得权限
105 | deniedPermission.add(permission);
106 | }
107 | }
108 | if (deniedPermission.size() > 0) {
109 | activity.requestPermissions(deniedPermission.toArray(new String[deniedPermission.size()]), 1);
110 | }else{
111 | PermissionDogAction permissionDogAction = mAction.get();
112 | if (permissionDogAction != null)
113 | permissionDogAction.allallow();
114 | }
115 | }else{
116 | PermissionDogAction permissionDogAction = mAction.get();
117 | if (permissionDogAction != null)
118 | permissionDogAction.allallow();
119 | }
120 | }
121 |
122 |
123 |
124 | /**
125 | * 通知权限更改
126 | *
127 | * @param activity
128 | * @param requestCode
129 | * @param permissions
130 | * @param grantResults
131 | */
132 | public void notifyPermissionsChanged(Activity activity, int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
133 | requestPermissionForResult(activity, requestCode, permissions, grantResults);
134 | }
135 |
136 |
137 | /**
138 | * 处理返回结果
139 | *
140 | * @param activity
141 | * @param requestCode
142 | * @param permissions
143 | * @param grantResults
144 | */
145 | private void requestPermissionForResult(@NonNull Activity activity, int requestCode, @Nullable String[] permissions, @NonNull int[] grantResults) {
146 | switch (requestCode) {
147 | case 0:
148 | //单个权限
149 | if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
150 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
151 | if (!activity.shouldShowRequestPermissionRationale(permissions[0])) {
152 | PermissionDogAction permissionDogAction = mAction.get();
153 | //自定义的对话框了
154 | if (permissionDogAction != null)
155 | permissionDogAction.never();
156 | } else {
157 | //没有勾选对话框
158 | PermissionDogAction permissionDogAction = mAction.get();
159 | if (permissionDogAction != null)
160 | permissionDogAction.denied();
161 | }
162 | } else {
163 | //允许权限
164 | PermissionDogAction permissionDogAction = mAction.get();
165 | if (permissionDogAction != null)
166 | permissionDogAction.grant();
167 | }
168 | break;
169 | case 1:
170 | NeverShow = new ArrayList<>();
171 | Granteds = new ArrayList<>();
172 | Denieds = new ArrayList<>();
173 | //多个权限申请时,每个权限都会有一个对话框,并带有勾选框
174 | for (int i = 0; i < grantResults.length; i++) {
175 | //遍历所有结果
176 | if (grantResults[i] == -1) {
177 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
178 | if (!activity.shouldShowRequestPermissionRationale(permissions[i])) {
179 | //自定义的对话框了
180 | NeverShow.add(permissions[i]);
181 | } else {
182 | //没有勾选对话框
183 | Denieds.add(permissions[i]);
184 | }
185 | } else {
186 | //允许权限
187 | Granteds.add(permissions[i]);
188 | }
189 | }
190 | PermissionDogAction permissionDogAction = mAction.get();
191 | if (permissionDogAction != null)
192 | permissionDogAction.multi(Granteds.toArray(new String[Granteds.size()]),
193 | Denieds.toArray(new String[Denieds.size()]),
194 | NeverShow.toArray(new String[NeverShow.size()]));
195 |
196 | break;
197 | }
198 |
199 | }
200 |
201 | /**
202 | * 权限更改后的回调接口
203 | */
204 | public static abstract class PermissionDogAction {
205 |
206 |
207 | /**
208 | * 允许权限
209 | */
210 | public void grant() {
211 | }
212 |
213 | /**
214 | * 拒绝权限
215 | */
216 | public void denied() {
217 | }
218 |
219 | /**
220 | * 勾选了不再显示框
221 | */
222 | public void never() {
223 | }
224 |
225 | /**
226 | * 多个请求时的回调
227 | *
228 | * @param granteds 获得权限的数组
229 | * @param denieds 未获得权限的数组
230 | * @param nevershows 勾选了nevershowagain
231 | */
232 | public void multi(String[] granteds, String[] denieds, String[] nevershows) {
233 | }
234 |
235 | /**
236 | * 申请多个权限时,所有权限都被允许
237 | */
238 | public void allallow() {
239 |
240 | }
241 | }
242 | }
243 |
--------------------------------------------------------------------------------