replace getString() calls that fetch format strings then apply them

with calls to the formatting (varargs) version of getString().  Should
be no behavior change.
This commit is contained in:
Eric House 2012-08-30 19:18:08 -07:00
parent 2eb8904a0a
commit adab1b5cea
13 changed files with 45 additions and 64 deletions

View file

@ -425,8 +425,7 @@ public class BoardActivity extends XWActivity
switch( id ) {
case DLG_INVITE:
AlertDialog ad = (AlertDialog)dialog;
String format = getString( R.string.invite_msgf );
String message = String.format( format, m_missing );
String message = getString( R.string.invite_msgf, m_missing );
if ( m_missing > 1 ) {
message += getString( R.string.invite_multiple );
}
@ -1097,8 +1096,7 @@ public class BoardActivity extends XWActivity
// All players have now joined the game. The device that
// created the room will assign tiles. Then it will be
// the first player's turn
String fmt = getString( R.string.msg_relay_all_heref );
str = String.format( fmt, room );
str = getString( R.string.msg_relay_all_heref, room );
if ( devOrder > 1 ) {
naMsg = R.string.not_again_conndall;
naKey = R.string.key_notagain_conndall;
@ -1113,9 +1111,8 @@ public class BoardActivity extends XWActivity
m_missing = nMissing;
showDialog( DLG_INVITE );
} else {
String fmt = getString( R.string.msg_relay_waiting );
str = String.format( fmt, devOrder,
room, nMissing );
str = getString( R.string.msg_relay_waiting, devOrder,
room, nMissing );
if ( devOrder == 1 ) {
naMsg = R.string.not_again_conndfirst;
naKey = R.string.key_notagain_conndfirst;
@ -1502,8 +1499,7 @@ public class BoardActivity extends XWActivity
sb.append( "; " );
}
String format = getString( R.string.ids_badwords );
String message = String.format( format, sb.toString() );
String message = getString( R.string.ids_badwords, sb.toString() );
if ( turnLost ) {
nonBlockingDialog( DLG_BADWORDS,
@ -1991,8 +1987,7 @@ public class BoardActivity extends XWActivity
private void setupPasswdVars()
{
String fmt = getString( R.string.msg_ask_password );
m_dlgTitleStr = String.format( fmt, m_pwdName );
m_dlgTitleStr = getString( R.string.msg_ask_password, m_pwdName );
m_passwdLyt = (LinearLayout)Utils.inflate( BoardActivity.this,
R.layout.passwd_view );
m_passwdEdit = (EditText)m_passwdLyt.findViewById( R.id.edit );

View file

@ -64,8 +64,8 @@ public class ChatActivity extends XWActivity implements View.OnClickListener {
((Button)findViewById( R.id.send_button )).setOnClickListener( this );
String fmt = getString( R.string.chat_titlef );
setTitle( String.format( fmt, GameUtils.getName( this, m_rowid ) ) );
setTitle( getString( R.string.chat_titlef,
GameUtils.getName( this, m_rowid ) ) );
}
@Override

View file

@ -108,8 +108,8 @@ public class DictImportActivity extends XWActivity {
DbgUtils.logf( "based on MIME type" );
new DownloadFilesTask().execute( uri );
} else if ( uri.toString().endsWith( XWConstants.DICT_EXTN ) ) {
String fmt = getString( R.string.downloading_dictf );
String txt = String.format( fmt, basename( uri.getPath()) );
String txt = getString( R.string.downloading_dictf,
basename( uri.getPath()) );
TextView view = (TextView)findViewById( R.id.dwnld_message );
view.setText( txt );
new DownloadFilesTask().execute( uri );

View file

@ -337,8 +337,7 @@ public class DictsActivity extends ExpandableListActivity
XWListItem rowView = m_adapter.getSelChildView();
String lang =
DictLangCache.getLangName( this, rowView.getText() );
format = getString( R.string.set_default_messagef );
message = String.format( format, lang );
message = getString( R.string.set_default_messagef, lang );
dialog = new AlertDialog.Builder( this )
.setTitle( R.string.query_title )
.setMessage( message )
@ -507,8 +506,9 @@ public class DictsActivity extends ExpandableListActivity
menu.removeItem( R.id.dicts_item_move );
}
String fmt = getString(R.string.game_item_menu_titlef );
menu.setHeaderTitle( String.format( fmt, row.getText() ) );
String title = getString( R.string.game_item_menu_titlef,
row.getText() );
menu.setHeaderTitle( title );
}
}
@ -575,8 +575,7 @@ public class DictsActivity extends ExpandableListActivity
public void deleteCalled( XWListItem item )
{
String dict = item.getText();
String msg = String.format( getString( R.string.confirm_delete_dictf ),
dict );
String msg = getString( R.string.confirm_delete_dictf, dict );
m_deleteDict = dict;
m_moveFromLoc = (DictUtils.DictLoc)item.getCached();
@ -605,9 +604,8 @@ public class DictsActivity extends ExpandableListActivity
fmtid = R.string.confirm_deletemore_dictf;
}
if ( 0 != fmtid ) {
String fmt = getString( fmtid );
msg += String.format( fmt, DictLangCache.
getLangName( this, langcode ) );
msg += getString( fmtid, DictLangCache.
getLangName( this, langcode ) );
}
}

View file

@ -261,10 +261,9 @@ public class GameConfig extends XWActivity
});
break;
case NO_NAME_FOUND:
String format = getString( R.string.no_name_found_f );
String msg =
String.format( format, m_gi.nPlayers, DictLangCache.
getLangName( this, m_gi.dictLang ) );
String msg = getString( R.string.no_name_found_f,
m_gi.nPlayers, DictLangCache.
getLangName( this, m_gi.dictLang ) );
dialog = new AlertDialog.Builder( this )
.setPositiveButton( R.string.button_ok, null )
// message added below since varies with language etc.
@ -315,8 +314,7 @@ public class GameConfig extends XWActivity
// Dicts spinner with label
String langName = DictLangCache.getLangName( this, m_gi.dictLang );
String label = String.format( getString( R.string.dict_lang_labelf ),
langName );
String label = getString( R.string.dict_lang_labelf, langName );
TextView text = (TextView)dialog.findViewById( R.id.dict_label );
text.setText( label );
configDictSpinner( dialog, lp );
@ -724,9 +722,8 @@ public class GameConfig extends XWActivity
{
Spinner dictsSpinner =
(Spinner)dialog.findViewById( R.id.dict_spinner );
String fmt = getString( R.string.dicts_list_promptf );
String lang = DictLangCache.getLangName( this, m_gi.dictLang );
dictsSpinner.setPrompt(String.format( fmt, lang ) );
dictsSpinner.setPrompt( getString( R.string.dicts_list_promptf, lang ) );
OnItemSelectedListener onSel =
new OnItemSelectedListener() {
@ -922,10 +919,10 @@ public class GameConfig extends XWActivity
if ( localOnlyGame() ) {
label = getString( R.string.players_label_standalone );
} else {
String fmt = getString( R.string.players_label_host );
int remoteCount = m_gi.remoteCount();
label = String.format( fmt, m_gi.nPlayers - remoteCount,
remoteCount );
label = getString( R.string.players_label_host,
m_gi.nPlayers - remoteCount,
remoteCount );
}
((TextView)findViewById( R.id.players_label )).setText( label );
}

View file

@ -172,11 +172,10 @@ public class GameListAdapter extends XWListAdapter {
}
String name = GameUtils.getName( m_context, m_rowid );
String format =
m_context.getString( R.string.str_game_namef );
if ( null != value ) {
value = String.format( format, name, value );
value = m_context.getString( R.string.str_game_namef,
name, value );
} else {
value = name;
}

View file

@ -329,8 +329,7 @@ public class GameUtils {
{
String result = DBUtils.getName( context, rowid );
if ( null == result || 0 == result.length() ) {
String fmt = context.getString( R.string.gamef );
result = String.format( fmt, rowid );
result = context.getString( R.string.gamef, rowid );
}
return result;
}
@ -531,8 +530,7 @@ public class GameUtils {
if ( null != gameUri ) {
int fmtId = choseEmail? R.string.invite_htmf : R.string.invite_txtf;
int choiceID;
String format = context.getString( fmtId );
String message = String.format( format, gameUri.toString() );
String message = context.getString( fmtId, gameUri.toString() );
Intent intent = new Intent();
if ( choseEmail ) {

View file

@ -116,12 +116,12 @@ public class GamesList extends XWListActivity
DictLangCache.getLangName( this, m_missingDictLang );
String gameName = GameUtils.getName( this, m_rowid );
if ( WARN_NODICT == id ) {
message = String.format( getString( R.string.no_dictf ),
gameName, langName );
message = getString( R.string.no_dictf,
gameName, langName );
} else {
message = String.format( getString(R.string.no_dict_substf),
gameName, m_missingDictNames[0],
langName );
message = getString( R.string.no_dict_substf,
gameName, m_missingDictNames[0],
langName );
}
ab = new AlertDialog.Builder( this )
@ -510,8 +510,8 @@ public class GamesList extends XWListActivity
int position = info.position;
long rowid = DBUtils.gamesList( this )[position];
String title = GameUtils.getName( this, rowid );
String fmt = getString(R.string.game_item_menu_titlef );
menu.setHeaderTitle( String.format( fmt, title ) );
menu.setHeaderTitle( getString( R.string.game_item_menu_titlef,
title ) );
}
@Override
@ -751,8 +751,7 @@ public class GamesList extends XWListActivity
rowid = GameUtils.makeNewNetGame( this, info );
GameUtils.launchGame( this, rowid, true );
} else {
String fmt = getString( R.string.dup_game_queryf );
String msg = String.format( fmt, info.room );
String msg = getString( R.string.dup_game_queryf, info.room );
m_netLaunchInfo = info;
showConfirmThen( msg, NEW_NET_GAME_ACTION );
}

View file

@ -82,9 +82,8 @@ public class NetLaunchInfo {
{
Builder ub = new Builder();
ub.scheme( "http" );
String format = context.getString( R.string.game_url_pathf );
ub.path( String.format( format,
XWPrefs.getDefaultRedirHost( context ) ) );
ub.path( context.getString( R.string.game_url_pathf,
XWPrefs.getDefaultRedirHost( context ) ) );
ub.appendQueryParameter( "lang", String.format("%d", lang ) );
ub.appendQueryParameter( "np", String.format( "%d", nPlayers ) );

View file

@ -78,11 +78,10 @@ public class NewGameActivity extends XWActivity {
setContentView( R.layout.new_game );
TextView desc = (TextView)findViewById( R.id.newgame_local_desc );
String fmt = getString( R.string.newgame_local_descf );
String dict = CommonPrefs.getDefaultHumanDict( this );
String lang = DictLangCache.getLangName( this, dict );
m_lang = DictLangCache.getLangLangCode( this, lang );
desc.setText( String.format( fmt, lang ) );
desc.setText( getString( R.string.newgame_local_descf, lang ) );
Button button = (Button)findViewById( R.id.newgame_local );
button.setOnClickListener( new View.OnClickListener() {

View file

@ -55,10 +55,9 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
m_lang = lang;
m_nInGame = nInGame;
String fmt = context.getString( R.string.public_names_progress );
String msg = String.format( fmt, nInGame,
DictLangCache.getLangName(context,lang) );
String msg = context.getString( R.string.public_names_progress,
nInGame,
DictLangCache.getLangName(context,lang) );
m_progress = ProgressDialog.show( context, msg, null, true,
true );
}

View file

@ -82,9 +82,8 @@ public class RelayGameActivity extends XWActivity
XwJNI.game_dispose( gamePtr );
String lang = DictLangCache.getLangName( this, m_gi.dictLang );
String fmt = getString( R.string.relay_game_explainf );
TextView text = (TextView)findViewById( R.id.explain );
text.setText( String.format( fmt, lang ) );
text.setText( getString( R.string.relay_game_explainf, lang ) );
}
@Override

View file

@ -342,8 +342,7 @@ public class Utils {
public static String format( Context context, int id, Object... args )
{
String fmt = context.getString( id );
return String.format( fmt, args );
return context.getString( id, args );
}
private static void setFirstBootStatics( Context context )