Skip to content

Commit

Permalink
vibr
Browse files Browse the repository at this point in the history
  • Loading branch information
arpruss committed Sep 16, 2019
1 parent ea3ea77 commit 506d45b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "omegacentauri.mobi.simplestopwatch"
minSdkVersion 4
targetSdkVersion 28
versionCode 18
versionName "1.18"
versionCode 19
versionName "1.19"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class MyChrono {
static final long MIN_DELAY_TIME = -9000;
static final long delayTimes[] = { 0, -3000, -6000, MIN_DELAY_TIME };
long lastLapTime;
int vibrateAfterCountDown = 100;
public boolean paused = false;
public boolean active = false;
boolean quiet = false;
Expand Down Expand Up @@ -92,8 +93,8 @@ public long getTime() {
}

private void announce(long t) {
long vibrate = Options.getVibration(options);
if ((quiet && vibrate == 0) || !active || paused)
// long vibrate = Options.getVibration(options);
if (/*(quiet && vibrate == 0) || */ !active || paused)
return;
if (t < -3000 || t >= 1000) {
lastAnnounced = floorDiv(t, 1000)*1000;
Expand Down Expand Up @@ -126,7 +127,7 @@ else if (t >= 0) {
longTone.reloadStaticData();
longTone.play();
}
StopWatch.vibrate(context, vibrate * 4);
StopWatch.vibrate(context, vibrateAfterCountDown);
lastAnnounced = 0;
}
}
Expand Down Expand Up @@ -330,6 +331,8 @@ public void setAudio(String soundMode) {
boostAudio = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && options.getBoolean(Options.PREF_BOOST, false);
STREAM = Options.getStream(options);

vibrateAfterCountDown = options.getBoolean(Options.PREF_VIBRATE_AFTER_COUNTDOWN, true) ? (int)LONG_TONE_LENGTH/2 : 0;

if (soundMode.equals("none")) {
quiet = true;
ttsMode = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Options extends PreferenceActivity {
public static final String PREF_LINE_SPACING = "lineSpacing";
public static final String PREF_LETTER_SPACING = "letterSpacing";
public static final String PREF_LAST_LAP_TIME = "lastLapTime";
public static final String PREF_VIBRATION = "vibration";
// public static final String PREF_VIBRATION = "vibration";
public static final String PREF_DELAY = "delay";
public static final String PREF_SCALE = "scale";
public static final String PREF_LAPS = "laps";
Expand All @@ -52,6 +52,7 @@ public class Options extends PreferenceActivity {
public static final String PREF_VOLUME = "volume";
public static final String PREF_FULLSCREEN = "fullscreen";
public static final String PREF_FS_BRIGHT = "fsBright";
public static final String PREF_VIBRATE_AFTER_COUNTDOWN = "vibrateAfterCountdown";
public static String PREF_CONTROL_FULLSCREEN = "controlFS";
public static final String PREF_BOOT_ADJUSTED = "bootAdjusted";
public static final int highlightPercent = 25;
Expand Down Expand Up @@ -233,10 +234,10 @@ public void setSummary(ListPreference p) {
}
}

public static int getVibration(SharedPreferences options) {
String v = options.getString(PREF_VIBRATION, "20");
return Integer.parseInt(v);
}
// public static int getVibration(SharedPreferences options) {
// String v = options.getString(PREF_VIBRATION, "20");
// return Integer.parseInt(v);
// }

/* public static class MyPreferenceFragment extends PreferenceFragment
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.graphics.PorterDuff;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.StateListDrawable;
import android.media.AudioManager;
import android.os.Build;
import android.os.Vibrator;
import android.preference.PreferenceManager;
Expand All @@ -23,6 +24,7 @@
import android.text.style.TabStopSpan;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
Expand Down Expand Up @@ -325,13 +327,15 @@ void updateButtons() {
}

void pressSecondButton() {
vibrate(this,Options.getVibration(options));
chrono.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
// vibrate(this,Options.getVibration(options));
stopwatch.secondButton();
updateButtons();
}

void pressFirstButton() {
vibrate(this,Options.getVibration(options));
chrono.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
// vibrate(this,Options.getVibration(options));
stopwatch.firstButton();
updateButtons();
}
Expand Down Expand Up @@ -375,12 +379,10 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
return super.onKeyDown(keyCode, event);
}
if (isFirstButton(keyCode)) {
chrono.playSoundEffect(SoundEffectConstants.CLICK);
pressFirstButton();
return true;
}
else if (isSecondButton(keyCode)) {
chrono.playSoundEffect(SoundEffectConstants.CLICK);
pressSecondButton();
return true;
}
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/res/xml/options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
android:defaultValue="automatic"
android:entries="@array/orientationValues"
android:entryValues="@array/orientationValues" />
<ListPreference android:title="Standard Vibration Time"
android:summary=""
android:key="vibration"
android:defaultValue="20"
android:entries="@array/vibrationDisplayValues"
android:entryValues="@array/vibrationValues" />
<PreferenceCategory android:title="Advanced">
<CheckBoxPreference android:title="Keep Aspect"
android:key="keepAspect"
Expand Down Expand Up @@ -86,6 +80,10 @@
android:defaultValue="98%"
android:entries="@array/scaleValues"
android:entryValues="@array/scaleValues" />
<CheckBoxPreference android:title="Vibrate After Countdown"
android:key="vibrateAfterCountdown"
android:defaultValue="true"
/>
<CheckBoxPreference android:title="Boost Countdown Audio"
android:key="boost"
android:defaultValue="false"
Expand Down

0 comments on commit 506d45b

Please sign in to comment.