From 26f6bb8b431fdf853a29d436ea9e722ae89b0dc0 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 1 Nov 2020 19:32:58 -0800 Subject: [PATCH] cleanup/refactor --- .../eehouse/android/xw4/BoardDelegate.java | 6 +++ .../android/xw4/XWConnAddrPreference.java | 45 +++++++++++-------- .../app/src/main/res/values/strings.xml | 2 +- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java index 5ddc20d45..1e72a3423 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java @@ -242,6 +242,7 @@ public class BoardDelegate extends DelegateBase int title = (Integer)params[0]; String msg = (String)params[1]; lstnr = new OnClickListener() { + @Override public void onClick( DialogInterface dlg, int whichButton ) { if ( DlgID.DLG_USEDICT == dlgID ) { @@ -283,6 +284,7 @@ public class BoardDelegate extends DelegateBase case QUERY_MOVE: { String msg = (String)params[0]; lstnr = new OnClickListener() { + @Override public void onClick( DialogInterface dialog, int whichButton ) { handleViaThread( JNICmd.CMD_COMMIT, true, true ); @@ -298,6 +300,7 @@ public class BoardDelegate extends DelegateBase case NOTIFY_BADWORDS: { lstnr = new OnClickListener() { + @Override public void onClick( DialogInterface dlg, int bx ) { handleViaThread( JNICmd.CMD_COMMIT, true, false ); } @@ -334,6 +337,7 @@ public class BoardDelegate extends DelegateBase buttonTxt = getString( resID ); } lstnr = new OnClickListener() { + @Override public void onClick( DialogInterface dialog, int whichButton ) { makeNotAgainBuilder( R.string.not_again_lookup, @@ -539,6 +543,7 @@ public class BoardDelegate extends DelegateBase .setMessage( message ); OnClickListener lstnr = new OnClickListener() { + @Override public void onClick( DialogInterface dialog, int item ){ if ( !state.relayMissing || ! state.connTypes.contains(CommsConnType.COMMS_CONN_RELAY) ) { @@ -559,6 +564,7 @@ public class BoardDelegate extends DelegateBase if ( showNeutButton ) { lstnr = new OnClickListener() { + @Override public void onClick( DialogInterface dialog, int item ) { String msg = sentInfo[0].getAsText( activity ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWConnAddrPreference.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWConnAddrPreference.java index 6c9254530..0214fa557 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWConnAddrPreference.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWConnAddrPreference.java @@ -59,45 +59,52 @@ public class XWConnAddrPreference extends DialogPreference { final PrefsActivity activity = (PrefsActivity)m_context; m_view.configure( XWPrefs.getAddrTypes( m_context ), new ConnViaViewLayout.CheckEnabledWarner() { + @Override public void warnDisabled( CommsConnType typ ) { + String msg = null; + int msgID = 0; + Action action = null; + int buttonID = 0; switch( typ ) { case COMMS_CONN_SMS: - activity - .makeConfirmThenBuilder( R.string.warn_sms_disabled, - Action.ENABLE_NBS_ASK ) - .setPosButton( R.string.button_enable_sms ) - .setNegButton( R.string.button_later ) - .show(); + msgID = R.string.warn_sms_disabled; + action = Action.ENABLE_NBS_ASK; + buttonID = R.string.button_enable_sms; break; case COMMS_CONN_BT: - activity - .makeConfirmThenBuilder( R.string.warn_bt_disabled, - Action.ENABLE_BT_DO ) - .setPosButton( R.string.button_enable_bt ) - .setNegButton( R.string.button_later ) - .show(); + msgID = R.string.warn_bt_disabled; + action = Action.ENABLE_BT_DO; + buttonID = R.string.button_enable_bt; break; case COMMS_CONN_RELAY: - String msg = LocUtils + msg = LocUtils .getString( m_context, R.string .warn_relay_disabled ); msg += "\n\n" + LocUtils .getString( m_context, R.string.warn_relay_later ); - activity - .makeConfirmThenBuilder( msg, Action - .ENABLE_RELAY_DO ) - .setPosButton( R.string.button_enable_relay ) - .setNegButton( R.string.button_later ) - .show(); + action = Action.ENABLE_RELAY_DO; + buttonID = R.string.button_enable_relay; break; default: Assert.failDbg(); break; } + + if ( 0 != msgID ) { + Assert.assertTrueNR( null == msg ); + msg = LocUtils.getString( activity, msgID ); + } + if ( null != msg ) { + activity.makeConfirmThenBuilder( msg, action ) + .setPosButton( buttonID ) + .setNegButton( R.string.button_later ) + .show(); + } } }, new ConnViaViewLayout.SetEmptyWarner() { + @Override public void typeSetEmpty() { PrefsActivity activity = (PrefsActivity)m_context; activity diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index 6c6da97a8..c97aa98d0 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -1880,7 +1880,7 @@ disabled, and no moves will be exchanged via Bluetooth until it is enabled.\n\nYou can enable Bluetooth now, or later. - Relay play is currently disable + Relay play is currently disabled on this device. No moves will be sent or received via the relay. You can enable relay play now, or