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.util.AttributeSet; | 10 import android.util.AttributeSet; |
(...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 mFocus = 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 mUrlTextView.clearFocus(); | 172 mUrlTextView.clearFocus(); |
172 setKeyboardVisibilityForUrl(false); | 173 setKeyboardVisibilityForUrl(false); |
173 tab.getView().requestFocus(); | 174 tab.getView().requestFocus(); |
174 return true; | 175 return true; |
175 } | 176 } |
176 }); | 177 }); |
177 mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() { | 178 mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() { |
178 @Override | 179 @Override |
179 public void onFocusChange(View v, boolean hasFocus) { | 180 public void onFocusChange(View v, boolean hasFocus) { |
180 setKeyboardVisibilityForUrl(hasFocus); | 181 setKeyboardVisibilityForUrl(hasFocus); |
181 mStopReloadButton.setVisibility(hasFocus ? GONE : VISIBLE); | 182 mFocus = hasFocus; |
183 updateStopReloadButtonState(hasFocus); | |
182 if (!hasFocus && mTab != null) { | 184 if (!hasFocus && mTab != null) { |
183 mUrlTextView.setText(mTab.getWebContents().getUrl()); | 185 mUrlTextView.setText(mTab.getWebContents().getUrl()); |
184 mSuggestionPopup.dismissPopup(); | 186 mSuggestionPopup.dismissPopup(); |
185 } | 187 } |
186 } | 188 } |
187 }); | 189 }); |
188 mUrlTextView.setOnKeyListener(new OnKeyListener() { | 190 mUrlTextView.setOnKeyListener(new OnKeyListener() { |
189 @Override | 191 @Override |
190 public boolean onKey(View v, int keyCode, KeyEvent event) { | 192 public boolean onKey(View v, int keyCode, KeyEvent event) { |
191 if (keyCode == KeyEvent.KEYCODE_BACK) { | 193 if (keyCode == KeyEvent.KEYCODE_BACK) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 mAddButton = (ImageButton) findViewById(R.id.add_button); | 251 mAddButton = (ImageButton) findViewById(R.id.add_button); |
250 mAddButton.setOnClickListener(new OnClickListener() { | 252 mAddButton.setOnClickListener(new OnClickListener() { |
251 @Override | 253 @Override |
252 public void onClick(View v) { | 254 public void onClick(View v) { |
253 mTabManager.createNewTab(); | 255 mTabManager.createNewTab(); |
254 } | 256 } |
255 }); | 257 }); |
256 } | 258 } |
257 | 259 |
258 /** | 260 /** |
259 * Shows or hides the add and the stop/reload button . | 261 * Shows or hides the add button . |
260 * @param visibility The visibility status of the add button. | 262 * @param visibility The visibility status of the add button. |
261 */ | 263 */ |
262 public void showAddButton(boolean visibility) { | 264 public void showAddButton(boolean visibility) { |
263 mAddButton.setVisibility(visibility ? VISIBLE : GONE); | 265 mAddButton.setVisibility(visibility ? VISIBLE : GONE); |
264 mStopReloadButton.setVisibility(visibility ? GONE : VISIBLE); | 266 updateStopReloadButtonState(visibility); |
265 } | 267 } |
266 | 268 |
267 /** | 269 /** |
270 * Shows or hides the stop/reload button . | |
271 * @param visibility The visibility status of the stop/reload button. | |
Bernhard Bauer
2015/02/12 09:55:09
This parameter doesn't really control the visibili
| |
272 */ | |
273 public void updateStopReloadButtonState(boolean visibility) { | |
274 mStopReloadButton.setVisibility(mFocus || visibility ? GONE : VISIBLE); | |
275 } | |
276 | |
277 /** | |
268 * @return Current tab that is shown by ChromeShell. | 278 * @return Current tab that is shown by ChromeShell. |
269 */ | 279 */ |
270 public ChromeShellTab getCurrentTab() { | 280 public ChromeShellTab getCurrentTab() { |
271 return mTab; | 281 return mTab; |
272 } | 282 } |
273 | 283 |
274 /** | 284 /** |
275 * Change the visibility of the software keyboard. | 285 * Change the visibility of the software keyboard. |
276 * @param visible Whether the keyboard should be shown or hidden. | 286 * @param visible Whether the keyboard should be shown or hidden. |
277 */ | 287 */ |
(...skipping 18 matching lines...) Expand all Loading... | |
296 public void onLoadProgressChanged(Tab tab, int progress) { | 306 public void onLoadProgressChanged(Tab tab, int progress) { |
297 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); | 307 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); |
298 } | 308 } |
299 | 309 |
300 @Override | 310 @Override |
301 public void onUpdateUrl(Tab tab, String url) { | 311 public void onUpdateUrl(Tab tab, String url) { |
302 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); | 312 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); |
303 } | 313 } |
304 } | 314 } |
305 } | 315 } |
OLD | NEW |