├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── 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 │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── activity_chekonly.xml │ │ │ │ ├── activity_need_reslut.xml │ │ │ │ └── activity_main.xml │ │ │ ├── values-en │ │ │ │ └── strings.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── zyq │ │ │ │ └── permissiondemo │ │ │ │ ├── ChekOnlyActivity.java │ │ │ │ ├── FloatWindowActivity.java │ │ │ │ ├── NotificationActivity.java │ │ │ │ ├── NeedReslutActivity.java │ │ │ │ ├── BaseActivity.java │ │ │ │ ├── MyApplication.java │ │ │ │ ├── LocationServiceActivity.java │ │ │ │ ├── EndlessActivity.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── DismissAskActivity.java │ │ │ │ └── RequestWithExplainActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── zyq │ │ │ └── permissiondemo │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── zyq │ │ └── permissiondemo │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── easypermissionlib ├── .gitignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── style.xml │ │ │ ├── drawable │ │ │ │ ├── bg_alert_white_shape8.xml │ │ │ │ ├── bg_button_blue_shape20.xml │ │ │ │ └── bg_button_blueline_shape20.xml │ │ │ ├── values-en │ │ │ │ └── strings.xml │ │ │ └── layout │ │ │ │ ├── alert_info_top.xml │ │ │ │ └── dialog_info_middle.xml │ │ └── java │ │ │ └── com │ │ │ └── zyq │ │ │ └── easypermission │ │ │ ├── EasyPermissionConfig.java │ │ │ ├── bean │ │ │ ├── PermissionAlertInfo.java │ │ │ ├── EasyAppSettingDialogStyle.java │ │ │ └── EasyTopAlertStyle.java │ │ │ ├── util │ │ │ ├── EasyFloatWindowTool.java │ │ │ ├── EasyLocationTool.java │ │ │ ├── EasyAlphaTouchListener.java │ │ │ ├── EasyShapeUtil.java │ │ │ ├── EasyViewUtil.java │ │ │ ├── EasyCacheData.java │ │ │ ├── EasyNotificationTool.java │ │ │ └── EasyAppDialogTool.java │ │ │ ├── EasyPermissionLog.java │ │ │ ├── EasyPermissionResult.java │ │ │ ├── EasyPermission.java │ │ │ └── EasyPermissionHelper.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── zyq │ │ │ └── easypermission │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── zyq │ │ └── easypermission │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── .gitignore ├── gradlew.bat ├── gradlew ├── README.md ├── LICENSE └── README-en.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /easypermissionlib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':easypermissionlib' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubZYQ/easypermission/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubZYQ/easypermission/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubZYQ/easypermission/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubZYQ/easypermission/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubZYQ/easypermission/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubZYQ/easypermission/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubZYQ/easypermission/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/githubZYQ/easypermission/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/githubZYQ/easypermission/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /easypermissionlib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/githubZYQ/easypermission/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/githubZYQ/easypermission/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /easypermissionlib/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #0086f6 4 | #ffffff 5 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/res/drawable/bg_alert_white_shape8.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/res/drawable/bg_button_blue_shape20.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Jun 03 11:40:41 CST 2019 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-5.6.4-all.zip 7 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/res/drawable/bg_button_blueline_shape20.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | #008577 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 需要给该应用授权 3 | 请到 “应用信息 -> 权限” 中授予! 4 | 去打开 5 | 取消 6 | 7 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/res/values-en/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | The APP needs to be authorized 3 | Go to "APP info -> permissions" to grant! 4 | Understand 5 | Cancel 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/zyq/permissiondemo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.zyq.permissiondemo; 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() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /easypermissionlib/src/test/java/com/zyq/easypermission/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.zyq.easypermission; 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() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /easypermissionlib/src/main/res/values/style.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/java/com/zyq/easypermission/EasyPermissionConfig.java: -------------------------------------------------------------------------------- 1 | package com.zyq.easypermission; 2 | 3 | /** 4 | * @author Zhang YanQiang 5 | * @date 2019/6/2 14:58. 6 | */ 7 | public class EasyPermissionConfig { 8 | /** 9 | * Print the tag for the log 10 | * 打印日志的tag 11 | */ 12 | public static final String LOG_TAG = "EasyPermissionLog"; 13 | /** 14 | * Debug mode 15 | * 是否是debug模式 16 | */ 17 | private static boolean DEBUG = false; 18 | 19 | public static boolean isDebug() { 20 | return DEBUG; 21 | } 22 | 23 | /** 24 | * isDebug 25 | * @return 26 | */ 27 | public static void setDebug(boolean isDebug) { 28 | DEBUG = isDebug; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 权限极简 3 | 只检测权限状态 4 | 仅申请,不需要结果 5 | 需要权限申请通过/拒绝回调 6 | 需要权限禁止询问回调 7 | 强制需要权限(慎用) 8 | 申请权限附带说明(推荐) 9 | 通知栏权限 10 | 悬浮窗权限 11 | 定位服务 12 | 拨打电话 - 需要这个权限来调用拨打电话功能 13 | 相机 - 需要这个权限来实现照相功能 14 | 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | android.enableJetifier=true 10 | android.useAndroidX=true 11 | org.gradle.jvmargs=-Xmx1536m 12 | # When configured, Gradle will run in incubating parallel mode. 13 | # This option should only be used with decoupled projects. More details, visit 14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 15 | # org.gradle.parallel=true 16 | 17 | 18 | -------------------------------------------------------------------------------- /easypermissionlib/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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/zyq/permissiondemo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.zyq.permissiondemo; 2 | 3 | import android.content.Context; 4 | import androidx.test.platform.app.InstrumentationRegistry; 5 | import androidx.test.ext.junit.runners.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("cn.nova.permissiondemo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_chekonly.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/values-en/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | EasyPermission 3 | ONLY CHECK 4 | ONLY APPLY 5 | NEED RESULT 6 | DISMISSED TO ASK 7 | ENDLESSLY 8 | WITH EXPLAIN(Recommended) 9 | Notification 10 | FloatWindow 11 | GPS 12 | Call Phone - Give me the permission to dial the number for you 13 | Camera - Give me the permission to photo for you 14 | 15 | -------------------------------------------------------------------------------- /easypermissionlib/src/androidTest/java/com/zyq/easypermission/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.zyq.easypermission; 2 | 3 | import android.content.Context; 4 | import androidx.test.platform.app.InstrumentationRegistry; 5 | import androidx.test.ext.junit.runners.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("cn.nova.easypermissionlib.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /easypermissionlib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | group='com.gitee.zhang-yanqiang' 4 | 5 | android { 6 | compileSdkVersion 30 7 | 8 | defaultConfig { 9 | minSdkVersion 19 10 | targetSdkVersion 30 11 | versionCode 1 12 | versionName "1.0.0" 13 | 14 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 15 | 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | } 26 | 27 | dependencies { 28 | implementation fileTree(include: ['*.jar'], dir: 'libs') 29 | implementation 'androidx.appcompat:appcompat:1.0.0' 30 | //MMKV 31 | implementation 'com.tencent:mmkv:1.0.19' 32 | testImplementation 'junit:junit:4.12' 33 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 34 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' 35 | } 36 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 30 5 | buildToolsVersion "30.0.1" 6 | 7 | defaultConfig { 8 | applicationId "cn.nova.permissiondemo" 9 | minSdkVersion 19 10 | targetSdkVersion 30 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | implementation fileTree(include: ['*.jar'], dir: 'libs') 25 | implementation 'androidx.appcompat:appcompat:1.0.0' 26 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 27 | testImplementation 'junit:junit:4.12' 28 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 29 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' 30 | implementation project(':easypermissionlib') 31 | } 32 | -------------------------------------------------------------------------------- /.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/ 38 | 39 | # Keystore files 40 | # Uncomment the following line if you do not want to check your keystore files in. 41 | #*.jks 42 | 43 | # External native build folder generated in Android Studio 2.2 and later 44 | .externalNativeBuild 45 | 46 | # Google Services (e.g. APIs or Firebase) 47 | google-services.json 48 | 49 | # Freeline 50 | freeline.py 51 | freeline/ 52 | freeline_project_description.json 53 | 54 | # fastlane 55 | fastlane/report.xml 56 | fastlane/Preview.html 57 | fastlane/screenshots 58 | fastlane/test_output 59 | fastlane/readme.md 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/zyq/permissiondemo/ChekOnlyActivity.java: -------------------------------------------------------------------------------- 1 | package com.zyq.permissiondemo; 2 | 3 | import android.Manifest; 4 | import androidx.appcompat.app.AppCompatActivity; 5 | 6 | import android.content.Intent; 7 | import android.os.Bundle; 8 | import android.view.View; 9 | import android.widget.TextView; 10 | 11 | import com.zyq.easypermission.EasyPermission; 12 | 13 | /** 14 | * 只检查权限和结果并显示它 15 | * only check the permission and result and show it 16 | * @author zyq 17 | * @date 2019 06 03 18 | */ 19 | public class ChekOnlyActivity extends BaseActivity { 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_chekonly); 25 | TextView textView = findViewById(R.id.textView); 26 | textView.setText(EasyPermission.build().hasPermission(Manifest.permission.CAMERA) ? "已允许" : "未允许"); 27 | findViewById(R.id.btnRequest).setOnClickListener(new View.OnClickListener() { 28 | @Override 29 | public void onClick(View v) { 30 | startActivity(new Intent(mContext,RequestWithExplainActivity.class)); 31 | } 32 | }); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_need_reslut.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 18 | 19 | 24 | 25 | 31 | 32 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/java/com/zyq/easypermission/bean/PermissionAlertInfo.java: -------------------------------------------------------------------------------- 1 | package com.zyq.easypermission.bean; 2 | 3 | /** 4 | * 权限提示信息 5 | * @author by Zhang YanQiang 6 | * @date 2022/3/17. 7 | */ 8 | public class PermissionAlertInfo { 9 | /** 10 | * Title of permission prompt, for example, need to locate permission 11 | * 权限提示的标题,如:需要定位权限 12 | */ 13 | public String alertTitle; 14 | /** 15 | * Permission prompt content, such as: used to confirm your current location, convenient driver to accurately arrive at your side 16 | * 权限提示的内容,如:用于确认您当前的位置,方便司机准确地到达您的身边 17 | */ 18 | public String alertMessage; 19 | 20 | public PermissionAlertInfo(String alertTitle) { 21 | this.alertTitle = alertTitle; 22 | } 23 | 24 | public PermissionAlertInfo(String alertTitle, String alertMessage) { 25 | this.alertTitle = alertTitle; 26 | this.alertMessage = alertMessage; 27 | } 28 | 29 | public String getAlertTitle() { 30 | return alertTitle; 31 | } 32 | 33 | public PermissionAlertInfo setAlertTitle(String alertTitle) { 34 | this.alertTitle = alertTitle; 35 | return this; 36 | } 37 | 38 | public String getAlertMessage() { 39 | return alertMessage; 40 | } 41 | 42 | public PermissionAlertInfo setAlertMessage(String alertMessage) { 43 | this.alertMessage = alertMessage; 44 | return this; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/zyq/permissiondemo/FloatWindowActivity.java: -------------------------------------------------------------------------------- 1 | package com.zyq.permissiondemo; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | import android.widget.TextView; 6 | 7 | import com.zyq.easypermission.util.EasyFloatWindowTool; 8 | 9 | /** 10 | * 演示悬浮窗权限 11 | * demo for FloatWindow 12 | * @author Zhang YanQiang 13 | * @date 2022 03 22 14 | */ 15 | public class FloatWindowActivity extends BaseActivity { 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_need_reslut); 20 | findViewById(R.id.btnRequest).setOnClickListener(new View.OnClickListener() { 21 | @Override 22 | public void onClick(View v) { 23 | EasyFloatWindowTool.gotoAppSettings(mContext); 24 | } 25 | }); 26 | findViewById(R.id.btnShowResult).setOnClickListener(new View.OnClickListener() { 27 | @Override 28 | public void onClick(View v) { 29 | showResult(); 30 | } 31 | }); 32 | } 33 | 34 | @Override 35 | protected void onResume() { 36 | super.onResume(); 37 | showResult(); 38 | } 39 | private void showResult(){ 40 | TextView textView2 = findViewById(R.id.textView2); 41 | textView2.setText(EasyFloatWindowTool.isFloatWindowEnabled(mContext)?"已通过":"未通过"); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/zyq/permissiondemo/NotificationActivity.java: -------------------------------------------------------------------------------- 1 | package com.zyq.permissiondemo; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | import android.widget.TextView; 6 | 7 | import com.zyq.easypermission.util.EasyNotificationTool; 8 | 9 | /** 10 | * 演示通知栏权限 11 | * demo for Notification 12 | * @author Zhang YanQiang 13 | * @date 2022 03 22 14 | */ 15 | public class NotificationActivity extends BaseActivity { 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_need_reslut); 20 | findViewById(R.id.btnRequest).setOnClickListener(new View.OnClickListener() { 21 | @Override 22 | public void onClick(View v) { 23 | EasyNotificationTool.gotoAppSettings(mContext); 24 | } 25 | }); 26 | findViewById(R.id.btnShowResult).setOnClickListener(new View.OnClickListener() { 27 | @Override 28 | public void onClick(View v) { 29 | showResult(); 30 | } 31 | }); 32 | } 33 | 34 | @Override 35 | protected void onResume() { 36 | super.onResume(); 37 | showResult(); 38 | } 39 | private void showResult(){ 40 | TextView textView2 = findViewById(R.id.textView2); 41 | textView2.setText(EasyNotificationTool.isNotificationEnabled(mContext)?"已通过":"未通过"); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/java/com/zyq/easypermission/util/EasyFloatWindowTool.java: -------------------------------------------------------------------------------- 1 | package com.zyq.easypermission.util; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.os.Build; 7 | import android.provider.Settings; 8 | 9 | /** 10 | * Hover window permission management 11 | * 悬浮窗权限管理 12 | * @author by Zhang YanQiang 13 | * @date 2022/3/22. 14 | */ 15 | public class EasyFloatWindowTool { 16 | /** 17 | * Whether you have suspension window permission 18 | * 是否有悬浮窗权限 19 | * 20 | * @return 21 | */ 22 | public static boolean isFloatWindowEnabled(Context context) { 23 | //在6.0以前的系统版本,悬浮窗权限是默认开启的,直接使用即可 24 | //In system versions prior to 6.0, hover window permission is enabled by default and can be used directly 25 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 26 | return Settings.canDrawOverlays(context); 27 | } else { 28 | return true; 29 | } 30 | } 31 | /** 32 | * Go set hover window permissions 33 | * 去设置悬浮窗权限 34 | * 35 | * @return 36 | */ 37 | public static void gotoAppSettings(Context context) { 38 | try { 39 | Intent intent = new Intent(); 40 | intent.setAction(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); 41 | intent.addCategory(Intent.CATEGORY_DEFAULT); 42 | intent.setData(Uri.parse("package:" + context.getPackageName())); 43 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 44 | intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 45 | context.startActivity(intent); 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/java/com/zyq/easypermission/EasyPermissionLog.java: -------------------------------------------------------------------------------- 1 | package com.zyq.easypermission; 2 | 3 | import android.text.TextUtils; 4 | import android.util.Log; 5 | 6 | /** 7 | * Print log tool 8 | * 打印日志工具 9 | * 10 | * @author Zhang YanQiang 11 | * @date 2019/6/2 15:02. 12 | */ 13 | public class EasyPermissionLog { 14 | 15 | /** 16 | * Print log 17 | * the debug level, EasyPermissionConfig. Info = false without printing 18 | * 19 | * 打印log日志 20 | * info级别,EasyPermissionConfig.DEBUG=false时不打印 21 | * 22 | * @param logString 23 | */ 24 | public static void i(String logString) { 25 | if (TextUtils.isEmpty(logString)) { 26 | return; 27 | } 28 | if (EasyPermissionConfig.isDebug()) { 29 | Log.i(EasyPermissionConfig.LOG_TAG, logString); 30 | } 31 | } 32 | 33 | /** 34 | * Print log 35 | * the debug level, EasyPermissionConfig. Debug = false without printing 36 | * 37 | * 打印log日志 38 | * debug级别,EasyPermissionConfig.DEBUG=false时不打印 39 | * 40 | * @param logString 41 | */ 42 | public static void d(String logString) { 43 | if (TextUtils.isEmpty(logString)) { 44 | return; 45 | } 46 | if (EasyPermissionConfig.isDebug()) { 47 | Log.d(EasyPermissionConfig.LOG_TAG, logString); 48 | } 49 | } 50 | 51 | /** 52 | * 打印log日志 53 | * error级别,不管是不是debug模式,都打印 54 | * 打印log日志 55 | * error级别,不管是不是debug模式,都打印 56 | * 57 | * @param logString 58 | */ 59 | public static void e(String logString) { 60 | if (TextUtils.isEmpty(logString)) { 61 | return; 62 | } 63 | Log.e(EasyPermissionConfig.LOG_TAG, logString); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/java/com/zyq/easypermission/util/EasyLocationTool.java: -------------------------------------------------------------------------------- 1 | package com.zyq.easypermission.util; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Build; 7 | import android.provider.Settings; 8 | import android.text.TextUtils; 9 | 10 | /** 11 | * Location service management tool 12 | * 定位服务管理工具 13 | * @author by Zhang YanQiang 14 | * @date 2022/3/22. 15 | */ 16 | public class EasyLocationTool { 17 | 18 | /** 19 | * Check whether the location service is enabled 20 | * 判断定位服务是否开启 21 | * @param 22 | * @return true 表示开启 true-open 23 | */ 24 | public static boolean isLocationEnabled(Context context) { 25 | int locationMode = 0; 26 | String locationProviders; 27 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 28 | try { 29 | locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE); 30 | } catch (Settings.SettingNotFoundException e) { 31 | e.printStackTrace(); 32 | return false; 33 | } 34 | return locationMode != Settings.Secure.LOCATION_MODE_OFF; 35 | } else { 36 | locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); 37 | return !TextUtils.isEmpty(locationProviders); 38 | } 39 | } 40 | 41 | /** 42 | * The page for setting location information is displayed 43 | * 直接跳转至位置信息设置界面 44 | */ 45 | public static void gotoAppSettings(Activity context) { 46 | Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); 47 | context.startActivity(intent); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/res/layout/alert_info_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 22 | 23 | 32 | 33 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/java/com/zyq/easypermission/util/EasyAlphaTouchListener.java: -------------------------------------------------------------------------------- 1 | package com.zyq.easypermission.util; 2 | 3 | import android.view.MotionEvent; 4 | import android.view.View; 5 | 6 | /** 7 | * 使用的实现View点击改变透明度 8 | * 在ListView中只响应了ACTION_DOWN,先不要用于ListView 9 | * RecycleView可以用 10 | * 11 | * @author Zhang YanQiang 12 | * @date 2019/10/9 20:39. 13 | */ 14 | public class EasyAlphaTouchListener implements View.OnTouchListener { 15 | private final float F_SCACLE_MIN = 0.5f; 16 | private final float F_SCACLE_MAX = 1f; 17 | 18 | @Override 19 | public boolean onTouch(final View v, MotionEvent event) { 20 | switch (event.getAction()) { 21 | case MotionEvent.ACTION_DOWN: 22 | v.setAlpha(F_SCACLE_MIN); 23 | break; 24 | case MotionEvent.ACTION_UP: 25 | v.setAlpha(F_SCACLE_MAX); 26 | break; 27 | case MotionEvent.ACTION_CANCEL: 28 | v.setAlpha(F_SCACLE_MAX); 29 | if (isOutterMotionEvent(event, v)) { 30 | if (v.getParent() != null) { 31 | v.getParent().requestDisallowInterceptTouchEvent(true); 32 | return true; 33 | } 34 | } else { 35 | break; 36 | } 37 | break; 38 | default: 39 | break; 40 | } 41 | return false; 42 | } 43 | 44 | /** 45 | * 事件触发是否超出View边界 46 | * 47 | * @param event 48 | * @param v 49 | * @return 50 | */ 51 | private boolean isOutterMotionEvent(MotionEvent event, View v) { 52 | float touchX = event.getX(); 53 | float touchY = event.getY(); 54 | float maxX = v.getWidth(); 55 | float maxY = v.getHeight(); 56 | 57 | return touchX < 0 || touchX > maxX || touchY < 0 || touchY > maxY; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/java/com/zyq/easypermission/util/EasyShapeUtil.java: -------------------------------------------------------------------------------- 1 | package com.zyq.easypermission.util; 2 | 3 | import android.graphics.Color; 4 | import android.graphics.drawable.GradientDrawable; 5 | 6 | /** 7 | * 动态创建shape获得drawable 8 | * 9 | * @author by Zhang YanQiang 10 | * @date 2022/3/24. 11 | */ 12 | public class EasyShapeUtil { 13 | 14 | /** 15 | * 创建一个Shape - GradientDrawable 16 | * 17 | * @param _strokeWidth - 沿边线厚度(px);无需传入-1 18 | * @param _roundRadius - 圆角半径(px);无需传入-1 19 | * @param _shape - shape绘制类型(GradientDrawable.RECTANGLE、oval等);无需传入-1,将采用默认的GradientDrawable.RECTANGLE 20 | * @param _strokeColor - 沿边线颜色;无需传入null/"" 21 | * @param _fillColor - 内部填充颜色 22 | * @return 23 | */ 24 | public static GradientDrawable createShape(int _strokeWidth, 25 | int _roundRadius, int _shape, 26 | String _strokeColor, String _fillColor) { 27 | GradientDrawable gd = null; 28 | try { 29 | int strokeWidth = _strokeWidth; // px not dp 30 | int roundRadius = _roundRadius; // px not dp 31 | int strokeColor = -1; 32 | if (null != _strokeColor && !_strokeColor.equals("")) { 33 | strokeColor = Color.parseColor(_strokeColor); 34 | } 35 | int fillColor = Color.parseColor(_fillColor); 36 | 37 | gd = new GradientDrawable(); 38 | gd.setColor(fillColor); 39 | 40 | if (-1 == _shape) { 41 | gd.setShape(GradientDrawable.RECTANGLE); 42 | } else { 43 | gd.setShape(_shape); 44 | } 45 | 46 | if (-1 != roundRadius) { 47 | gd.setCornerRadius(roundRadius); 48 | } 49 | if (-1 != strokeWidth && -1 != strokeColor) { 50 | gd.setStroke(strokeWidth, strokeColor); 51 | } 52 | } catch (Exception e) { 53 | e.printStackTrace(); 54 | } 55 | return gd; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/zyq/permissiondemo/NeedReslutActivity.java: -------------------------------------------------------------------------------- 1 | package com.zyq.permissiondemo; 2 | 3 | import android.Manifest; 4 | import android.os.Bundle; 5 | import androidx.annotation.NonNull; 6 | 7 | import android.view.View; 8 | import android.widget.TextView; 9 | 10 | import com.zyq.easypermission.EasyPermission; 11 | import com.zyq.easypermission.EasyPermissionResult; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * 演示需要结果的 17 | * demo for NeedReslut 18 | * @author Zhang YanQiang 19 | * @date 2019 06 03 20 | */ 21 | public class NeedReslutActivity extends BaseActivity { 22 | TextView textView2; 23 | EasyPermission easyPermission; 24 | 25 | @Override 26 | protected void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.activity_need_reslut); 29 | textView2 = findViewById(R.id.textView2); 30 | findViewById(R.id.btnRequest).setOnClickListener(new View.OnClickListener() { 31 | @Override 32 | public void onClick(View v) { 33 | easyPermission.requestPermission(); 34 | } 35 | }); 36 | findViewById(R.id.btnShowResult).setOnClickListener(new View.OnClickListener() { 37 | @Override 38 | public void onClick(View v) { 39 | startOneActivity(ChekOnlyActivity.class); 40 | } 41 | }); 42 | //权限请求 43 | easyPermission = EasyPermission.build() 44 | .mRequestCode(RC_CODE_PERMISSION) 45 | // .mContext(NeedReslutActivity.this) 46 | .mPerms(Manifest.permission.CAMERA) 47 | .mResult(new EasyPermissionResult() { 48 | @Override 49 | public void onPermissionsAccess(int requestCode) { 50 | super.onPermissionsAccess(requestCode); 51 | mToast("权限通过"); 52 | //做你想做的 53 | textView2.setText("权限已通过"); 54 | } 55 | 56 | @Override 57 | public void onPermissionsDismiss(int requestCode, @NonNull List permissions) { 58 | super.onPermissionsDismiss(requestCode, permissions); 59 | mToast("权限被拒绝"); 60 | //你的权限被用户拒绝了你怎么办 61 | textView2.setText(permissions.toString() + " 被拒绝了"); 62 | } 63 | }).requestPermission(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/zyq/permissiondemo/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.zyq.permissiondemo; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import androidx.annotation.NonNull; 6 | import androidx.annotation.Nullable; 7 | import androidx.appcompat.app.AppCompatActivity; 8 | import android.widget.Toast; 9 | 10 | import com.zyq.easypermission.EasyPermissionHelper; 11 | 12 | /** 13 | * @author Zhang YanQiang 14 | * @date 2019/6/3 14:49. 15 | */ 16 | public class BaseActivity extends AppCompatActivity { 17 | /** 18 | * 不同的权限应该有不同的回调code 19 | */ 20 | protected static final int RC_CODE_PERMISSION = 1024; 21 | protected BaseActivity mContext; 22 | 23 | @Override 24 | protected void onCreate(@Nullable Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | mContext = this; 27 | } 28 | 29 | /** 30 | * 在baseActivity覆盖该方法,或者每个活动需要使用EasyPermission 31 | * Override this method in baseActivity ,or each Activity who need use EasyPermission 32 | */ 33 | @Override 34 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { 35 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); 36 | //使用EasyPermissionHelper注入回调 37 | // Inject the callback using EasyPermissionHelper 38 | EasyPermissionHelper.getInstance().onRequestPermissionsResult(requestCode, permissions, grantResults, this); 39 | } 40 | 41 | /** 42 | * 需要从系统设置界面返回时判断权限情况的,在baseActivity覆盖该方法,或者每个活动需要使用EasyPermission 43 | * Override this method in baseActivity ,or each Activity who need use EasyPermission, 44 | * if you want to get the new state form settings page 45 | */ 46 | @Override 47 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { 48 | super.onActivityResult(requestCode, resultCode, data); 49 | //使用EasyPermissionHelper注入回调 50 | // Inject the callback using EasyPermissionHelper 51 | EasyPermissionHelper.getInstance().onActivityResult(requestCode, resultCode, data); 52 | } 53 | 54 | /** 55 | * start one activity 56 | * @param newClass activity's name 57 | */ 58 | protected void startOneActivity(@NonNull Class newClass) { 59 | startActivity(new Intent(this, newClass)); 60 | } 61 | 62 | /** 63 | * A Tip 64 | * @param msg 65 | */ 66 | protected void mToast(CharSequence msg){ 67 | Toast.makeText(mContext, msg, Toast.LENGTH_LONG).show(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /easypermissionlib/src/main/res/layout/dialog_info_middle.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 22 | 23 | 34 | 42 | 52 | 53 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/zyq/permissiondemo/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.zyq.permissiondemo; 2 | 3 | import android.app.Application; 4 | import android.view.Gravity; 5 | 6 | import com.zyq.easypermission.EasyPermissionHelper; 7 | import com.zyq.easypermission.bean.EasyAppSettingDialogStyle; 8 | import com.zyq.easypermission.bean.EasyTopAlertStyle; 9 | 10 | /** 11 | * @author by Zhang YanQiang 12 | * @date 2022/3/21. 13 | */ 14 | public class MyApplication extends Application { 15 | @Override 16 | public void onCreate() { 17 | super.onCreate(); 18 | //首次使用权限申请之前完成初始化,建议放在Application onCreate()中完成 19 | EasyPermissionHelper.getInstance().init(this); 20 | 21 | //设置被禁止时说明弹窗的样式,可以不设置 使用默认的STYLE_DEFAULT,STYLE_SYSTEM 22 | //默认样式,可以不用设置 23 | // EasyPermissionHelper.getInstance().setDialogStyle( 24 | // new EasyAppSettingDialogStyle(EasyAppSettingDialogStyle.DialogStyle.STYLE_DEFAULT)); 25 | //系统样式 26 | // EasyPermissionHelper.getInstance().setDialogStyle( 27 | // new EasyAppSettingDialogStyle(EasyAppSettingDialogStyle.DialogStyle.STYLE_SYSTEM)); 28 | //自定义样式 29 | EasyPermissionHelper.getInstance().setDialogStyle( 30 | new EasyAppSettingDialogStyle(EasyAppSettingDialogStyle.DialogStyle.STYLE_CUSTOM) 31 | .setTitleGravity(Gravity.CENTER)//设置居中 32 | .setTitleSize(17)//设置标题样式 33 | .setTitleColor("#333333") 34 | .setMessageSize(14)//设置内容样式 35 | .setMessageColor("#666666") 36 | .setButtonTextSize(14)//设置按钮样式 37 | .setButtonThemeColor("#FF0000") 38 | .setCancelText("取消")//设置按钮文本 39 | .setConfirmText("去打开")); 40 | 41 | //设置申请权限时顶部提示框样式,可以不设置 使用默认的STYLE_DEFAULT 42 | //默认样式,可以不用设置 43 | EasyPermissionHelper.getInstance().setTopAlertStyle( 44 | new EasyTopAlertStyle(EasyTopAlertStyle.AlertStyle.STYLE_DEFAULT)); 45 | //自定义样式 46 | // EasyPermissionHelper.getInstance().setTopAlertStyle( 47 | // new EasyTopAlertStyle(EasyTopAlertStyle.AlertStyle.STYLE_CUSTOM) 48 | // .setTitleGravity(Gravity.LEFT)//默认居左 49 | // .setTitleSize(16)//设置标题样式,默认16sp 50 | // .setTitleColor("#333333") 51 | // .setMessageSize(14)//设置内容样式,默认14sp 52 | // .setMessageColor("#333333") 53 | // .setBackgroundColor("#FFFFFF")//设置背景色,默认白色 54 | // .setBackgroundRadius(8)//设置背景圆角弧度,默认8dp 55 | // .setBackgroundElevation(6)//设置背景阴影范围,默认6dp 56 | // .setTopMargin(10)//设置距离顶部标题栏间距,默认10dp 57 | // .setSideMargin(10));//设置距离屏幕两边宽度,默认10dp 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 17 |