OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.chrome.shell; | 5 package org.chromium.chrome.shell; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.res.Configuration; | 9 import android.content.res.Configuration; |
10 import android.graphics.drawable.ClipDrawable; | 10 import android.graphics.drawable.ClipDrawable; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 private AppMenuButtonHelper mAppMenuButtonHelper; | 69 private AppMenuButtonHelper mAppMenuButtonHelper; |
70 | 70 |
71 private TabManager mTabManager; | 71 private TabManager mTabManager; |
72 | 72 |
73 private SuggestionPopup mSuggestionPopup; | 73 private SuggestionPopup mSuggestionPopup; |
74 | 74 |
75 private ImageButton mStopReloadButton; | 75 private ImageButton mStopReloadButton; |
76 private ImageButton mAddButton; | 76 private ImageButton mAddButton; |
77 private int mProgress = 0; | 77 private int mProgress = 0; |
78 private boolean mLoading = true; | 78 private boolean mLoading = true; |
79 private boolean mHasFocus = false; | |
79 | 80 |
80 /** | 81 /** |
81 * @param context The Context the view is running in. | 82 * @param context The Context the view is running in. |
82 * @param attrs The attributes of the XML tag that is inflating the view. | 83 * @param attrs The attributes of the XML tag that is inflating the view. |
83 */ | 84 */ |
84 public ChromeShellToolbar(Context context, AttributeSet attrs) { | 85 public ChromeShellToolbar(Context context, AttributeSet attrs) { |
85 super(context, attrs); | 86 super(context, attrs); |
86 // When running performance benchmark, we don't want to observe the tab | 87 // When running performance benchmark, we don't want to observe the tab |
87 // invalidation which would interfere with browser's processing content | 88 // invalidation which would interfere with browser's processing content |
88 // frame. See crbug.com/394976. | 89 // frame. See crbug.com/394976. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 UrlUtilities.fixupUrl(mUrlTextView.getText().toString()) ); | 175 UrlUtilities.fixupUrl(mUrlTextView.getText().toString()) ); |
175 mUrlTextView.clearFocus(); | 176 mUrlTextView.clearFocus(); |
176 setKeyboardVisibilityForUrl(false); | 177 setKeyboardVisibilityForUrl(false); |
177 tab.getView().requestFocus(); | 178 tab.getView().requestFocus(); |
178 return true; | 179 return true; |
179 } | 180 } |
180 }); | 181 }); |
181 mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() { | 182 mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() { |
182 @Override | 183 @Override |
183 public void onFocusChange(View v, boolean hasFocus) { | 184 public void onFocusChange(View v, boolean hasFocus) { |
185 mHasFocus = hasFocus; | |
184 setKeyboardVisibilityForUrl(hasFocus); | 186 setKeyboardVisibilityForUrl(hasFocus); |
185 mStopReloadButton.setVisibility(hasFocus ? GONE : VISIBLE); | 187 mStopReloadButton.setVisibility(hasFocus ? GONE : VISIBLE); |
186 if (!hasFocus && mTab != null) { | 188 if (!hasFocus && mTab != null) { |
187 mUrlTextView.setText(mTab.getWebContents().getUrl()); | 189 mUrlTextView.setText(mTab.getWebContents().getUrl()); |
188 mSuggestionPopup.dismissPopup(); | 190 mSuggestionPopup.dismissPopup(); |
189 } | 191 } |
190 } | 192 } |
191 }); | 193 }); |
192 mUrlTextView.setOnKeyListener(new OnKeyListener() { | 194 mUrlTextView.setOnKeyListener(new OnKeyListener() { |
193 @Override | 195 @Override |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 }); | 261 }); |
260 } | 262 } |
261 | 263 |
262 /** | 264 /** |
263 * Shows or hides the add and the stop/reload button . | 265 * Shows or hides the add and the stop/reload button . |
264 * @param visibility The visibility status of the add button. | 266 * @param visibility The visibility status of the add button. |
265 */ | 267 */ |
266 public void showAddButton(boolean visibility) { | 268 public void showAddButton(boolean visibility) { |
267 mAddButton.setVisibility(visibility ? VISIBLE : GONE); | 269 mAddButton.setVisibility(visibility ? VISIBLE : GONE); |
268 mStopReloadButton.setVisibility(visibility ? GONE : VISIBLE); | 270 mStopReloadButton.setVisibility(visibility ? GONE : VISIBLE); |
271 if (visibility) | |
272 setKeyboardVisibilityForUrl(mHasFocus); | |
Bernhard Bauer
2014/11/13 09:35:09
I don't understand this. If |mHasFocus| is false a
divya.bansal
2014/11/13 09:49:07
@Bernhard this case is when focus is not on url fi
Bernhard Bauer
2014/11/13 10:06:30
Could we achieve this by unfocusing the text field
divya.bansal
2014/11/13 10:34:00
But if we unfocus the text field on opening the ta
Bernhard Bauer
2014/11/13 10:45:35
Okay, I see.
Could we simply hide the keyboard wh
divya.bansal
2014/11/13 11:47:51
Done.
| |
269 } | 273 } |
270 | 274 |
271 /** | 275 /** |
272 * @return Current tab that is shown by ChromeShell. | 276 * @return Current tab that is shown by ChromeShell. |
273 */ | 277 */ |
274 public ChromeShellTab getCurrentTab() { | 278 public ChromeShellTab getCurrentTab() { |
275 return mTab; | 279 return mTab; |
276 } | 280 } |
277 | 281 |
278 /** | 282 /** |
(...skipping 21 matching lines...) Expand all Loading... | |
300 public void onLoadProgressChanged(Tab tab, int progress) { | 304 public void onLoadProgressChanged(Tab tab, int progress) { |
301 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); | 305 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); |
302 } | 306 } |
303 | 307 |
304 @Override | 308 @Override |
305 public void onUpdateUrl(Tab tab, String url) { | 309 public void onUpdateUrl(Tab tab, String url) { |
306 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); | 310 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); |
307 } | 311 } |
308 } | 312 } |
309 } | 313 } |
OLD | NEW |