Build 1.0_r1(from source)

android.preference
Class RingtonePreference

java.lang.Object
  extended by android.preference.Preference
      extended by android.preference.RingtonePreference
All Implemented Interfaces:
OnDependencyChangeListener, PreferenceManager.OnActivityResultListener, Comparable<Preference>

public class RingtonePreference
extends Preference
implements PreferenceManager.OnActivityResultListener

The RingtonePreference allows the user to choose one from all of the available ringtones. The chosen ringtone's URI will be persisted as a string.

If the user chooses the "Default" item, the saved string will be one of Settings.System.DEFAULT_RINGTONE_URI or Settings.System.DEFAULT_NOTIFICATION_URI. If the user chooses the "Silent" item, the saved string will be an empty string.


Nested Class Summary
 
Nested classes/interfaces inherited from class android.preference.Preference
Preference.BaseSavedState, Preference.OnPreferenceChangeInternalListener, Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener
 
Field Summary
 
Fields inherited from class android.preference.Preference
DEFAULT_ORDER
 
Constructor Summary
RingtonePreference(Context context)
           
RingtonePreference(Context context, AttributeSet attrs)
           
RingtonePreference(Context context, AttributeSet attrs, int defStyle)
           
 
Method Summary
 int getRingtoneType()
          Returns the sound type(s) that are shown in the picker.
 boolean getShowDefault()
          Returns whether to a show an item for the default sound/ringtone.
 boolean getShowSilent()
          Returns whether to a show an item for 'Silent'.
 boolean onActivityResult(int requestCode, int resultCode, Intent data)
          See Activity's onActivityResult.
protected  void onAttachedToHierarchy(PreferenceManager preferenceManager)
          Called when this preference has been attached to a preference hierarchy.
protected  void onClick()
          Processes a click on the preference.
protected  Object onGetDefaultValue(TypedArray a, int index)
          Called when Preference is being inflated and the default value attribute needs to be read.
protected  void onPrepareRingtonePickerIntent(Intent ringtonePickerIntent)
          Prepares the intent to launch the ringtone picker.
protected  Uri onRestoreRingtone()
          Called when the chooser is about to be shown and the current ringtone should be marked.
protected  void onSaveRingtone(Uri ringtoneUri)
          Called when a ringtone is chosen.
protected  void onSetInitialValue(boolean restorePersistedValue, Object defaultValueObj)
          Implement this to set the initial value of the Preference.
 void setRingtoneType(int type)
          Sets the sound type(s) that are shown in the picker.
 void setShowDefault(boolean showDefault)
          Sets whether to show an item for the default sound/ringtone.
 void setShowSilent(boolean showSilent)
          Sets whether to show an item for 'Silent'.
 
Methods inherited from class android.preference.Preference
callChangeListener, compareTo, dispatchRestoreInstanceState, dispatchSaveInstanceState, findPreferenceInHierarchy, getContext, getDependency, getEditor, getFilterableStringBuilder, getId, getIntent, getKey, getLayoutResource, getOnPreferenceChangeListener, getOnPreferenceClickListener, getOrder, getPersistedBoolean, getPersistedFloat, getPersistedInt, getPersistedLong, getPersistedString, getPreferenceManager, getSharedPreferences, getShouldDisableView, getSummary, getTitle, getView, getWidgetLayoutResource, hasKey, hasSpecifiedLayout, isEnabled, isPersistent, isSelectable, notifyChanged, notifyDependencyChange, notifyHierarchyChanged, onAttachedToActivity, onBindView, onCreateView, onDependencyChanged, onPrepareForRemoval, onRestoreInstanceState, onSaveInstanceState, performClick, persistBoolean, persistFloat, persistInt, persistLong, persistString, requireKey, restoreHierarchyState, saveHierarchyState, setDefaultValue, setDependency, setEnabled, setIntent, setKey, setLayoutResource, setOnPreferenceChangeInternalListener, setOnPreferenceChangeListener, setOnPreferenceClickListener, setOrder, setPersistent, setSelectable, setShouldDisableView, setSummary, setSummary, setTitle, setTitle, setWidgetLayoutResource, shouldCommit, shouldDisableDependents, shouldPersist, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RingtonePreference

public RingtonePreference(Context context,
                          AttributeSet attrs,
                          int defStyle)

RingtonePreference

public RingtonePreference(Context context,
                          AttributeSet attrs)

RingtonePreference

public RingtonePreference(Context context)
Method Detail

getRingtoneType

public int getRingtoneType()
Returns the sound type(s) that are shown in the picker.

Returns:
The sound type(s) that are shown in the picker.
See Also:
setRingtoneType(int)

setRingtoneType

public void setRingtoneType(int type)
Sets the sound type(s) that are shown in the picker.

Parameters:
type - The sound type(s) that are shown in the picker.
See Also:
RingtoneManager.EXTRA_RINGTONE_TYPE

getShowDefault

public boolean getShowDefault()
Returns whether to a show an item for the default sound/ringtone.

Returns:
Whether to show an item for the default sound/ringtone.

setShowDefault

public void setShowDefault(boolean showDefault)
Sets whether to show an item for the default sound/ringtone. The default to use will be deduced from the sound type(s) being shown.

Parameters:
showDefault - Whether to show the default or not.
See Also:
RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT

getShowSilent

public boolean getShowSilent()
Returns whether to a show an item for 'Silent'.

Returns:
Whether to show an item for 'Silent'.

setShowSilent

public void setShowSilent(boolean showSilent)
Sets whether to show an item for 'Silent'.

Parameters:
showSilent - Whether to show 'Silent'.
See Also:
RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT

onClick

protected void onClick()
Description copied from class: Preference
Processes a click on the preference. This includes saving the value to the SharedPreferences. However, the overridden method should call Preference.callChangeListener(Object) to make sure the client wants to update the preference's state with the new value.

Overrides:
onClick in class Preference

onPrepareRingtonePickerIntent

protected void onPrepareRingtonePickerIntent(Intent ringtonePickerIntent)
Prepares the intent to launch the ringtone picker. This can be modified to adjust the parameters of the ringtone picker.

Parameters:
ringtonePickerIntent - The ringtone picker intent that can be modified by putting extras.

onSaveRingtone

protected void onSaveRingtone(Uri ringtoneUri)
Called when a ringtone is chosen.

By default, this saves the ringtone URI to the persistent storage as a string.

Parameters:
ringtoneUri - The chosen ringtone's Uri. Can be null.

onRestoreRingtone

protected Uri onRestoreRingtone()
Called when the chooser is about to be shown and the current ringtone should be marked. Can return null to not mark any ringtone.

By default, this restores the previous ringtone URI from the persistent storage.

Returns:
The ringtone to be marked as the current ringtone.

onGetDefaultValue

protected Object onGetDefaultValue(TypedArray a,
                                   int index)
Description copied from class: Preference
Called when Preference is being inflated and the default value attribute needs to be read. Since different preference types have different value types, the subclass should get and return the default value which will be its value type.

For example, if the value type is String, the body of the method would proxy to TypedArray.getString(int).

Overrides:
onGetDefaultValue in class Preference
Parameters:
a - The set of attributes.
index - The index of the default value attribute.
Returns:
The default value of this preference type.

onSetInitialValue

protected void onSetInitialValue(boolean restorePersistedValue,
                                 Object defaultValueObj)
Description copied from class: Preference
Implement this to set the initial value of the Preference. If the restoreValue flag is true, you should restore the value from the shared preferences. If false, you should set (and possibly store to shared preferences if Preference.shouldPersist()) to defaultValue.

This may not always be called. One example is if it should not persist but there is no default value given.

Overrides:
onSetInitialValue in class Preference
Parameters:
restorePersistedValue - Whether to restore the persisted value (true), or use the given default value (false).
defaultValueObj - The default value. Only use if restoreValue is false.

onAttachedToHierarchy

protected void onAttachedToHierarchy(PreferenceManager preferenceManager)
Description copied from class: Preference
Called when this preference has been attached to a preference hierarchy. Make sure to call the super implementation.

Overrides:
onAttachedToHierarchy in class Preference
Parameters:
preferenceManager - The preference manager of the hierarchy.

onActivityResult

public boolean onActivityResult(int requestCode,
                                int resultCode,
                                Intent data)
Description copied from interface: PreferenceManager.OnActivityResultListener
See Activity's onActivityResult.

Specified by:
onActivityResult in interface PreferenceManager.OnActivityResultListener
Returns:
Whether the request code was handled (in which case subsequent listeners will not be called.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature