Support customized summary in Channel Notification
Want to show the vibration name if customised vibration in channel notification is enabled. Therefore, need the summary function could be overrided. Flag: com.android.server.notification.notification_vibration_in_sound_uri Test: manual test Bug: 351975435 Change-Id: I1fcd6deb3f176ef5943da59ae8861136d4a63f79
This commit is contained in:
@@ -24,9 +24,8 @@ import android.media.RingtoneManager;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.RingtonePreference;
|
import com.android.settings.RingtonePreference;
|
||||||
|
|
||||||
public class NotificationSoundPreference extends RingtonePreference {
|
public class NotificationSoundPreference extends RingtonePreference {
|
||||||
@@ -49,6 +48,20 @@ public class NotificationSoundPreference extends RingtonePreference {
|
|||||||
updateRingtoneName(mRingtone);
|
updateRingtoneName(mRingtone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String generateRingtoneTitle(Uri uri) {
|
||||||
|
if (uri == null) {
|
||||||
|
return getContext().getString(com.android.internal.R.string.ringtone_silent);
|
||||||
|
} else if (RingtoneManager.isDefault(uri)) {
|
||||||
|
return getContext().getString(com.android.settings.R.string.notification_sound_default);
|
||||||
|
} else if (ContentResolver.SCHEME_ANDROID_RESOURCE.equals(uri.getScheme())) {
|
||||||
|
return getContext().getString(
|
||||||
|
com.android.settings.R.string.notification_unknown_sound_title);
|
||||||
|
} else {
|
||||||
|
return Ringtone.getTitle(getContext(), uri, false /* followSettingsUri */,
|
||||||
|
true /* allowRemote */);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
|
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
@@ -69,16 +82,7 @@ public class NotificationSoundPreference extends RingtonePreference {
|
|||||||
AsyncTask ringtoneNameTask = new AsyncTask<Object, Void, CharSequence>() {
|
AsyncTask ringtoneNameTask = new AsyncTask<Object, Void, CharSequence>() {
|
||||||
@Override
|
@Override
|
||||||
protected CharSequence doInBackground(Object... params) {
|
protected CharSequence doInBackground(Object... params) {
|
||||||
if (uri == null) {
|
return generateRingtoneTitle(uri);
|
||||||
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
|
@Override
|
||||||
|
Reference in New Issue
Block a user