Merge "[Settings App] Get ringtone titles from Ringtone"
This commit is contained in:
committed by
Android (Google) Code Review
commit
1355d03287
@@ -478,37 +478,8 @@ public class SoundSettings extends SettingsPreferenceFragment
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Uri ringtoneUri = RingtoneManager.getActualDefaultRingtoneUri(context, type);
|
Uri ringtoneUri = RingtoneManager.getActualDefaultRingtoneUri(context, type);
|
||||||
CharSequence summary = context.getString(com.android.internal.R.string.ringtone_unknown);
|
return Ringtone.getTitle(context, ringtoneUri, false /* followSettingsUri */,
|
||||||
// Is it a silent ringtone?
|
true /* allowRemote */);
|
||||||
if (ringtoneUri == null) {
|
|
||||||
summary = context.getString(com.android.internal.R.string.ringtone_silent);
|
|
||||||
} else {
|
|
||||||
Cursor cursor = null;
|
|
||||||
try {
|
|
||||||
if (MediaStore.AUTHORITY.equals(getUriWithoutUserId(ringtoneUri).getAuthority())) {
|
|
||||||
// Fetch the ringtone title from the media provider
|
|
||||||
cursor = context.getContentResolver().query(ringtoneUri,
|
|
||||||
new String[] { MediaStore.Audio.Media.TITLE }, null, null, null);
|
|
||||||
} else if (ContentResolver.SCHEME_CONTENT.equals(ringtoneUri.getScheme())) {
|
|
||||||
cursor = context.getContentResolver().query(ringtoneUri,
|
|
||||||
new String[] { OpenableColumns.DISPLAY_NAME }, null, null, null);
|
|
||||||
}
|
|
||||||
if (cursor != null) {
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
summary = cursor.getString(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLiteException sqle) {
|
|
||||||
// Unknown title for the ringtone
|
|
||||||
} catch (IllegalArgumentException iae) {
|
|
||||||
// Some other error retrieving the column from the provider
|
|
||||||
} finally {
|
|
||||||
if (cursor != null) {
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return summary;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Vibrate when ringing ===
|
// === Vibrate when ringing ===
|
||||||
|
Reference in New Issue
Block a user