Loading src/com/android/contacts/editor/LabeledEditorView.java +14 −0 Original line number Diff line number Diff line Loading @@ -29,10 +29,12 @@ import android.text.TextWatcher; import android.util.AttributeSet; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; Loading Loading @@ -137,6 +139,18 @@ public abstract class LabeledEditorView extends LinearLayout implements Editor, // Turn off the Spinner's own state management. We do this ourselves on rotation mLabel.setId(View.NO_ID); mLabel.setOnItemSelectedListener(mSpinnerListener); mLabel.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (v == mLabel) { final InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow( mLabel.getWindowToken(), /* flags */ 0); } return false; } }); mDelete = (ImageView) findViewById(R.id.delete_button); mDeleteContainer = findViewById(R.id.delete_button_container); Loading src/com/android/contacts/editor/TextFieldsEditorView.java +15 −7 Original line number Diff line number Diff line Loading @@ -123,13 +123,7 @@ public class TextFieldsEditorView extends LabeledEditorView { final View editor = mFields.getChildAt(0); // Show the soft-keyboard. InputMethodManager imm = (InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { if (!imm.showSoftInput(editor, InputMethodManager.SHOW_IMPLICIT)) { Log.w(TAG, "Failed to show soft input method."); } } showSoftKeyboard(editor); } @Override Loading Loading @@ -178,12 +172,26 @@ public class TextFieldsEditorView extends LabeledEditorView { } if (editText.hasFocus()) { anyFieldHasFocus = true; showSoftKeyboard(editText); break; } } if (!anyFieldHasFocus && firstField != null) { firstField.requestFocus(); showSoftKeyboard(firstField); } } } /** * Show soft keyboard for the currently focused view. */ private void showSoftKeyboard(View v) { final InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); if (inputMethodManager != null && !inputMethodManager.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT)) { Log.w(TAG, "Failed to show soft input method."); } } Loading Loading
src/com/android/contacts/editor/LabeledEditorView.java +14 −0 Original line number Diff line number Diff line Loading @@ -29,10 +29,12 @@ import android.text.TextWatcher; import android.util.AttributeSet; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; Loading Loading @@ -137,6 +139,18 @@ public abstract class LabeledEditorView extends LinearLayout implements Editor, // Turn off the Spinner's own state management. We do this ourselves on rotation mLabel.setId(View.NO_ID); mLabel.setOnItemSelectedListener(mSpinnerListener); mLabel.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (v == mLabel) { final InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow( mLabel.getWindowToken(), /* flags */ 0); } return false; } }); mDelete = (ImageView) findViewById(R.id.delete_button); mDeleteContainer = findViewById(R.id.delete_button_container); Loading
src/com/android/contacts/editor/TextFieldsEditorView.java +15 −7 Original line number Diff line number Diff line Loading @@ -123,13 +123,7 @@ public class TextFieldsEditorView extends LabeledEditorView { final View editor = mFields.getChildAt(0); // Show the soft-keyboard. InputMethodManager imm = (InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { if (!imm.showSoftInput(editor, InputMethodManager.SHOW_IMPLICIT)) { Log.w(TAG, "Failed to show soft input method."); } } showSoftKeyboard(editor); } @Override Loading Loading @@ -178,12 +172,26 @@ public class TextFieldsEditorView extends LabeledEditorView { } if (editText.hasFocus()) { anyFieldHasFocus = true; showSoftKeyboard(editText); break; } } if (!anyFieldHasFocus && firstField != null) { firstField.requestFocus(); showSoftKeyboard(firstField); } } } /** * Show soft keyboard for the currently focused view. */ private void showSoftKeyboard(View v) { final InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); if (inputMethodManager != null && !inputMethodManager.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT)) { Log.w(TAG, "Failed to show soft input method."); } } Loading