mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-02-11 22:57:49 +01:00
DroidFish: Added a third configurable button.
This commit is contained in:
parent
6540f2f49a
commit
4932e44a92
|
@ -19,6 +19,12 @@
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/custom3Button"
|
||||||
|
android:contentDescription="@string/buttonDesc_custom3"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="32dp">
|
||||||
|
</ImageButton>
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/custom2Button"
|
android:id="@+id/custom2Button"
|
||||||
android:contentDescription="@string/buttonDesc_custom2"
|
android:contentDescription="@string/buttonDesc_custom2"
|
||||||
|
@ -37,13 +43,13 @@
|
||||||
android:layout_width="36dp"
|
android:layout_width="36dp"
|
||||||
android:layout_height="32dp">
|
android:layout_height="32dp">
|
||||||
</ImageButton>
|
</ImageButton>
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/undoButton"
|
android:id="@+id/undoButton"
|
||||||
android:contentDescription="@string/buttonDesc_back"
|
android:contentDescription="@string/buttonDesc_back"
|
||||||
android:layout_width="36dp"
|
android:layout_width="36dp"
|
||||||
android:layout_height="32dp">
|
android:layout_height="32dp">
|
||||||
</ImageButton>
|
</ImageButton>
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/redoButton"
|
android:id="@+id/redoButton"
|
||||||
android:contentDescription="@string/buttonDesc_forward"
|
android:contentDescription="@string/buttonDesc_forward"
|
||||||
android:layout_width="36dp"
|
android:layout_width="36dp"
|
||||||
|
|
|
@ -21,6 +21,12 @@
|
||||||
android:includeFontPadding="true"
|
android:includeFontPadding="true"
|
||||||
android:typeface="monospace"
|
android:typeface="monospace"
|
||||||
android:textSize="10dip"/>
|
android:textSize="10dip"/>
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/custom3Button"
|
||||||
|
android:contentDescription="@string/buttonDesc_custom3"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="32dp">
|
||||||
|
</ImageButton>
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/custom2Button"
|
android:id="@+id/custom2Button"
|
||||||
android:contentDescription="@string/buttonDesc_custom2"
|
android:contentDescription="@string/buttonDesc_custom2"
|
||||||
|
|
|
@ -14,6 +14,12 @@
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/custom3Button"
|
||||||
|
android:contentDescription="@string/buttonDesc_custom3"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="32dp">
|
||||||
|
</ImageButton>
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/custom2Button"
|
android:id="@+id/custom2Button"
|
||||||
android:contentDescription="@string/buttonDesc_custom2"
|
android:contentDescription="@string/buttonDesc_custom2"
|
||||||
|
|
|
@ -269,6 +269,7 @@ you are not actively using the program.\
|
||||||
<string name="prefs_button_action_6_title">Menu Action 6</string>
|
<string name="prefs_button_action_6_title">Menu Action 6</string>
|
||||||
<string name="prefs_custom_button_1">Custom Button 1</string>
|
<string name="prefs_custom_button_1">Custom Button 1</string>
|
||||||
<string name="prefs_custom_button_2">Custom Button 2</string>
|
<string name="prefs_custom_button_2">Custom Button 2</string>
|
||||||
|
<string name="prefs_custom_button_3">Custom Button 3</string>
|
||||||
<string name="prefs_colors_title">Color Settings</string>
|
<string name="prefs_colors_title">Color Settings</string>
|
||||||
<string name="prefs_colors_summary">Change individual colors</string>
|
<string name="prefs_colors_summary">Change individual colors</string>
|
||||||
<string name="prefs_chess_board">Chess Board</string>
|
<string name="prefs_chess_board">Chess Board</string>
|
||||||
|
@ -343,6 +344,7 @@ you are not actively using the program.\
|
||||||
<string name="prefs_gtbPath_summary">Directory where Gaviota tablebases are installed. Leave blank to use default directory</string>
|
<string name="prefs_gtbPath_summary">Directory where Gaviota tablebases are installed. Leave blank to use default directory</string>
|
||||||
<string name="buttonDesc_custom1">@string/prefs_custom_button_1</string>
|
<string name="buttonDesc_custom1">@string/prefs_custom_button_1</string>
|
||||||
<string name="buttonDesc_custom2">@string/prefs_custom_button_2</string>
|
<string name="buttonDesc_custom2">@string/prefs_custom_button_2</string>
|
||||||
|
<string name="buttonDesc_custom3">@string/prefs_custom_button_3</string>
|
||||||
<string name="buttonDesc_mode">Mode button</string>
|
<string name="buttonDesc_mode">Mode button</string>
|
||||||
<string name="buttonDesc_back">Backward button</string>
|
<string name="buttonDesc_back">Backward button</string>
|
||||||
<string name="buttonDesc_forward">Forward button</string>
|
<string name="buttonDesc_forward">Forward button</string>
|
||||||
|
|
|
@ -286,7 +286,59 @@
|
||||||
android:defaultValue="">
|
android:defaultValue="">
|
||||||
</ListPreference>
|
</ListPreference>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
<PreferenceCategory
|
||||||
|
android:title="@string/prefs_custom_button_3">
|
||||||
|
<ListPreference
|
||||||
|
android:key="button_action_custom3_0"
|
||||||
|
android:title="@string/prefs_button_action_0_title"
|
||||||
|
android:entryValues="@array/button_action_values"
|
||||||
|
android:entries="@array/button_action_texts"
|
||||||
|
android:defaultValue="">
|
||||||
|
</ListPreference>
|
||||||
|
<ListPreference
|
||||||
|
android:key="button_action_custom3_1"
|
||||||
|
android:title="@string/prefs_button_action_1_title"
|
||||||
|
android:entryValues="@array/button_action_values"
|
||||||
|
android:entries="@array/button_action_texts"
|
||||||
|
android:defaultValue="">
|
||||||
|
</ListPreference>
|
||||||
|
<ListPreference
|
||||||
|
android:key="button_action_custom3_2"
|
||||||
|
android:title="@string/prefs_button_action_2_title"
|
||||||
|
android:entryValues="@array/button_action_values"
|
||||||
|
android:entries="@array/button_action_texts"
|
||||||
|
android:defaultValue="">
|
||||||
|
</ListPreference>
|
||||||
|
<ListPreference
|
||||||
|
android:key="button_action_custom3_3"
|
||||||
|
android:title="@string/prefs_button_action_3_title"
|
||||||
|
android:entryValues="@array/button_action_values"
|
||||||
|
android:entries="@array/button_action_texts"
|
||||||
|
android:defaultValue="">
|
||||||
|
</ListPreference>
|
||||||
|
<ListPreference
|
||||||
|
android:key="button_action_custom3_4"
|
||||||
|
android:title="@string/prefs_button_action_4_title"
|
||||||
|
android:entryValues="@array/button_action_values"
|
||||||
|
android:entries="@array/button_action_texts"
|
||||||
|
android:defaultValue="">
|
||||||
|
</ListPreference>
|
||||||
|
<ListPreference
|
||||||
|
android:key="button_action_custom3_5"
|
||||||
|
android:title="@string/prefs_button_action_5_title"
|
||||||
|
android:entryValues="@array/button_action_values"
|
||||||
|
android:entries="@array/button_action_texts"
|
||||||
|
android:defaultValue="">
|
||||||
|
</ListPreference>
|
||||||
|
<ListPreference
|
||||||
|
android:key="button_action_custom3_6"
|
||||||
|
android:title="@string/prefs_button_action_6_title"
|
||||||
|
android:entryValues="@array/button_action_values"
|
||||||
|
android:entries="@array/button_action_texts"
|
||||||
|
android:defaultValue="">
|
||||||
|
</ListPreference>
|
||||||
|
</PreferenceCategory>
|
||||||
|
</PreferenceScreen>
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="colors"
|
android:key="colors"
|
||||||
android:title="@string/prefs_colors_title"
|
android:title="@string/prefs_colors_title"
|
||||||
|
|
|
@ -104,6 +104,7 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup.LayoutParams;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
@ -113,7 +114,6 @@ import android.view.View.OnTouchListener;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -148,7 +148,6 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||||
// FIXME!!! Handle PGN intents with more than one game.
|
// FIXME!!! Handle PGN intents with more than one game.
|
||||||
// FIXME!!! File load/save of FEN data
|
// FIXME!!! File load/save of FEN data
|
||||||
// FIXME!!! Make engine hash size configurable.
|
// FIXME!!! Make engine hash size configurable.
|
||||||
// FIXME!!! Nicer looking icons.
|
|
||||||
|
|
||||||
private ChessBoard cb;
|
private ChessBoard cb;
|
||||||
private static DroidChessController ctrl = null;
|
private static DroidChessController ctrl = null;
|
||||||
|
@ -169,9 +168,9 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||||
private ScrollView moveListScroll;
|
private ScrollView moveListScroll;
|
||||||
private TextView moveList;
|
private TextView moveList;
|
||||||
private TextView thinking;
|
private TextView thinking;
|
||||||
private ImageButton custom1Button, custom2Button;
|
private ImageButton custom1Button, custom2Button, custom3Button;
|
||||||
private ImageButton modeButton, undoButton, redoButton;
|
private ImageButton modeButton, undoButton, redoButton;
|
||||||
private ButtonActions custom1ButtonActions, custom2ButtonActions;
|
private ButtonActions custom1ButtonActions, custom2ButtonActions, custom3ButtonActions;
|
||||||
private TextView whiteClock, blackClock, titleText;
|
private TextView whiteClock, blackClock, titleText;
|
||||||
|
|
||||||
SharedPreferences settings;
|
SharedPreferences settings;
|
||||||
|
@ -336,6 +335,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||||
R.string.select_action);
|
R.string.select_action);
|
||||||
custom2ButtonActions = new ButtonActions("custom2", CUSTOM2_BUTTON_DIALOG,
|
custom2ButtonActions = new ButtonActions("custom2", CUSTOM2_BUTTON_DIALOG,
|
||||||
R.string.select_action);
|
R.string.select_action);
|
||||||
|
custom3ButtonActions = new ButtonActions("custom3", CUSTOM3_BUTTON_DIALOG,
|
||||||
|
R.string.select_action);
|
||||||
|
|
||||||
initUI(true);
|
initUI(true);
|
||||||
|
|
||||||
|
@ -600,9 +601,10 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||||
|
|
||||||
custom1Button = (ImageButton)findViewById(R.id.custom1Button);
|
custom1Button = (ImageButton)findViewById(R.id.custom1Button);
|
||||||
custom1ButtonActions.setImageButton(custom1Button, this);
|
custom1ButtonActions.setImageButton(custom1Button, this);
|
||||||
|
|
||||||
custom2Button = (ImageButton)findViewById(R.id.custom2Button);
|
custom2Button = (ImageButton)findViewById(R.id.custom2Button);
|
||||||
custom2ButtonActions.setImageButton(custom2Button, this);
|
custom2ButtonActions.setImageButton(custom2Button, this);
|
||||||
|
custom3Button = (ImageButton)findViewById(R.id.custom3Button);
|
||||||
|
custom3ButtonActions.setImageButton(custom3Button, this);
|
||||||
|
|
||||||
modeButton = (ImageButton)findViewById(R.id.modeButton);
|
modeButton = (ImageButton)findViewById(R.id.modeButton);
|
||||||
modeButton.setOnClickListener(new OnClickListener() {
|
modeButton.setOnClickListener(new OnClickListener() {
|
||||||
|
@ -745,7 +747,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||||
|
|
||||||
custom1ButtonActions.readPrefs(settings, actionFactory);
|
custom1ButtonActions.readPrefs(settings, actionFactory);
|
||||||
custom2ButtonActions.readPrefs(settings, actionFactory);
|
custom2ButtonActions.readPrefs(settings, actionFactory);
|
||||||
|
custom3ButtonActions.readPrefs(settings, actionFactory);
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
|
||||||
bookOptions.filename = settings.getString("bookFile", "");
|
bookOptions.filename = settings.getString("bookFile", "");
|
||||||
|
@ -804,10 +806,12 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||||
SVG svg = SVGParser.getSVGFromResource(getResources(),
|
SVG svg = SVGParser.getSVGFromResource(getResources(),
|
||||||
custom1ButtonActions.getIcon());
|
custom1ButtonActions.getIcon());
|
||||||
custom1Button.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
custom1Button.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
||||||
|
|
||||||
svg = SVGParser.getSVGFromResource(getResources(),
|
svg = SVGParser.getSVGFromResource(getResources(),
|
||||||
custom2ButtonActions.getIcon());
|
custom2ButtonActions.getIcon());
|
||||||
custom2Button.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
custom2Button.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
||||||
|
svg = SVGParser.getSVGFromResource(getResources(),
|
||||||
|
custom3ButtonActions.getIcon());
|
||||||
|
custom3Button.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
||||||
|
|
||||||
svg = SVGParser.getSVGFromResource(getResources(), R.raw.right);
|
svg = SVGParser.getSVGFromResource(getResources(), R.raw.right);
|
||||||
redoButton.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
redoButton.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
||||||
|
@ -818,11 +822,19 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||||
svg = SVGParser.getSVGFromResource(getResources(), R.raw.mode);
|
svg = SVGParser.getSVGFromResource(getResources(), R.raw.mode);
|
||||||
modeButton.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
modeButton.setBackgroundDrawable(new SVGPictureDrawable(svg));
|
||||||
|
|
||||||
custom1Button.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight));
|
setButtonSize(custom1Button, bWidth, bHeight);
|
||||||
custom2Button.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight));
|
setButtonSize(custom2Button, bWidth, bHeight);
|
||||||
modeButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight));
|
setButtonSize(custom3Button, bWidth, bHeight);
|
||||||
undoButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight));
|
setButtonSize(modeButton, bWidth, bHeight);
|
||||||
redoButton.setLayoutParams(new LinearLayout.LayoutParams(bWidth, bHeight));
|
setButtonSize(undoButton, bWidth, bHeight);
|
||||||
|
setButtonSize(redoButton, bWidth, bHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setButtonSize(ImageButton button, int bWidth, int bHeight) {
|
||||||
|
LayoutParams lp = button.getLayoutParams();
|
||||||
|
lp.height = bHeight;
|
||||||
|
lp.width = bWidth;
|
||||||
|
button.setLayoutParams(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized final void setWakeLock(boolean enableLock) {
|
private synchronized final void setWakeLock(boolean enableLock) {
|
||||||
|
@ -1356,6 +1368,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||||
static private final int NEW_GAME_DIALOG = 16;
|
static private final int NEW_GAME_DIALOG = 16;
|
||||||
static private final int CUSTOM1_BUTTON_DIALOG = 17;
|
static private final int CUSTOM1_BUTTON_DIALOG = 17;
|
||||||
static private final int CUSTOM2_BUTTON_DIALOG = 18;
|
static private final int CUSTOM2_BUTTON_DIALOG = 18;
|
||||||
|
static private final int CUSTOM3_BUTTON_DIALOG = 19;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(int id) {
|
protected Dialog onCreateDialog(int id) {
|
||||||
|
@ -2112,6 +2125,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||||
return makeButtonDialog(custom1ButtonActions);
|
return makeButtonDialog(custom1ButtonActions);
|
||||||
case CUSTOM2_BUTTON_DIALOG:
|
case CUSTOM2_BUTTON_DIALOG:
|
||||||
return makeButtonDialog(custom2ButtonActions);
|
return makeButtonDialog(custom2ButtonActions);
|
||||||
|
case CUSTOM3_BUTTON_DIALOG:
|
||||||
|
return makeButtonDialog(custom3ButtonActions);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user