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

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

Issue 583673002: [Android] Invalidate ChromeShell progress bar during animation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Line break cleanup Created 6 years, 3 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
« no previous file with comments | « base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.content.Context; 7 import android.content.Context;
8 import android.content.res.Configuration; 8 import android.content.res.Configuration;
9 import android.graphics.drawable.ClipDrawable; 9 import android.graphics.drawable.ClipDrawable;
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.CommandLine; 23 import org.chromium.base.CommandLine;
23 import org.chromium.chrome.browser.EmptyTabObserver; 24 import org.chromium.chrome.browser.EmptyTabObserver;
24 import org.chromium.chrome.browser.Tab; 25 import org.chromium.chrome.browser.Tab;
25 import org.chromium.chrome.browser.TabObserver; 26 import org.chromium.chrome.browser.TabObserver;
26 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; 27 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
27 import org.chromium.chrome.browser.appmenu.AppMenuHandler; 28 import org.chromium.chrome.browser.appmenu.AppMenuHandler;
28 import org.chromium.chrome.shell.omnibox.SuggestionPopup; 29 import org.chromium.chrome.shell.omnibox.SuggestionPopup;
29 import org.chromium.content.common.ContentSwitches; 30 import org.chromium.content.common.ContentSwitches;
30 31
31 /** 32 /**
32 * A Toolbar {@link View} that shows the URL and navigation buttons. 33 * A Toolbar {@link View} that shows the URL and navigation buttons.
33 */ 34 */
34 public class ChromeShellToolbar extends LinearLayout { 35 public class ChromeShellToolbar extends LinearLayout {
35 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; 36 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200;
36 37
37 private final Runnable mClearProgressRunnable = new Runnable() { 38 private final Runnable mClearProgressRunnable = new Runnable() {
38 @Override 39 @Override
39 public void run() { 40 public void run() {
40 mProgressDrawable.setLevel(0); 41 mProgressDrawable.setLevel(0);
41 } 42 }
42 }; 43 };
43 44
45 private final Runnable mUpdateProgressRunnable = new Runnable() {
46 @Override
47 public void run() {
48 mProgressDrawable.setLevel(100 * mProgress);
49 if (mLoading) {
50 mStopReloadButton.setImageResource(R.drawable.btn_stop_normal);
51 } else {
52 mStopReloadButton.setImageResource(R.drawable.btn_reload_normal) ;
53 ApiCompatibilityUtils.postOnAnimationDelayed(ChromeShellToolbar. this,
54 mClearProgressRunnable, COMPLETED_PROGRESS_TIMEOUT_MS);
55 }
56 }
57 };
58
44 private EditText mUrlTextView; 59 private EditText mUrlTextView;
45 private ClipDrawable mProgressDrawable; 60 private ClipDrawable mProgressDrawable;
46 61
47 private ChromeShellTab mTab; 62 private ChromeShellTab mTab;
48 private final TabObserver mTabObserver; 63 private final TabObserver mTabObserver;
49 64
50 private AppMenuHandler mMenuHandler; 65 private AppMenuHandler mMenuHandler;
51 private AppMenuButtonHelper mAppMenuButtonHelper; 66 private AppMenuButtonHelper mAppMenuButtonHelper;
52 67
53 private SuggestionPopup mSuggestionPopup; 68 private SuggestionPopup mSuggestionPopup;
54 69
55 private ImageButton mStopReloadButton; 70 private ImageButton mStopReloadButton;
71 private int mProgress = 0;
56 private boolean mLoading = true; 72 private boolean mLoading = true;
57 73
58 /** 74 /**
59 * @param context The Context the view is running in. 75 * @param context The Context the view is running in.
60 * @param attrs The attributes of the XML tag that is inflating the view. 76 * @param attrs The attributes of the XML tag that is inflating the view.
61 */ 77 */
62 public ChromeShellToolbar(Context context, AttributeSet attrs) { 78 public ChromeShellToolbar(Context context, AttributeSet attrs) {
63 super(context, attrs); 79 super(context, attrs);
64 // When running performance benchmark, we don't want to observe the tab 80 // When running performance benchmark, we don't want to observe the tab
65 // invalidation which would interfere with browser's processing content 81 // invalidation which would interfere with browser's processing content
(...skipping 15 matching lines...) Expand all
81 mTab = tab; 97 mTab = tab;
82 mTab.addObserver(mTabObserver); 98 mTab.addObserver(mTabObserver);
83 mUrlTextView.setText(mTab.getWebContents().getUrl()); 99 mUrlTextView.setText(mTab.getWebContents().getUrl());
84 } 100 }
85 101
86 private void onUpdateUrl(String url) { 102 private void onUpdateUrl(String url) {
87 mUrlTextView.setText(url); 103 mUrlTextView.setText(url);
88 } 104 }
89 105
90 private void onLoadProgressChanged(int progress) { 106 private void onLoadProgressChanged(int progress) {
91 removeCallbacks(mClearProgressRunnable); 107 removeCallbacks(mClearProgressRunnable);
nyquist 2014/09/18 21:43:23 Should this stay here or move to the other update
jdduke (slow) 2014/09/18 21:59:22 I think it can go there, but then we might have a
92 mProgressDrawable.setLevel(100 * progress); 108 removeCallbacks(mUpdateProgressRunnable);
109 mProgress = progress;
93 mLoading = progress != 100; 110 mLoading = progress != 100;
94 if (mLoading) { 111 ApiCompatibilityUtils.postOnAnimation(this, mUpdateProgressRunnable);
95 mStopReloadButton.setImageResource(R.drawable.btn_stop_normal);
96 } else {
97 mStopReloadButton.setImageResource(R.drawable.btn_reload_normal);
98 postDelayed(mClearProgressRunnable, COMPLETED_PROGRESS_TIMEOUT_MS);
99 }
100 } 112 }
101 113
102 /** 114 /**
103 * Closes the suggestion popup. 115 * Closes the suggestion popup.
104 */ 116 */
105 public void hideSuggestions() { 117 public void hideSuggestions() {
106 if (mSuggestionPopup != null) mSuggestionPopup.hideSuggestions(); 118 if (mSuggestionPopup != null) mSuggestionPopup.hideSuggestions();
107 } 119 }
108 120
109 @Override 121 @Override
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 public void onLoadProgressChanged(Tab tab, int progress) { 242 public void onLoadProgressChanged(Tab tab, int progress) {
231 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); 243 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess);
232 } 244 }
233 245
234 @Override 246 @Override
235 public void onUpdateUrl(Tab tab, String url) { 247 public void onUpdateUrl(Tab tab, String url) {
236 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); 248 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url);
237 } 249 }
238 } 250 }
239 } 251 }
OLDNEW
« no previous file with comments | « base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698