Commit 2bdff99f authored by kkimlabs's avatar kkimlabs Committed by Commit bot

Revert of [Andorid] ClipDrawable progress bar experiment. (patchset #2...

Revert of [Andorid] ClipDrawable progress bar experiment. (patchset #2 id:20001 of https://codereview.chromium.org/960733002/)

Reason for revert:
Although ClipDrawableProgressBar showed some perf improvement on blink_perf.svg, it didn't show any meaningful difference on page_cycler.top_10_mobile test.

Original issue's description:
> [Andorid] ClipDrawable progress bar experiment.
>
> Recently it was discovered that ClipDrawable is much faster than our
> default ToolbarProgressBar on content shell.
>
> So we plan to experiment with ClipDrawable based progress bar
> implementation.
>
> BUG=455891
>
> Committed: https://crrev.com/b13144e2f2b4ac80f81cee8ce4d4c7f4831b625e
> Cr-Commit-Position: refs/heads/master@{#318292}

TBR=dtrainor@chromium.org,jaekyun@chromium.org
NOPRESUBMIT=false
NOTREECHECKS=false
NOTRY=false
BUG=455891

Review URL: https://codereview.chromium.org/994753002

Cr-Commit-Position: refs/heads/master@{#319777}
parent eedb763e
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* An alternative progress bar implemented using ClipDrawable. We're experimenting with this for
* faster performance. http://crbug.com/455891
*/
public class ClipDrawableProgressBar extends ImageView {
private static final long PROGRESS_CLEARING_DELAY_MS = 200;
private final Runnable mClearLoadProgressRunnable = new Runnable() {
@Override
public void run() {
setProgress(0);
}
};
/**
* Constructor for inflating from XML.
*/
public ClipDrawableProgressBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* Set the current progress to the specified value.
* @param progress The new progress, between 0 and 10000.
*/
public void setProgress(int progress) {
getDrawable().setLevel(progress);
removeCallbacks(mClearLoadProgressRunnable);
if (progress == 10000) postDelayed(mClearLoadProgressRunnable, PROGRESS_CLEARING_DELAY_MS);
}
/**
* Get the progress bar's current level of progress.
* @return The current progress, between 0 and getMax().
*/
public int getProgress() {
return getDrawable().getLevel();
}
}
......@@ -128,7 +128,7 @@ public class ToolbarProgressBar extends SmoothProgressBar {
* @return Whether or not this progress bar has animations running for showing/hiding itself.
*/
@VisibleForTesting
public boolean isAnimatingForShowOrHide() {
boolean isAnimatingForShowOrHide() {
return (mShowAnimator != null && mShowAnimator.isStarted())
|| (mHideAnimator != null && mHideAnimator.isStarted());
}
......
......@@ -4,10 +4,13 @@
package org.chromium.chrome.browser.widget;
import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_PHONE;
import android.test.suitebuilder.annotation.MediumTest;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.shell.ChromeShellTestBase;
import org.chromium.chrome.shell.R;
import org.chromium.content.browser.test.util.Criteria;
......@@ -18,7 +21,7 @@ import java.util.concurrent.atomic.AtomicReference;
/**
* Tests related to the ToolbarProgressBar.
*/
public class ClipDrawableProgressBarTest extends ChromeShellTestBase {
public class ToolbarProgressBarTest extends ChromeShellTestBase {
/**
* Test that calling progressBar.setProgress(# > 0) followed by progressBar.setProgress(0)
* results in a hidden progress bar (the secondary progress needs to be 0).
......@@ -26,33 +29,54 @@ public class ClipDrawableProgressBarTest extends ChromeShellTestBase {
*/
@Feature({"Android-Toolbar"})
@MediumTest
@Restriction(RESTRICTION_TYPE_PHONE)
public void testProgressBarDisappearsAfterFastShowHide() throws InterruptedException {
launchChromeShellWithUrl("about:blank");
waitForActiveShellToBeDoneLoading();
final AtomicReference<ClipDrawableProgressBar> progressBar =
new AtomicReference<ClipDrawableProgressBar>();
final AtomicReference<ToolbarProgressBar> progressBar =
new AtomicReference<ToolbarProgressBar>();
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
progressBar.set(
(ClipDrawableProgressBar) getActivity().findViewById(R.id.progress));
progressBar.set((ToolbarProgressBar) getActivity().findViewById(R.id.progress));
}
});
// Make sure that there is some progress.
// Wait for the progress bar to be reset.
CriteriaHelper.pollForUIThreadCriteria(new Criteria() {
@Override
public boolean isSatisfied() {
return progressBar.get().getProgress() > 0;
return progressBar.get().getProgress() == 0;
}
});
// Wait for the progress bar to be reset.
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
assertEquals("Progress bar should be hidden to start.", 0,
progressBar.get().getProgress());
progressBar.get().setProgress(10);
assertTrue("Progress bar did not start animating",
progressBar.get().isAnimatingForShowOrHide());
progressBar.get().setProgress(0);
}
});
// Wait for the progress bar to finish any and all animations.
CriteriaHelper.pollForUIThreadCriteria(new Criteria() {
@Override
public boolean isSatisfied() {
return progressBar.get().getProgress() == 0;
return !progressBar.get().isAnimatingForShowOrHide();
}
});
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
// The secondary progress should be gone.
assertEquals("Progress bar background still visible.", 0,
progressBar.get().getSecondaryProgress());
}
});
}
......
......@@ -27,7 +27,7 @@ import org.chromium.chrome.browser.TabObserver;
import org.chromium.chrome.browser.UrlUtilities;
import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
import org.chromium.chrome.browser.appmenu.AppMenuHandler;
import org.chromium.chrome.browser.widget.ClipDrawableProgressBar;
import org.chromium.chrome.browser.widget.SmoothProgressBar;
import org.chromium.chrome.shell.omnibox.SuggestionPopup;
import org.chromium.content.common.ContentSwitches;
......@@ -35,22 +35,32 @@ import org.chromium.content.common.ContentSwitches;
* A Toolbar {@link View} that shows the URL and navigation buttons.
*/
public class ChromeShellToolbar extends LinearLayout {
private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200;
private final Runnable mClearProgressRunnable = new Runnable() {
@Override
public void run() {
mProgressBar.setProgress(0);
}
};
private final Runnable mUpdateProgressRunnable = new Runnable() {
@Override
public void run() {
mProgressBar.setProgress(100 * mProgress);
mProgressBar.setProgress(mProgress);
if (mLoading) {
mStopReloadButton.setImageResource(
R.drawable.btn_close);
} else {
mStopReloadButton.setImageResource(R.drawable.btn_toolbar_reload);
ApiCompatibilityUtils.postOnAnimationDelayed(ChromeShellToolbar.this,
mClearProgressRunnable, COMPLETED_PROGRESS_TIMEOUT_MS);
}
}
};
private EditText mUrlTextView;
private ClipDrawableProgressBar mProgressBar;
private SmoothProgressBar mProgressBar;
private ChromeShellTab mTab;
private final TabObserver mTabObserver;
......@@ -113,6 +123,7 @@ public class ChromeShellToolbar extends LinearLayout {
}
private void onLoadProgressChanged(int progress) {
removeCallbacks(mClearProgressRunnable);
removeCallbacks(mUpdateProgressRunnable);
mProgress = progress;
mLoading = progress != 100;
......@@ -130,7 +141,7 @@ public class ChromeShellToolbar extends LinearLayout {
protected void onFinishInflate() {
super.onFinishInflate();
mProgressBar = (ClipDrawableProgressBar) findViewById(R.id.progress);
mProgressBar = (SmoothProgressBar) findViewById(R.id.progress);
initializeUrlField();
initializeTabSwitcherButton();
initializeMenuButton();
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<clip xmlns:android="http://schemas.android.com/apk/res/android" >
<shape>
<solid android:color="@color/material_deep_teal_500" />
</shape>
</clip>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/secondaryProgress">
<clip android:gravity="left">
<shape>
<solid android:color="@color/material_deep_teal_200" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip android:gravity="left">
<shape>
<solid android:color="@color/material_deep_teal_500" />
</shape>
</clip>
</item>
</layer-list>
......@@ -60,11 +60,13 @@
android:background="?attr/selectableItemBackground"
android:scaleType="center"/>
</LinearLayout>
<org.chromium.chrome.browser.widget.ClipDrawableProgressBar
<org.chromium.chrome.browser.widget.ToolbarProgressBar
android:id="@+id/progress"
style="@android:style/Widget.Holo.Light.ProgressBar.Horizontal"
android:progressDrawable="@drawable/progress_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:src="@drawable/clip_drawable_progress_bar" />
android:progress="0" />
</org.chromium.chrome.shell.ChromeShellToolbar>
<FrameLayout android:id="@+id/content_container"
android:layout_width="match_parent"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment