DroidFish: Optionally vibrate when the computer makes a move.

This commit is contained in:
Peter Osterlund 2012-05-10 18:36:02 +00:00
parent 00013ebaa9
commit 77b25099eb
4 changed files with 18 additions and 0 deletions

View File

@ -8,6 +8,7 @@
android:anyDensity="true" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-sdk android:minSdkVersion="3"
android:targetSdkVersion="10"/>
<application android:icon="@drawable/icon"

View File

@ -399,6 +399,8 @@ you are not actively using the program.\
<string name="prefs_oneTouchMoves_summary">Touching a square that corresponds to one unique move makes that move immediately</string>
<string name="prefs_soundEnabled_title">Enable Sounds</string>
<string name="prefs_soundEnabled_summary">Play sound when computer makes a move</string>
<string name="prefs_vibrateEnabled_title">Enable Vibration</string>
<string name="prefs_vibrateEnabled_summary">Vibrate when computer makes a move</string>
<string name="prefs_fullScreenMode_title">Fullscreen Mode</string>
<string name="prefs_fullScreenMode_summary">Fullscreen mode hides the status bar</string>
<string name="prefs_wakeLock_title">Disable Screen Timeout</string>

View File

@ -121,6 +121,12 @@
android:summary="@string/prefs_soundEnabled_summary"
android:defaultValue="false">
</CheckBoxPreference>
<CheckBoxPreference
android:key="vibrateEnabled"
android:title="@string/prefs_vibrateEnabled_title"
android:summary="@string/prefs_vibrateEnabled_summary"
android:defaultValue="false">
</CheckBoxPreference>
<CheckBoxPreference
android:key="fullScreenMode"
android:title="@string/prefs_fullScreenMode_title"

View File

@ -78,6 +78,7 @@ import android.os.Environment;
import android.os.Handler;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.text.ClipboardManager;
import android.text.Html;
@ -144,6 +145,8 @@ public class DroidFish extends Activity implements GUIInterface {
// FIXME!!! Handle PGN intents with more than one game.
// FIXME!!! File load/save of FEN data
// FIXME!!! Make engine hash size configurable.
// FIXME!!! Startup slow when all GTB files installed.
// FIXME!!! Nicer looking icons.
private ChessBoard cb;
private static DroidChessController ctrl = null;
@ -174,6 +177,7 @@ public class DroidFish extends Activity implements GUIInterface {
private boolean leftHanded;
private boolean soundEnabled;
private MediaPlayer moveSound;
private boolean vibrateEnabled;
private boolean animateMoves;
private final static String bookDir = "DroidFish";
@ -621,6 +625,7 @@ public class DroidFish extends Activity implements GUIInterface {
moveList.setTextSize(fontSize);
thinking.setTextSize(fontSize);
soundEnabled = settings.getBoolean("soundEnabled", false);
vibrateEnabled = settings.getBoolean("vibrateEnabled", false);
animateMoves = settings.getBoolean("animateMoves", true);
boolean largeButtons = settings.getBoolean("largeButtons", false);
@ -2113,6 +2118,10 @@ public class DroidFish extends Activity implements GUIInterface {
moveSound = MediaPlayer.create(this, R.raw.movesound);
moveSound.start();
}
if (vibrateEnabled) {
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(500);
}
}
@Override