Restore original SoundManager
Some checks failed
Build Android APK / build (push) Failing after 3m1s
Some checks failed
Build Android APK / build (push) Failing after 3m1s
This commit is contained in:
@@ -17,44 +17,38 @@ public class SoundManager {
|
||||
private ToneGenerator toneGenerator;
|
||||
private Handler handler;
|
||||
private boolean enabled = true;
|
||||
private boolean isPlaying = false;
|
||||
private Runnable stopToneRunnable;
|
||||
|
||||
public SoundManager(Context context) {
|
||||
// ToneGenerator.STREAM_MUSIC para compatibilidad API 18+
|
||||
toneGenerator = new ToneGenerator(AudioManager.STREAM_MUSIC, VOLUME);
|
||||
handler = new Handler(Looper.getMainLooper());
|
||||
stopToneRunnable = () -> isPlaying = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sonido de click de boton - tono corto y agudo
|
||||
*/
|
||||
public void playButtonClick() {
|
||||
if (!enabled || toneGenerator == null || isPlaying) return;
|
||||
isPlaying = true;
|
||||
if (!enabled || toneGenerator == null) return;
|
||||
// Tono DTMF 6 - sonido tipo boton tactil
|
||||
toneGenerator.startTone(ToneGenerator.TONE_DTMF_6, 80);
|
||||
handler.postDelayed(stopToneRunnable, 80);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sonido de exito - secuencia ascendente
|
||||
*/
|
||||
public void playSuccess() {
|
||||
if (!enabled || toneGenerator == null || isPlaying) return;
|
||||
isPlaying = true;
|
||||
if (!enabled || toneGenerator == null) return;
|
||||
// Tono de confirmacion propositivo
|
||||
toneGenerator.startTone(ToneGenerator.TONE_PROP_ACK, 150);
|
||||
handler.postDelayed(stopToneRunnable, 150);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sonido de fallo - tono bajo grave
|
||||
*/
|
||||
public void playFailure() {
|
||||
if (!enabled || toneGenerator == null || isPlaying) return;
|
||||
isPlaying = true;
|
||||
if (!enabled || toneGenerator == null) return;
|
||||
// Tono de error
|
||||
toneGenerator.startTone(ToneGenerator.TONE_PROP_NACK, 200);
|
||||
handler.postDelayed(stopToneRunnable, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,8 +56,7 @@ public class SoundManager {
|
||||
* Usa diferentes tonos DTMF para cada direccion
|
||||
*/
|
||||
public void playTone(int direction) {
|
||||
if (!enabled || toneGenerator == null || isPlaying) return;
|
||||
isPlaying = true;
|
||||
if (!enabled || toneGenerator == null) return;
|
||||
|
||||
int tone;
|
||||
switch (direction) {
|
||||
@@ -83,27 +76,22 @@ public class SoundManager {
|
||||
tone = ToneGenerator.TONE_DTMF_0;
|
||||
}
|
||||
toneGenerator.startTone(tone, 100);
|
||||
handler.postDelayed(stopToneRunnable, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tono de inicio de secuencia
|
||||
*/
|
||||
public void playSequenceStart() {
|
||||
if (!enabled || toneGenerator == null || isPlaying) return;
|
||||
isPlaying = true;
|
||||
if (!enabled || toneGenerator == null) return;
|
||||
toneGenerator.startTone(ToneGenerator.TONE_SUP_DIAL, 100);
|
||||
handler.postDelayed(stopToneRunnable, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tono de alerta/peligro
|
||||
*/
|
||||
public void playAlert() {
|
||||
if (!enabled || toneGenerator == null || isPlaying) return;
|
||||
isPlaying = true;
|
||||
if (!enabled || toneGenerator == null) return;
|
||||
toneGenerator.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 150);
|
||||
handler.postDelayed(stopToneRunnable, 150);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
|
||||
Reference in New Issue
Block a user