ringtone, led, vibration for messages

beta11
Georg Lukas 2011-07-31 00:00:15 +02:00
rodzic dd9e04f570
commit d0b6640da3
4 zmienionych plików z 66 dodań i 12 usunięć

Wyświetl plik

@ -8,8 +8,9 @@
<uses-sdk android:minSdkVersion="3"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<application android:label="@string/app_name" android:icon="@drawable/icon">
<uses-library android:name="com.google.android.maps" />

Wyświetl plik

@ -40,6 +40,11 @@
android:defaultValue="5"
android:dialogTitle="@string/p_ssid_entry" />
<!-- sub-screen "Position Reports" -->
<PreferenceScreen
android:title="@string/p__position"
android:summary="@string/p__position_summary">
<EditTextPreference
android:key="symbol"
android:hint="@string/default_symbol"
@ -56,8 +61,6 @@
android:summary="@string/p_status_summary"
android:dialogTitle="@string/p_status_entry" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/p__location">
@ -92,13 +95,40 @@
android:summary="@string/p_netloc_summary" />
</PreferenceCategory>
</PreferenceScreen>
<!-- sub-screen "Messaging" -->
<PreferenceScreen
android:title="@string/p__message"
android:summary="@string/p__message_summary">
<PreferenceCategory
android:title="@string/p__msg_notify">
<CheckBoxPreference
android:key="keepscreen"
android:title="@string/p_keepscreen"
android:summary="@string/p_keepscreen_summary" />
<CheckBoxPreference
android:key="notify_led"
android:title="@string/p_msg_led"
android:summaryOn="@string/p_msg_led_on"
android:summaryOff="@string/p_msg_led_off"
android:defaultValue="true"
/>
<CheckBoxPreference
android:key="notify_vibr"
android:title="@string/p_msg_vibr"
android:summaryOn="@string/p_msg_vibr_on"
android:summaryOff="@string/p_msg_vibr_off"
android:defaultValue="true"
/>
<RingtonePreference
android:key="notify_ringtone"
android:title="@string/p_msg_ring"
android:summary="@string/p_msg_ring_summary"
android:ringtoneType="notification"
android:showDefault="true"
android:showSilent="true"
/>
</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/p__connection">
@ -122,4 +152,12 @@
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/p__display">
<CheckBoxPreference
android:key="keepscreen"
android:title="@string/p_keepscreen"
android:summary="@string/p_keepscreen_summary" />
</PreferenceCategory>
</PreferenceScreen>

Wyświetl plik

@ -34,7 +34,8 @@ class MessageService(s : AprsService) {
val status = s.poster.update(ack)
s.addPost(StorageDatabase.Post.TYPE_POST, status, ack.toString)
}
ServiceNotifier.instance.notifyMessage(s, ap.getSourceCall(), msg.getMessageBody())
ServiceNotifier.instance.notifyMessage(s, s.prefs,
ap.getSourceCall(), msg.getMessageBody())
}
s.sendBroadcast(new Intent(AprsService.MESSAGE).putExtra(AprsService.STATUS, ap.toString))
}

Wyświetl plik

@ -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.graphics.Color
object ServiceNotifier {
@ -43,7 +44,7 @@ abstract class ServiceNotifier {
val n = new Notification()
n.icon = R.drawable.icon
n.when = System.currentTimeMillis
n.flags |= Notification.FLAG_AUTO_CANCEL
n.flags = Notification.FLAG_AUTO_CANCEL
val i = new Intent(ctx, classOf[MessageActivity])
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
i.setData(Uri.parse(call))
@ -57,9 +58,22 @@ abstract class ServiceNotifier {
def start(ctx : Service, status : String)
def stop(ctx : Service)
def notifyMessage(ctx : Service, call : String, message : String) {
def notifyMessage(ctx : Service, prefs : PrefsWrapper,
call : String, message : String) {
val n = newMessageNotification(ctx, call, message)
// set notification LED
if (prefs.getBoolean("notify_led", true)) {
n.ledARGB = Color.YELLOW
n.ledOnMS = 300
n.ledOffMS = 1000
n.flags |= Notification.FLAG_SHOW_LIGHTS
}
if (prefs.getBoolean("notify_vibr", true)) {
n.vibrate = Array[Long](200, 10000)
}
n.sound = Uri.parse(prefs.getString("notify_ringtone", null))
getNotificationMgr(ctx).notify(getCallNumber(call),
newMessageNotification(ctx, call, message))
n)
}
def cancelMessage(ctx : Context, call : String) {