Loading res/values/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -6364,6 +6364,12 @@ <!-- Sound: Title for the option defining the default notification sound. [CHAR LIMIT=30] --> <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] --> <string name="alarm_ringtone_title">Default alarm sound</string> Loading res/xml/channel_notification_settings.xml +5 −3 Original line number Diff line number Diff line Loading @@ -32,10 +32,12 @@ android:title="@string/notification_importance_title" /> <!-- Default ringtone --> <com.android.settings.notification.DefaultNotificationTonePreference <com.android.settings.notification.NotificationSoundPreference android:key="ringtone" android:title="@string/notification_ringtone_title" android:dialogTitle="@string/notification_ringtone_title" android:title="@string/notification_channel_sound_title" android:dialogTitle="@string/notification_channel_sound_title" android:showSilent="true" android:showDefault="true" android:ringtoneType="notification" /> <!-- Vibration --> Loading src/com/android/settings/notification/ChannelNotificationSettings.java +2 −4 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import static android.app.NotificationManager.IMPORTANCE_LOW; import static android.app.NotificationManager.IMPORTANCE_MIN; import static android.app.NotificationManager.IMPORTANCE_NONE; import android.app.Activity; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; Loading @@ -29,7 +28,6 @@ import android.app.admin.DevicePolicyManager; import android.content.Intent; import android.content.pm.UserInfo; import android.net.Uri; import android.os.Bundle; import android.os.UserHandle; import android.provider.Settings; import android.service.notification.NotificationListenerService.Ranking; Loading Loading @@ -63,7 +61,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { protected RestrictedSwitchPreference mLights; protected RestrictedSwitchPreference mVibrate; protected DefaultNotificationTonePreference mRingtone; protected NotificationSoundPreference mRingtone; protected RestrictedDropDownPreference mImportance; protected RestrictedSwitchPreference mPriority; protected RestrictedDropDownPreference mVisibilityOverride; Loading Loading @@ -102,7 +100,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { (RestrictedDropDownPreference) findPreference(KEY_VISIBILITY_OVERRIDE); mLights = (RestrictedSwitchPreference) findPreference(KEY_LIGHTS); mVibrate = (RestrictedSwitchPreference) findPreference(KEY_VIBRATE); mRingtone = (DefaultNotificationTonePreference) findPreference(KEY_RINGTONE); mRingtone = (NotificationSoundPreference) findPreference(KEY_RINGTONE); if (mPkgInfo != null && mChannel != null) { setupPriorityPref(mChannel.canBypassDnd()); Loading src/com/android/settings/notification/NotificationSoundPreference.java 0 → 100644 +54 −0 Original line number Diff line number Diff line 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(); } } Loading
res/values/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -6364,6 +6364,12 @@ <!-- Sound: Title for the option defining the default notification sound. [CHAR LIMIT=30] --> <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] --> <string name="alarm_ringtone_title">Default alarm sound</string> Loading
res/xml/channel_notification_settings.xml +5 −3 Original line number Diff line number Diff line Loading @@ -32,10 +32,12 @@ android:title="@string/notification_importance_title" /> <!-- Default ringtone --> <com.android.settings.notification.DefaultNotificationTonePreference <com.android.settings.notification.NotificationSoundPreference android:key="ringtone" android:title="@string/notification_ringtone_title" android:dialogTitle="@string/notification_ringtone_title" android:title="@string/notification_channel_sound_title" android:dialogTitle="@string/notification_channel_sound_title" android:showSilent="true" android:showDefault="true" android:ringtoneType="notification" /> <!-- Vibration --> Loading
src/com/android/settings/notification/ChannelNotificationSettings.java +2 −4 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import static android.app.NotificationManager.IMPORTANCE_LOW; import static android.app.NotificationManager.IMPORTANCE_MIN; import static android.app.NotificationManager.IMPORTANCE_NONE; import android.app.Activity; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; Loading @@ -29,7 +28,6 @@ import android.app.admin.DevicePolicyManager; import android.content.Intent; import android.content.pm.UserInfo; import android.net.Uri; import android.os.Bundle; import android.os.UserHandle; import android.provider.Settings; import android.service.notification.NotificationListenerService.Ranking; Loading Loading @@ -63,7 +61,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { protected RestrictedSwitchPreference mLights; protected RestrictedSwitchPreference mVibrate; protected DefaultNotificationTonePreference mRingtone; protected NotificationSoundPreference mRingtone; protected RestrictedDropDownPreference mImportance; protected RestrictedSwitchPreference mPriority; protected RestrictedDropDownPreference mVisibilityOverride; Loading Loading @@ -102,7 +100,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase { (RestrictedDropDownPreference) findPreference(KEY_VISIBILITY_OVERRIDE); mLights = (RestrictedSwitchPreference) findPreference(KEY_LIGHTS); mVibrate = (RestrictedSwitchPreference) findPreference(KEY_VIBRATE); mRingtone = (DefaultNotificationTonePreference) findPreference(KEY_RINGTONE); mRingtone = (NotificationSoundPreference) findPreference(KEY_RINGTONE); if (mPkgInfo != null && mChannel != null) { setupPriorityPref(mChannel.canBypassDnd()); Loading
src/com/android/settings/notification/NotificationSoundPreference.java 0 → 100644 +54 −0 Original line number Diff line number Diff line 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(); } }