Bug 1264783 - Use Hardware layers for tabs curve (except on pre-lollipop) r?sebastian draft
authorAndrzej Hunt <ahunt@mozilla.com>
Fri, 03 Jun 2016 15:12:54 -0700
changeset 375324 218b78c5daf126c76f936a36450895dcfdf5570a
parent 375309 ab5e81678aaae8da42e11e8daf118e2a9c90baac
child 522829 10e9463b5fc885c73a4cf8495e6dc3c4ffddd227
push id20233
push userahunt@mozilla.com
push dateFri, 03 Jun 2016 22:13:19 +0000
reviewerssebastian
bugs1264783
milestone49.0a1
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
mobile/android/base/java/org/mozilla/gecko/toolbar/PhoneTabsButton.java
--- 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();