From cfba0411fe708afc1c5742708918b075d278b335 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 16 Sep 2014 06:42:53 -0700 Subject: [PATCH] hide the expandable headers completely when BT or SMS isn't available --- .../org/eehouse/android/xw4/BTService.java | 6 ++++ .../eehouse/android/xw4/NewGameDelegate.java | 28 ++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java index 49a6454bc..487482cfd 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java @@ -139,6 +139,12 @@ public class BTService extends XWService { private BTListenerThread m_listener; private BTSenderThread m_sender; + public static boolean BTAvailable() + { + BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); + return null != adapter; + } + public static boolean BTEnabled() { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameDelegate.java index c42823603..04d1bc386 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameDelegate.java @@ -401,7 +401,11 @@ public class NewGameDelegate extends DelegateBase { private void checkEnableBT( boolean force ) { - if ( XWApp.BTSUPPORTED ) { + boolean available = XWApp.BTSUPPORTED && BTService.BTAvailable(); + setVisibility( R.id.newgame_bt_header, + available? View.VISIBLE : View.GONE ); + + if ( available ) { boolean enabled = BTService.BTEnabled(); if ( force || enabled != m_showsOn ) { @@ -447,16 +451,20 @@ public class NewGameDelegate extends DelegateBase { } private void checkEnableSMS() - { - if ( XWApp.SMSSUPPORTED && Utils.deviceSupportsSMS(m_activity) ) { - boolean enabled = XWPrefs.getSMSEnabled( m_activity ); - findViewById( R.id.newgame_sms_header ). - setVisibility( View.VISIBLE ); + { + boolean available = XWApp.SMSSUPPORTED + && Utils.deviceSupportsSMS(m_activity); + setVisibility( R.id.newgame_sms_header, + available? View.VISIBLE : View.GONE ); - findViewById( R.id.sms_disabled ). - setVisibility( enabled ? View.GONE : View.VISIBLE ); - findViewById( R.id.sms_stuff ). - setVisibility( enabled ? View.VISIBLE : View.GONE ); + if ( available ) { + boolean enabled = XWPrefs.getSMSEnabled( m_activity ); + setVisibility( R.id.newgame_sms_header, View.VISIBLE ); + + setVisibility( R.id.sms_disabled, + enabled ? View.GONE : View.VISIBLE ); + setVisibility( R.id.sms_stuff, + enabled ? View.VISIBLE : View.GONE ); Button button; if ( enabled ) {