Repo created
This commit is contained in:
parent
f2d952b743
commit
3ecd57d1b2
475 changed files with 37130 additions and 2 deletions
46
srcs/juloo.keyboard2/VibratorCompat.java
Normal file
46
srcs/juloo.keyboard2/VibratorCompat.java
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package juloo.keyboard2;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Vibrator;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.View;
|
||||
|
||||
public final class VibratorCompat
|
||||
{
|
||||
public static void vibrate(View v, Config config)
|
||||
{
|
||||
if (config.vibrate_custom)
|
||||
{
|
||||
if (config.vibrate_duration > 0)
|
||||
vibrator_vibrate(v, config.vibrate_duration);
|
||||
}
|
||||
else
|
||||
{
|
||||
v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP,
|
||||
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
|
||||
}
|
||||
}
|
||||
|
||||
/** Use the older [Vibrator] when the newer API is not available or the user
|
||||
wants more control. */
|
||||
static void vibrator_vibrate(View v, long duration)
|
||||
{
|
||||
try
|
||||
{
|
||||
get_vibrator(v).vibrate(duration);
|
||||
}
|
||||
catch (Exception e) {}
|
||||
}
|
||||
|
||||
static Vibrator vibrator_service = null;
|
||||
|
||||
static Vibrator get_vibrator(View v)
|
||||
{
|
||||
if (vibrator_service == null)
|
||||
{
|
||||
vibrator_service =
|
||||
(Vibrator)v.getContext().getSystemService(Context.VIBRATOR_SERVICE);
|
||||
}
|
||||
return vibrator_service;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue