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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java

Issue 1249793003: Revert of [Andorid] Migrate to ClipDrawable progress bar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.browser.toolbar; 5 package org.chromium.chrome.browser.toolbar;
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.graphics.Canvas; 9 import android.graphics.Canvas;
10 import android.graphics.Rect; 10 import android.graphics.Rect;
11 import android.graphics.drawable.Drawable; 11 import android.graphics.drawable.Drawable;
12 import android.os.SystemClock; 12 import android.os.SystemClock;
13 import android.util.AttributeSet; 13 import android.util.AttributeSet;
14 import android.view.Gravity; 14 import android.view.Gravity;
15 import android.view.MotionEvent; 15 import android.view.MotionEvent;
16 import android.view.View; 16 import android.view.View;
17 import android.view.ViewGroup; 17 import android.view.ViewGroup;
18 import android.widget.FrameLayout; 18 import android.widget.FrameLayout;
19 import android.widget.ProgressBar; 19 import android.widget.ProgressBar;
20 import android.widget.Toast; 20 import android.widget.Toast;
21 21
22 import org.chromium.chrome.R; 22 import org.chromium.chrome.R;
23 import org.chromium.chrome.browser.Tab; 23 import org.chromium.chrome.browser.Tab;
24 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; 24 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
25 import org.chromium.chrome.browser.compositor.Invalidator; 25 import org.chromium.chrome.browser.compositor.Invalidator;
26 import org.chromium.chrome.browser.ntp.NewTabPage; 26 import org.chromium.chrome.browser.ntp.NewTabPage;
27 import org.chromium.chrome.browser.omnibox.LocationBar; 27 import org.chromium.chrome.browser.omnibox.LocationBar;
28 import org.chromium.chrome.browser.util.ViewUtils; 28 import org.chromium.chrome.browser.util.ViewUtils;
29 import org.chromium.chrome.browser.widget.SmoothProgressBar;
29 import org.chromium.chrome.browser.widget.TintedImageButton; 30 import org.chromium.chrome.browser.widget.TintedImageButton;
30 import org.chromium.chrome.browser.widget.ToolbarProgressBar;
31 import org.chromium.ui.UiUtils; 31 import org.chromium.ui.UiUtils;
32 32
33 /** 33 /**
34 * Layout class that contains the base shared logic for manipulating the toolbar component. For 34 * Layout class that contains the base shared logic for manipulating the toolbar component. For
35 * interaction that are not from Views inside Toolbar hierarchy all interactions should be done 35 * interaction that are not from Views inside Toolbar hierarchy all interactions should be done
36 * through {@link Toolbar} rather than using this class directly. 36 * through {@link Toolbar} rather than using this class directly.
37 */ 37 */
38 abstract class ToolbarLayout extends FrameLayout implements Toolbar { 38 abstract class ToolbarLayout extends FrameLayout implements Toolbar {
39 protected static final int BACKGROUND_TRANSITION_DURATION_MS = 400; 39 protected static final int BACKGROUND_TRANSITION_DURATION_MS = 400;
40 40
41 private Invalidator mInvalidator; 41 private Invalidator mInvalidator;
42 42
43 private final int[] mTempPosition = new int[2]; 43 private final int[] mTempPosition = new int[2];
44 44
45 /** 45 /**
46 * The ImageButton view that represents the menu button. 46 * The ImageButton view that represents the menu button.
47 */ 47 */
48 protected TintedImageButton mMenuButton; 48 protected TintedImageButton mMenuButton;
49 private AppMenuButtonHelper mAppMenuButtonHelper; 49 private AppMenuButtonHelper mAppMenuButtonHelper;
50 50
51 private ToolbarDataProvider mToolbarDataProvider; 51 private ToolbarDataProvider mToolbarDataProvider;
52 private ToolbarTabController mToolbarTabController; 52 private ToolbarTabController mToolbarTabController;
53 private ToolbarProgressBar mProgressBar; 53 private SmoothProgressBar mProgressBar;
54 54
55 private boolean mNativeLibraryReady; 55 private boolean mNativeLibraryReady;
56 private boolean mUrlHasFocus; 56 private boolean mUrlHasFocus;
57 57
58 private long mFirstDrawTimeMs; 58 private long mFirstDrawTimeMs;
59 59
60 protected final int mToolbarHeightWithoutShadow; 60 protected final int mToolbarHeightWithoutShadow;
61 61
62 private boolean mFindInPageToolbarShowing; 62 private boolean mFindInPageToolbarShowing;
63 63
64 /** 64 /**
65 * Basic constructor for {@link ToolbarLayout}. 65 * Basic constructor for {@link ToolbarLayout}.
66 */ 66 */
67 public ToolbarLayout(Context context, AttributeSet attrs) { 67 public ToolbarLayout(Context context, AttributeSet attrs) {
68 super(context, attrs); 68 super(context, attrs);
69 mToolbarHeightWithoutShadow = getResources().getDimensionPixelOffset( 69 mToolbarHeightWithoutShadow = getResources().getDimensionPixelOffset(
70 getToolbarHeightWithoutShadowResId()); 70 getToolbarHeightWithoutShadowResId());
71 } 71 }
72 72
73 @Override 73 @Override
74 protected void onFinishInflate() { 74 protected void onFinishInflate() {
75 super.onFinishInflate(); 75 super.onFinishInflate();
76 76
77 mProgressBar = (ToolbarProgressBar) findViewById(R.id.progress); 77 mProgressBar = (SmoothProgressBar) findViewById(R.id.progress);
78 if (mProgressBar != null) { 78 if (mProgressBar != null) {
79 removeView(mProgressBar); 79 removeView(mProgressBar);
80 Drawable progressDrawable = mProgressBar.getProgressDrawable();
80 getFrameLayoutParams(mProgressBar).topMargin = mToolbarHeightWithout Shadow 81 getFrameLayoutParams(mProgressBar).topMargin = mToolbarHeightWithout Shadow
81 - getFrameLayoutParams(mProgressBar).height; 82 - progressDrawable.getIntrinsicHeight();
82 } 83 }
83 84
84 mMenuButton = (TintedImageButton) findViewById(R.id.menu_button); 85 mMenuButton = (TintedImageButton) findViewById(R.id.menu_button);
85 // Initialize the provider to an empty version to avoid null checking ev erywhere. 86 // Initialize the provider to an empty version to avoid null checking ev erywhere.
86 mToolbarDataProvider = new ToolbarDataProvider() { 87 mToolbarDataProvider = new ToolbarDataProvider() {
87 @Override 88 @Override
88 public boolean isIncognito() { 89 public boolean isIncognito() {
89 return false; 90 return false;
90 } 91 }
91 92
(...skipping 11 matching lines...) Expand all
103 public boolean wouldReplaceURL() { 104 public boolean wouldReplaceURL() {
104 return false; 105 return false;
105 } 106 }
106 107
107 @Override 108 @Override
108 public NewTabPage getNewTabPageForCurrentTab() { 109 public NewTabPage getNewTabPageForCurrentTab() {
109 return null; 110 return null;
110 } 111 }
111 112
112 @Override 113 @Override
114 public int getLoadProgress() {
115 return 0;
116 }
117
118 @Override
113 public String getCorpusChipText() { 119 public String getCorpusChipText() {
114 return null; 120 return null;
115 } 121 }
116 122
117 @Override 123 @Override
118 public int getPrimaryColor() { 124 public int getPrimaryColor() {
119 return 0; 125 return 0;
120 } 126 }
121 127
122 @Override 128 @Override
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 /** 179 /**
174 * @return The menu button view. 180 * @return The menu button view.
175 */ 181 */
176 protected View getMenuButton() { 182 protected View getMenuButton() {
177 return mMenuButton; 183 return mMenuButton;
178 } 184 }
179 185
180 /** 186 /**
181 * @return The {@link ProgressBar} this layout uses. 187 * @return The {@link ProgressBar} this layout uses.
182 */ 188 */
183 ToolbarProgressBar getProgressBar() { 189 SmoothProgressBar getProgressBar() {
184 return mProgressBar; 190 return mProgressBar;
185 } 191 }
186 192
187 @Override 193 @Override
188 public void getPositionRelativeToContainer(View containerView, int[] positio n) { 194 public void getPositionRelativeToContainer(View containerView, int[] positio n) {
189 ViewUtils.getRelativeDrawPosition(containerView, this, position); 195 ViewUtils.getRelativeDrawPosition(containerView, this, position);
190 } 196 }
191 197
192 /** 198 /**
193 * @return The helper for menu button UI interactions. 199 * @return The helper for menu button UI interactions.
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 return mFirstDrawTimeMs; 496 return mFirstDrawTimeMs;
491 } 497 }
492 498
493 /** 499 /**
494 * Notified when a navigation to a different page has occurred. 500 * Notified when a navigation to a different page has occurred.
495 */ 501 */
496 protected void onNavigatedToDifferentPage() { 502 protected void onNavigatedToDifferentPage() {
497 } 503 }
498 504
499 /** 505 /**
500 * Starts load progress.
501 */
502 protected void startLoadProgress() {
503 if (mProgressBar != null) {
504 mProgressBar.start();
505 }
506 }
507
508 /**
509 * Sets load progress. 506 * Sets load progress.
510 * @param progress The load progress between 0 and 1. 507 * @param progress The load progress between 0 and 100.
511 */ 508 */
512 protected void setLoadProgress(float progress) { 509 protected void setLoadProgress(int progress) {
513 if (mProgressBar != null) { 510 if (mProgressBar != null) mProgressBar.setProgress(progress);
514 mProgressBar.setProgress(progress);
515 }
516 } 511 }
517 512
518 /** 513 /**
519 * Finishes load progress.
520 * @param delayed Whether hiding progress bar should be delayed to give enou gh time for user to
521 * recognize the last state.
522 */
523 protected void finishLoadProgress(boolean delayed) {
524 if (mProgressBar != null) {
525 mProgressBar.finish(delayed);
526 }
527 }
528
529 /**
530 * Finish any toolbar animations. 514 * Finish any toolbar animations.
531 */ 515 */
532 public void finishAnimations() { } 516 public void finishAnimations() { }
533 517
534 /** 518 /**
535 * @return The current View showing in the Tab. 519 * @return The current View showing in the Tab.
536 */ 520 */
537 protected View getCurrentTabView() { 521 protected View getCurrentTabView() {
538 Tab tab = mToolbarDataProvider.getTab(); 522 Tab tab = mToolbarDataProvider.getTab();
539 if (tab != null) { 523 if (tab != null) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 } 568 }
585 569
586 /** 570 /**
587 * Opens hompage in the current tab. 571 * Opens hompage in the current tab.
588 */ 572 */
589 protected void openHomepage() { 573 protected void openHomepage() {
590 getLocationBar().hideSuggestions(); 574 getLocationBar().hideSuggestions();
591 if (mToolbarTabController != null) mToolbarTabController.openHomepage(); 575 if (mToolbarTabController != null) mToolbarTabController.openHomepage();
592 } 576 }
593 } 577 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698