Skip to content

Commit

Permalink
fix(android): get PermissionState enum by state value (#4100)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlpoole authored Jan 21, 2021
1 parent 55ef5ff commit 194ae86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ protected Map<String, PermissionState> getPermissionStates(Plugin plugin) {
String state = prefs.getString(permString, null);

if (state != null) {
permissionStatus = PermissionState.valueOf(state);
permissionStatus = PermissionState.byState(state);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.getcapacitor;

import java.util.Locale;

/**
* Represents the state of a permission
*
Expand All @@ -21,4 +23,9 @@ public enum PermissionState {
public String toString() {
return state;
}

public static PermissionState byState(String state) {
state = state.toUpperCase(Locale.ROOT).replace('-', '_');
return valueOf(state);
}
}

0 comments on commit 194ae86

Please sign in to comment.