diff --git a/CuckooChessAPK/.classpath b/CuckooChessAPK/.classpath new file mode 100644 index 0000000..e221cc8 --- /dev/null +++ b/CuckooChessAPK/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/CuckooChessAPK/.project b/CuckooChessAPK/.project new file mode 100644 index 0000000..aadbd11 --- /dev/null +++ b/CuckooChessAPK/.project @@ -0,0 +1,34 @@ + + + CuckooChessAPK + + + CuckooChessEngine + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/CuckooChessAPK/AndroidManifest.xml b/CuckooChessAPK/AndroidManifest.xml new file mode 100644 index 0000000..09afc15 --- /dev/null +++ b/CuckooChessAPK/AndroidManifest.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/CuckooChessAPK/assets/casefont.ttf b/CuckooChessAPK/assets/casefont.ttf new file mode 100644 index 0000000..61c12d6 Binary files /dev/null and b/CuckooChessAPK/assets/casefont.ttf differ diff --git a/CuckooChessAPK/project.properties b/CuckooChessAPK/project.properties new file mode 100644 index 0000000..19f2f1b --- /dev/null +++ b/CuckooChessAPK/project.properties @@ -0,0 +1,13 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Indicates whether an apk should be generated for each density. +split.density=false +# Project target. +target=android-4 diff --git a/CuckooChessAPK/res/drawable-hdpi/icon.png b/CuckooChessAPK/res/drawable-hdpi/icon.png new file mode 100644 index 0000000..afb7408 Binary files /dev/null and b/CuckooChessAPK/res/drawable-hdpi/icon.png differ diff --git a/CuckooChessAPK/res/drawable-ldpi/icon.png b/CuckooChessAPK/res/drawable-ldpi/icon.png new file mode 100644 index 0000000..70888c2 Binary files /dev/null and b/CuckooChessAPK/res/drawable-ldpi/icon.png differ diff --git a/CuckooChessAPK/res/drawable-mdpi/icon.png b/CuckooChessAPK/res/drawable-mdpi/icon.png new file mode 100644 index 0000000..5f7e2f2 Binary files /dev/null and b/CuckooChessAPK/res/drawable-mdpi/icon.png differ diff --git a/CuckooChessAPK/res/layout-land/main.xml b/CuckooChessAPK/res/layout-land/main.xml new file mode 100644 index 0000000..8e09e46 --- /dev/null +++ b/CuckooChessAPK/res/layout-land/main.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + diff --git a/CuckooChessAPK/res/layout/main.xml b/CuckooChessAPK/res/layout/main.xml new file mode 100644 index 0000000..1723648 --- /dev/null +++ b/CuckooChessAPK/res/layout/main.xml @@ -0,0 +1,40 @@ + + + + + + + + + + diff --git a/CuckooChessAPK/res/menu/options_menu.xml b/CuckooChessAPK/res/menu/options_menu.xml new file mode 100644 index 0000000..b12dfe5 --- /dev/null +++ b/CuckooChessAPK/res/menu/options_menu.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/CuckooChessAPK/res/values/strings.xml b/CuckooChessAPK/res/values/strings.xml new file mode 100644 index 0000000..5077822 --- /dev/null +++ b/CuckooChessAPK/res/values/strings.xml @@ -0,0 +1,30 @@ + + + CuckooChess + + Easy + 1s + 5s + 10s + 30s + 60s + + + -1 + 1000 + 5000 + 10000 + 30000 + 60000 + + + Small + Medium + Large + + + 10 + 12 + 16 + + diff --git a/CuckooChessAPK/res/xml/preferences.xml b/CuckooChessAPK/res/xml/preferences.xml new file mode 100644 index 0000000..0f5269d --- /dev/null +++ b/CuckooChessAPK/res/xml/preferences.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/CuckooChessAPK/src/org/petero/cuckoochess/ChessBoard.java b/CuckooChessAPK/src/org/petero/cuckoochess/ChessBoard.java new file mode 100644 index 0000000..ba1535a --- /dev/null +++ b/CuckooChessAPK/src/org/petero/cuckoochess/ChessBoard.java @@ -0,0 +1,323 @@ +/* + CuckooChess - A java chess program. + Copyright (C) 2011 Peter Österlund, peterosterlund2@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +package org.petero.cuckoochess; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Rect; +import android.graphics.Typeface; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; +import chess.Move; +import chess.Piece; +import chess.Position; + +public class ChessBoard extends View { + private Position pos; + private int selectedSquare; + private float cursorX, cursorY; + private boolean cursorVisible; + private int x0, y0, sqSize; + private boolean flipped; + + private Paint darkPaint; + private Paint brightPaint; + private Paint redOutline; + private Paint greenOutline; + private Paint whitePiecePaint; + private Paint blackPiecePaint; + + public ChessBoard(Context context, AttributeSet attrs) { + super(context, attrs); + pos = new Position(); + selectedSquare = -1; + cursorX = cursorY = 0; + cursorVisible = false; + x0 = y0 = sqSize = 0; + flipped = false; + + darkPaint = new Paint(); + darkPaint.setARGB(255, 128, 128, 128); + + brightPaint = new Paint(); + brightPaint.setARGB(255, 190, 190, 90); + + redOutline = new Paint(); + redOutline.setARGB(255, 255, 0, 0); + redOutline.setStyle(Paint.Style.STROKE); + redOutline.setAntiAlias(true); + + greenOutline = new Paint(); + greenOutline.setARGB(255, 0, 255, 0); + greenOutline.setStyle(Paint.Style.STROKE); + greenOutline.setAntiAlias(true); + + whitePiecePaint = new Paint(); + whitePiecePaint.setARGB(255, 255, 255, 255); + whitePiecePaint.setAntiAlias(true); + + blackPiecePaint = new Paint(); + blackPiecePaint.setARGB(255, 0, 0, 0); + blackPiecePaint.setAntiAlias(true); + } + + public void setFont(Typeface tf) { + whitePiecePaint.setTypeface(tf); + blackPiecePaint.setTypeface(tf); + invalidate(); + } + + /** + * Set the board to a given state. + * @param pos + */ + final public void setPosition(Position pos) { + this.pos = pos; + invalidate(); + } + + /** + * Set/clear the board flipped status. + * @param flipped + */ + final public void setFlipped(boolean flipped) { + this.flipped = flipped; + invalidate(); + } + + /** + * Set/clear the selected square. + * @param square The square to select, or -1 to clear selection. + */ + final public void setSelection(int square) { + if (square != selectedSquare) { + selectedSquare = square; + invalidate(); + } + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + int width = getMeasuredWidth(); + int height = getMeasuredHeight(); + int minSize = Math.min(width, height); + setMeasuredDimension(minSize, minSize); + } + + @Override + protected void onDraw(Canvas canvas) { + final int width = getWidth(); + final int height = getHeight(); + sqSize = (Math.min(width, height) - 4) / 8; + x0 = (width - sqSize * 8) / 2; + y0 = (height - sqSize * 8) / 2; + + for (int x = 0; x < 8; x++) { + for (int y = 0; y < 8; y++) { + final int xCrd = getXCrd(x); + final int yCrd = getYCrd(y); + Paint paint = Position.darkSquare(x, y) ? darkPaint : brightPaint; + canvas.drawRect(xCrd, yCrd, xCrd+sqSize, yCrd+sqSize, paint); + + int sq = Position.getSquare(x, y); + int p = pos.getPiece(sq); + drawPiece(canvas, xCrd + sqSize / 2, yCrd + sqSize / 2, p); + } + } + if (selectedSquare >= 0) { + int selX = Position.getX(selectedSquare); + int selY = Position.getY(selectedSquare); + redOutline.setStrokeWidth(sqSize/(float)16); + int x0 = getXCrd(selX); + int y0 = getYCrd(selY); + canvas.drawRect(x0, y0, x0 + sqSize, y0 + sqSize, redOutline); + } + if (cursorVisible) { + int x = Math.round(cursorX); + int y = Math.round(cursorY); + int x0 = getXCrd(x); + int y0 = getYCrd(y); + greenOutline.setStrokeWidth(sqSize/(float)16); + canvas.drawRect(x0, y0, x0 + sqSize, y0 + sqSize, greenOutline); + } + } + + private final void drawPiece(Canvas canvas, int xCrd, int yCrd, int p) { + String ps; + switch (p) { + case Piece.EMPTY: + ps = ""; + break; + case Piece.WKING: + ps = "k"; + break; + case Piece.WQUEEN: + ps = "q"; + break; + case Piece.WROOK: + ps = "r"; + break; + case Piece.WBISHOP: + ps = "b"; + break; + case Piece.WKNIGHT: + ps = "n"; + break; + case Piece.WPAWN: + ps = "p"; + break; + case Piece.BKING: + ps = "l"; + break; + case Piece.BQUEEN: + ps = "w"; + break; + case Piece.BROOK: + ps = "t"; + break; + case Piece.BBISHOP: + ps = "v"; + break; + case Piece.BKNIGHT: + ps = "m"; + break; + case Piece.BPAWN: + ps = "o"; + break; + default: + ps = "?"; + break; + } + if (ps.length() > 0) { + Paint paint = Piece.isWhite(p) ? whitePiecePaint : blackPiecePaint; + paint.setTextSize(sqSize); + Rect bounds = new Rect(); + paint.getTextBounds(ps, 0, ps.length(), bounds); + int xCent = bounds.centerX(); + int yCent = bounds.centerY(); + canvas.drawText(ps, xCrd - xCent, yCrd - yCent, paint); + } + } + + private final int getXCrd(int x) { + return x0 + sqSize * (flipped ? 7 - x : x); + } + private final int getYCrd(int y) { + return y0 + sqSize * (flipped ? y : (7 - y)); + } + + /** + * Compute the square corresponding to the coordinates of a mouse event. + * @param evt Details about the mouse event. + * @return The square corresponding to the mouse event, or -1 if outside board. + */ + final int eventToSquare(MotionEvent evt) { + int xCrd = (int)(evt.getX()); + int yCrd = (int)(evt.getY()); + + int sq = -1; + if ((xCrd >= x0) && (yCrd >= y0) && (sqSize > 0)) { + int x = (xCrd - x0) / sqSize; + int y = 7 - (yCrd - y0) / sqSize; + if ((x >= 0) && (x < 8) && (y >= 0) && (y < 8)) { + if (flipped) { + x = 7 - x; + y = 7 - y; + } + sq = Position.getSquare(x, y); + } + } + return sq; + } + + final Move mousePressed(int sq) { + if (sq < 0) + return null; + cursorVisible = false; + if (selectedSquare >= 0) { + int p = pos.getPiece(selectedSquare); + if ((p == Piece.EMPTY) || (Piece.isWhite(p) != pos.whiteMove)) { + setSelection(-1); // Remove selection of opponents last moving piece + } + } + + int p = pos.getPiece(sq); + if (selectedSquare >= 0) { + if (sq != selectedSquare) { + if ((p == Piece.EMPTY) || (Piece.isWhite(p) != pos.whiteMove)) { + Move m = new Move(selectedSquare, sq, Piece.EMPTY); + setSelection(sq); + return m; + } + } + setSelection(-1); + } else { + boolean myColor = (p != Piece.EMPTY) && (Piece.isWhite(p) == pos.whiteMove); + if (myColor) { + setSelection(sq); + } + } + return null; + } + + public static class OnTrackballListener { + public void onTrackballEvent(MotionEvent event) { } + } + OnTrackballListener otbl = null; + public void setOnTrackballListener(OnTrackballListener onTrackballListener) { + otbl = onTrackballListener; + } + @Override + public boolean onTrackballEvent(MotionEvent event) { + if (otbl != null) { + otbl.onTrackballEvent(event); + return true; + } + return false; + } + + public Move handleTrackballEvent(MotionEvent event) { + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + invalidate(); + if (cursorVisible) { + int x = Math.round(cursorX); + int y = Math.round(cursorY); + cursorX = x; + cursorY = y; + int sq = Position.getSquare(x, y); + return mousePressed(sq); + } + return null; + } + cursorVisible = true; + int c = flipped ? -1 : 1; + cursorX += c * event.getX(); + cursorY -= c * event.getY(); + if (cursorX < 0) cursorX = 0; + if (cursorX > 7) cursorX = 7; + if (cursorY < 0) cursorY = 0; + if (cursorY > 7) cursorY = 7; + invalidate(); + return null; + } +} diff --git a/CuckooChessAPK/src/org/petero/cuckoochess/CuckooChess.java b/CuckooChessAPK/src/org/petero/cuckoochess/CuckooChess.java new file mode 100644 index 0000000..fdb1dda --- /dev/null +++ b/CuckooChessAPK/src/org/petero/cuckoochess/CuckooChess.java @@ -0,0 +1,366 @@ +/* + CuckooChess - A java chess program. + Copyright (C) 2011 Peter Österlund, peterosterlund2@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +package org.petero.cuckoochess; + +import java.util.ArrayList; +import java.util.List; + +import guibase.ChessController; +import guibase.GUIInterface; +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; +import android.graphics.Typeface; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.text.ClipboardManager; +import android.view.Menu; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.View; +import android.view.View.OnLongClickListener; +import android.view.View.OnTouchListener; +import android.widget.ScrollView; +import android.widget.TextView; +import android.widget.Toast; +import chess.ChessParseError; +import chess.Move; +import chess.Position; +import chess.TextIO; + +public class CuckooChess extends Activity implements GUIInterface { + ChessBoard cb; + ChessController ctrl; + boolean mShowThinking; + int mTimeLimit; + boolean playerWhite; + static final int ttLogSize = 16; // Use 2^ttLogSize hash entries. + + TextView status; + ScrollView moveListScroll; + TextView moveList; + TextView thinking; + + SharedPreferences settings; + + private void readPrefs() { + mShowThinking = settings.getBoolean("showThinking", false); + String timeLimitStr = settings.getString("timeLimit", "5000"); + mTimeLimit = Integer.parseInt(timeLimitStr); + playerWhite = settings.getBoolean("playerWhite", true); + boolean boardFlipped = settings.getBoolean("boardFlipped", false); + cb.setFlipped(boardFlipped); + ctrl.setTimeLimit(); + String fontSizeStr = settings.getString("fontSize", "12"); + int fontSize = Integer.parseInt(fontSizeStr); + status.setTextSize(fontSize); + moveList.setTextSize(fontSize); + thinking.setTextSize(fontSize); + } + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + settings = PreferenceManager.getDefaultSharedPreferences(this); + settings.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() { + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + readPrefs(); + ctrl.setHumanWhite(playerWhite); + } + }); + + setContentView(R.layout.main); + status = (TextView)findViewById(R.id.status); + moveListScroll = (ScrollView)findViewById(R.id.scrollView); + moveList = (TextView)findViewById(R.id.moveList); + thinking = (TextView)findViewById(R.id.thinking); + cb = (ChessBoard)findViewById(R.id.chessboard); + status.setFocusable(false); + moveListScroll.setFocusable(false); + moveList.setFocusable(false); + thinking.setFocusable(false); + ctrl = new ChessController(this); + ctrl.setThreadStackSize(32768); + readPrefs(); + + Typeface chessFont = Typeface.createFromAsset(getAssets(), "casefont.ttf"); + cb.setFont(chessFont); + cb.setFocusable(true); + cb.requestFocus(); + cb.setClickable(true); + + ctrl.newGame(playerWhite, ttLogSize, false); + { + String fen = ""; + String moves = ""; + String numUndo = "0"; + String tmp; + if (savedInstanceState != null) { + tmp = savedInstanceState.getString("startFEN"); + if (tmp != null) fen = tmp; + tmp = savedInstanceState.getString("moves"); + if (tmp != null) moves = tmp; + tmp = savedInstanceState.getString("numUndo"); + if (tmp != null) numUndo = tmp; + } else { + tmp = settings.getString("startFEN", null); + if (tmp != null) fen = tmp; + tmp = settings.getString("moves", null); + if (tmp != null) moves = tmp; + tmp = settings.getString("numUndo", null); + if (tmp != null) numUndo = tmp; + } + List posHistStr = new ArrayList(); + posHistStr.add(fen); + posHistStr.add(moves); + posHistStr.add(numUndo); + ctrl.setPosHistory(posHistStr); + } + ctrl.startGame(); + + cb.setOnTouchListener(new OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + if (ctrl.humansTurn() && (event.getAction() == MotionEvent.ACTION_UP)) { + int sq = cb.eventToSquare(event); + Move m = cb.mousePressed(sq); + if (m != null) { + ctrl.humanMove(m); + } + return false; + } + return false; + } + }); + + cb.setOnTrackballListener(new ChessBoard.OnTrackballListener() { + public void onTrackballEvent(MotionEvent event) { + if (ctrl.humansTurn()) { + Move m = cb.handleTrackballEvent(event); + if (m != null) { + ctrl.humanMove(m); + } + } + } + }); + cb.setOnLongClickListener(new OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + if (!ctrl.computerThinking()) + showDialog(CLIPBOARD_DIALOG); + return true; + } + }); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + List posHistStr = ctrl.getPosHistory(); + outState.putString("startFEN", posHistStr.get(0)); + outState.putString("moves", posHistStr.get(1)); + outState.putString("numUndo", posHistStr.get(2)); + } + + @Override + protected void onPause() { + List posHistStr = ctrl.getPosHistory(); + Editor editor = settings.edit(); + editor.putString("startFEN", posHistStr.get(0)); + editor.putString("moves", posHistStr.get(1)); + editor.putString("numUndo", posHistStr.get(2)); + editor.commit(); + super.onPause(); + } + + @Override + protected void onDestroy() { + ctrl.stopComputerThinking(); + super.onDestroy(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.options_menu, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.item_new_game: + ctrl.newGame(playerWhite, ttLogSize, false); + ctrl.startGame(); + return true; + case R.id.item_undo: + ctrl.takeBackMove(); + return true; + case R.id.item_redo: + ctrl.redoMove(); + return true; + case R.id.item_settings: + { + Intent i = new Intent(CuckooChess.this, Preferences.class); + startActivityForResult(i, 0); + return true; + } + } + return false; + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == 0) { + readPrefs(); + ctrl.setHumanWhite(playerWhite); + } + } + + // FIXME!!! Implement "edit board" + // FIXME!!! Implement analysis mode + + @Override + public void setPosition(Position pos) { + cb.setPosition(pos); + ctrl.setHumanWhite(playerWhite); + } + + @Override + public void setSelection(int sq) { + cb.setSelection(sq); + } + + @Override + public void setStatusString(String str) { + status.setText(str); + } + + @Override + public void setMoveListString(String str) { + moveList.setText(str); + moveListScroll.fullScroll(ScrollView.FOCUS_DOWN); + } + + @Override + public void setThinkingString(String str) { + thinking.setText(str); + } + + @Override + public int timeLimit() { + return mTimeLimit; + } + + @Override + public boolean randomMode() { + return mTimeLimit == -1; + } + + @Override + public boolean showThinking() { + return mShowThinking; + } + + static final int PROMOTE_DIALOG = 0; + static final int CLIPBOARD_DIALOG = 1; + + @Override + protected Dialog onCreateDialog(int id) { + switch (id) { + case PROMOTE_DIALOG: { + final CharSequence[] items = {"Queen", "Rook", "Bishop", "Knight"}; + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle("Promote pawn to?"); + builder.setItems(items, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int item) { + ctrl.reportPromotePiece(item); + } + }); + AlertDialog alert = builder.create(); + return alert; + } + case CLIPBOARD_DIALOG: { + final CharSequence[] items = {"Copy Game", "Copy Position", "Paste"}; + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle("Clipboard"); + builder.setItems(items, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int item) { + switch (item) { + case 0: { + String pgn = ctrl.getPGN(); + ClipboardManager clipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE); + clipboard.setText(pgn); + break; + } + case 1: { + String fen = ctrl.getFEN() + "\n"; + ClipboardManager clipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE); + clipboard.setText(fen); + break; + } + case 2: { + ClipboardManager clipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE); + if (clipboard.hasText()) { + String fenPgn = clipboard.getText().toString(); + try { + ctrl.setFENOrPGN(fenPgn); + } catch (ChessParseError e) { + Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); + } + } + break; + } + } + } + }); + AlertDialog alert = builder.create(); + return alert; + } + } + return null; + } + + @Override + public void requestPromotePiece() { + runOnUIThread(new Runnable() { + public void run() { + showDialog(PROMOTE_DIALOG); + } + }); + } + + @Override + public void reportInvalidMove(Move m) { + String msg = String.format("Invalid move %s-%s", TextIO.squareToString(m.from), TextIO.squareToString(m.to)); + Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show(); + } + + @Override + public void runOnUIThread(Runnable runnable) { + runOnUiThread(runnable); + } +} diff --git a/CuckooChessAPK/src/org/petero/cuckoochess/Preferences.java b/CuckooChessAPK/src/org/petero/cuckoochess/Preferences.java new file mode 100644 index 0000000..90873e9 --- /dev/null +++ b/CuckooChessAPK/src/org/petero/cuckoochess/Preferences.java @@ -0,0 +1,31 @@ +/* + CuckooChess - A java chess program. + Copyright (C) 2011 Peter Österlund, peterosterlund2@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +package org.petero.cuckoochess; + +import android.os.Bundle; +import android.preference.PreferenceActivity; + +public class Preferences extends PreferenceActivity { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.preferences); + } +}