File tree 4 files changed +62
-7
lines changed
acp/src/main/java/com/mylhyl/acp
4 files changed +62
-7
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,15 @@ private Acp(Context context) {
23
23
mAcpManager = new AcpManager (context .getApplicationContext ());
24
24
}
25
25
26
+ /**
27
+ * 开始请求权限
28
+ *
29
+ * @param options
30
+ * @param acpListener
31
+ */
26
32
public void request (AcpOptions options , AcpListener acpListener ) {
27
- if (options == null ) new RuntimeException ("AcpOptions is null..." );
28
- if (acpListener == null ) new RuntimeException ("AcpListener is null..." );
33
+ if (options == null ) new NullPointerException ("AcpOptions is null..." );
34
+ if (acpListener == null ) new NullPointerException ("AcpListener is null..." );
29
35
mAcpManager .request (options , acpListener );
30
36
}
31
37
Original file line number Diff line number Diff line change 6
6
* Created by hupei on 2016/4/26.
7
7
*/
8
8
public interface AcpListener {
9
+ /**
10
+ *同意
11
+ */
9
12
void onGranted ();
10
13
14
+ /**
15
+ * 拒绝
16
+ */
11
17
void onDenied (List <String > permissions );
12
18
}
Original file line number Diff line number Diff line change @@ -57,31 +57,67 @@ public static class Builder {
57
57
private String mRationalBtn = DEF_RATIONAL_BTN_TEXT ;
58
58
private String [] mPermissions ;
59
59
60
+ /**
61
+ * 申请权限框提示语
62
+ *
63
+ * @param rationalMessage
64
+ * @return
65
+ */
60
66
public Builder setRationalMessage (String rationalMessage ) {
61
67
mRationalMessage = rationalMessage ;
62
68
return this ;
63
69
}
64
70
71
+ /**
72
+ * 申请权限框按钮
73
+ *
74
+ * @param rationalBtnText
75
+ * @return
76
+ */
77
+ public Builder setRationalBtn (String rationalBtnText ) {
78
+ this .mRationalBtn = rationalBtnText ;
79
+ return this ;
80
+ }
81
+
82
+ /**
83
+ * 拒绝框提示语
84
+ *
85
+ * @param deniedMessage
86
+ * @return
87
+ */
65
88
public Builder setDeniedMessage (String deniedMessage ) {
66
89
mDeniedMessage = deniedMessage ;
67
90
return this ;
68
91
}
69
92
93
+ /**
94
+ * 拒绝框关闭按钮
95
+ *
96
+ * @param deniedCloseBtnText
97
+ * @return
98
+ */
70
99
public Builder setDeniedCloseBtn (String deniedCloseBtnText ) {
71
100
this .mDeniedCloseBtn = deniedCloseBtnText ;
72
101
return this ;
73
102
}
74
103
104
+ /**
105
+ * 拒绝框跳转设置权限按钮
106
+ *
107
+ * @param deniedSettingText
108
+ * @return
109
+ */
75
110
public Builder setDeniedSettingBtn (String deniedSettingText ) {
76
111
this .mDeniedSettingBtn = deniedSettingText ;
77
112
return this ;
78
113
}
79
114
80
- public Builder setRationalBtn (String rationalBtnText ) {
81
- this .mRationalBtn = rationalBtnText ;
82
- return this ;
83
- }
84
-
115
+ /**
116
+ * 需要申请的权限
117
+ *
118
+ * @param mPermissions {@linkplain android.Manifest.permission android.Manifest.permission}
119
+ * @return
120
+ */
85
121
public Builder setPermissions (String ... mPermissions ) {
86
122
this .mPermissions = mPermissions ;
87
123
return this ;
Original file line number Diff line number Diff line change 9
9
* Created by hupei on 2016/4/26.
10
10
*/
11
11
class AcpService {
12
+ /**
13
+ * 检查权限授权状态
14
+ *
15
+ * @param context
16
+ * @param permission
17
+ * @return
18
+ */
12
19
int checkSelfPermission (Context context , String permission ) {
13
20
return ContextCompat .checkSelfPermission (context , permission );
14
21
}
You can’t perform that action at this time.
0 commit comments