Bug 1264783 - Use Hardware layers for tabs curve (except on pre-lollipop) r?sebastian
On Android N, the tab button flickers when drawing animations such as the loading progress bar,
or even the tab count increment, over the tabs button. Using hardware layers appears to fix
this. For consistency we could use this across most devices, except those running 4.4 or earlier.
There the button background (light gray) is drawn black with hardware layers, so we should stick
with the default on such devices.
MozReview-Commit-ID: H5VWEkrRbVf
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/PhoneTabsButton.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/PhoneTabsButton.java
@@ -2,21 +2,30 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.toolbar;
import android.content.Context;
import android.util.AttributeSet;
+import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.tabs.TabCurve;
public class PhoneTabsButton extends ShapedButton {
public PhoneTabsButton(Context context, AttributeSet attrs) {
super(context, attrs);
+
+ if (!AppConstants.Versions.preLollipop) {
+ // The Android N preview has issues rendering our tabs button during animations
+ // unless we use hardware layers, see bug 1264783. For consistency we should
+ // try and set this across all devices, however on 4.X devices the background
+ // isn't drawn when we use hardware layers - hence we need to disable this there.
+ setLayerType(LAYER_TYPE_HARDWARE, null);
+ }
}
@Override
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
super.onSizeChanged(width, height, oldWidth, oldHeight);
mPath.reset();