/// <summary> /// Feedback the specified effect and mode. /// </summary> /// <param name="effect">Effect.</param> /// <param name="mode">Mode.</param> public static void Feedback(HapticEffect effect, KeyClicks mode = KeyClicks.Default) { if (mode == KeyClicks.Off) { return; } Service?.Feedback(effect, mode); }
public void Feedback(HapticEffect effect, KeyClicks mode = KeyClicks.Default) { var soundEnabled = (mode & KeyClicks.On) > 0; if (mode == KeyClicks.Default) { soundEnabled = (Forms9Patch.Settings.KeyClicks & KeyClicks.On) > 0; if (Forms9Patch.Settings.KeyClicks == KeyClicks.Default) { soundEnabled = Android.Provider.Settings.System.GetInt(Android.App.Application.Context.ContentResolver, Android.Provider.Settings.System.SoundEffectsEnabled) != 0; //vibeEnabled = Android.Provider.Settings.System.GetInt(Android.App.Application.Context.ContentResolver, Android.Provider.Settings.System.HapticFeedbackEnabled) != 0; } } var permission = Android.App.Application.Context.CheckCallingOrSelfPermission("android.permission.VIBRATE"); if (_vibrator != null && permission == Permission.Granted && Android.Provider.Settings.System.GetInt(Android.App.Application.Context.ContentResolver, Android.Provider.Settings.System.HapticFeedbackEnabled) != 0) { _vibrator.Vibrate(10); } if (_audio != null && soundEnabled) { SoundEffect sound = SoundEffect.KeyClick; switch (effect) { case HapticEffect.None: return; case HapticEffect.KeyClick: break; case HapticEffect.Return: sound = SoundEffect.Return; break; case HapticEffect.Delete: sound = SoundEffect.Delete; break; } _audio.PlaySoundEffect(sound); } }
/// <summary> /// Feedback the specified effect and mode. /// </summary> /// <param name="effect">Effect.</param> /// <param name="mode">Mode.</param> public void Feedback(HapticEffect effect, KeyClicks mode = KeyClicks.Default) { var soundEnabled = (mode & KeyClicks.On) > 0; if (mode == KeyClicks.Default) { soundEnabled = (Forms9Patch.Settings.KeyClicks & KeyClicks.On) > 0; if (Forms9Patch.Settings.KeyClicks == KeyClicks.Default) { // this no longer works and there doesn't appear to be a way to detect if keyclicks is on //var type = CFPreferences.CurrentApplication; CFPreferences.AppSynchronize("/var/mobile/Library/Preferences/com.apple.preferences.sounds"); soundEnabled = CFPreferences.GetAppBooleanValue("keyboard", "/var/mobile/Library/Preferences/com.apple.preferences.sounds"); } } if (soundEnabled) { switch (effect) { case HapticEffect.None: break; case HapticEffect.KeyClick: click.PlaySystemSoundAsync(); break; case HapticEffect.Return: modifier.PlaySystemSoundAsync(); break; case HapticEffect.Delete: delete.PlaySystemSoundAsync(); break; } } }