mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
tweak permissions; stop using shouldShowRequestPermissionRationale()
It apparently returns false if I haven't asked before, and that's the one time you want to be sure to ask.
This commit is contained in:
parent
71e90eed77
commit
2148288cf1
2 changed files with 42 additions and 37 deletions
|
@ -55,11 +55,6 @@ public class Perms23 {
|
|||
public String getString() { return m_str; }
|
||||
public boolean isBanned( Context context )
|
||||
{
|
||||
// PENDING... Once this has been here for a week or so, remove
|
||||
// SMS_BANNED. That way absence of the permission from a variant's
|
||||
// manifest is the only way being banned is expressed. It sucks
|
||||
// keeping two things in sync.
|
||||
// Assert.assertFalse( m_banned == permInManifest( context, this ) );
|
||||
return !permInManifest( context, this );
|
||||
}
|
||||
public static Perm getFor( String str ) {
|
||||
|
@ -159,9 +154,7 @@ public class Perms23 {
|
|||
Assert.assertFalse( perm.isBanned(activity) );
|
||||
askStrings.add( permStr );
|
||||
|
||||
if ( null != m_onShow && ActivityCompat
|
||||
.shouldShowRequestPermissionRationale( activity,
|
||||
permStr ) ) {
|
||||
if ( null != m_onShow ) {
|
||||
needShow.add( perm );
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +232,7 @@ public class Perms23 {
|
|||
doItAsk( validPerms, showRationale );
|
||||
}
|
||||
if ( 0 < bannedPerms.size() ) {
|
||||
doItFail( bannedPerms );
|
||||
postNeg();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,8 +246,8 @@ public class Perms23 {
|
|||
m_delegate.makeConfirmThenBuilder( m_rationaleMsg,
|
||||
Action.PERMS_QUERY )
|
||||
.setTitle( R.string.perms_rationale_title )
|
||||
.setPosButton( R.string.button_ask_again )
|
||||
.setNegButton( R.string.button_skip )
|
||||
.setPosButton( R.string.button_ask )
|
||||
.setNegButton( R.string.button_deny )
|
||||
.setParams( QueryInfo.this.getParams() )
|
||||
.setNAKey( mNAKey )
|
||||
.show();
|
||||
|
@ -276,31 +269,25 @@ public class Perms23 {
|
|||
} );
|
||||
}
|
||||
|
||||
// Cons up a call with a "no" answer, and post it.
|
||||
private void doItFail( Set<Perm> bannedPerms )
|
||||
{
|
||||
m_delegate.post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d( TAG, "doItFail(); passing perms to onNegButton(%s)", m_action );
|
||||
m_delegate.onNegButton( m_action, m_params );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
// Post this in case we're called from inside dialog dismiss
|
||||
// code. Better to unwind the stack...
|
||||
private void handleButton( final boolean positive )
|
||||
{
|
||||
m_delegate.post( new Runnable() {
|
||||
public void run() {
|
||||
if ( positive ) {
|
||||
if ( positive ) {
|
||||
m_delegate.post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doIt( false );
|
||||
} else {
|
||||
m_delegate.onNegButton( m_action, m_params );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} else {
|
||||
postNeg();
|
||||
}
|
||||
}
|
||||
|
||||
private void postNeg()
|
||||
{
|
||||
Perms23.postNeg( m_delegate, m_action, m_params );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,13 +303,31 @@ public class Perms23 {
|
|||
* Request permissions, giving rationale once, then call with action and
|
||||
* either positive or negative, the former if permission granted.
|
||||
*/
|
||||
private static void tryGetPermsImpl( DelegateBase delegate, Perm[] perms,
|
||||
private static void tryGetPermsImpl( final DelegateBase delegate, Perm[] perms,
|
||||
String rationaleMsg, int naKey,
|
||||
final Action action, Object... params )
|
||||
{
|
||||
// Log.d( TAG, "tryGetPerms(%s)", perm.toString() );
|
||||
new QueryInfo( delegate, action, perms, rationaleMsg, naKey, params )
|
||||
.doIt( true );
|
||||
|
||||
if ( 0 != naKey &&
|
||||
XWPrefs.getPrefsBoolean( delegate.getActivity(), naKey, false ) ) {
|
||||
postNeg( delegate, action, params );
|
||||
} else {
|
||||
new QueryInfo( delegate, action, perms, rationaleMsg,
|
||||
naKey, params )
|
||||
.doIt( true );
|
||||
}
|
||||
}
|
||||
|
||||
private static void postNeg( final DelegateBase delegate,
|
||||
final Action action, final Object[] params )
|
||||
{
|
||||
delegate.post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
delegate.onNegButton( action, params );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public static void tryGetPerms( DelegateBase delegate, Perm[] perms, int rationaleId,
|
||||
|
|
|
@ -2404,7 +2404,7 @@
|
|||
</string>
|
||||
<string name="dicts_storage_rationale">
|
||||
CrossWords can store and read wordlists in your device’s
|
||||
Downloads area but it needs permission to access them
|
||||
Downloads area but it needs to ask for permission to access them
|
||||
there.\n\nYou can safely deny this permission if you will never
|
||||
download wordlists except from inside CrossWords and have not
|
||||
previously stored any there.
|
||||
|
@ -2441,13 +2441,13 @@
|
|||
<string name="remove_sms">Remove SMS</string>
|
||||
<!-- In the permissions rationale explanation, means go ahead and
|
||||
have the OS ask for permission -->
|
||||
<string name="button_ask_again">Ask again</string>
|
||||
<string name="button_ask">Ask</string>
|
||||
<!-- Displayed as a toast -->
|
||||
<string name="sms_send_failed">SMS send failed</string>
|
||||
<!-- In the permissions rationale explanation, means don't have the
|
||||
OS ask for permission: user is denying it implicitly -->
|
||||
<string name="button_skip">Skip</string>
|
||||
<string name="perms_rationale_title">Android Permissions</string>
|
||||
<string name="button_deny">Deny</string>
|
||||
<string name="perms_rationale_title">Android Permission Explained</string>
|
||||
<string name="toast_no_permission">Permission not granted</string>
|
||||
<!-- Explanation in settings for always-on BT notification -->
|
||||
<string name="nbsproxy_channel_expl">Alerts about NBSProxy</string>
|
||||
|
|
Loading…
Reference in a new issue