From 41e2e4117e72f0cb9aaa9e7e6a5410b7778981c5 Mon Sep 17 00:00:00 2001 From: HJQ Date: Mon, 6 Aug 2018 14:36:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AF=B7=E6=B1=82=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=92=8C=E6=82=AC=E6=B5=AE=E7=AA=97=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=92=8C=E6=96=B0=E5=A2=9E=E6=97=A0=E9=99=90=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +- app/build.gradle | 18 ++-- app/src/main/AndroidManifest.xml | 1 + .../hjq/permissions/demo/MainActivity.java | 5 +- build.gradle | 9 ++ library/build.gradle | 9 +- .../com/hjq/permissions/OnPermission.java | 8 +- .../hjq/permissions/OverlaySettingPage.java | 70 ------------ .../java/com/hjq/permissions/Permission.java | 4 + .../hjq/permissions/PermissionFragment.java | 100 +++++++----------- .../permissions/PermissionSettingPage.java | 4 +- .../com/hjq/permissions/PermissionUtils.java | 61 ++++++----- .../com/hjq/permissions/XXPermissions.java | 32 +++--- 13 files changed, 132 insertions(+), 194 deletions(-) delete mode 100644 library/src/main/java/com/hjq/permissions/OverlaySettingPage.java diff --git a/README.md b/README.md index 1e255f5..d9c6b89 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,14 @@ #### 集成步骤 dependencies { - compile 'com.hjq:xxpermissions:2.2' + implementation 'com.hjq:xxpermissions:3.0' } #### 一句代码搞定权限请求,从未如此简单 XXPermissions.with(this) //.constantRequest() //可设置被拒绝后继续申请,直到用户授权或者永久拒绝 + //.permission(Permission.REQUEST_INSTALL_PACKAGES, Permission.SYSTEM_ALERT_WINDOW) //支持请求安装权限和悬浮窗权限 .permission(Permission.Group.STORAGE) //支持多个权限组进行请求,不指定则默以清单文件中的危险权限进行请求 .request(new OnPermission() { @@ -50,6 +51,8 @@ * 可设置被拒绝后继续申请,直到用户授权或者永久拒绝 +* 支持请求6.0以上的悬浮窗权限以及8.0以上的安装权限 + * 本框架不依赖AppCompatSupport库,兼容Eclipse和Studio #### 混淆规则 diff --git a/app/build.gradle b/app/build.gradle index d969273..9748956 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,14 +1,14 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.3" + compileSdkVersion 26 + buildToolsVersion "27.0.3" defaultConfig { applicationId "com.hjq.permissions.demo" - minSdkVersion 11 + minSdkVersion 14 targetSdkVersion 26 - versionCode 1 - versionName "1.0" + versionCode 30 + versionName "3.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { @@ -20,7 +20,7 @@ android { } dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') - compile project(':library') - compile 'com.android.support:appcompat-v7:25+' -} + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation project(':library') + implementation 'com.android.support:appcompat-v7:26.1.0' +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 473f245..40a63b7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ + + if (task.name.equals('mockableAndroidJar')) { + task.enabled = false + } + } + } } task clean(type: Delete) { diff --git a/library/build.gradle b/library/build.gradle index 57c1a5c..912513c 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -4,13 +4,12 @@ apply plugin: 'com.novoda.bintray-release' android { compileSdkVersion 26 - buildToolsVersion "25.0.3" defaultConfig { minSdkVersion 11 - targetSdkVersion 23 - versionCode 20 - versionName "2.2" + targetSdkVersion 26 + versionCode 30 + versionName "3.0" } } @@ -18,7 +17,7 @@ publish { userOrg = 'getactivity'//填写bintray用户名,注意大小写 groupId = 'com.hjq'//定义的maven group id最终引用形式 artifactId = 'xxpermissions'//maven的artifact id - version = '2.2'//maven 上发布版本号 + version = '3.0'//maven 上发布版本号 description = 'Android 6.0 permissions adaptation framework'//描述,自己定义 website = "https://github.com/getActivity/XXPermissions"//项目在github中的地址 } diff --git a/library/src/main/java/com/hjq/permissions/OnPermission.java b/library/src/main/java/com/hjq/permissions/OnPermission.java index 43d5906..7b4b81f 100644 --- a/library/src/main/java/com/hjq/permissions/OnPermission.java +++ b/library/src/main/java/com/hjq/permissions/OnPermission.java @@ -10,16 +10,16 @@ public interface OnPermission { /** * 有权限被授予时回调 * - * @param granted 请求成功的权限组 - * @param isAll 是否全部授予了 + * @param granted 请求成功的权限组 + * @param isAll 是否全部授予了 */ void hasPermission(List granted, boolean isAll); /** * 有权限被拒绝授予时回调 * - * @param denied 请求失败的权限组 - * @param quick 是否被系统自动拒绝了 + * @param denied 请求失败的权限组 + * @param quick 是否被系统自动拒绝了 */ void noPermission(List denied, boolean quick); } \ No newline at end of file diff --git a/library/src/main/java/com/hjq/permissions/OverlaySettingPage.java b/library/src/main/java/com/hjq/permissions/OverlaySettingPage.java deleted file mode 100644 index 29788d8..0000000 --- a/library/src/main/java/com/hjq/permissions/OverlaySettingPage.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2018 Yan Zhenjie - * - * 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 com.hjq.permissions; - -import android.app.Activity; -import android.content.ComponentName; -import android.content.Intent; -import android.net.Uri; -import android.os.Build; -import android.provider.Settings; - -/** - * Created by HJQ on 2018-8-5. - */ -public class OverlaySettingPage { - - private static final String MARK = Build.MANUFACTURER.toLowerCase(); - - static void start(Activity activity, int requestCode) { - if (MARK.contains("meizu")) { - if (!meizu(activity, requestCode) && !google(activity, requestCode)) { - details(activity, requestCode); - } - } else if (!google(activity, requestCode)) { - details(activity, requestCode); - } - } - - private static boolean meizu(Activity activity, int requestCode) { - Intent overlayIntent = new Intent("com.meizu.safe.security.SHOW_APPSEC"); - overlayIntent.putExtra("packageName", activity.getPackageName()); - overlayIntent.setComponent(new ComponentName("com.meizu.safe", "com.meizu.safe.security.AppSecActivity")); - try { - activity.startActivityForResult(overlayIntent, requestCode); - } catch (Exception e) { - return false; - } - return true; - } - - private static boolean google(Activity activity, int requestCode) { - Intent manageIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); - manageIntent.setData(Uri.fromParts("package", activity.getPackageName(), null)); - try { - activity.startActivityForResult(manageIntent, requestCode); - } catch (Exception e) { - return false; - } - return true; - } - - private static void details(Activity activity, int requestCode) { - Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.setData(Uri.fromParts("package", activity.getPackageName(), null)); - activity.startActivityForResult(intent, requestCode); - } -} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/permissions/Permission.java b/library/src/main/java/com/hjq/permissions/Permission.java index 57446b1..630bab6 100644 --- a/library/src/main/java/com/hjq/permissions/Permission.java +++ b/library/src/main/java/com/hjq/permissions/Permission.java @@ -40,6 +40,8 @@ public final class Permission { public static final String REQUEST_INSTALL_PACKAGES = "android.permission.REQUEST_INSTALL_PACKAGES"; + public static final String SYSTEM_ALERT_WINDOW = "android.permission.SYSTEM_ALERT_WINDOW"; + public static final class Group { public static final String[] CALENDAR = new String[]{ @@ -82,5 +84,7 @@ public static final class Group { Permission.WRITE_EXTERNAL_STORAGE}; public static final String[] INSTALL = new String[]{Permission.REQUEST_INSTALL_PACKAGES}; + + public static final String[] WINDOW = new String[]{Permission.SYSTEM_ALERT_WINDOW}; } } \ No newline at end of file diff --git a/library/src/main/java/com/hjq/permissions/PermissionFragment.java b/library/src/main/java/com/hjq/permissions/PermissionFragment.java index ad423b9..64cee67 100644 --- a/library/src/main/java/com/hjq/permissions/PermissionFragment.java +++ b/library/src/main/java/com/hjq/permissions/PermissionFragment.java @@ -10,7 +10,6 @@ import android.util.SparseArray; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Random; @@ -20,16 +19,13 @@ public final class PermissionFragment extends Fragment { private static final String PERMISSION_GROUP = "permission_group";//请求的权限 - private static final String REQUEST_CODE ="request_code"; - private static final String REQUEST_CONSTANT ="request_constant"; + private static final String REQUEST_CODE = "request_code"; + private static final String REQUEST_CONSTANT = "request_constant"; private final static SparseArray sContainer = new SparseArray<>(); private final static int TIME_DELAY = 200;//延迟时间,用于是否是系统拒绝的 private static long sRequestTime;//请求的时间 - private boolean requestInstall;//是否请求安装权限 - private boolean isInstallPermission;//是否有安装权限 - public static PermissionFragment newInstant(ArrayList permissions, boolean constant) { PermissionFragment fragment = new PermissionFragment(); Bundle bundle = new Bundle(); @@ -62,18 +58,29 @@ public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ArrayList permissions = getArguments().getStringArrayList(PERMISSION_GROUP); - if (permissions.contains(Permission.REQUEST_INSTALL_PACKAGES)) { - isInstallPermission = PermissionUtils.isHasInstallPermission(getActivity()); - requestInstall = !isInstallPermission; - if (isInstallPermission) { - handleInstallPermission(); - }else { - //跳转到允许安装未知来源页面 + + if ((permissions.contains(Permission.REQUEST_INSTALL_PACKAGES) && !PermissionUtils.isHasInstallPermission(getActivity())) + || (permissions.contains(Permission.SYSTEM_ALERT_WINDOW) && !PermissionUtils.isHasOverlaysPermission(getActivity()))) { + + if (permissions.contains(Permission.REQUEST_INSTALL_PACKAGES) && !PermissionUtils.isHasInstallPermission(getActivity())) { + //跳转到允许安装未知来源设置页面 Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, Uri.parse("package:" + getActivity().getPackageName())); startActivityForResult(intent, getArguments().getInt(REQUEST_CODE)); } - }else { + + if (permissions.contains(Permission.SYSTEM_ALERT_WINDOW) && !PermissionUtils.isHasOverlaysPermission(getActivity())) { + //跳转到悬浮窗设置页面 + Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getActivity().getPackageName())); + startActivityForResult(intent, getArguments().getInt(REQUEST_CODE)); + } + + //记录本次申请时间 + sRequestTime = System.currentTimeMillis(); + + } else { requestPermission(); + //记录本次申请时间 + sRequestTime = System.currentTimeMillis(); } } @@ -82,8 +89,6 @@ public void onActivityCreated(Bundle savedInstanceState) { */ public void requestPermission() { if (PermissionUtils.isOverMarshmallow()) { - //记录本次申请时间 - sRequestTime = System.currentTimeMillis(); ArrayList permissions = getArguments().getStringArrayList(PERMISSION_GROUP); requestPermissions(permissions.toArray(new String[permissions.size() - 1]), getArguments().getInt(REQUEST_CODE)); } @@ -97,24 +102,23 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in //根据请求码取出的对象为空,就直接返回不处理 if (call == null) return; - //是否请求了安装权限 - if (requestInstall) { - - String[] s = new String[permissions.length + 1]; - System.arraycopy(permissions, 0, s, 0, permissions.length); - s[s.length - 1] = Permission.REQUEST_INSTALL_PACKAGES; + for (int i = 0; i < permissions.length; i++) { - int[] i = new int[grantResults.length + 1]; - System.arraycopy(grantResults, 0, i, 0, grantResults.length); - //有请求安装权限并且被用户授予了 - if (isInstallPermission) { - i[i.length - 1] = PackageManager.PERMISSION_GRANTED; - }else { - i[i.length - 1] = PackageManager.PERMISSION_DENIED; + if (Permission.REQUEST_INSTALL_PACKAGES.equals(permissions[i])) { + if (PermissionUtils.isHasInstallPermission(getActivity())) { + grantResults[i] = PackageManager.PERMISSION_GRANTED; + } else { + grantResults[i] = PackageManager.PERMISSION_DENIED; + } } - permissions = s; - grantResults = i; + if (Permission.SYSTEM_ALERT_WINDOW.equals(permissions[i])) { + if (PermissionUtils.isHasOverlaysPermission(getActivity())) { + grantResults[i] = PackageManager.PERMISSION_GRANTED; + } else { + grantResults[i] = PackageManager.PERMISSION_DENIED; + } + } } //获取授予权限 @@ -123,7 +127,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in if (succeedPermissions.size() == permissions.length) { //代表申请的所有的权限都授予了 call.hasPermission(succeedPermissions, true); - }else { + } else { if (getArguments().getBoolean(REQUEST_CONSTANT) && System.currentTimeMillis() - sRequestTime > TIME_DELAY) { requestPermission(); return; @@ -144,37 +148,13 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in getFragmentManager().beginTransaction().remove(this).commit(); } + private boolean isBackCall;//是否已经回调了,避免安装权限和悬浮窗同时请求导致的重复回调 + @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { //super.onActivityResult(requestCode, resultCode, data); - if (PermissionUtils.isOverOreo() && requestCode == getArguments().getInt(REQUEST_CODE)) { - handleInstallPermission(); - } - } - - private void handleInstallPermission() { - - isInstallPermission = PermissionUtils.isHasInstallPermission(getActivity()); - - ArrayList permissions = getArguments().getStringArrayList(PERMISSION_GROUP); - permissions.remove(Permission.REQUEST_INSTALL_PACKAGES); - if (permissions.size() == 0) { - OnPermission call = sContainer.get(getArguments().getInt(REQUEST_CODE)); - - //根据请求码取出的对象为空,就直接返回不处理 - if (call == null) return; - if (isInstallPermission) { - //只请求了安装权限并且被授予了 - call.hasPermission(Arrays.asList(Permission.REQUEST_INSTALL_PACKAGES), true); - }else { - //只请求了安装权限并且被拒绝了 - call.noPermission(Arrays.asList(Permission.REQUEST_INSTALL_PACKAGES), false); - } - - //权限回调结束后要删除集合中的对象,避免重复请求 - sContainer.remove(getArguments().getInt(REQUEST_CODE)); - getFragmentManager().beginTransaction().remove(this).commit(); - }else { + if (!isBackCall && requestCode == getArguments().getInt(REQUEST_CODE) ) { + isBackCall = true; //请求其他危险权限 requestPermission(); } diff --git a/library/src/main/java/com/hjq/permissions/PermissionSettingPage.java b/library/src/main/java/com/hjq/permissions/PermissionSettingPage.java index a63ff07..a119774 100644 --- a/library/src/main/java/com/hjq/permissions/PermissionSettingPage.java +++ b/library/src/main/java/com/hjq/permissions/PermissionSettingPage.java @@ -18,8 +18,8 @@ final class PermissionSettingPage { /** * 跳转到应用权限设置页面 * - * @param context 上下文对象 - * @param newTask 是否使用新的任务栈启动 + * @param context 上下文对象 + * @param newTask 是否使用新的任务栈启动 */ static void start(Context context, boolean newTask) { diff --git a/library/src/main/java/com/hjq/permissions/PermissionUtils.java b/library/src/main/java/com/hjq/permissions/PermissionUtils.java index 6b0cead..281cb56 100644 --- a/library/src/main/java/com/hjq/permissions/PermissionUtils.java +++ b/library/src/main/java/com/hjq/permissions/PermissionUtils.java @@ -1,14 +1,11 @@ package com.hjq.permissions; import android.app.Activity; -import android.app.AppOpsManager; import android.content.Context; -import android.content.Intent; import android.content.pm.PackageManager; import android.os.Build; import android.provider.Settings; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -50,7 +47,7 @@ static List getManifestPermissions(Context context) { public static boolean isHasInstallPermission(Context context) { if (isOverOreo()) { - //必须设置目标SDK为26及以上才能请求安装权限 + //必须设置目标SDK为26及以上才能正常检测安装权限 if (context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.O) { throw new RuntimeException("The targetSdkVersion SDK must be 26 or more"); } @@ -60,37 +57,53 @@ public static boolean isHasInstallPermission(Context context) { return true; } + /** + * 是否有悬浮窗权限 + */ + public static boolean isHasOverlaysPermission(Context context) { + + if (isOverMarshmallow()) { + + //必须设置目标SDK为23及以上才能正常检测安装权限 + if (context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.M) { + throw new RuntimeException("The targetSdkVersion SDK must be 23 or more"); + } + + return Settings.canDrawOverlays(context); + } + return true; + } + /** * 获取没有授予的权限 * - * @param context 上下文对象 - * @param permissions 需要请求的权限组 + * @param context 上下文对象 + * @param permissions 需要请求的权限组 */ static ArrayList getFailPermissions(Context context, List permissions) { //如果是安卓6.0以下版本就返回null - if(!PermissionUtils.isOverMarshmallow()) { + if (!PermissionUtils.isOverMarshmallow()) { return null; } - ArrayList failPermissions = null; + ArrayList failPermissions = new ArrayList<>(); for (String permission : permissions) { //检测安装权限 if (permission.equals(Permission.REQUEST_INSTALL_PACKAGES) && !isHasInstallPermission(context)) { + failPermissions.add(permission); + continue; + } - if (failPermissions == null) { - failPermissions = new ArrayList<>(); - } + //检查悬浮窗权限 + if (permission.equals(Permission.SYSTEM_ALERT_WINDOW) && !isHasOverlaysPermission(context)) { failPermissions.add(permission); continue; } //把没有授予过的权限加入到集合中 if (context.checkSelfPermission(permission) == PackageManager.PERMISSION_DENIED) { - if (failPermissions == null) { - failPermissions = new ArrayList<>(); - } failPermissions.add(permission); } } @@ -101,12 +114,12 @@ static ArrayList getFailPermissions(Context context, List permis /** * 获取没有授予的权限 * - * @param permissions 需要请求的权限组 - * @param grantResults 允许结果组 + * @param permissions 需要请求的权限组 + * @param grantResults 允许结果组 */ static List getFailPermissions(String[] permissions, int[] grantResults) { List failPermissions = new ArrayList<>(); - for (int i = 0; i < grantResults.length ; i++) { + for (int i = 0; i < grantResults.length; i++) { //把没有授予过的权限加入到集合中,-1表示没有授予,0表示已经授予 if (grantResults[i] == PackageManager.PERMISSION_DENIED) { @@ -119,13 +132,13 @@ static List getFailPermissions(String[] permissions, int[] grantResults) /** * 获取已授予的权限 * - * @param permissions 需要请求的权限组 - * @param grantResults 允许结果组 + * @param permissions 需要请求的权限组 + * @param grantResults 允许结果组 */ static List getSucceedPermissions(String[] permissions, int[] grantResults) { List succeedPermissions = new ArrayList<>(); - for (int i = 0; i < grantResults.length ; i++) { + for (int i = 0; i < grantResults.length; i++) { //把授予过的权限加入到集合中,-1表示没有授予,0表示已经授予 if (grantResults[i] == PackageManager.PERMISSION_GRANTED) { @@ -138,8 +151,8 @@ static List getSucceedPermissions(String[] permissions, int[] grantResul /** * 检测权限有没有在清单文件中注册 * - * @param activity Activity对象 - * @param requestPermissions 请求的权限组 + * @param activity Activity对象 + * @param requestPermissions 请求的权限组 */ static void checkPermissions(Activity activity, List requestPermissions) { List manifest = PermissionUtils.getManifestPermissions(activity); @@ -149,8 +162,8 @@ static void checkPermissions(Activity activity, List requestPermissions) throw new ManifestPermissionException(permission); } } - }else { + } else { throw new ManifestPermissionException(null); } } -} +} \ No newline at end of file diff --git a/library/src/main/java/com/hjq/permissions/XXPermissions.java b/library/src/main/java/com/hjq/permissions/XXPermissions.java index 802afa0..dc8ca95 100644 --- a/library/src/main/java/com/hjq/permissions/XXPermissions.java +++ b/library/src/main/java/com/hjq/permissions/XXPermissions.java @@ -2,9 +2,6 @@ import android.app.Activity; import android.content.Context; -import android.content.Intent; -import android.os.Build; -import android.provider.Settings; import java.util.ArrayList; import java.util.Arrays; @@ -36,7 +33,7 @@ public static XXPermissions with(Activity activity) { /** * 设置权限组 */ - public XXPermissions permission(String... permissions){ + public XXPermissions permission(String... permissions) { mPermissions = Arrays.asList(permissions); return this; } @@ -44,7 +41,7 @@ public XXPermissions permission(String... permissions){ /** * 设置权限组 */ - public XXPermissions permission(String[]... permissions){ + public XXPermissions permission(String[]... permissions) { mPermissions = new ArrayList<>(); for (String[] group : permissions) { mPermissions.addAll(Arrays.asList(group)); @@ -55,7 +52,7 @@ public XXPermissions permission(String[]... permissions){ /** * 设置权限组 */ - public XXPermissions permission(List permissions){ + public XXPermissions permission(List permissions) { mPermissions = permissions; return this; } @@ -73,12 +70,15 @@ public XXPermissions constantRequest() { */ public void request(OnPermission call) { //如果没有指定请求的权限,就使用清单注册的权限进行请求 - if (mPermissions == null || mPermissions.size() == 0) mPermissions = PermissionUtils.getManifestPermissions(mActivity); - if (mPermissions == null || mPermissions.size() == 0) throw new IllegalArgumentException("The requested permission cannot be empty"); + if (mPermissions == null || mPermissions.size() == 0) + mPermissions = PermissionUtils.getManifestPermissions(mActivity); + if (mPermissions == null || mPermissions.size() == 0) + throw new IllegalArgumentException("The requested permission cannot be empty"); //使用isFinishing方法Activity在熄屏状态下会导致崩溃 //if (mActivity == null || mActivity.isFinishing()) throw new IllegalArgumentException("Illegal Activity was passed in"); if (mActivity == null) throw new IllegalArgumentException("The activity is empty"); - if (call == null) throw new IllegalArgumentException("The permission request callback interface must be implemented"); + if (call == null) + throw new IllegalArgumentException("The permission request callback interface must be implemented"); ArrayList failPermissions = PermissionUtils.getFailPermissions(mActivity, mPermissions); @@ -96,8 +96,8 @@ public void request(OnPermission call) { /** * 检查某些权限是否全部授予了 * - * @param context 上下文对象 - * @param permissions 需要请求的权限组 + * @param context 上下文对象 + * @param permissions 需要请求的权限组 */ public static boolean isHasPermission(Context context, String... permissions) { return PermissionUtils.getFailPermissions(context, Arrays.asList(permissions)) == null; @@ -106,8 +106,8 @@ public static boolean isHasPermission(Context context, String... permissions) { /** * 检查某些权限是否全部授予了 * - * @param context 上下文对象 - * @param permissions 需要请求的权限组 + * @param context 上下文对象 + * @param permissions 需要请求的权限组 */ public static boolean isHasPermission(Context context, String[]... permissions) { List permissionList = new ArrayList<>(); @@ -120,7 +120,7 @@ public static boolean isHasPermission(Context context, String[]... permissions) /** * 跳转到应用权限设置页面 * - * @param context 上下文对象 + * @param context 上下文对象 */ public static void gotoPermissionSettings(Context context) { PermissionSettingPage.start(context, false); @@ -129,8 +129,8 @@ public static void gotoPermissionSettings(Context context) { /** * 跳转到应用权限设置页面 * - * @param context 上下文对象 - * @param newTask 是否使用新的任务栈启动 + * @param context 上下文对象 + * @param newTask 是否使用新的任务栈启动 */ public static void gotoPermissionSettings(Context context, boolean newTask) { PermissionSettingPage.start(context, newTask);