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

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

Issue 1256343004: [Android] Add phone progress bar animation behind a flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: telemetry_perf_unittest fix attempt #1 Created 5 years, 4 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;
(...skipping 18 matching lines...) Expand all
29 import org.chromium.chrome.browser.widget.ToolbarProgressBar; 29 import org.chromium.chrome.browser.widget.ToolbarProgressBar;
30 import org.chromium.chrome.shell.omnibox.SuggestionPopup; 30 import org.chromium.chrome.shell.omnibox.SuggestionPopup;
31 import org.chromium.content.common.ContentSwitches; 31 import org.chromium.content.common.ContentSwitches;
32 32
33 /** 33 /**
34 * A Toolbar {@link View} that shows the URL and navigation buttons. 34 * A Toolbar {@link View} that shows the URL and navigation buttons.
35 */ 35 */
36 public class ChromeShellToolbar extends LinearLayout { 36 public class ChromeShellToolbar extends LinearLayout {
37 37
38 private final Runnable mUpdateProgressRunnable = new Runnable() { 38 private final Runnable mUpdateProgressRunnable = new Runnable() {
39 private boolean mIsStarted = false;
40
39 @Override 41 @Override
40 public void run() { 42 public void run() {
41 mStopReloadButton.setImageResource( 43 mStopReloadButton.setImageResource(
42 mLoading ? R.drawable.btn_close : R.drawable.btn_toolbar_rel oad); 44 mLoading ? R.drawable.btn_close : R.drawable.btn_toolbar_rel oad);
43 45
44 // Note: We have an assertion in setProgress that checks if it's sta rted.
45 // Calling mProgressBar.start(); here is not ideal as it could be redundant.
46 // But currently we didn't hook loading start/end events in Ch rome shell and
47 // anyways we will be deleting Chrome shell soon, so will leav e as it is.
48 mProgressBar.start();
49 if (mProgress == 100.0f) { 46 if (mProgress == 100.0f) {
50 if (mProgressBar.getProgress() != 1.0f) mProgressBar.setProgress (1.0f); 47 if (mIsStarted) {
51 mProgressBar.finish(true); 48 if (mProgressBar.getProgress() != 1.0f) mProgressBar.setProg ress(1.0f);
49 mProgressBar.finish(true);
50 mIsStarted = false;
51 }
52 } else { 52 } else {
53 if (!mIsStarted) {
54 mProgressBar.start();
55 mIsStarted = true;
56 }
53 mProgressBar.setProgress(mProgress / 100.0f); 57 mProgressBar.setProgress(mProgress / 100.0f);
54 } 58 }
55 } 59 }
56 }; 60 };
57 61
58 private EditText mUrlTextView; 62 private EditText mUrlTextView;
59 private ToolbarProgressBar mProgressBar; 63 private ToolbarProgressBar mProgressBar;
60 64
61 private ChromeShellTab mTab; 65 private ChromeShellTab mTab;
62 private final TabObserver mTabObserver; 66 private final TabObserver mTabObserver;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 */ 134 */
131 public void hideSuggestions() { 135 public void hideSuggestions() {
132 if (mSuggestionPopup != null) mSuggestionPopup.hideSuggestions(); 136 if (mSuggestionPopup != null) mSuggestionPopup.hideSuggestions();
133 } 137 }
134 138
135 @Override 139 @Override
136 protected void onFinishInflate() { 140 protected void onFinishInflate() {
137 super.onFinishInflate(); 141 super.onFinishInflate();
138 142
139 mProgressBar = (ToolbarProgressBar) findViewById(R.id.progress); 143 mProgressBar = (ToolbarProgressBar) findViewById(R.id.progress);
144 mProgressBar.initializeAnimation();
140 initializeUrlField(); 145 initializeUrlField();
141 initializeTabSwitcherButton(); 146 initializeTabSwitcherButton();
142 initializeMenuButton(); 147 initializeMenuButton();
143 initializeStopReloadButton(); 148 initializeStopReloadButton();
144 initializeAddButton(); 149 initializeAddButton();
145 } 150 }
146 151
147 void setMenuHandler(AppMenuHandler menuHandler) { 152 void setMenuHandler(AppMenuHandler menuHandler) {
148 mMenuHandler = menuHandler; 153 mMenuHandler = menuHandler;
149 mAppMenuButtonHelper = new AppMenuButtonHelper(mMenuHandler); 154 mAppMenuButtonHelper = new AppMenuButtonHelper(mMenuHandler);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 public void onLoadProgressChanged(Tab tab, int progress) { 299 public void onLoadProgressChanged(Tab tab, int progress) {
295 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); 300 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess);
296 } 301 }
297 302
298 @Override 303 @Override
299 public void onUpdateUrl(Tab tab, String url) { 304 public void onUpdateUrl(Tab tab, String url) {
300 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); 305 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url);
301 } 306 }
302 } 307 }
303 } 308 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698