mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 05:52:47 +00:00
do not vibrate if do not disturb is enabled, fixes #1125
This commit is contained in:
parent
27d257ce1d
commit
d754e7ca7f
2 changed files with 12 additions and 4 deletions
|
@ -28,6 +28,7 @@ public final class AudioAndHapticFeedbackManager {
|
||||||
|
|
||||||
private SettingsValues mSettingsValues;
|
private SettingsValues mSettingsValues;
|
||||||
private boolean mSoundOn;
|
private boolean mSoundOn;
|
||||||
|
private boolean mDoNotDisturb;
|
||||||
|
|
||||||
private static final AudioAndHapticFeedbackManager sInstance =
|
private static final AudioAndHapticFeedbackManager sInstance =
|
||||||
new AudioAndHapticFeedbackManager();
|
new AudioAndHapticFeedbackManager();
|
||||||
|
@ -67,7 +68,7 @@ public final class AudioAndHapticFeedbackManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean reevaluateIfSoundIsOn() {
|
private boolean reevaluateIfSoundIsOn() {
|
||||||
if (mSettingsValues == null || !mSettingsValues.mSoundOn || mAudioManager == null) {
|
if (mSettingsValues == null || !mSettingsValues.mSoundOn || mAudioManager == null || mDoNotDisturb) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL;
|
return mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL;
|
||||||
|
@ -91,7 +92,7 @@ public final class AudioAndHapticFeedbackManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performHapticFeedback(final View viewToPerformHapticFeedbackOn) {
|
public void performHapticFeedback(final View viewToPerformHapticFeedbackOn) {
|
||||||
if (!mSettingsValues.mVibrateOn) {
|
if (!mSettingsValues.mVibrateOn || mDoNotDisturb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mSettingsValues.mKeypressVibrationDuration >= 0) {
|
if (mSettingsValues.mKeypressVibrationDuration >= 0) {
|
||||||
|
@ -111,7 +112,8 @@ public final class AudioAndHapticFeedbackManager {
|
||||||
mSoundOn = reevaluateIfSoundIsOn();
|
mSoundOn = reevaluateIfSoundIsOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRingerModeChanged() {
|
public void onRingerModeChanged(boolean doNotDisturb) {
|
||||||
|
mDoNotDisturb = doNotDisturb;
|
||||||
mSoundOn = reevaluateIfSoundIsOn();
|
mSoundOn = reevaluateIfSoundIsOn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1853,7 +1853,13 @@ public class LatinIME extends InputMethodService implements
|
||||||
public void onReceive(final Context context, final Intent intent) {
|
public void onReceive(final Context context, final Intent intent) {
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(action)) {
|
if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(action)) {
|
||||||
AudioAndHapticFeedbackManager.getInstance().onRingerModeChanged();
|
boolean dnd;
|
||||||
|
try {
|
||||||
|
dnd = android.provider.Settings.Global.getInt(context.getContentResolver(), "zen_mode") != 0;
|
||||||
|
} catch (android.provider.Settings.SettingNotFoundException e) {
|
||||||
|
dnd = false;
|
||||||
|
}
|
||||||
|
AudioAndHapticFeedbackManager.getInstance().onRingerModeChanged(dnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue