-
Notifications
You must be signed in to change notification settings - Fork 0
/
PermissionValidatorWrapper.java
56 lines (47 loc) · 2.33 KB
/
PermissionValidatorWrapper.java
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
package org.firstinspires.ftc.robotcontroller.internal;
import android.Manifest;
import android.os.Bundle;
import com.qualcomm.ftcrobotcontroller.R;
import org.firstinspires.ftc.robotcore.internal.system.Misc;
import org.firstinspires.ftc.robotcore.internal.system.PermissionValidatorActivity;
import java.util.ArrayList;
import java.util.List;
public class PermissionValidatorWrapper extends PermissionValidatorActivity {
private final String TAG = "PermissionValidatorWrapper";
protected List<String> robotControllerPermissions = new ArrayList<String>() {{
add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
add(Manifest.permission.READ_EXTERNAL_STORAGE);
add(Manifest.permission.CAMERA);
add(Manifest.permission.ACCESS_COARSE_LOCATION);
add(Manifest.permission.ACCESS_FINE_LOCATION);
add(Manifest.permission.READ_PHONE_STATE);
}};
private final static Class startApplication = FtcRobotControllerActivity.class;
public String mapPermissionToExplanation(final String permission) {
if (permission.equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
return Misc.formatForUser(R.string.permRcWriteExternalStorageExplain);
} else if (permission.equals(Manifest.permission.READ_EXTERNAL_STORAGE)) {
return Misc.formatForUser(R.string.permRcReadExternalStorageExplain);
} else if (permission.equals(Manifest.permission.CAMERA)) {
return Misc.formatForUser(R.string.permRcCameraExplain);
} else if (permission.equals(Manifest.permission.ACCESS_COARSE_LOCATION)) {
return Misc.formatForUser(R.string.permAccessLocationExplain);
} else if (permission.equals(Manifest.permission.ACCESS_FINE_LOCATION)) {
return Misc.formatForUser(R.string.permAccessLocationExplain);
} else if (permission.equals(Manifest.permission.READ_PHONE_STATE)) {
return Misc.formatForUser(R.string.permReadPhoneState);
}
return Misc.formatForUser(R.string.permGenericExplain);
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
permissions = robotControllerPermissions;
}
protected Class onStartApplication()
{
FtcRobotControllerActivity.setPermissionsValidated();
return startApplication;
}
}