mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
add static final boolean by which to turn BT support off and change so
UI and background service disappear/don't run when it's off. Goal's to ship two apps that differ in this setting, a change in Android.mk, and little else.
This commit is contained in:
parent
b7f82475b8
commit
c1c20db6dd
5 changed files with 72 additions and 56 deletions
|
@ -106,16 +106,19 @@
|
|||
</LinearLayout>
|
||||
|
||||
<!-- Bluetooth -->
|
||||
<TextView style="@style/config_separator"
|
||||
<TextView android:id="@+id/bt_separator"
|
||||
style="@style/config_separator"
|
||||
android:layout_marginTop="10dip"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/newgame_bt_header"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<LinearLayout android:id="@+id/bt_disabled"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<TextView android:text="@string/bt_disabled"
|
||||
style="@style/relay_explain"
|
||||
|
@ -131,6 +134,7 @@
|
|||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
|
|
|
@ -31,6 +31,7 @@ public class BTReceiver extends BroadcastReceiver {
|
|||
@Override
|
||||
public void onReceive( Context context, Intent intent )
|
||||
{
|
||||
if ( XWApp.BTSUPPORTED ) {
|
||||
DbgUtils.logf( "BTReceiver.onReceive()" );
|
||||
String action = intent.getAction();
|
||||
DbgUtils.logf( "BTReceiver.onReceive(action=%s)", action );
|
||||
|
@ -53,3 +54,4 @@ public class BTReceiver extends BroadcastReceiver {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,10 +246,12 @@ public class BTService extends Service {
|
|||
@Override
|
||||
public void onCreate()
|
||||
{
|
||||
m_adapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if ( null != m_adapter && m_adapter.isEnabled() ) {
|
||||
BluetoothAdapter adapter = XWApp.BTSUPPORTED
|
||||
? BluetoothAdapter.getDefaultAdapter() : null;
|
||||
if ( null != adapter && adapter.isEnabled() ) {
|
||||
m_adapter = adapter;
|
||||
DbgUtils.logf( "BTService.onCreate(); bt name = %s",
|
||||
m_adapter.getName() );
|
||||
adapter.getName() );
|
||||
initNames();
|
||||
listLocalBTGames( false );
|
||||
startListener();
|
||||
|
@ -263,6 +265,7 @@ public class BTService extends Service {
|
|||
@Override
|
||||
public int onStartCommand( Intent intent, int flags, int startId )
|
||||
{
|
||||
Assert.assertTrue( XWApp.BTSUPPORTED );
|
||||
if ( null != intent ) {
|
||||
int cmd = intent.getIntExtra( CMD_STR, -1 );
|
||||
DbgUtils.logf( "BTService.onStartCommand; cmd=%d", cmd );
|
||||
|
|
|
@ -264,11 +264,14 @@ public class NewGameActivity extends XWActivity {
|
|||
|
||||
private void checkEnableBT( boolean force )
|
||||
{
|
||||
if ( XWApp.BTSUPPORTED ) {
|
||||
boolean enabled = BTService.BTEnabled();
|
||||
|
||||
if ( force || enabled != m_showsOn ) {
|
||||
m_showsOn = enabled;
|
||||
|
||||
findViewById( R.id.bt_separator ).setVisibility( View.VISIBLE );
|
||||
|
||||
findViewById( R.id.bt_disabled ).
|
||||
setVisibility( enabled ? View.GONE : View.VISIBLE );
|
||||
findViewById( R.id.bt_stuff ).
|
||||
|
@ -296,7 +299,8 @@ public class NewGameActivity extends XWActivity {
|
|||
@Override
|
||||
public void onClick( View v ) {
|
||||
Intent enableBtIntent =
|
||||
new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
|
||||
new Intent(BluetoothAdapter.
|
||||
ACTION_REQUEST_ENABLE);
|
||||
startActivityForResult( enableBtIntent, 0 );
|
||||
}
|
||||
} );
|
||||
|
@ -304,3 +308,4 @@ public class NewGameActivity extends XWActivity {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ import org.eehouse.android.xw4.jni.XwJNI;
|
|||
|
||||
public class XWApp extends Application {
|
||||
|
||||
public static final boolean BTSUPPORTED = true;
|
||||
|
||||
private static UUID s_UUID = null;
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue