From 2d30854949d4b9dc2db0abaaa4924ad5900ee02a Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 13 Nov 2022 17:52:23 -0800 Subject: [PATCH] better way to create enum --- .../src/main/java/org/eehouse/android/xw4/Perms23.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Perms23.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Perms23.java index 71a9f32fd..d6756aa1d 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Perms23.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Perms23.java @@ -51,16 +51,15 @@ public class Perms23 { BLUETOOTH_CONNECT(BuildConfig.BLUETOOTH_CONNECT), BLUETOOTH_SCAN(BuildConfig.BLUETOOTH_SCAN); - private String m_str; - private boolean m_granted; + private String m_str = null; private Perm(String str) { m_str = str; } - private Perm(boolean granted) { m_granted = granted; } public String getString() { return m_str; } public boolean isBanned( Context context ) { return !permInManifest( context, this ); } + public boolean notNeeded() { return null == m_str; } public static Perm getFor( String str ) { Perm result = null; for ( Perm one : Perm.values() ) { @@ -423,7 +422,9 @@ public class Perms23 { for ( int ii = 0; result && ii < perms.length; ++ii ) { Perm perm = perms[ii]; boolean thisResult; - if ( perm.isBanned(context) ) { + if ( perm.notNeeded() ) { + thisResult = true; + } else if ( perm.isBanned(context) ) { thisResult = bannedWithWorkaround( context, perm ); } else { thisResult = PackageManager.PERMISSION_GRANTED