Skip to content

Commit

Permalink
Remove vibrate function from barcode scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
CatotheCat11 committed Dec 23, 2024
1 parent e36b9a0 commit df12b8a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import android.content.res.AssetFileDescriptor;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.util.Log;

Expand All @@ -37,12 +36,10 @@ public final class BeepManager implements MediaPlayer.OnCompletionListener,
private static final String TAG = BeepManager.class.getSimpleName();

private static final float BEEP_VOLUME = 0.10f;
private static final long VIBRATE_DURATION = 200L;

private final Activity activity;
private MediaPlayer mediaPlayer;
private boolean playBeep;
private boolean vibrate;

public BeepManager(Activity activity) {
this.activity = activity;
Expand All @@ -54,7 +51,6 @@ public synchronized void updatePrefs() {
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(activity);
playBeep = shouldBeep(prefs, activity);
vibrate = false;
if (playBeep && mediaPlayer == null) {
// The volume on STREAM_SYSTEM is not adjustable, and users found it too loud,
// so we now play on the music stream.
Expand All @@ -63,15 +59,10 @@ public synchronized void updatePrefs() {
}
}

public synchronized void playBeepSoundAndVibrate() {
public synchronized void playBeepSound() {
if (playBeep && mediaPlayer != null) {
mediaPlayer.start();
}
if (vibrate) {
Vibrator vibrator = (Vibrator) activity
.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_DURATION);
}
}

private static boolean shouldBeep(SharedPreferences prefs, Context activity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import java.util.Map;

import android.app.AlertDialog;
import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
Expand Down Expand Up @@ -247,7 +245,7 @@ public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) {

boolean fromLiveScan = barcode != null;
if (fromLiveScan) {
mBeepManager.playBeepSoundAndVibrate();
mBeepManager.playBeepSound();
drawResultPoints(barcode, scaleFactor, rawResult, getResources()
.getColor(R.color.result_points));
}
Expand Down

0 comments on commit df12b8a

Please sign in to comment.