Fields Summary |
---|
private static final int | CM_CONFIRMsimple confirmation (OK / CANCEL) |
private static final int | CM_ACTIVATIONtoggle [(ENABLE / CANCEL) or (DISABLE / CANCEL)], use isToggled() to see requested state. |
private int | mConfirmationMode |
private static final String | VALUE_SEPARATOR |
private static final String | VALUE_OFF |
private static final String | VALUE_ON |
private android.widget.ImageButton | mContactPickButton |
private View.OnFocusChangeListener | mDialogFocusChangeListenerCalled when focus is changed between fields |
private OnDialogClosedListener | mDialogOnClosedListenerCalled when the Dialog is closed. |
private GetDefaultNumberListener | mGetDefaultNumberListenerUsed to indicate that we are going to request for a
default number. for the dialog. |
private android.app.Activity | mParentActivity |
private android.content.Intent | mContactListIntent |
private int | mPrefIdArbitrary activity-assigned preference id value |
private CharSequence | mEnableText |
private CharSequence | mDisableText |
private CharSequence | mChangeNumberText |
private CharSequence | mSummaryOn |
private CharSequence | mSummaryOff |
private int | mButtonClicked |
private String | mPhoneNumber |
private boolean | mChecked |
private String | mEncodedTextOverride persistString so that we can get a hold of the EditTextPreference's
text field. |
Methods Summary |
---|
public java.lang.String | getPhoneNumber()Phone number handling code
// return the phone number, after it has been stripped of all
// irrelevant text.
return PhoneNumberUtils.stripSeparators(mPhoneNumber);
|
protected java.lang.String | getStringValue()
return ((isToggled() ? VALUE_ON : VALUE_OFF) + VALUE_SEPARATOR + getPhoneNumber());
|
public java.lang.CharSequence | getSummaryOff()
return mSummaryOff;
|
public java.lang.CharSequence | getSummaryOn()
return mSummaryOn;
|
public boolean | isToggled()
return mChecked;
|
protected void | onAddEditTextToDialogView(android.view.View dialogView, android.widget.EditText editText)Overriding EditTextPreference's onAddEditTextToDialogView.
This method attaches the EditText to the container specific to this
preference's dialog layout.
// look for the container object
ViewGroup container = (ViewGroup) dialogView
.findViewById(R.id.edit_container);
// add the edittext to the container.
if (container != null) {
container.addView(editText, ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
}
|
protected void | onBindDialogView(android.view.View view)
// default the button clicked to be the cancel button.
mButtonClicked = DialogInterface.BUTTON2;
super.onBindDialogView(view);
//get the edittext component within the number field
EditText editText = getEditText();
//get the contact pick button within the number field
mContactPickButton = (ImageButton) view.findViewById(R.id.select_contact);
//setup number entry
if (editText != null) {
// see if there is a means to get a default number,
// and set it accordingly.
if (mGetDefaultNumberListener != null) {
String defaultNumber = mGetDefaultNumberListener.onGetDefaultNumber(this);
if (defaultNumber != null) {
mPhoneNumber = defaultNumber;
}
}
editText.setText(mPhoneNumber);
editText.setMovementMethod(ArrowKeyMovementMethod.getInstance());
editText.setKeyListener(DialerKeyListener.getInstance());
editText.setOnFocusChangeListener(mDialogFocusChangeListener);
}
//set contact picker
if (mContactPickButton != null) {
mContactPickButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mParentActivity != null) {
mParentActivity.startActivityForResult(mContactListIntent, mPrefId);
}
}
});
}
|
protected void | onBindView(android.view.View view)
super.onBindView(view);
// Sync the summary view
TextView summaryView = (TextView) view.findViewById(android.R.id.summary);
if (summaryView != null) {
CharSequence sum;
int vis;
//set summary depending upon mode
if (mConfirmationMode == CM_ACTIVATION) {
if (mChecked) {
sum = (mSummaryOn == null) ? getSummary() : mSummaryOn;
} else {
sum = (mSummaryOff == null) ? getSummary() : mSummaryOff;
}
} else {
sum = getSummary();
}
if (sum != null) {
summaryView.setText(sum);
vis = View.VISIBLE;
} else {
vis = View.GONE;
}
if (vis != summaryView.getVisibility()) {
summaryView.setVisibility(vis);
}
}
|
public void | onClick(android.content.DialogInterface dialog, int which)
// The neutral button (button3) is always the toggle.
if ((mConfirmationMode == CM_ACTIVATION) && (which == DialogInterface.BUTTON3)) {
//flip the toggle if we are in the correct mode.
setToggled(!isToggled());
}
// record the button that was clicked.
mButtonClicked = which;
super.onClick(dialog, which);
|
protected void | onDialogClosed(boolean positiveResult)
// A positive result is technically either button1 or button3.
if ((mButtonClicked == DialogInterface.BUTTON1) ||
(mButtonClicked == DialogInterface.BUTTON3)){
setPhoneNumber(getEditText().getText().toString());
super.onDialogClosed(positiveResult);
setText(getStringValue());
} else {
super.onDialogClosed(positiveResult);
}
// send the clicked button over to the listener.
if (mDialogOnClosedListener != null) {
mDialogOnClosedListener.onDialogClosed(this, mButtonClicked);
}
|
public void | onPickActivityResult(java.lang.String pickedValue)
EditText editText = getEditText();
if (editText != null) {
editText.setText(pickedValue);
}
|
protected void | onPrepareDialogBuilder(AlertDialog.Builder builder)
// modified so that we just worry about the buttons being
// displayed, since there is no need to hide the edittext
// field anymore.
if (mConfirmationMode == CM_ACTIVATION) {
if (mChecked) {
builder.setPositiveButton(mChangeNumberText, this);
builder.setNeutralButton(mDisableText, this);
} else {
builder.setPositiveButton(null, null);
builder.setNeutralButton(mEnableText, this);
}
}
// set the call icon on the title.
builder.setIcon(R.drawable.ic_dialog_call);
|
protected void | onSetInitialValue(boolean restoreValue, java.lang.Object defaultValue)
setValueFromString(restoreValue ? getPersistedString(getStringValue())
: (String) defaultValue);
|
protected boolean | persistString(java.lang.String value)
mEncodedText = value;
return super.persistString(value);
|
public void | setDialogOnClosedListener(com.android.phone.EditPhoneNumberPreference$OnDialogClosedListener l)
mDialogOnClosedListener = l;
|
public void | setDialogOnFocusChangeListener(View.OnFocusChangeListener l)
mDialogFocusChangeListener = l;
|
public void | setParentActivity(android.app.Activity parent, int identifier, com.android.phone.EditPhoneNumberPreference$GetDefaultNumberListener l)
mParentActivity = parent;
mPrefId = identifier;
mGetDefaultNumberListener = l;
|
public void | setParentActivity(android.app.Activity parent, int identifier)
mParentActivity = parent;
mPrefId = identifier;
mGetDefaultNumberListener = null;
|
public com.android.phone.EditPhoneNumberPreference | setPhoneNumber(java.lang.String number)
mPhoneNumber = number;
setText(getStringValue());
notifyChanged();
return this;
|
public com.android.phone.EditPhoneNumberPreference | setSummaryOff(java.lang.CharSequence summary)
mSummaryOff = summary;
if (!isToggled()) {
notifyChanged();
}
return this;
|
public com.android.phone.EditPhoneNumberPreference | setSummaryOff(int summaryResId)
return setSummaryOff(getContext().getString(summaryResId));
|
public com.android.phone.EditPhoneNumberPreference | setSummaryOn(java.lang.CharSequence summary)
mSummaryOn = summary;
if (isToggled()) {
notifyChanged();
}
return this;
|
public com.android.phone.EditPhoneNumberPreference | setSummaryOn(int summaryResId)
return setSummaryOn(getContext().getString(summaryResId));
|
public com.android.phone.EditPhoneNumberPreference | setToggled(boolean checked)
mChecked = checked;
setText(getStringValue());
notifyChanged();
return this;
|
protected void | setValueFromString(java.lang.String value)
String[] inValues = value.split(":", 2);
setToggled(inValues[0].equals(VALUE_ON));
setPhoneNumber(inValues[1]);
|
public boolean | shouldDisableDependents()Decides how to disable dependents.
// There is really only one case we care about, but for consistency
// we fill out the dependency tree for all of the cases. If this
// is in activation mode (CF), we look for the encoded toggle value
// in the string. If this in confirm mode (VM), then we just
// examine the number field.
// Note: The toggle value is stored in the string in an encoded
// manner (refer to setValueFromString and getStringValue below).
boolean shouldDisable = false;
if ((mConfirmationMode == CM_ACTIVATION) && (mEncodedText != null)) {
String[] inValues = mEncodedText.split(":", 2);
shouldDisable = inValues[0].equals(VALUE_ON);
} else {
shouldDisable = (TextUtils.isEmpty(mPhoneNumber) && (mConfirmationMode == CM_CONFIRM));
}
return shouldDisable;
|
public void | showPhoneNumberDialog()Externally visible method to bring up the dialog.
Generally used when we are navigating the user to this preference.
showDialog(null);
|