Bug 1366679 - Part 1: Support configuring FaviconView backgroud corner radius in xml. r?nechen,walkingice draft
authorJing-wei Wu <topwu.tw@gmail.com>
Tue, 27 Jun 2017 10:38:00 -0700
changeset 601559 660a82c108c34628dfe483076c9f90e999822ad9
parent 601499 b7f85a213aaca5a17bf202800619b1075927c871
child 601560 d94e6f801bc7142c9b8a402a23bfc19aa6fe7a9a
push id66109
push userbmo:topwu.tw@gmail.com
push dateWed, 28 Jun 2017 22:04:34 +0000
reviewersnechen, walkingice
bugs1366679
milestone56.0a1
Bug 1366679 - Part 1: Support configuring FaviconView backgroud corner radius in xml. r?nechen,walkingice MozReview-Commit-ID: 5qH9Bu1ORCa
mobile/android/app/src/main/res/values/attrs.xml
mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
--- a/mobile/android/app/src/main/res/values/attrs.xml
+++ b/mobile/android/app/src/main/res/values/attrs.xml
@@ -151,16 +151,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"/>
+        <attr name="backgroundCornerRadius" format="dimension"/>
     </declare-styleable>
 
     <declare-styleable name="OverlayDialogButton">
         <attr name="drawable" format="reference" />
         <attr name="enabledText" format="string" />
         <attr name="disabledText" format="string" />
     </declare-styleable>
 
--- a/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
@@ -82,29 +82,29 @@ public class FaviconView extends ImageVi
     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);
+
+            final DisplayMetrics metrics = getResources().getDisplayMetrics();
+            mBackgroundCornerRadius = a.getDimension(R.styleable.FaviconView_backgroundCornerRadius,
+                                                     TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_CORNER_RADIUS_DP, metrics));
         } finally {
             a.recycle();
         }
 
         if (isOverrideScaleTypeEnabled) {
             setScaleType(ImageView.ScaleType.CENTER);
         }
 
-        final DisplayMetrics metrics = getResources().getDisplayMetrics();
-
         mBackgroundRect = new RectF(0, 0, 0, 0);
-        mBackgroundCornerRadius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_CORNER_RADIUS_DP, metrics);
-
         mResources = getResources();
     }
 
     @Override
     protected void onSizeChanged(int w, int h, int oldw, int oldh) {
         super.onSizeChanged(w, h, oldw, oldh);
 
         // No point rechecking the image if there hasn't really been any change.