From 358aa465bc4b8425fe59fe75c341fb9716ed1ea2 Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Thu, 10 Nov 2011 19:13:06 +0100 Subject: [PATCH] override system vibration settings --- src/ServiceNotifier.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ServiceNotifier.scala b/src/ServiceNotifier.scala index 615b75c..b395d7e 100644 --- a/src/ServiceNotifier.scala +++ b/src/ServiceNotifier.scala @@ -4,6 +4,7 @@ import _root_.android.app.{Notification, NotificationManager, PendingIntent, Ser import _root_.android.content.{Context, Intent} import _root_.android.net.Uri import _root_.android.os.Build +import _root_.android.os.Vibrator import _root_.android.graphics.Color @@ -58,7 +59,7 @@ abstract class ServiceNotifier { def start(ctx : Service, status : String) def stop(ctx : Service) - def setupNotification(n : Notification, prefs : PrefsWrapper, prefix : String) { + def setupNotification(n : Notification, ctx : Context, prefs : PrefsWrapper, prefix : String) { // set notification LED if (prefs.getBoolean(prefix + "notify_led", true)) { n.ledARGB = Color.YELLOW @@ -67,7 +68,8 @@ abstract class ServiceNotifier { n.flags |= Notification.FLAG_SHOW_LIGHTS } if (prefs.getBoolean(prefix + "notify_vibr", true)) { - n.vibrate = Array[Long](0, 200, 200) + ctx.getSystemService(Context.VIBRATOR_SERVICE).asInstanceOf[Vibrator] + .vibrate(Array[Long](0, 200, 200), -1) } n.sound = Uri.parse(prefs.getString(prefix + "notify_ringtone", null)) } @@ -76,7 +78,7 @@ abstract class ServiceNotifier { call : String, message : String) { val n = newMessageNotification(ctx, call, message) // set notification LED - setupNotification(n, prefs, "") + setupNotification(n, ctx, prefs, "") getNotificationMgr(ctx).notify(getCallNumber(call), n) } @@ -88,7 +90,7 @@ abstract class ServiceNotifier { def notifyPosition(ctx : Service, prefs : PrefsWrapper, status : String) { val n = newNotification(ctx, status) - setupNotification(n, prefs, "pos_") + setupNotification(n, ctx, prefs, "pos_") getNotificationMgr(ctx).notify(SERVICE_NOTIFICATION, n) } }