|
| 1 | +/* |
| 2 | + * The MIT License (MIT) |
| 3 | + * |
| 4 | + * Copyright (c) 2017 Raphaël Bussa |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in all |
| 14 | + * copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | + * SOFTWARE. |
| 23 | + */ |
| 24 | + |
| 25 | +package com.blankj.utilcode.constant; |
| 26 | + |
| 27 | +import android.Manifest; |
| 28 | +import android.annotation.SuppressLint; |
| 29 | +import android.support.annotation.NonNull; |
| 30 | + |
| 31 | +/** |
| 32 | + * Created by raphaelbussa on 22/06/16. |
| 33 | + */ |
| 34 | +@SuppressWarnings("SpellCheckingInspection") |
| 35 | +@SuppressLint("InlinedApi") |
| 36 | +public enum PermissionEnum { |
| 37 | + |
| 38 | + GROUP_CALENDAR(Manifest.permission_group.CALENDAR), |
| 39 | + READ_CALENDAR(Manifest.permission.READ_CALENDAR), |
| 40 | + WRITE_CALENDAR(Manifest.permission.WRITE_CALENDAR), |
| 41 | + |
| 42 | + GROUP_CAMERA(Manifest.permission_group.CAMERA), |
| 43 | + CAMERA(Manifest.permission.CAMERA), |
| 44 | + |
| 45 | + GROUP_CONTACTS(Manifest.permission_group.CONTACTS), |
| 46 | + READ_CONTACTS(Manifest.permission.READ_CONTACTS), |
| 47 | + WRITE_CONTACTS(Manifest.permission.WRITE_CONTACTS), |
| 48 | + GET_ACCOUNTS(Manifest.permission.GET_ACCOUNTS), |
| 49 | + |
| 50 | + GROUP_LOCATION(Manifest.permission_group.LOCATION), |
| 51 | + ACCESS_FINE_LOCATION(Manifest.permission.ACCESS_FINE_LOCATION), |
| 52 | + ACCESS_COARSE_LOCATION(Manifest.permission.ACCESS_COARSE_LOCATION), |
| 53 | + |
| 54 | + GROUP_MICROPHONE(Manifest.permission_group.MICROPHONE), |
| 55 | + RECORD_AUDIO(Manifest.permission.RECORD_AUDIO), |
| 56 | + |
| 57 | + GROUP_PHONE(Manifest.permission_group.PHONE), |
| 58 | + READ_PHONE_STATE(Manifest.permission.READ_PHONE_STATE), |
| 59 | + READ_PHONE_NUMBERS(Manifest.permission.READ_PHONE_NUMBERS), |
| 60 | + CALL_PHONE(Manifest.permission.CALL_PHONE), |
| 61 | + ANSWER_PHONE_CALLS(Manifest.permission.ANSWER_PHONE_CALLS), |
| 62 | + READ_CALL_LOG(Manifest.permission.READ_CALL_LOG), |
| 63 | + WRITE_CALL_LOG(Manifest.permission.WRITE_CALL_LOG), |
| 64 | + ADD_VOICEMAIL(Manifest.permission.ADD_VOICEMAIL), |
| 65 | + USE_SIP(Manifest.permission.USE_SIP), |
| 66 | + PROCESS_OUTGOING_CALLS(Manifest.permission.PROCESS_OUTGOING_CALLS), |
| 67 | + |
| 68 | + GROUP_SENSORS(Manifest.permission_group.SENSORS), |
| 69 | + BODY_SENSORS(Manifest.permission.BODY_SENSORS), |
| 70 | + |
| 71 | + GROUP_SMS(Manifest.permission_group.SMS), |
| 72 | + SEND_SMS(Manifest.permission.SEND_SMS), |
| 73 | + RECEIVE_SMS(Manifest.permission.RECEIVE_SMS), |
| 74 | + READ_SMS(Manifest.permission.READ_SMS), |
| 75 | + RECEIVE_WAP_PUSH(Manifest.permission.RECEIVE_WAP_PUSH), |
| 76 | + RECEIVE_MMS(Manifest.permission.RECEIVE_MMS), |
| 77 | + |
| 78 | + GROUP_STORAGE(Manifest.permission_group.STORAGE), |
| 79 | + READ_EXTERNAL_STORAGE(Manifest.permission.READ_EXTERNAL_STORAGE), |
| 80 | + WRITE_EXTERNAL_STORAGE(Manifest.permission.WRITE_EXTERNAL_STORAGE), |
| 81 | + |
| 82 | + NULL(""); |
| 83 | + |
| 84 | + private final String permission; |
| 85 | + |
| 86 | + PermissionEnum(String permission) { |
| 87 | + this.permission = permission; |
| 88 | + } |
| 89 | + |
| 90 | + public static PermissionEnum fromManifestPermission(@NonNull String value) { |
| 91 | + for (PermissionEnum permissionEnum : PermissionEnum.values()) { |
| 92 | + if (value.equalsIgnoreCase(permissionEnum.permission)) { |
| 93 | + return permissionEnum; |
| 94 | + } |
| 95 | + } |
| 96 | + return NULL; |
| 97 | + } |
| 98 | + |
| 99 | + @Override |
| 100 | + public String toString() { |
| 101 | + return permission; |
| 102 | + } |
| 103 | + |
| 104 | +} |
0 commit comments