mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-27 06:10:28 +01:00
Remove onTrackballEvent support
Only very old devices have a trackball/trackstick and those run a too old Android version to be supported anyway.
This commit is contained in:
parent
b9f9dff315
commit
546c3a7251
|
@ -87,10 +87,6 @@ public class ChessBoardPlay extends ChessBoard {
|
|||
@Override
|
||||
protected int getYFromSq(int sq) { return Position.getY(sq); }
|
||||
|
||||
@Override
|
||||
protected int minValidY() { return 0; }
|
||||
@Override
|
||||
protected int maxValidX() { return 7; }
|
||||
@Override
|
||||
protected int getSquare(int x, int y) { return Position.getSquare(x, y); }
|
||||
|
||||
|
@ -105,7 +101,6 @@ public class ChessBoardPlay extends ChessBoard {
|
|||
public Move mousePressed(int sq) {
|
||||
if (sq < 0)
|
||||
return null;
|
||||
cursorVisible = false;
|
||||
if ((selectedSquare != -1) && !userSelectedSquare)
|
||||
setSelection(-1); // Remove selection of opponents last moving piece
|
||||
|
||||
|
|
|
@ -23,12 +23,9 @@ import android.view.MotionEvent;
|
|||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
import org.petero.droidfish.gamelogic.DroidChessController;
|
||||
import org.petero.droidfish.gamelogic.Move;
|
||||
import org.petero.droidfish.view.ChessBoard;
|
||||
|
||||
public class ChessBoardPlayListener implements View.OnTouchListener,
|
||||
ChessBoard.OnTrackballListener {
|
||||
public class ChessBoardPlayListener implements View.OnTouchListener {
|
||||
private DroidFish df;
|
||||
private ChessBoardPlay cb;
|
||||
|
||||
|
@ -181,16 +178,4 @@ public class ChessBoardPlayListener implements View.OnTouchListener,
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrackballEvent(MotionEvent event) {
|
||||
if (df.ctrl.humansTurn()) {
|
||||
Move m = cb.handleTrackballEvent(event);
|
||||
if (m != null) {
|
||||
df.setAutoMode(DroidFish.AutoMode.OFF);
|
||||
df.ctrl.makeHumanMove(m);
|
||||
}
|
||||
df.setEgtbHints(cb.getSelectedSquare());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,30 +35,29 @@ public class ColorTheme {
|
|||
public final static int DARK_SQUARE = 0;
|
||||
public final static int BRIGHT_SQUARE = 1;
|
||||
public final static int SELECTED_SQUARE = 2;
|
||||
public final static int CURSOR_SQUARE = 3;
|
||||
public final static int DARK_PIECE = 4;
|
||||
public final static int BRIGHT_PIECE = 5;
|
||||
public final static int CURRENT_MOVE = 6;
|
||||
public final static int ARROW_0 = 7;
|
||||
public final static int ARROW_1 = 8;
|
||||
public final static int ARROW_2 = 9;
|
||||
public final static int ARROW_3 = 10;
|
||||
public final static int ARROW_4 = 11;
|
||||
public final static int ARROW_5 = 12;
|
||||
public final static int ARROW_6 = 13;
|
||||
public final static int ARROW_7 = 14;
|
||||
public final static int DARK_PIECE = 3;
|
||||
public final static int BRIGHT_PIECE = 4;
|
||||
public final static int CURRENT_MOVE = 5;
|
||||
public final static int ARROW_0 = 6;
|
||||
public final static int ARROW_1 = 7;
|
||||
public final static int ARROW_2 = 8;
|
||||
public final static int ARROW_3 = 9;
|
||||
public final static int ARROW_4 = 10;
|
||||
public final static int ARROW_5 = 11;
|
||||
public final static int ARROW_6 = 12;
|
||||
public final static int ARROW_7 = 13;
|
||||
public final static int MAX_ARROWS = 8;
|
||||
public final static int SQUARE_LABEL = 15;
|
||||
public final static int DECORATION = 16;
|
||||
public final static int PGN_COMMENT = 17;
|
||||
public final static int FONT_FOREGROUND = 18;
|
||||
public final static int GENERAL_BACKGROUND = 19;
|
||||
private final static int numColors = 20;
|
||||
public final static int SQUARE_LABEL = 14;
|
||||
public final static int DECORATION = 15;
|
||||
public final static int PGN_COMMENT = 16;
|
||||
public final static int FONT_FOREGROUND = 17;
|
||||
public final static int GENERAL_BACKGROUND = 18;
|
||||
private final static int numColors = 19;
|
||||
|
||||
private int colorTable[] = new int[numColors];
|
||||
|
||||
private static final String[] prefNames = {
|
||||
"darkSquare", "brightSquare", "selectedSquare", "cursorSquare", "darkPiece", "brightPiece", "currentMove",
|
||||
"darkSquare", "brightSquare", "selectedSquare", "darkPiece", "brightPiece", "currentMove",
|
||||
"arrow0", "arrow1", "arrow2", "arrow3", "arrow4", "arrow5", "arrow6", "arrow7",
|
||||
"squareLabel", "decoration", "pgnComment", "fontForeground", "generalBackground"
|
||||
};
|
||||
|
@ -76,37 +75,37 @@ public class ColorTheme {
|
|||
};
|
||||
private final static String themeColors[][] = {
|
||||
{ // Original
|
||||
"#FF808080", "#FFBEBE5A", "#FFFF0000", "#FF00FF00", "#FF000000", "#FFFFFFFF", "#FF888888",
|
||||
"#FF808080", "#FFBEBE5A", "#FFFF0000", "#FF000000", "#FFFFFFFF", "#FF888888",
|
||||
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#371F1FFF", "#3CFF1F1F", "#1E1F1FFF", "#28FF1F1F",
|
||||
"#FFFF0000", "#FF9F9F66", "#FFC0C000", "#FFF7FBC6", "#FF292C10"
|
||||
},
|
||||
{ // XBoard
|
||||
"#FF77A26D", "#FFC8C365", "#FFFFFF00", "#FF00FF00", "#FF202020", "#FFFFFFCC", "#FF6B9262",
|
||||
"#FF77A26D", "#FFC8C365", "#FFFFFF00", "#FF202020", "#FFFFFFCC", "#FF6B9262",
|
||||
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#371F1FFF", "#3CFF1F1F", "#1E1F1FFF", "#28FF1F1F",
|
||||
"#FFFF0000", "#FF808080", "#FFC0C000", "#FFEFFBBC", "#FF28320C"
|
||||
},
|
||||
{ // Blue
|
||||
"#FF83A5D2", "#FFFFFFFA", "#FF3232D1", "#FF5F5FFD", "#FF282828", "#FFF0F0F0", "#FF3333FF",
|
||||
"#FF83A5D2", "#FFFFFFFA", "#FF3232D1", "#FF282828", "#FFF0F0F0", "#FF3333FF",
|
||||
"#A01F1FFF", "#A01FFF1F", "#501F1FFF", "#501FFF1F", "#371F1FFF", "#3C1FFF1F", "#1E1F1FFF", "#281FFF1F",
|
||||
"#FFFF0000", "#FF808080", "#FFC0C000", "#FFFFFF00", "#FF2E2B53"
|
||||
},
|
||||
{ // Grey
|
||||
"#FF666666", "#FFDDDDDD", "#FFFF0000", "#FF0000FF", "#FF000000", "#FFFFFFFF", "#FF888888",
|
||||
"#FF666666", "#FFDDDDDD", "#FFFF0000", "#FF000000", "#FFFFFFFF", "#FF888888",
|
||||
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#371F1FFF", "#3CFF1F1F", "#1E1F1FFF", "#28FF1F1F",
|
||||
"#FFFF0000", "#FF909090", "#FFC0C000", "#FFFFFFFF", "#FF202020"
|
||||
},
|
||||
{ // Scid Default
|
||||
"#FF80A0A0", "#FFD0E0D0", "#FFFF0000", "#FF00FF00", "#FF000000", "#FFFFFFFF", "#FF666666",
|
||||
"#FF80A0A0", "#FFD0E0D0", "#FFFF0000", "#FF000000", "#FFFFFFFF", "#FF666666",
|
||||
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#371F1FFF", "#3CFF1F1F", "#1E1F1FFF", "#28FF1F1F",
|
||||
"#FFFF0000", "#FF808080", "#FFC0C000", "#FFDEFBDE", "#FF213429"
|
||||
},
|
||||
{ // Scid Brown
|
||||
"#B58863", "#F0D9B5", "#FFFF0000", "#FF00FF00", "#FF000000", "#FFFFFFFF", "#FF666666",
|
||||
"#B58863", "#F0D9B5", "#FFFF0000", "#FF000000", "#FFFFFFFF", "#FF666666",
|
||||
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#371F1FFF", "#3CFF1F1F", "#1E1F1FFF", "#28FF1F1F",
|
||||
"#FFFF0000", "#FF808080", "#FFC0C000", "#FFF7FAE3", "#FF40260A"
|
||||
},
|
||||
{ // Scid Green
|
||||
"#FF769656", "#FFEEEED2", "#FFFF0000", "#FF0000FF", "#FF000000", "#FFFFFFFF", "#FF666666",
|
||||
"#FF769656", "#FFEEEED2", "#FFFF0000", "#FF000000", "#FFFFFFFF", "#FF666666",
|
||||
"#A01F1FFF", "#A0FF1F1F", "#501F1FFF", "#50FF1F1F", "#371F1FFF", "#3CFF1F1F", "#1E1F1FFF", "#28FF1F1F",
|
||||
"#FFFF0000", "#FF808080", "#FFC0C000", "#FFDEE3CE", "#FF183C21"
|
||||
}
|
||||
|
@ -120,8 +119,7 @@ public class ColorTheme {
|
|||
colorTable[i] = 0;
|
||||
try {
|
||||
colorTable[i] = Color.parseColor(colorString);
|
||||
} catch (IllegalArgumentException ignore) {
|
||||
} catch (StringIndexOutOfBoundsException ignore) {
|
||||
} catch (IllegalArgumentException|StringIndexOutOfBoundsException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -866,9 +866,6 @@ public class DroidFish extends Activity
|
|||
String statusStr = status.getText().toString();
|
||||
initUI();
|
||||
readPrefs(true);
|
||||
cb.cursorX = oldCB.cursorX;
|
||||
cb.cursorY = oldCB.cursorY;
|
||||
cb.cursorVisible = oldCB.cursorVisible;
|
||||
cb.setPosition(oldCB.pos);
|
||||
cb.setFlipped(oldCB.flipped);
|
||||
cb.setDrawSquareLabels(oldCB.drawSquareLabels);
|
||||
|
@ -975,7 +972,6 @@ public class DroidFish extends Activity
|
|||
|
||||
ChessBoardPlayListener cbpListener = new ChessBoardPlayListener(this, cb);
|
||||
cb.setOnTouchListener(cbpListener);
|
||||
cb.setOnTrackballListener(cbpListener);
|
||||
|
||||
moveList.setOnLongClickListener(v -> {
|
||||
reShowDialog(MOVELIST_MENU_DIALOG);
|
||||
|
|
|
@ -195,7 +195,6 @@ public class ChessBoardEdit extends ChessBoard {
|
|||
Move mousePressed(int sq) {
|
||||
if (sq == -1)
|
||||
return null;
|
||||
cursorVisible = false;
|
||||
if (selectedSquare != -1) {
|
||||
if (sq != selectedSquare) {
|
||||
Move m = new Move(selectedSquare, sq, Piece.EMPTY);
|
||||
|
@ -209,15 +208,6 @@ public class ChessBoardEdit extends ChessBoard {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int minValidY() {
|
||||
return landScape ? 0 : -2;
|
||||
}
|
||||
@Override
|
||||
protected int maxValidX() {
|
||||
return landScape ? 9 : 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected XYCoord sqToPix(int x, int y) {
|
||||
if (flipped && (x >= 0) && (x < 8) && (y >= 0) && (y < 8)) {
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.petero.droidfish.gamelogic.Position;
|
|||
import org.petero.droidfish.gamelogic.TextIO;
|
||||
import org.petero.droidfish.tb.Probe;
|
||||
import org.petero.droidfish.tb.ProbeResult;
|
||||
import org.petero.droidfish.view.ChessBoard;
|
||||
import org.petero.droidfish.view.ChessBoard.SquareDecoration;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
@ -126,9 +125,6 @@ public class EditBoard extends Activity {
|
|||
ChessBoardEdit oldCB = cb;
|
||||
String statusStr = status.getText().toString();
|
||||
initUI();
|
||||
cb.cursorX = oldCB.cursorX;
|
||||
cb.cursorY = oldCB.cursorY;
|
||||
cb.cursorVisible = oldCB.cursorVisible;
|
||||
cb.setPosition(oldCB.pos);
|
||||
setSelection(oldCB.selectedSquare);
|
||||
cb.userSelectedSquare = oldCB.userSelectedSquare;
|
||||
|
@ -227,15 +223,6 @@ public class EditBoard extends Activity {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
cb.setOnTrackballListener(new ChessBoard.OnTrackballListener() {
|
||||
@Override
|
||||
public void onTrackballEvent(MotionEvent event) {
|
||||
Move m = cb.handleTrackballEvent(event);
|
||||
if (m != null)
|
||||
doMove(m);
|
||||
setEgtbHints(cb.getSelectedSquare());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Initialize the drawer part of the user interface. */
|
||||
|
|
|
@ -48,8 +48,6 @@ public abstract class ChessBoard extends View {
|
|||
public int selectedSquare;
|
||||
public boolean userSelectedSquare; // True if selectedSquare was set by user tap/click,
|
||||
// false if selectedSquare used to highlight last move
|
||||
public float cursorX, cursorY;
|
||||
public boolean cursorVisible;
|
||||
protected int x0, y0;
|
||||
public int sqSize;
|
||||
public boolean flipped;
|
||||
|
@ -78,7 +76,6 @@ public abstract class ChessBoard extends View {
|
|||
protected Paint darkPaint;
|
||||
protected Paint brightPaint;
|
||||
private Paint selectedSquarePaint;
|
||||
private Paint cursorSquarePaint;
|
||||
private Paint piecePaint;
|
||||
private Paint labelPaint;
|
||||
private Paint decorationPaint;
|
||||
|
@ -89,8 +86,6 @@ public abstract class ChessBoard extends View {
|
|||
pos = new Position();
|
||||
selectedSquare = -1;
|
||||
userSelectedSquare = false;
|
||||
cursorX = cursorY = 0;
|
||||
cursorVisible = false;
|
||||
x0 = y0 = sqSize = 0;
|
||||
flipped = false;
|
||||
drawSquareLabels = false;
|
||||
|
@ -105,10 +100,6 @@ public abstract class ChessBoard extends View {
|
|||
selectedSquarePaint.setStyle(Paint.Style.STROKE);
|
||||
selectedSquarePaint.setAntiAlias(true);
|
||||
|
||||
cursorSquarePaint = new Paint();
|
||||
cursorSquarePaint.setStyle(Paint.Style.STROKE);
|
||||
cursorSquarePaint.setAntiAlias(true);
|
||||
|
||||
piecePaint = new Paint();
|
||||
piecePaint.setAntiAlias(true);
|
||||
|
||||
|
@ -138,7 +129,6 @@ public abstract class ChessBoard extends View {
|
|||
darkPaint.setColor(ct.getColor(ColorTheme.DARK_SQUARE));
|
||||
brightPaint.setColor(ct.getColor(ColorTheme.BRIGHT_SQUARE));
|
||||
selectedSquarePaint.setColor(ct.getColor(ColorTheme.SELECTED_SQUARE));
|
||||
cursorSquarePaint.setColor(ct.getColor(ColorTheme.CURSOR_SQUARE));
|
||||
labelPaint.setColor(ct.getColor(ColorTheme.SQUARE_LABEL));
|
||||
decorationPaint.setColor(ct.getColor(ColorTheme.DECORATION));
|
||||
for (int i = 0; i < ColorTheme.MAX_ARROWS; i++)
|
||||
|
@ -415,15 +405,6 @@ public abstract class ChessBoard extends View {
|
|||
int y0 = crd.y;
|
||||
canvas.drawRect(x0, y0, x0 + sqSize, y0 + sqSize, selectedSquarePaint);
|
||||
}
|
||||
if (cursorVisible) {
|
||||
int x = Math.round(cursorX);
|
||||
int y = Math.round(cursorY);
|
||||
XYCoord crd = sqToPix(x, y);
|
||||
int x0 = crd.x;
|
||||
int y0 = crd.y;
|
||||
cursorSquarePaint.setStrokeWidth(sqSize/(float)16);
|
||||
canvas.drawRect(x0, y0, x0 + sqSize, y0 + sqSize, cursorSquarePaint);
|
||||
}
|
||||
if (!animActive) {
|
||||
drawMoveHints(canvas);
|
||||
drawDecorations(canvas);
|
||||
|
@ -562,52 +543,8 @@ public abstract class ChessBoard extends View {
|
|||
|
||||
protected abstract Move mousePressed(int sq);
|
||||
|
||||
public interface OnTrackballListener {
|
||||
void onTrackballEvent(MotionEvent event);
|
||||
}
|
||||
private OnTrackballListener otbl = null;
|
||||
public final void setOnTrackballListener(OnTrackballListener onTrackballListener) {
|
||||
otbl = onTrackballListener;
|
||||
}
|
||||
@Override
|
||||
public boolean onTrackballEvent(MotionEvent event) {
|
||||
if (otbl != null) {
|
||||
otbl.onTrackballEvent(event);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract int minValidY();
|
||||
protected abstract int maxValidX();
|
||||
protected abstract int getSquare(int x, int y);
|
||||
|
||||
public final 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 = 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 > maxValidX()) cursorX = maxValidX();
|
||||
if (cursorY < minValidY()) cursorY = minValidY();
|
||||
if (cursorY > 7) cursorY = 7;
|
||||
invalidate();
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setMoveHints(List<Move> moveHints) {
|
||||
boolean equal;
|
||||
if ((this.moveHints == null) || (moveHints == null)) {
|
||||
|
|
|
@ -355,7 +355,6 @@ If you are running on battery power, it is recommended that you change settings
|
|||
<string name="prefs_color_brightSquare_title">Bright Squares</string>
|
||||
<string name="prefs_color_darkSquare_title">Dark Squares</string>
|
||||
<string name="prefs_color_selectedSquare_title">Selected Square</string>
|
||||
<string name="prefs_color_cursorSquare_title">Trackball Cursor</string>
|
||||
<string name="prefs_color_brightPiece_title">White Pieces</string>
|
||||
<string name="prefs_color_darkPiece_title">Black Pieces</string>
|
||||
<string name="prefs_color_arrow0_title">Arrow 1</string>
|
||||
|
|
|
@ -240,12 +240,6 @@
|
|||
alphaSlider="true"
|
||||
android:defaultValue="#FF3232D1">
|
||||
</net.margaritov.preference.colorpicker.ColorPickerPreference>
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="color_cursorSquare"
|
||||
android:title="@string/prefs_color_cursorSquare_title"
|
||||
alphaSlider="true"
|
||||
android:defaultValue="#FF5F5FFD">
|
||||
</net.margaritov.preference.colorpicker.ColorPickerPreference>
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="color_brightPiece"
|
||||
android:title="@string/prefs_color_brightPiece_title"
|
||||
|
|
Loading…
Reference in New Issue
Block a user