Notification sound field updates
- Show default and silent options - Don't also update the default notification sound - Display a better summary in case the sound isn't in media store Change-Id: I42d537657a7bbddb8a1ce41fd03b8e5847899a82 Fixes: 36734113 Fixes: 36849670 Test: manual (silent sound, default sound, normal sound, private sound)
This commit is contained in:
@@ -6360,6 +6360,12 @@
|
|||||||
<!-- Sound: Title for the option defining the default notification sound. [CHAR LIMIT=30] -->
|
<!-- Sound: Title for the option defining the default notification sound. [CHAR LIMIT=30] -->
|
||||||
<string name="notification_ringtone_title">Default notification sound</string>
|
<string name="notification_ringtone_title">Default notification sound</string>
|
||||||
|
|
||||||
|
<!-- Sound: Sound title for apps that have not provided a title. [CHAR LIMIT=30] -->
|
||||||
|
<string name="notification_unknown_sound_title">App provided sound</string>
|
||||||
|
|
||||||
|
<!-- Notification sound summary when chosen sound is the system default. -->
|
||||||
|
<string name="notification_sound_default">Default notification sound</string>
|
||||||
|
|
||||||
<!-- Sound: Title for the option defining the default alarm sound. [CHAR LIMIT=30] -->
|
<!-- Sound: Title for the option defining the default alarm sound. [CHAR LIMIT=30] -->
|
||||||
<string name="alarm_ringtone_title">Default alarm sound</string>
|
<string name="alarm_ringtone_title">Default alarm sound</string>
|
||||||
|
|
||||||
|
@@ -32,10 +32,12 @@
|
|||||||
android:title="@string/notification_importance_title" />
|
android:title="@string/notification_importance_title" />
|
||||||
|
|
||||||
<!-- Default ringtone -->
|
<!-- Default ringtone -->
|
||||||
<com.android.settings.notification.DefaultNotificationTonePreference
|
<com.android.settings.notification.NotificationSoundPreference
|
||||||
android:key="ringtone"
|
android:key="ringtone"
|
||||||
android:title="@string/notification_ringtone_title"
|
android:title="@string/notification_channel_sound_title"
|
||||||
android:dialogTitle="@string/notification_ringtone_title"
|
android:dialogTitle="@string/notification_channel_sound_title"
|
||||||
|
android:showSilent="true"
|
||||||
|
android:showDefault="true"
|
||||||
android:ringtoneType="notification" />
|
android:ringtoneType="notification" />
|
||||||
|
|
||||||
<!-- Vibration -->
|
<!-- Vibration -->
|
||||||
|
@@ -21,7 +21,6 @@ import static android.app.NotificationManager.IMPORTANCE_LOW;
|
|||||||
import static android.app.NotificationManager.IMPORTANCE_MIN;
|
import static android.app.NotificationManager.IMPORTANCE_MIN;
|
||||||
import static android.app.NotificationManager.IMPORTANCE_NONE;
|
import static android.app.NotificationManager.IMPORTANCE_NONE;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
@@ -29,7 +28,6 @@ import android.app.admin.DevicePolicyManager;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.notification.NotificationListenerService.Ranking;
|
import android.service.notification.NotificationListenerService.Ranking;
|
||||||
@@ -63,7 +61,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
|
|||||||
|
|
||||||
protected RestrictedSwitchPreference mLights;
|
protected RestrictedSwitchPreference mLights;
|
||||||
protected RestrictedSwitchPreference mVibrate;
|
protected RestrictedSwitchPreference mVibrate;
|
||||||
protected DefaultNotificationTonePreference mRingtone;
|
protected NotificationSoundPreference mRingtone;
|
||||||
protected RestrictedDropDownPreference mImportance;
|
protected RestrictedDropDownPreference mImportance;
|
||||||
protected RestrictedSwitchPreference mPriority;
|
protected RestrictedSwitchPreference mPriority;
|
||||||
protected RestrictedDropDownPreference mVisibilityOverride;
|
protected RestrictedDropDownPreference mVisibilityOverride;
|
||||||
@@ -102,7 +100,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
|
|||||||
(RestrictedDropDownPreference) findPreference(KEY_VISIBILITY_OVERRIDE);
|
(RestrictedDropDownPreference) findPreference(KEY_VISIBILITY_OVERRIDE);
|
||||||
mLights = (RestrictedSwitchPreference) findPreference(KEY_LIGHTS);
|
mLights = (RestrictedSwitchPreference) findPreference(KEY_LIGHTS);
|
||||||
mVibrate = (RestrictedSwitchPreference) findPreference(KEY_VIBRATE);
|
mVibrate = (RestrictedSwitchPreference) findPreference(KEY_VIBRATE);
|
||||||
mRingtone = (DefaultNotificationTonePreference) findPreference(KEY_RINGTONE);
|
mRingtone = (NotificationSoundPreference) findPreference(KEY_RINGTONE);
|
||||||
|
|
||||||
if (mPkgInfo != null && mChannel != null) {
|
if (mPkgInfo != null && mChannel != null) {
|
||||||
setupPriorityPref(mChannel.canBypassDnd());
|
setupPriorityPref(mChannel.canBypassDnd());
|
||||||
|
@@ -0,0 +1,54 @@
|
|||||||
|
package com.android.settings.notification;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.media.Ringtone;
|
||||||
|
import android.media.RingtoneManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.RingtonePreference;
|
||||||
|
|
||||||
|
public class NotificationSoundPreference extends RingtonePreference {
|
||||||
|
private Uri mRingtone;
|
||||||
|
|
||||||
|
public NotificationSoundPreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Uri onRestoreRingtone() {
|
||||||
|
return mRingtone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRingtone(Uri ringtone) {
|
||||||
|
mRingtone = ringtone;
|
||||||
|
updateRingtoneName(mRingtone);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateRingtoneName(final Uri uri) {
|
||||||
|
AsyncTask ringtoneNameTask = new AsyncTask<Object, Void, CharSequence>() {
|
||||||
|
@Override
|
||||||
|
protected CharSequence doInBackground(Object... params) {
|
||||||
|
if (uri == null) {
|
||||||
|
return getContext().getString(com.android.internal.R.string.ringtone_silent);
|
||||||
|
} else if (RingtoneManager.isDefault(uri)) {
|
||||||
|
return getContext().getString(R.string.notification_sound_default);
|
||||||
|
} else if(ContentResolver.SCHEME_ANDROID_RESOURCE.equals(uri.getScheme())) {
|
||||||
|
return getContext().getString(R.string.notification_unknown_sound_title);
|
||||||
|
} else {
|
||||||
|
return Ringtone.getTitle(getContext(), uri, false /* followSettingsUri */,
|
||||||
|
true /* allowRemote */);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(CharSequence name) {
|
||||||
|
setSummary(name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ringtoneNameTask.execute();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user