play notification sound pre notification categories
This commit is contained in:
parent
e545e95d39
commit
8472712b3e
|
@ -355,7 +355,9 @@ public class NotificationService {
|
||||||
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
||||||
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
|
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
|
||||||
builder.setCategory(NotificationCompat.CATEGORY_CALL);
|
builder.setCategory(NotificationCompat.CATEGORY_CALL);
|
||||||
builder.setFullScreenIntent(createPendingRtpSession(id, Intent.ACTION_VIEW, 101), true);
|
PendingIntent pendingIntent = createPendingRtpSession(id, Intent.ACTION_VIEW, 101);
|
||||||
|
builder.setFullScreenIntent(pendingIntent, true);
|
||||||
|
builder.setContentIntent(pendingIntent); //old androids need this?
|
||||||
builder.setOngoing(true);
|
builder.setOngoing(true);
|
||||||
builder.addAction(new NotificationCompat.Action.Builder(
|
builder.addAction(new NotificationCompat.Action.Builder(
|
||||||
R.drawable.ic_call_end_white_48dp,
|
R.drawable.ic_call_end_white_48dp,
|
||||||
|
@ -367,6 +369,7 @@ public class NotificationService {
|
||||||
mXmppConnectionService.getString(R.string.answer_call),
|
mXmppConnectionService.getString(R.string.answer_call),
|
||||||
createPendingRtpSession(id, RtpSessionActivity.ACTION_ACCEPT_CALL, 103))
|
createPendingRtpSession(id, RtpSessionActivity.ACTION_ACCEPT_CALL, 103))
|
||||||
.build());
|
.build());
|
||||||
|
modifyIncomingCall(builder);
|
||||||
final Notification notification = builder.build();
|
final Notification notification = builder.build();
|
||||||
notification.flags = notification.flags | Notification.FLAG_INSISTENT;
|
notification.flags = notification.flags | Notification.FLAG_INSISTENT;
|
||||||
notify(INCOMING_CALL_NOTIFICATION_ID, notification);
|
notify(INCOMING_CALL_NOTIFICATION_ID, notification);
|
||||||
|
@ -570,6 +573,27 @@ public class NotificationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void modifyIncomingCall(Builder mBuilder) {
|
||||||
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mXmppConnectionService);
|
||||||
|
final Resources resources = mXmppConnectionService.getResources();
|
||||||
|
final String ringtone = preferences.getString("call_ringtone", resources.getString(R.string.incoming_call_ringtone));
|
||||||
|
final int dat = 70;
|
||||||
|
final long[] pattern = {0, 3 * dat, dat, dat, 3 * dat, dat, dat};
|
||||||
|
mBuilder.setVibrate(pattern);
|
||||||
|
Uri uri = Uri.parse(ringtone);
|
||||||
|
try {
|
||||||
|
mBuilder.setSound(fixRingtoneUri(uri));
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Log.d(Config.LOGTAG, "unable to use custom notification sound " + uri.toString());
|
||||||
|
}
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
mBuilder.setCategory(Notification.CATEGORY_MESSAGE);
|
||||||
|
}
|
||||||
|
mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
|
||||||
|
setNotificationColor(mBuilder);
|
||||||
|
mBuilder.setLights(LED_COLOR, 2000, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
private Uri fixRingtoneUri(Uri uri) {
|
private Uri fixRingtoneUri(Uri uri) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && "file".equals(uri.getScheme())) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && "file".equals(uri.getScheme())) {
|
||||||
return FileBackend.getUriForFile(mXmppConnectionService, new File(uri.getPath()));
|
return FileBackend.getUriForFile(mXmppConnectionService, new File(uri.getPath()));
|
||||||
|
|
|
@ -30,7 +30,9 @@ public class Compatibility {
|
||||||
"led",
|
"led",
|
||||||
"notification_ringtone",
|
"notification_ringtone",
|
||||||
"notification_headsup",
|
"notification_headsup",
|
||||||
"vibrate_on_notification");
|
"vibrate_on_notification",
|
||||||
|
"call_ringtone"
|
||||||
|
);
|
||||||
private static final List<String> UNUESD_SETTINGS_PRE_TWENTYSIX = Collections.singletonList("more_notification_settings");
|
private static final List<String> UNUESD_SETTINGS_PRE_TWENTYSIX = Collections.singletonList("more_notification_settings");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<bool name="led">true</bool>
|
<bool name="led">true</bool>
|
||||||
<bool name="enable_quiet_hours">false</bool>
|
<bool name="enable_quiet_hours">false</bool>
|
||||||
<string name="notification_ringtone">content://settings/system/notification_sound</string>
|
<string name="notification_ringtone">content://settings/system/notification_sound</string>
|
||||||
|
<string name="incoming_call_ringtone">content://settings/system/ringtone</string>
|
||||||
<integer name="grace_period">144</integer>
|
<integer name="grace_period">144</integer>
|
||||||
<integer name="auto_accept_filesize">524288</integer>
|
<integer name="auto_accept_filesize">524288</integer>
|
||||||
<string name="picture_compression">auto</string>
|
<string name="picture_compression">auto</string>
|
||||||
|
|
|
@ -116,8 +116,10 @@
|
||||||
<string name="pref_vibrate_summary">Vibrate when a new message arrives</string>
|
<string name="pref_vibrate_summary">Vibrate when a new message arrives</string>
|
||||||
<string name="pref_led">LED Notification</string>
|
<string name="pref_led">LED Notification</string>
|
||||||
<string name="pref_led_summary">Blink notification light when a new message arrives</string>
|
<string name="pref_led_summary">Blink notification light when a new message arrives</string>
|
||||||
<string name="pref_sound">Ringtone</string>
|
<string name="pref_ringtone">Ringtone</string>
|
||||||
<string name="pref_sound_summary">Play sound when a new message arrives</string>
|
<string name="pref_notification_sound">Notification sound</string>
|
||||||
|
<string name="pref_notification_sound_summary">Notification sound for new messages</string>
|
||||||
|
<string name="pref_call_ringtone_summary">Ringtone for incoming call</string>
|
||||||
<string name="pref_notification_grace_period">Grace Period</string>
|
<string name="pref_notification_grace_period">Grace Period</string>
|
||||||
<string name="pref_notification_grace_period_summary">The length of time notifications are silenced after detecting activity on one of your other devices.</string>
|
<string name="pref_notification_grace_period_summary">The length of time notifications are silenced after detecting activity on one of your other devices.</string>
|
||||||
<string name="pref_advanced_options">Advanced</string>
|
<string name="pref_advanced_options">Advanced</string>
|
||||||
|
|
|
@ -117,8 +117,14 @@
|
||||||
android:defaultValue="@string/notification_ringtone"
|
android:defaultValue="@string/notification_ringtone"
|
||||||
android:key="notification_ringtone"
|
android:key="notification_ringtone"
|
||||||
android:ringtoneType="notification"
|
android:ringtoneType="notification"
|
||||||
android:summary="@string/pref_sound_summary"
|
android:summary="@string/pref_notification_sound_summary"
|
||||||
android:title="@string/pref_sound" />
|
android:title="@string/pref_notification_sound" />
|
||||||
|
<RingtonePreference
|
||||||
|
android:defaultValue="@string/notification_ringtone"
|
||||||
|
android:key="call_ringtone"
|
||||||
|
android:ringtoneType="ringtone"
|
||||||
|
android:summary="@string/pref_call_ringtone_summary"
|
||||||
|
android:title="@string/pref_ringtone" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="attachments"
|
android:key="attachments"
|
||||||
|
|
Loading…
Reference in a new issue