FileDocCategorySizeDatePackage
ImRingtonePreference.javaAPI DocAndroid 1.5 API2861Wed May 06 22:42:46 BST 2009com.android.im.app

ImRingtonePreference

public 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.UrionRestoreRingtone()

        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 voidonSaveRingtone(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();