Merge change 25299 into eclair
* changes: Show keyboard automatically in EditTextPreference dialogs
This commit is contained in:
@@ -31,6 +31,9 @@ import android.text.TextUtils;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -297,10 +300,32 @@ public abstract class DialogPreference extends Preference implements
|
|||||||
if (state != null) {
|
if (state != null) {
|
||||||
dialog.onRestoreInstanceState(state);
|
dialog.onRestoreInstanceState(state);
|
||||||
}
|
}
|
||||||
|
if (needInputMethod()) {
|
||||||
|
requestInputMethod(dialog);
|
||||||
|
}
|
||||||
dialog.setOnDismissListener(this);
|
dialog.setOnDismissListener(this);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the preference needs to display a soft input method when the dialog
|
||||||
|
* is displayed. Default is false. Subclasses should override this method if they need
|
||||||
|
* the soft input method brought up automatically.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
protected boolean needInputMethod() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the required flags on the dialog window to enable input method window to show up.
|
||||||
|
*/
|
||||||
|
private void requestInputMethod(Dialog dialog) {
|
||||||
|
Window window = dialog.getWindow();
|
||||||
|
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE |
|
||||||
|
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the content view for the dialog (if a custom content view is
|
* Creates the content view for the dialog (if a custom content view is
|
||||||
* required). By default, it inflates the dialog layout resource if it is
|
* required). By default, it inflates the dialog layout resource if it is
|
||||||
|
|||||||
@@ -169,6 +169,13 @@ public class EditTextPreference extends DialogPreference {
|
|||||||
return mEditText;
|
return mEditText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@Override
|
||||||
|
protected boolean needInputMethod() {
|
||||||
|
// We want the input method to show, if possible, when dialog is displayed
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Parcelable onSaveInstanceState() {
|
protected Parcelable onSaveInstanceState() {
|
||||||
final Parcelable superState = super.onSaveInstanceState();
|
final Parcelable superState = super.onSaveInstanceState();
|
||||||
|
|||||||
Reference in New Issue
Block a user