use superclass's getString() where possible instead of LocUtils's static version

This commit is contained in:
Eric House 2014-04-15 06:36:18 -07:00
parent 9720684ce7
commit dc8b5b073e
6 changed files with 61 additions and 89 deletions

View file

@ -317,7 +317,7 @@ public class BoardDelegate extends DelegateBase
waitCloseGame( false );
GameUtils.deleteGame( m_activity, m_rowid, false );
m_activity.finish();
finish();
}
};
ab.setNegativeButton( R.string.button_delete, lstnr );
@ -357,12 +357,11 @@ public class BoardDelegate extends DelegateBase
int resID = studyOn
? R.string.button_lookup_study_fmt
: R.string.button_lookup_fmt;
buttonTxt = LocUtils.getString( m_activity, resID,
m_words[0] );
buttonTxt = getString( resID, m_words[0] );
} else {
int resID = studyOn ? R.string.button_lookup_study
: R.string.button_lookup;
buttonTxt = LocUtils.getString( m_activity, resID );
buttonTxt = getString( resID );
}
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dialog,
@ -395,8 +394,7 @@ public class BoardDelegate extends DelegateBase
if ( DlgID.PICK_TILE_REQUESTBLANK_BLK == dlgID ) {
ab.setTitle( R.string.title_tile_picker );
} else {
ab.setTitle( LocUtils.getString( m_activity, R.string.cur_tiles_fmt,
m_curTiles ) );
ab.setTitle( getString( R.string.cur_tiles_fmt, m_curTiles ) );
if ( m_canUndoTiles ) {
DialogInterface.OnClickListener undoClicked =
new DialogInterface.OnClickListener() {
@ -494,11 +492,9 @@ public class BoardDelegate extends DelegateBase
case DLG_INVITE:
AlertDialog ad = (AlertDialog)dialog;
String message =
LocUtils.getString( m_activity, R.string.invite_msg_fmt,
m_missing );
getString( R.string.invite_msg_fmt, m_missing );
if ( m_missing > 1 ) {
message += LocUtils.getString( m_activity,
R.string.invite_multiple );
message += getString( R.string.invite_multiple );
}
ad.setMessage( message );
break;
@ -689,7 +685,7 @@ public class BoardDelegate extends DelegateBase
strId = R.string.board_menu_tray_show;
}
item = menu.findItem( R.id.board_menu_tray );
item.setTitle( LocUtils.getString( m_activity, strId ) );
item.setTitle( getString( strId ) );
Utils.setItemVisible( menu, R.id.board_menu_flip,
m_gsi.visTileCount >= 1 );
@ -732,13 +728,12 @@ public class BoardDelegate extends DelegateBase
} else {
strId = R.string.board_menu_done;
}
item.setTitle( LocUtils.getString( m_activity, strId ) );
item.setTitle( getString( strId ) );
}
if ( m_gameOver || DBUtils.gameOver( m_activity, m_rowid ) ) {
m_gameOver = true;
item = menu.findItem( R.id.board_menu_game_resign );
item.setTitle( LocUtils.getString( m_activity,
R.string.board_menu_game_final ) );
item.setTitle( getString( R.string.board_menu_game_final ) );
}
}
@ -808,10 +803,10 @@ public class BoardDelegate extends DelegateBase
break;
case R.id.board_menu_trade:
String msg = LocUtils.getString( m_activity, R.string.not_again_trading );
String msg = getString( R.string.not_again_trading );
int strID = ABUtils.haveActionBar() ? R.string.not_again_trading_menu
: R.string. not_again_trading_buttons;
msg += LocUtils.getString( m_activity, strID );
msg += getString( strID );
showNotAgainDlgThen( msg, R.string.key_notagain_trading,
Action.START_TRADE_ACTION );
break;
@ -1133,7 +1128,7 @@ public class BoardDelegate extends DelegateBase
final DlgID dlgIDf = dlgID;
post( new Runnable() {
public void run() {
m_dlgBytes = LocUtils.getString( m_activity, strIDf );
m_dlgBytes = getString( strIDf );
m_dlgTitle = R.string.relay_alert;
showDialog( dlgIDf );
}
@ -1206,10 +1201,9 @@ public class BoardDelegate extends DelegateBase
{
m_jniThread.setSaveDict( getDict );
String msg = LocUtils.getString( m_activity, R.string.reload_new_dict_fmt,
getDict );
String msg = getString( R.string.reload_new_dict_fmt, getDict );
Utils.showToast( m_activity, msg );
m_activity.finish();
finish();
GameUtils.launchGame( m_activity, m_rowid, false );
}
@ -1302,9 +1296,7 @@ public class BoardDelegate extends DelegateBase
// Skip this until there's a way to show it only once per game
if ( false ) {
toastStr = LocUtils.getString( m_activity,
R.string.msg_relay_all_here_fmt,
room );
toastStr = getString( R.string.msg_relay_all_here_fmt, room );
if ( devOrder > 1 ) {
naMsg = R.string.not_again_conndall;
naKey = R.string.key_notagain_conndall;
@ -1318,8 +1310,8 @@ public class BoardDelegate extends DelegateBase
showDialog( DlgID.DLG_INVITE );
ABUtils.invalidateOptionsMenuIf( m_activity );
} else {
toastStr = LocUtils.getString( m_activity,R.string.msg_relay_waiting_fmt,
devOrder, room, nMissing );
toastStr = getString( R.string.msg_relay_waiting_fmt, devOrder,
room, nMissing );
if ( devOrder == 1 ) {
naMsg = R.string.not_again_conndfirst;
naKey = R.string.key_notagain_conndfirst;
@ -1405,7 +1397,7 @@ public class BoardDelegate extends DelegateBase
}
if ( 0 != id ) {
final String bonusStr = LocUtils.getString( m_activity, id );
final String bonusStr = getString( id );
post( new Runnable() {
public void run() {
Utils.showToast( m_activity, bonusStr );
@ -1420,7 +1412,7 @@ public class BoardDelegate extends DelegateBase
String expl = XwJNI.model_getPlayersLastScore( m_jniGamePtr,
player );
if ( expl.length() == 0 ) {
expl = LocUtils.getString( m_activity, R.string.no_moves_made );
expl = getString( R.string.no_moves_made );
}
String name = m_gi.players[player].name;
final String text = String.format( "%s\n%s", name, expl );
@ -1566,8 +1558,8 @@ public class BoardDelegate extends DelegateBase
public boolean confirmTrade( String[] tiles )
{
m_dlgTitle = R.string.info_title;
m_dlgBytes = LocUtils.getString( m_activity, R.string.query_trade_fmt,
TextUtils.join( ", ", tiles ) );
m_dlgBytes = getString( R.string.query_trade_fmt,
TextUtils.join( ", ", tiles ) );
return 0 != waitBlockingDialog( DlgID.QUERY_REQUEST_BLK, 0 );
}
@ -1623,8 +1615,7 @@ public class BoardDelegate extends DelegateBase
}
if ( resid != 0 ) {
nonBlockingDialog( DlgID.DLG_OKONLY,
LocUtils.getString( m_activity,resid ) );
nonBlockingDialog( DlgID.DLG_OKONLY, getString( resid ) );
}
} // userError
@ -1648,15 +1639,13 @@ public class BoardDelegate extends DelegateBase
if ( null != action ) {
m_haveInvited = true;
final Action faction = action;
final String fmsg = LocUtils.getString( m_activity,
R.string.invite_msg_fmt,
nMissingPlayers );
final String fmsg = getString( R.string.invite_msg_fmt,
nMissingPlayers );
post( new Runnable() {
public void run() {
DbgUtils.showf( m_activity,
LocUtils.getString( m_activity,
R.string.players_miss_fmt,
nMissingPlayers ) );
getString( R.string.players_miss_fmt,
nMissingPlayers ) );
m_nMissingPlayers = nMissingPlayers;
showConfirmThen( fmsg, faction );
}
@ -1675,8 +1664,7 @@ public class BoardDelegate extends DelegateBase
public void informUndo()
{
nonBlockingDialog( DlgID.DLG_OKONLY,
LocUtils.getString( m_activity,
R.string.remote_undone ) );
getString( R.string.remote_undone ) );
}
@Override
@ -1694,23 +1682,21 @@ public class BoardDelegate extends DelegateBase
oldName );
if ( !oldSum.equals( newSum ) ) {
// Same dict, different versions
msg = LocUtils.getString( m_activity,
R.string.inform_dict_diffversion_fmt,
oldName );
msg = getString( R.string.inform_dict_diffversion_fmt,
oldName );
}
} else {
// Different dict! If we have the other one, switch
// to it. Otherwise offer to download
DlgID dlgID;
msg = LocUtils.getString( m_activity, R.string.inform_dict_diffdict_fmt,
oldName, newName, newName );
msg = getString( R.string.inform_dict_diffdict_fmt,
oldName, newName, newName );
if ( DictLangCache.haveDict( m_activity, code,
newName ) ) {
dlgID = DlgID.DLG_USEDICT;
} else {
dlgID = DlgID.DLG_GETDICT;
msg += LocUtils.getString( m_activity,
R.string.inform_dict_download );
msg += getString( R.string.inform_dict_download );
}
m_getDict = newName;
nonBlockingDialog( dlgID, msg );
@ -1737,12 +1723,10 @@ public class BoardDelegate extends DelegateBase
String wordsString = TextUtils.join( ", ", words );
String message =
LocUtils.getString( m_activity, R.string.ids_badwords_fmt,
wordsString, dict );
getString( R.string.ids_badwords_fmt, wordsString, dict );
if ( turnLost ) {
m_dlgBytes = message +
LocUtils.getString( m_activity, R.string.badwords_lost );
m_dlgBytes = message + getString( R.string.badwords_lost );
m_dlgTitle = R.string.badwords_title;
waitBlockingDialog( DlgID.DLG_BADWORDS_BLK, 0 );
} else {
@ -1908,7 +1892,7 @@ public class BoardDelegate extends DelegateBase
}
} catch ( GameUtils.NoSuchGameException nsge ) {
DbgUtils.loge( nsge );
m_activity.finish();
finish();
}
}
} // loadGame
@ -2246,9 +2230,7 @@ public class BoardDelegate extends DelegateBase
private void setupPasswdVars()
{
m_dlgTitleStr =
LocUtils.getString( m_activity, R.string.msg_ask_password_fmt,
m_pwdName );
m_dlgTitleStr = getString( R.string.msg_ask_password_fmt, m_pwdName );
m_passwdLyt = (LinearLayout)LocUtils.inflate( m_activity,
R.layout.passwd_view );
m_passwdEdit = (EditText)m_passwdLyt.findViewById( R.id.edit );
@ -2259,7 +2241,7 @@ public class BoardDelegate extends DelegateBase
Intent intent = GamesListActivity.makeRematchIntent( m_activity, m_gi, m_rowid );
if ( null != intent ) {
m_activity.startActivity( intent );
m_activity.finish();
finish();
}
}

View file

@ -71,13 +71,12 @@ public class ChatDelegate extends DelegateBase
((Button)m_activity.findViewById( R.id.send_button ))
.setOnClickListener( this );
String title =
LocUtils.getString( m_activity, R.string.chat_title_fmt,
GameUtils.getName( m_activity, m_rowid ) );
String title = getString( R.string.chat_title_fmt,
GameUtils.getName( m_activity, m_rowid ) );
m_activity.setTitle( title );
} else {
// Should really assert....
m_activity.finish();
finish();
}
}
@ -106,6 +105,6 @@ public class ChatDelegate extends DelegateBase
result.putExtra( BoardActivity.INTENT_KEY_CHAT, text );
m_activity.setResult( Activity.RESULT_OK, result );
}
m_activity.finish();
finish();
}
}

View file

@ -248,8 +248,8 @@ public class DictsDelegate extends DelegateBase
case MOVE_DICT:
final XWListItem[] selItems = getSelItems();
final int[] moveTo = { -1 };
message = LocUtils.getString( m_activity, R.string.move_dict_fmt,
getJoinedNames( selItems ) );
message = getString( R.string.move_dict_fmt,
getJoinedNames( selItems ) );
OnClickListener newSelLstnr =
new OnClickListener() {
@ -310,9 +310,7 @@ public class DictsDelegate extends DelegateBase
};
String name = row.getText();
String lang = DictLangCache.getLangName( m_activity, name);
message = LocUtils.getString( m_activity,
R.string.set_default_message_fmt,
name, lang );
message = getString( R.string.set_default_message_fmt, name, lang );
dialog = new LocUtils.AlertBuilder( m_activity )
.setTitle( R.string.query_title )
.setMessage( message )
@ -336,7 +334,7 @@ public class DictsDelegate extends DelegateBase
};
lstnr2 = new OnClickListener() {
public void onClick( DialogInterface dlg, int item ) {
m_activity.finish();
finish();
}
};
@ -381,7 +379,7 @@ public class DictsDelegate extends DelegateBase
m_locNames = LocUtils.getStringArray( m_activity, R.array.loc_names );
m_downloadStr = LocUtils.getString( m_activity, R.string.download_dicts );
m_downloadStr = getString( R.string.download_dicts );
setContentView( R.layout.dict_browse );
m_expView = m_activity.getExpandableListView();
@ -495,7 +493,7 @@ public class DictsDelegate extends DelegateBase
String url =
intent.getStringExtra( UpdateCheckReceiver.NEW_DICT_URL );
DictImportActivity.downloadDictInBack( m_activity, url );
m_activity.finish();
finish();
}
}
@ -504,7 +502,7 @@ public class DictsDelegate extends DelegateBase
SharedPreferences sp
= PreferenceManager.getDefaultSharedPreferences( m_activity );
SharedPreferences.Editor editor = sp.edit();
String key = LocUtils.getString( m_activity, keyId );
String key = getString( keyId );
String name = view.getText();
editor.putString( key, name );
editor.commit();
@ -538,9 +536,8 @@ public class DictsDelegate extends DelegateBase
private void deleteSelected()
{
XWListItem[] items = getSelItems();
String msg = LocUtils.getString( m_activity,
R.string.confirm_delete_dict_fmt,
getJoinedNames( items ) );
String msg = getString( R.string.confirm_delete_dict_fmt,
getJoinedNames( items ) );
// When and what to warn about. First off, if there's another
// identical dict, simply confirm. Or if nobody's using this
@ -563,15 +560,12 @@ public class DictsDelegate extends DelegateBase
if ( 1 == langDals.length ) { // last in this language?
if ( 0 < nUsingLang ) {
newMsg =
LocUtils.getString( m_activity, R.string
.confirm_deleteonly_dict_fmt,
dict, langName );
newMsg = getString( R.string.confirm_deleteonly_dict_fmt,
dict, langName );
}
} else if ( 0 < DBUtils.countGamesUsingDict( m_activity, dict ) ) {
newMsg = LocUtils.getString( m_activity, R.string.
confirm_deletemore_dict_fmt,
langName );
newMsg = getString( R.string.confirm_deletemore_dict_fmt,
langName );
}
if ( null != newMsg ) {
msg += "\n\n" + newMsg;
@ -720,9 +714,7 @@ public class DictsDelegate extends DelegateBase
{
int nSels = m_selDicts.size();
if ( 0 < nSels ) {
m_activity.setTitle( LocUtils.getString( m_activity,
R.string.sel_items_fmt,
nSels ) );
m_activity.setTitle( getString( R.string.sel_items_fmt, nSels ) );
} else {
m_activity.setTitle( m_origTitle );
}
@ -795,7 +787,7 @@ public class DictsDelegate extends DelegateBase
Intent intent = m_activity.getIntent();
if ( MultiService.returnOnDownload( m_activity,
intent ) ) {
m_activity.finish();
finish();
}
} else {
Utils.showToast( m_activity,

View file

@ -786,9 +786,8 @@ public class GamesListDelegate extends DelegateBase
// Game menus: one or more games selected
case R.id.games_game_delete:
String msg = LocUtils.getString( m_activity,
R.string.confirm_seldeletes_fmt,
selRowIDs.length );
String msg = getString( R.string.confirm_seldeletes_fmt,
selRowIDs.length );
showConfirmThen( msg, R.string.button_delete,
Action.DELETE_GAMES, selRowIDs );
break;
@ -928,7 +927,7 @@ public class GamesListDelegate extends DelegateBase
if ( 0 == fmt ) {
m_activity.setTitle( m_origTitle );
} else {
m_activity.setTitle( LocUtils.getString( m_activity, fmt, nSels ) );
m_activity.setTitle( getString( fmt, nSels ) );
}
}

View file

@ -182,7 +182,7 @@ public class NewGameDelegate extends DelegateBase {
// We'll leave it up to BoardActivity to detect that
// it's not had any remote connections yet.
GameUtils.launchGame( m_activity, m_newRowID );
m_activity.finish();
finish();
}
break;
case INVITE_FOR_BT: // user selected device

View file

@ -264,7 +264,7 @@ public class StudyListDelegate extends DelegateBase
{
m_langCodes = DBUtils.studyListLangs( m_activity );
if ( 0 == m_langCodes.length ) {
m_activity.finish();
finish();
} else if ( 1 == m_langCodes.length ) {
m_pickView.setVisibility( View.GONE );
m_langPosition = 0;