Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellToolbar.java

Issue 994753002: Revert of [Andorid] ClipDrawable progress bar experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add progress_bar.xml back which was removed in https://codereview.chromium.org/971223004 Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
11 import android.view.KeyEvent; 11 import android.view.KeyEvent;
12 import android.view.MotionEvent; 12 import android.view.MotionEvent;
13 import android.view.View; 13 import android.view.View;
14 import android.view.inputmethod.EditorInfo; 14 import android.view.inputmethod.EditorInfo;
15 import android.view.inputmethod.InputMethodManager; 15 import android.view.inputmethod.InputMethodManager;
16 import android.widget.EditText; 16 import android.widget.EditText;
17 import android.widget.ImageButton; 17 import android.widget.ImageButton;
18 import android.widget.LinearLayout; 18 import android.widget.LinearLayout;
19 import android.widget.TextView; 19 import android.widget.TextView;
20 import android.widget.TextView.OnEditorActionListener; 20 import android.widget.TextView.OnEditorActionListener;
21 21
22 import org.chromium.base.ApiCompatibilityUtils; 22 import org.chromium.base.ApiCompatibilityUtils;
23 import org.chromium.base.CommandLine; 23 import org.chromium.base.CommandLine;
24 import org.chromium.chrome.browser.EmptyTabObserver; 24 import org.chromium.chrome.browser.EmptyTabObserver;
25 import org.chromium.chrome.browser.Tab; 25 import org.chromium.chrome.browser.Tab;
26 import org.chromium.chrome.browser.TabObserver; 26 import org.chromium.chrome.browser.TabObserver;
27 import org.chromium.chrome.browser.UrlUtilities; 27 import org.chromium.chrome.browser.UrlUtilities;
28 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; 28 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
29 import org.chromium.chrome.browser.appmenu.AppMenuHandler; 29 import org.chromium.chrome.browser.appmenu.AppMenuHandler;
30 import org.chromium.chrome.browser.widget.ClipDrawableProgressBar; 30 import org.chromium.chrome.browser.widget.SmoothProgressBar;
31 import org.chromium.chrome.shell.omnibox.SuggestionPopup; 31 import org.chromium.chrome.shell.omnibox.SuggestionPopup;
32 import org.chromium.content.common.ContentSwitches; 32 import org.chromium.content.common.ContentSwitches;
33 33
34 /** 34 /**
35 * A Toolbar {@link View} that shows the URL and navigation buttons. 35 * A Toolbar {@link View} that shows the URL and navigation buttons.
36 */ 36 */
37 public class ChromeShellToolbar extends LinearLayout { 37 public class ChromeShellToolbar extends LinearLayout {
38 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200;
39
40 private final Runnable mClearProgressRunnable = new Runnable() {
41 @Override
42 public void run() {
43 mProgressBar.setProgress(0);
44 }
45 };
38 46
39 private final Runnable mUpdateProgressRunnable = new Runnable() { 47 private final Runnable mUpdateProgressRunnable = new Runnable() {
40 @Override 48 @Override
41 public void run() { 49 public void run() {
42 mProgressBar.setProgress(100 * mProgress); 50 mProgressBar.setProgress(mProgress);
43 if (mLoading) { 51 if (mLoading) {
44 mStopReloadButton.setImageResource( 52 mStopReloadButton.setImageResource(
45 R.drawable.btn_close); 53 R.drawable.btn_close);
46 } else { 54 } else {
47 mStopReloadButton.setImageResource(R.drawable.btn_toolbar_reload ); 55 mStopReloadButton.setImageResource(R.drawable.btn_toolbar_reload );
56 ApiCompatibilityUtils.postOnAnimationDelayed(ChromeShellToolbar. this,
57 mClearProgressRunnable, COMPLETED_PROGRESS_TIMEOUT_MS);
48 } 58 }
49 } 59 }
50 }; 60 };
51 61
52 private EditText mUrlTextView; 62 private EditText mUrlTextView;
53 private ClipDrawableProgressBar mProgressBar; 63 private SmoothProgressBar mProgressBar;
54 64
55 private ChromeShellTab mTab; 65 private ChromeShellTab mTab;
56 private final TabObserver mTabObserver; 66 private final TabObserver mTabObserver;
57 67
58 private AppMenuHandler mMenuHandler; 68 private AppMenuHandler mMenuHandler;
59 private AppMenuButtonHelper mAppMenuButtonHelper; 69 private AppMenuButtonHelper mAppMenuButtonHelper;
60 70
61 private TabManager mTabManager; 71 private TabManager mTabManager;
62 72
63 private SuggestionPopup mSuggestionPopup; 73 private SuggestionPopup mSuggestionPopup;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 */ 116 */
107 public void setTabManager(TabManager tabManager) { 117 public void setTabManager(TabManager tabManager) {
108 mTabManager = tabManager; 118 mTabManager = tabManager;
109 } 119 }
110 120
111 private void onUpdateUrl(String url) { 121 private void onUpdateUrl(String url) {
112 mUrlTextView.setText(url); 122 mUrlTextView.setText(url);
113 } 123 }
114 124
115 private void onLoadProgressChanged(int progress) { 125 private void onLoadProgressChanged(int progress) {
126 removeCallbacks(mClearProgressRunnable);
116 removeCallbacks(mUpdateProgressRunnable); 127 removeCallbacks(mUpdateProgressRunnable);
117 mProgress = progress; 128 mProgress = progress;
118 mLoading = progress != 100; 129 mLoading = progress != 100;
119 ApiCompatibilityUtils.postOnAnimation(this, mUpdateProgressRunnable); 130 ApiCompatibilityUtils.postOnAnimation(this, mUpdateProgressRunnable);
120 } 131 }
121 132
122 /** 133 /**
123 * Closes the suggestion popup. 134 * Closes the suggestion popup.
124 */ 135 */
125 public void hideSuggestions() { 136 public void hideSuggestions() {
126 if (mSuggestionPopup != null) mSuggestionPopup.hideSuggestions(); 137 if (mSuggestionPopup != null) mSuggestionPopup.hideSuggestions();
127 } 138 }
128 139
129 @Override 140 @Override
130 protected void onFinishInflate() { 141 protected void onFinishInflate() {
131 super.onFinishInflate(); 142 super.onFinishInflate();
132 143
133 mProgressBar = (ClipDrawableProgressBar) findViewById(R.id.progress); 144 mProgressBar = (SmoothProgressBar) findViewById(R.id.progress);
134 initializeUrlField(); 145 initializeUrlField();
135 initializeTabSwitcherButton(); 146 initializeTabSwitcherButton();
136 initializeMenuButton(); 147 initializeMenuButton();
137 initializeStopReloadButton(); 148 initializeStopReloadButton();
138 initializeAddButton(); 149 initializeAddButton();
139 } 150 }
140 151
141 void setMenuHandler(AppMenuHandler menuHandler) { 152 void setMenuHandler(AppMenuHandler menuHandler) {
142 mMenuHandler = menuHandler; 153 mMenuHandler = menuHandler;
143 mAppMenuButtonHelper = new AppMenuButtonHelper(mMenuHandler); 154 mAppMenuButtonHelper = new AppMenuButtonHelper(mMenuHandler);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 public void onLoadProgressChanged(Tab tab, int progress) { 299 public void onLoadProgressChanged(Tab tab, int progress) {
289 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); 300 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess);
290 } 301 }
291 302
292 @Override 303 @Override
293 public void onUpdateUrl(Tab tab, String url) { 304 public void onUpdateUrl(Tab tab, String url) {
294 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); 305 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url);
295 } 306 }
296 } 307 }
297 } 308 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698