mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
add BT permissions requests
This commit is contained in:
parent
43a96fb6fc
commit
8ca83ae871
6 changed files with 35 additions and 11 deletions
|
@ -41,7 +41,7 @@ public class ConnViaViewLayout extends LinearLayout {
|
||||||
private static final String TAG = ConnViaViewLayout.class.getSimpleName();
|
private static final String TAG = ConnViaViewLayout.class.getSimpleName();
|
||||||
private CommsConnTypeSet m_curSet;
|
private CommsConnTypeSet m_curSet;
|
||||||
private DlgDelegate.HasDlgDelegate m_dlgDlgt;
|
private DlgDelegate.HasDlgDelegate m_dlgDlgt;
|
||||||
private Activity m_activity;
|
private DelegateBase mParent;
|
||||||
|
|
||||||
public interface CheckEnabledWarner {
|
public interface CheckEnabledWarner {
|
||||||
public void warnDisabled( CommsConnType typ );
|
public void warnDisabled( CommsConnType typ );
|
||||||
|
@ -57,9 +57,7 @@ public class ConnViaViewLayout extends LinearLayout {
|
||||||
super( context, as );
|
super( context, as );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActivity( Activity activity ) { m_activity = activity; }
|
protected void configure( DelegateBase parent, CommsConnTypeSet types,
|
||||||
|
|
||||||
protected void configure( CommsConnTypeSet types,
|
|
||||||
CheckEnabledWarner cew,
|
CheckEnabledWarner cew,
|
||||||
SetEmptyWarner sew,
|
SetEmptyWarner sew,
|
||||||
DlgDelegate.HasDlgDelegate dlgDlgt )
|
DlgDelegate.HasDlgDelegate dlgDlgt )
|
||||||
|
@ -71,6 +69,7 @@ public class ConnViaViewLayout extends LinearLayout {
|
||||||
m_disabledWarner = cew;
|
m_disabledWarner = cew;
|
||||||
m_emptyWarner = sew;
|
m_emptyWarner = sew;
|
||||||
m_dlgDlgt = dlgDlgt;
|
m_dlgDlgt = dlgDlgt;
|
||||||
|
mParent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CommsConnTypeSet getTypes()
|
protected CommsConnTypeSet getTypes()
|
||||||
|
@ -83,7 +82,7 @@ public class ConnViaViewLayout extends LinearLayout {
|
||||||
LinearLayout list = (LinearLayout)findViewById( R.id.conn_types );
|
LinearLayout list = (LinearLayout)findViewById( R.id.conn_types );
|
||||||
list.removeAllViews(); // in case being reused
|
list.removeAllViews(); // in case being reused
|
||||||
|
|
||||||
Context context = getContext();
|
final Context context = getContext();
|
||||||
List<CommsConnType> supported = CommsConnTypeSet.getSupported( context );
|
List<CommsConnType> supported = CommsConnTypeSet.getSupported( context );
|
||||||
|
|
||||||
for ( CommsConnType typ : supported ) {
|
for ( CommsConnType typ : supported ) {
|
||||||
|
@ -101,9 +100,13 @@ public class ConnViaViewLayout extends LinearLayout {
|
||||||
public void onCheckedChanged( CompoundButton buttonView,
|
public void onCheckedChanged( CompoundButton buttonView,
|
||||||
boolean isChecked ) {
|
boolean isChecked ) {
|
||||||
if ( isChecked ) {
|
if ( isChecked ) {
|
||||||
showNotAgainTypeTip( typf );
|
if ( disableUntil( context, typ ) ) {
|
||||||
enabledElseWarn( typf );
|
buttonView.setChecked( false );
|
||||||
m_curSet.add( typf );
|
} else {
|
||||||
|
showNotAgainTypeTip( typf );
|
||||||
|
enabledElseWarn( typf );
|
||||||
|
m_curSet.add( typf );
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
m_curSet.remove( typf );
|
m_curSet.remove( typf );
|
||||||
if ( null != m_emptyWarner && 0 == m_curSet.size()) {
|
if ( null != m_emptyWarner && 0 == m_curSet.size()) {
|
||||||
|
@ -115,6 +118,21 @@ public class ConnViaViewLayout extends LinearLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean disableUntil( Context context, CommsConnType typ )
|
||||||
|
{
|
||||||
|
boolean disable = false;
|
||||||
|
if ( typ == CommsConnType.COMMS_CONN_BT
|
||||||
|
&& ! BTUtils.havePermissions( context ) ) {
|
||||||
|
if ( null != mParent ) {
|
||||||
|
Perms23.tryGetPerms( mParent, BTUtils.BTPerms,
|
||||||
|
R.string.nearbydev_rationale,
|
||||||
|
Action.SKIP_CALLBACK );
|
||||||
|
}
|
||||||
|
disable = true;
|
||||||
|
}
|
||||||
|
return disable;
|
||||||
|
}
|
||||||
|
|
||||||
private void enabledElseWarn( CommsConnType typ )
|
private void enabledElseWarn( CommsConnType typ )
|
||||||
{
|
{
|
||||||
boolean enabled = true;
|
boolean enabled = true;
|
||||||
|
|
|
@ -258,9 +258,8 @@ public class GameConfigDelegate extends DelegateBase
|
||||||
LinearLayout layout = (LinearLayout)inflate( R.layout.conn_types_display );
|
LinearLayout layout = (LinearLayout)inflate( R.layout.conn_types_display );
|
||||||
final ConnViaViewLayout items = (ConnViaViewLayout)
|
final ConnViaViewLayout items = (ConnViaViewLayout)
|
||||||
layout.findViewById( R.id.conn_types );
|
layout.findViewById( R.id.conn_types );
|
||||||
items.setActivity( m_activity );
|
|
||||||
|
|
||||||
items.configure( conTypes,
|
items.configure( this, conTypes,
|
||||||
new ConnViaViewLayout.CheckEnabledWarner() {
|
new ConnViaViewLayout.CheckEnabledWarner() {
|
||||||
public void warnDisabled( CommsConnType typ ) {
|
public void warnDisabled( CommsConnType typ ) {
|
||||||
switch( typ ) {
|
switch( typ ) {
|
||||||
|
|
|
@ -320,6 +320,8 @@ public class XWActivity extends FragmentActivity
|
||||||
return m_dlgt.makeDialog( alert, params );
|
return m_dlgt.makeDialog( alert, params );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected DelegateBase getDelegate() { return m_dlgt; }
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// DlgClickNotify interface
|
// DlgClickNotify interface
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class XWConnAddrPreference extends DialogPreference
|
||||||
View view = LocUtils.inflate( activity, R.layout.conn_types_display );
|
View view = LocUtils.inflate( activity, R.layout.conn_types_display );
|
||||||
|
|
||||||
final ConnViaViewLayout cvl = (ConnViaViewLayout)view.findViewById( R.id.conn_types );
|
final ConnViaViewLayout cvl = (ConnViaViewLayout)view.findViewById( R.id.conn_types );
|
||||||
cvl.configure( XWPrefs.getAddrTypes( activity ),
|
cvl.configure( activity.getDelegate(), XWPrefs.getAddrTypes( activity ),
|
||||||
new ConnViaViewLayout.CheckEnabledWarner() {
|
new ConnViaViewLayout.CheckEnabledWarner() {
|
||||||
@Override
|
@Override
|
||||||
public void warnDisabled( CommsConnType typ ) {
|
public void warnDisabled( CommsConnType typ ) {
|
||||||
|
|
|
@ -462,6 +462,9 @@ public class XWPrefs {
|
||||||
if ( 0 == result.size() ) {
|
if ( 0 == result.size() ) {
|
||||||
result.add( CommsConnType.COMMS_CONN_MQTT );
|
result.add( CommsConnType.COMMS_CONN_MQTT );
|
||||||
}
|
}
|
||||||
|
if ( !BTUtils.havePermissions( context ) ) {
|
||||||
|
result.remove( CommsConnType.COMMS_CONN_BT );
|
||||||
|
}
|
||||||
if ( originalHash != result.hashCode() ) {
|
if ( originalHash != result.hashCode() ) {
|
||||||
setAddrTypes( context, result );
|
setAddrTypes( context, result );
|
||||||
}
|
}
|
||||||
|
|
|
@ -2395,6 +2395,8 @@
|
||||||
permission, but only the phone number of the sender will be
|
permission, but only the phone number of the sender will be
|
||||||
displayed.
|
displayed.
|
||||||
</string>
|
</string>
|
||||||
|
<string name="nearbydev_rationale">CrossWords needs permission to
|
||||||
|
discover nearby devices in order to use Bluetooth.</string>
|
||||||
<string name="move_dict_rationale">Storing a wordlist in the
|
<string name="move_dict_rationale">Storing a wordlist in the
|
||||||
Downloads area requires Storage permission.</string>
|
Downloads area requires Storage permission.</string>
|
||||||
<string name="remove_sms">Remove SMS</string>
|
<string name="remove_sms">Remove SMS</string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue