ImRingtonePreferencepublic class ImRingtonePreference extends android.preference.RingtonePreference RingtonePreference subclass to save/restore ringtone value from ImProvider. |
Fields Summary |
---|
private long | mProviderId |
Constructors Summary |
---|
public ImRingtonePreference(android.content.Context context, android.util.AttributeSet attrs)
super(context, attrs);
Intent intent = ((Activity)context).getIntent();
mProviderId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID, -1);
if (mProviderId < 0) {
Log.e(ImApp.LOG_TAG,"ImRingtonePreference intent requires provider id extra");
throw new RuntimeException("ImRingtonePreference must be created with an provider id");
}
|
Methods Summary |
---|
protected android.net.Uri | onRestoreRingtone()
final Im.ProviderSettings.QueryMap settings = new Im.ProviderSettings.QueryMap(
getContext().getContentResolver(), mProviderId,
false /* keep updated */, null /* no handler */);
String uri = settings.getRingtoneURI();
if (Log.isLoggable(ImApp.LOG_TAG, Log.VERBOSE)) {
Log.v(ImApp.LOG_TAG, "onRestoreRingtone() finds uri=" + uri + " key=" + getKey());
}
if (TextUtils.isEmpty(uri)) {
return null;
}
Uri result = Uri.parse(uri);
settings.close();
return result;
| protected void | onSaveRingtone(android.net.Uri ringtoneUri)
final Im.ProviderSettings.QueryMap settings = new Im.ProviderSettings.QueryMap(
getContext().getContentResolver(), mProviderId,
false /* keep updated */, null /* no handler */);
// When ringtoneUri is null, that means 'Silent' was chosen
settings.setRingtoneURI(ringtoneUri == null ? "" : ringtoneUri.toString());
settings.close();
|
|