From 546d7e8956ef91369435bda4100bb0fb2ed1705b Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 5 Apr 2010 14:54:18 -0700 Subject: [PATCH] Project-lib sample: externalize strings in lib. Change-Id: I5fff488ab96f1e28942143330c69370f2009e691 --- samples/TicTacToeLib/res/values/strings.xml | 6 +++++- .../android/tictactoe/library/GameActivity.java | 10 +++++----- .../example/android/tictactoe/library/GameView.java | 4 ---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/samples/TicTacToeLib/res/values/strings.xml b/samples/TicTacToeLib/res/values/strings.xml index 9fd841358..468975a8b 100755 --- a/samples/TicTacToeLib/res/values/strings.xml +++ b/samples/TicTacToeLib/res/values/strings.xml @@ -16,5 +16,9 @@ --> - + Player 2 (computer) wins! + Player 1 (you) wins! + This is a tie! No one wins! + Player 2\'s turn (that\'s the computer) + Player 1\'s turn -- that\'s you! diff --git a/samples/TicTacToeLib/src/com/example/android/tictactoe/library/GameActivity.java b/samples/TicTacToeLib/src/com/example/android/tictactoe/library/GameActivity.java index 811451f0d..df1cac076 100755 --- a/samples/TicTacToeLib/src/com/example/android/tictactoe/library/GameActivity.java +++ b/samples/TicTacToeLib/src/com/example/android/tictactoe/library/GameActivity.java @@ -106,11 +106,11 @@ public class GameActivity extends Activity { mButtonNext.setEnabled(false); if (player == State.PLAYER1) { - mInfoView.setText("Player 1's turn -- that's you!"); + mInfoView.setText(R.string.player1_turn); mGameView.setEnabled(true); } else if (player == State.PLAYER2) { - mInfoView.setText("Player 2's turn (that's the computer)"); + mInfoView.setText(R.string.player2_turn); mGameView.setEnabled(false); } @@ -248,11 +248,11 @@ public class GameActivity extends Activity { String text; if (player == State.EMPTY) { - text = "This is a tie! No one wins!"; + text = getString(R.string.tie); } else if (player == State.PLAYER1) { - text = "Player 1 (you) wins!"; + text = getString(R.string.player1_win); } else { - text = "Player 2 (computer) wins!"; + text = getString(R.string.player2_win); } mInfoView.setText(text); } diff --git a/samples/TicTacToeLib/src/com/example/android/tictactoe/library/GameView.java b/samples/TicTacToeLib/src/com/example/android/tictactoe/library/GameView.java index dbd43d95b..3af516aa6 100755 --- a/samples/TicTacToeLib/src/com/example/android/tictactoe/library/GameView.java +++ b/samples/TicTacToeLib/src/com/example/android/tictactoe/library/GameView.java @@ -35,7 +35,6 @@ import android.os.Message; import android.os.Parcelable; import android.os.Handler.Callback; import android.util.AttributeSet; -import android.util.Log; import android.view.MotionEvent; import android.view.View; @@ -43,8 +42,6 @@ import android.view.View; public class GameView extends View { - private static final String TAG = "GameView"; - public static final long FPS_MS = 1000/2; public enum State { @@ -280,7 +277,6 @@ public class GameView extends View { @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); - Log.d(TAG, String.format("onSizeChanged: %dx%d", w, h)); int sx = (w - 2 * MARGIN) / 3; int sy = (h - 2 * MARGIN) / 3;