PermissionCallOptions.java
4.1 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package com.xdy.commonlibrary.permission;
import android.support.annotation.StringRes;
import java.io.Serializable;
/**
* Options that are associated with Permission Request
*/
public class PermissionCallOptions implements Serializable {
private boolean showRationaleDialog;
private String rationaleDialogMsg;
private int rationaleDialogMsgRes;
private boolean rationaleEnabled = true;
private boolean showDenyDialog;
private String denyDialogMsg;
private int denyDialogMsgRes;
boolean showRationaleDialog() {
return showRationaleDialog;
}
String getRationaleDialogMsg() {
return rationaleDialogMsg;
}
int getRationaleDialogMsgRes() {
return rationaleDialogMsgRes;
}
boolean showDenyDialog() {
return showDenyDialog;
}
String getDenyDialogMsg() {
return denyDialogMsg;
}
int getDenyDialogMsgRes() {
return denyDialogMsgRes;
}
boolean isRationaleEnabled() {
return rationaleEnabled;
}
void setRationaleDialogMsgRes(int rationaleDialogMsgRes) {
this.rationaleDialogMsgRes = rationaleDialogMsgRes;
}
void setDenyDialogMsgRes(int denyDialogMsgRes) {
this.denyDialogMsgRes = denyDialogMsgRes;
}
/**
* Builder for creating PermissionCallOptions instance
*/
public static class Builder {
private PermissionCallOptions buildObj;
public Builder() {
buildObj = new PermissionCallOptions();
}
/**
* Builds instance of PermissifyConfig
*/
public PermissionCallOptions build() {
return buildObj;
}
/**
* Sets rationale dialog message
*
* @param rationaleMsgRes - string resource
*/
public Builder withRationaleDialogMsg(@StringRes int rationaleMsgRes) {
buildObj.rationaleDialogMsgRes = rationaleMsgRes;
buildObj.showRationaleDialog = true;
return this;
}
/**
* Sets rationale dialog message
*
* @param rationaleMsg - string message
*/
public Builder withRationaleDialogMsg(String rationaleMsg) {
buildObj.rationaleDialogMsg = rationaleMsg;
buildObj.showRationaleDialog = true;
return this;
}
/**
* Sets whether or not default rationale dialog should be used.
* This should be used when you want to disable default dialog and handle rationale in custom way.
* To disable rationale completely use {@link #withRationaleEnabled}
*
* @param useDefault - true - show rationale dialog
*/
public Builder withDefaultRationaleDialog(boolean useDefault) {
buildObj.showRationaleDialog = useDefault;
return this;
}
/**
* Sets whether or not rationale is enabled (custom or default).
*
* @param enabled - true rationale is enabled
*/
public Builder withRationaleEnabled(boolean enabled) {
buildObj.rationaleEnabled = enabled;
return this;
}
/**
* Sets deny dialog message
*
* @param denyDialogMsgRes - string resource
*/
public Builder withDenyDialogMsg(@StringRes int denyDialogMsgRes) {
buildObj.denyDialogMsgRes = denyDialogMsgRes;
buildObj.showDenyDialog = true;
return this;
}
/**
* Sets deny dialog message
*
* @param denyDialogMsg - string message
*/
public Builder withDenyDialogMsg(String denyDialogMsg) {
buildObj.denyDialogMsg = denyDialogMsg;
buildObj.showDenyDialog = true;
return this;
}
/**
* Sets whether or not default deny dialog should be used.
*
* @param useDefault - true - show deny dialog
*/
public Builder withDefaultDenyDialog(boolean useDefault) {
buildObj.showDenyDialog = useDefault;
return this;
}
}
}