OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content_shell; | 5 package org.chromium.content_shell; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.graphics.drawable.ClipDrawable; | 8 import android.graphics.drawable.ClipDrawable; |
9 import android.text.TextUtils; | 9 import android.text.TextUtils; |
10 import android.util.AttributeSet; | 10 import android.util.AttributeSet; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 initializeNavigationButtons(); | 102 initializeNavigationButtons(); |
103 } | 103 } |
104 | 104 |
105 private void initializeUrlField() { | 105 private void initializeUrlField() { |
106 mUrlTextView = (EditText) findViewById(R.id.url); | 106 mUrlTextView = (EditText) findViewById(R.id.url); |
107 mUrlTextView.setOnEditorActionListener(new OnEditorActionListener() { | 107 mUrlTextView.setOnEditorActionListener(new OnEditorActionListener() { |
108 @Override | 108 @Override |
109 public boolean onEditorAction(TextView v, int actionId, KeyEvent eve
nt) { | 109 public boolean onEditorAction(TextView v, int actionId, KeyEvent eve
nt) { |
110 if ((actionId != EditorInfo.IME_ACTION_GO) && (event == null || | 110 if ((actionId != EditorInfo.IME_ACTION_GO) && (event == null || |
111 event.getKeyCode() != KeyEvent.KEYCODE_ENTER || | 111 event.getKeyCode() != KeyEvent.KEYCODE_ENTER || |
112 event.getAction() != KeyEvent.ACTION_UP)) { | 112 event.getAction() != KeyEvent.ACTION_DOWN)) { |
113 return false; | 113 return false; |
114 } | 114 } |
115 loadUrl(mUrlTextView.getText().toString()); | 115 loadUrl(mUrlTextView.getText().toString()); |
116 setKeyboardVisibilityForUrl(false); | 116 setKeyboardVisibilityForUrl(false); |
117 mContentView.requestFocus(); | 117 mContentView.requestFocus(); |
118 return true; | 118 return true; |
119 } | 119 } |
120 }); | 120 }); |
121 mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() { | 121 mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() { |
122 @Override | 122 @Override |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 private void setKeyboardVisibilityForUrl(boolean visible) { | 234 private void setKeyboardVisibilityForUrl(boolean visible) { |
235 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( | 235 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( |
236 Context.INPUT_METHOD_SERVICE); | 236 Context.INPUT_METHOD_SERVICE); |
237 if (visible) { | 237 if (visible) { |
238 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 238 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
239 } else { | 239 } else { |
240 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 240 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
241 } | 241 } |
242 } | 242 } |
243 } | 243 } |
OLD | NEW |