| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 setKeyboardVisibilityForUrl(false); | 173 setKeyboardVisibilityForUrl(false); |
| 174 tab.getView().requestFocus(); | 174 tab.getView().requestFocus(); |
| 175 return true; | 175 return true; |
| 176 } | 176 } |
| 177 }); | 177 }); |
| 178 mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() { | 178 mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() { |
| 179 @Override | 179 @Override |
| 180 public void onFocusChange(View v, boolean hasFocus) { | 180 public void onFocusChange(View v, boolean hasFocus) { |
| 181 setKeyboardVisibilityForUrl(hasFocus); | 181 setKeyboardVisibilityForUrl(hasFocus); |
| 182 mFocus = hasFocus; | 182 mFocus = hasFocus; |
| 183 updateToolBarButtonState(); | 183 updateToolbarState(); |
| 184 if (!hasFocus && mTab != null) { | 184 if (!hasFocus && mTab != null) { |
| 185 mUrlTextView.setText(mTab.getWebContents().getUrl()); | 185 mUrlTextView.setText(mTab.getWebContents().getUrl()); |
| 186 mSuggestionPopup.dismissPopup(); | 186 mSuggestionPopup.dismissPopup(); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 }); | 189 }); |
| 190 mUrlTextView.setOnKeyListener(new OnKeyListener() { | 190 mUrlTextView.setOnKeyListener(new OnKeyListener() { |
| 191 @Override | 191 @Override |
| 192 public boolean onKey(View v, int keyCode, KeyEvent event) { | 192 public boolean onKey(View v, int keyCode, KeyEvent event) { |
| 193 if (keyCode == KeyEvent.KEYCODE_BACK) { | 193 if (keyCode == KeyEvent.KEYCODE_BACK) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 mAddButton = (ImageButton) findViewById(R.id.add_button); | 251 mAddButton = (ImageButton) findViewById(R.id.add_button); |
| 252 mAddButton.setOnClickListener(new OnClickListener() { | 252 mAddButton.setOnClickListener(new OnClickListener() { |
| 253 @Override | 253 @Override |
| 254 public void onClick(View v) { | 254 public void onClick(View v) { |
| 255 mTabManager.createNewTab(); | 255 mTabManager.createNewTab(); |
| 256 } | 256 } |
| 257 }); | 257 }); |
| 258 } | 258 } |
| 259 | 259 |
| 260 /** | 260 /** |
| 261 * Shows or hides the add and the stop/reload button. | 261 * Shows or hides the add button, the stop/reload button and the URL bar. |
| 262 */ | 262 */ |
| 263 public void updateToolBarButtonState() { | 263 public void updateToolbarState() { |
| 264 boolean tabSwitcherState = mTabManager.isTabSwitcherVisible(); | 264 boolean tabSwitcherState = mTabManager.isTabSwitcherVisible(); |
| 265 mAddButton.setVisibility(tabSwitcherState ? VISIBLE : GONE); | 265 mAddButton.setVisibility(tabSwitcherState ? VISIBLE : GONE); |
| 266 mStopReloadButton.setVisibility(tabSwitcherState || mFocus ? GONE : VISI
BLE); | 266 mStopReloadButton.setVisibility(tabSwitcherState || mFocus ? GONE : VISI
BLE); |
| 267 mUrlTextView.setVisibility(tabSwitcherState ? INVISIBLE : VISIBLE); |
| 267 } | 268 } |
| 268 | 269 |
| 269 /** | 270 /** |
| 270 * @return Current tab that is shown by ChromeShell. | 271 * @return Current tab that is shown by ChromeShell. |
| 271 */ | 272 */ |
| 272 public ChromeShellTab getCurrentTab() { | 273 public ChromeShellTab getCurrentTab() { |
| 273 return mTab; | 274 return mTab; |
| 274 } | 275 } |
| 275 | 276 |
| 276 /** | 277 /** |
| (...skipping 21 matching lines...) Expand all Loading... |
| 298 public void onLoadProgressChanged(Tab tab, int progress) { | 299 public void onLoadProgressChanged(Tab tab, int progress) { |
| 299 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr
ess); | 300 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr
ess); |
| 300 } | 301 } |
| 301 | 302 |
| 302 @Override | 303 @Override |
| 303 public void onUpdateUrl(Tab tab, String url) { | 304 public void onUpdateUrl(Tab tab, String url) { |
| 304 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); | 305 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); |
| 305 } | 306 } |
| 306 } | 307 } |
| 307 } | 308 } |
| OLD | NEW |