cleanup: remove asserts and unused strings

Some asserts were firing in the very rare case where for some reason
relay couldn't be converted to mqtt.
This commit is contained in:
Eric House 2022-07-01 12:00:35 -07:00
parent 2dfc9129f3
commit a6a6523e9c
15 changed files with 12 additions and 131 deletions

View file

@ -30,6 +30,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -160,12 +161,8 @@ public class BackupConfigView extends LinearLayout
CheckBox box = mCheckBoxes.get( what );
if ( box.isChecked() ) {
result.add( what );
Log.d( TAG, "getSaveWhat(): added %s", what );
} else {
Log.d( TAG, "getSaveWhat(): DID NOT add %s", what );
}
}
Log.d( TAG, "getSaveWhat() => %s", result );
return result;
}

View file

@ -1,5 +0,0 @@
public class BackupView {
}

View file

@ -2610,7 +2610,7 @@ public class BoardDelegate extends DelegateBase
}
}
if ( m_connTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
Assert.failDbg();
Log.e( TAG, "opened game with RELAY still" );
}
if ( m_connTypes.contains( CommsConnType.COMMS_CONN_MQTT ) ) {

View file

@ -101,7 +101,7 @@ public class CommsTransport implements TransportProcs {
int nSent = -1;
switch ( conType ) {
case COMMS_CONN_RELAY:
Assert.failDbg();
Log.e( TAG, "sendForAddr();still sending via RELAY" );
break;
case COMMS_CONN_SMS:
nSent = NBSProto.sendPacket( context, addr.sms_phone,

View file

@ -680,7 +680,6 @@ public class ConnStatusHandler {
//!getAirplaneModeOn( context );
break;
case COMMS_CONN_RELAY:
Assert.failDbg();
result = false;
break;
case COMMS_CONN_P2P:

View file

@ -175,10 +175,9 @@ public class DBUtils {
getString(cursor.getColumnIndex( DBHelper.PLAYERS ));
summary.readPlayers( context, players );
// isoCode will be null when game first created
summary.isoCode = cursor
.getString(cursor.getColumnIndex(DBHelper.ISOCODE));
// isoCode will be null when game first created
// Assert.assertTrueNR( null != summary.isoCode ); // fired!
summary.modtime =
cursor.getLong(cursor.
@ -335,7 +334,6 @@ public class DBUtils {
iter.hasNext(); ) {
switch ( iter.next() ) {
case COMMS_CONN_RELAY:
Assert.failDbg();
values.put( DBHelper.ROOMNAME, summary.roomName );
String relayID = summary.relayID;
values.put( DBHelper.RELAYID, relayID );
@ -2015,7 +2013,6 @@ public class DBUtils {
public static String[] studyListLangs( Context context )
{
String[] result = null;
String selection = null;//DBHelper.LANGUAGE;
String[] columns = { DBHelper.ISOCODE };
String groupBy = columns[0];

View file

@ -467,16 +467,12 @@ public abstract class DelegateBase implements DlgClickNotify,
NetUtils.copyAndLaunchGamePage( m_activity, gameID );
}
};
} else if ( conTypes.contains( CommsConnType.COMMS_CONN_RELAY )
|| conTypes.contains( CommsConnType.COMMS_CONN_P2P ) ) {
} else if ( conTypes.contains( CommsConnType.COMMS_CONN_P2P ) ) {
buttonTxt = R.string.button_reconnect;
lstnr = new OnClickListener() {
@Override
public void onClick( DialogInterface dlg, int buttn ) {
NetStateCache.reset( m_activity );
if ( conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
Assert.failDbg();
}
if ( conTypes.contains( CommsConnType.COMMS_CONN_P2P ) ) {
WiDirService.reset( getActivity() );
}
@ -751,9 +747,6 @@ public abstract class DelegateBase implements DlgClickNotify,
case APP_NOT_FOUND_BT:
fmtId = R.string.app_not_found_fmt;
break;
case RELAY_ALERT:
m_dlgDelegate.eventOccurred( event, args );
break;
default:
Log.d( TAG, "eventOccurred(event=%s) (DROPPED)", event.toString() );
break;

View file

@ -233,7 +233,7 @@ public class DictLangCache {
}
}
DictAndLoc[] result = al.toArray( new DictAndLoc[al.size()] );
Log.d( TAG, "getDALsHaveLang(%s) => %s", isoCode, result );
// Log.d( TAG, "getDALsHaveLang(%s) => %s", isoCode, result );
return result;
}
@ -289,7 +289,7 @@ public class DictLangCache {
{
makeMaps( context );
String result = s_langCodes.get( langName );
Log.d( TAG, "getLangIsoCode(%s) => %s", langName, result );
// Log.d( TAG, "getLangIsoCode(%s) => %s", langName, result );
return result;
}
@ -432,7 +432,7 @@ public class DictLangCache {
private static void putTwo( String isoCode, String langName )
{
Log.d( TAG, "putTwo(): adding %s => %s", langName, isoCode );
// Log.d( TAG, "putTwo(): adding %s => %s", langName, isoCode );
Assert.assertTrueNR( !TextUtils.isEmpty(isoCode)
&& !TextUtils.isEmpty(langName) );
s_langCodes.put( langName, isoCode );
@ -461,7 +461,7 @@ public class DictLangCache {
String isoCode = info.isoCode;
Assert.assertTrueNR( null != isoCode );
if ( !s_langNames.containsKey( isoCode ) ) {
Log.d( TAG, "looking at info %s", info );
// Log.d( TAG, "looking at info %s", info );
Assert.assertTrueNR( null != info.langName );
putTwo( isoCode, info.langName );
}
@ -503,7 +503,7 @@ public class DictLangCache {
Assert.assertTrueNR( null != info.fullSum );
DBUtils.dictsSetInfo( context, dal, info );
Log.d( TAG, "getInfo() => %s", info );
// Log.d( TAG, "getInfo() => %s", info );
} else {
Log.i( TAG, "getInfo(): unable to open dict %s", dal.name );
}

View file

@ -479,10 +479,6 @@ public class DlgDelegate {
msg = getString( R.string.bt_fail_fmt, (String)args[0] );
asToast = false;
break;
case RELAY_ALERT:
msg = (String)args[0];
asToast = false;
break;
default:
Log.e( TAG, "eventOccurred: unhandled event %s", event.toString() );

View file

@ -217,7 +217,7 @@ public class GameConfigDelegate extends DelegateBase
int whichButton ) {
applyChanges( true );
if ( DlgID.CONFIRM_CHANGE_PLAY == dlgID ) {
launchGame( true );
saveAndClose( true );
}
}
};
@ -1290,16 +1290,6 @@ public class GameConfigDelegate extends DelegateBase
}
}
private void launchGame( boolean forceNew )
{
if ( m_conTypes.contains( CommsConnType.COMMS_CONN_RELAY )
&& 0 == m_car.ip_relay_invite.length() ) {
makeOkOnlyBuilder( R.string.no_empty_rooms ).show();
} else {
saveAndClose( forceNew );
}
}
@Override
protected void setTitle()
{

View file

@ -93,8 +93,6 @@ public class MultiService {
SMS_SEND_FAILED_NOPERMISSION,
BT_GAME_CREATED,
RELAY_ALERT,
};
public interface MultiEventListener {

View file

@ -264,23 +264,6 @@ public class GameSummary implements Serializable {
}
}
// If we're using relay to connect, get status from that
if ( null == result
&& conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
if ( 0 < missing ) {
if ( null == relayID || 0 == relayID.length() ) {
fmtID = R.string.summary_relay_conf_fmt;
} else {
fmtID = R.string.summary_relay_wait_fmt;
}
} else if ( gameOver ) {
fmtID = R.string.summary_relay_gameover_fmt;
} else {
fmtID = R.string.summary_relay_conn_fmt;
}
result = LocUtils.getString( context, fmtID, roomName );
}
// Otherwise, use BT or SMS
if ( null == result ) {
if ( conTypes.contains( CommsConnType.COMMS_CONN_BT )

View file

@ -38,22 +38,7 @@
states it can be in in the process of connecting to the
relay. These next three strings are used to create those
three. -->
<!-- First state: is configured to use a room but has not yet
contacted the relay and been assigned that room. -->
<string name="summary_relay_conf_fmt">Configured for room
“%1$s”</string>
<!-- Second state: has been assigned to a room on the relay
(meaning the network is working) but there are not yet as
many players as expected: the game is not complete and play
cannot happen. -->
<string name="summary_relay_wait_fmt">Waiting for players in room
“%1$s”</string>
<!-- Third state: enough devices have connected in the room to
form a complete game. We'll be in this state as long as the
game exists. -->
<string name="summary_relay_conn_fmt">Game in play in room “%1$s”</string>
<!-- Final state: game is over. -->
<string name="summary_relay_gameover_fmt">Game over in room “%1$s”</string>
<string name="summary_invites_out">Players invited</string>
<string name="summary_invites_out_fmt">Players invited to room “%1$s”</string>
<!-- Games that have ended are listed with this string -->
@ -87,13 +72,6 @@
<string name="gamel_menu_dicts">Wordlists</string>
<!-- text of menu that brings up the Settings (preferences) dialog -->
<string name="menu_prefs">App Settings</string>
<!-- Text of progress indicator shown while check is being conducted -->
<string name="msgs_progress">Checking relay for moves
etc…</string>
<!-- If you choose the above option and have no networked games
you get this error message -->
<string name="no_games_to_refresh">No games found that connect via
the relay.</string>
<!-- Brings up "About CrossWords" dialog -->
<string name="board_menu_file_about">About CrossWords</string>
<!--
@ -521,32 +499,6 @@
tray in place of the first tile placed along with the points
the current move would earn if committed. -->
<string name="pts">pts</string>
<!-- Text of "toast" (mini window briefly displayed) shown when a
game first connects to the relay. The three substitutions
are the device's order within the game (e.g. 2), the name of
the room, and how many additional players have not yet
registered with the relay in this game. This should be seen
only once per game. -->
<plurals name="msg_relay_waiting_fmt">
<item quantity="one">Device %1$d connected to relay in
room “%2$s”. Waiting for one player.</item>
<item quantity="other">Device %1$d connected to relay in
room “%2$s”. Waiting for %3$d players.</item>
</plurals>
<!-- Title of dialog used to alert players to relay-related
problems with the current game. -->
<string name="relay_alert">Connection problem</string>
<!-- (I believe this can no longer occur) -->
<string name="msg_too_many">You are providing more players than
the host expects.</string>
<!-- (I believe this can no longer occur) -->
<string name="msg_no_room">No host has registered a room by that name.</string>
<!-- (I believe this can no longer occur) -->
<string name="msg_dup_room">Another host has already registered a
room using that name. Rename yours or retry later.</string>
<!-- (I believe this can no longer occur) -->
<string name="msg_lost_other">The relay has lost contact with
another device in this game.</string>
<!-- When a game has been connected and the relay is notified that
a device in the game has deleted its part of the game, this
message is posted when you connect your end of it to the
@ -1114,10 +1066,6 @@
other devices in the game: no "clear chat" message is
transmitted. -->
<string name="chat_menu_clear">Clear history</string>
<!-- If you click on the Play button without having entered a room
name you get an alert with this error message. -->
<string name="no_empty_rooms">This game cannot connect without a
room name.</string>
<!--
error messages
-->
@ -1999,7 +1947,6 @@
<string name="square_tiles">Square rack tiles</string>
<string name="square_tiles_summary">Even if they can be taller</string>
<string name="change_group">Move selected games to:</string>
<string name="relay_alert_title">Message from relay</string>
<!-- Displayed in a hint alert when user taps a game row -->
<string name="not_again_newselect">Tapping a games listing opens
the game.\n\nUnless you tap the icons at the left. Tapping there selects
@ -2069,9 +2016,6 @@
<string name="slmenu_select_all">Select all</string>
<string name="slmenu_deselect_all">Unselect all</string>
<string name="sel_items_fmt">Selected: %1$d</string>
<string name="loc_menu_xlate">Translate</string>
<string name="loc_lang_blessed">%1$s (official)</string>
<string name="loc_lang_local">%1$s (yours)</string>
<plurals name="new_xlations_fmt">
<item quantity="one">Installed one new translation</item>
<item quantity="other">Installed %1$d new translations</item>
@ -2109,13 +2053,6 @@
<string name="loc_item_check">Check</string>
<string name="loc_item_copy_eng">Copy English</string>
<string name="loc_item_copy_bless">Copy official</string>
<string name="loc_fmts_mismatch">Illegal translation: a translated
string must have the same format specifiers (e.g. %1$s) as the
original.</string>
<string name="not_again_fmt_expl">This string has special format
specifiers (e.g. %1$s). Please be sure that your translation has
the same ones as the original.\n\n(You will not be able to save it
unless it does.)</string>
<string name="remote_empty">Fetching wordlist information from server…</string>
<string name="remote_digesting">Processing wordlist information…</string>
<string name="remote_no_net">Unable to fetch wordlist information
@ -2139,7 +2076,6 @@
<string name="dict_lang_inst">(Installed: %1$d)</string>
<string name="dict_lang_inst_and_avail">(Installed: %1$d; Available: %2$d)</string>
<string name="dict_desc_fmt">%1$s (%2$s/%3$d words)</string>
<string name="lang_unknown">Unknown</string>
<string name="not_again_dicts">This screen lets you install new
wordlists and view the ones you already have.\n\nWhat wordlists
you have installed determines:\n• What languages you can play
@ -2659,7 +2595,6 @@
<!-- For color "themes", currently light and dark
supported. Custom may follow. -->
<string name="prefs_themes">Board color themes</string>
<string name="theme_which">Board color theme</string>
<string name="color_use_theme_light">Use Light theme</string>
<string name="color_use_theme_dark">Use Dark theme</string>

View file

@ -2286,8 +2286,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
setString( env, jsummary, "relayID", buf );
}
setString( env, jsummary, "roomName", addr.u.ip_relay.invite );
#else
XP_ASSERT(0);
#endif
}
break;