Bug 1299524 - Allow disabling FaviconView corner rounding via enableRoundCorners attribute r=sebastian
authorAndrzej Hunt <ahunt@mozilla.com>
Tue, 06 Sep 2016 10:46:47 -0700
changeset 312982 ae2cab55008a00901359a0e7f66889f1679d239a
parent 312981 38cb109c653c886d792b012bdbdb104259d2923b
child 312983 f14745862e04104db0c056f82b907b9a45e896c2
push id81509
push usercbook@mozilla.com
push dateWed, 07 Sep 2016 15:23:10 +0000
treeherdermozilla-inbound@80dccdd8c94a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1299524
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1299524 - Allow disabling FaviconView corner rounding via enableRoundCorners attribute r=sebastian MozReview-Commit-ID: 1qtt7xlTsHP
mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
mobile/android/base/resources/values/attrs.xml
--- a/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
@@ -60,29 +60,33 @@ public class FaviconView extends ImageVi
     private final float mBackgroundCornerRadius;
 
     // Type of the border whose value is defined in attrs.xml .
     private final boolean isDominantBorderEnabled;
 
     // boolean switch for overriding scaletype, whose value is defined in attrs.xml .
     private final boolean isOverrideScaleTypeEnabled;
 
+    // boolean switch for disabling rounded corners, value defined in attrs.xml .
+    private final boolean areRoundCornersEnabled;
+
     // Initializing the static paints.
     static {
         sBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
         sBackgroundPaint.setStyle(Paint.Style.FILL);
     }
 
     public FaviconView(Context context, AttributeSet attrs) {
         super(context, attrs);
         TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FaviconView, 0, 0);
 
         try {
             isDominantBorderEnabled = a.getBoolean(R.styleable.FaviconView_dominantBorderEnabled, true);
             isOverrideScaleTypeEnabled = a.getBoolean(R.styleable.FaviconView_overrideScaleType, true);
+            areRoundCornersEnabled = a.getBoolean(R.styleable.FaviconView_enableRoundCorners, true);
         } finally {
             a.recycle();
         }
 
         if (isOverrideScaleTypeEnabled) {
             setScaleType(ImageView.ScaleType.CENTER);
         }
 
@@ -110,17 +114,21 @@ public class FaviconView extends ImageVi
         formatImage();
     }
 
     @Override
     public void onDraw(Canvas canvas) {
         if (isDominantBorderEnabled) {
             sBackgroundPaint.setColor(mDominantColor & 0x7FFFFFFF);
 
-            canvas.drawRoundRect(mBackgroundRect, mBackgroundCornerRadius, mBackgroundCornerRadius, sBackgroundPaint);
+            if (areRoundCornersEnabled) {
+                canvas.drawRoundRect(mBackgroundRect, mBackgroundCornerRadius, mBackgroundCornerRadius, sBackgroundPaint);
+            } else {
+                canvas.drawRect(mBackgroundRect, sBackgroundPaint);
+            }
         }
 
         super.onDraw(canvas);
     }
 
     /**
      * Formats the image for display, if the prerequisite data are available. Upscales tiny Favicons to
      * normal sized ones, replaces null bitmaps with the default Favicon, and fills all remaining space
--- a/mobile/android/base/resources/values/attrs.xml
+++ b/mobile/android/base/resources/values/attrs.xml
@@ -168,16 +168,17 @@
 
     <declare-styleable name="EllipsisTextView">
         <attr name="ellipsizeAtLine" format="integer"/>
     </declare-styleable>
 
     <declare-styleable name="FaviconView">
         <attr name="dominantBorderEnabled" format="boolean" />
         <attr name="overrideScaleType" format="boolean" />
+        <attr name="enableRoundCorners" format="boolean"/>
     </declare-styleable>
 
     <declare-styleable name="OverlayDialogButton">
         <attr name="drawable" format="reference" />
         <attr name="enabledText" format="string" />
         <attr name="disabledText" format="string" />
     </declare-styleable>