Bug 793721 - Remove rounding and shadows on about:home thumbnails. r=mfinkle
authorWes Johnston <wjohnston@mozilla.com>
Fri, 19 Oct 2012 17:36:22 -0700
changeset 110843 d40649836ffaab8d927fdfea1c8f159eece9fda3
parent 110842 0636839be2d1530f1ff271d6d0558757b0612101
child 110844 ea132a82593c5544e8641ae96898555c3bacf59c
push id23717
push userryanvm@gmail.com
push dateSat, 20 Oct 2012 16:43:11 +0000
treeherdermozilla-central@5d03feda2300 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs793721
milestone19.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 793721 - Remove rounding and shadows on about:home thumbnails. r=mfinkle
mobile/android/base/AboutHomeContent.java.in
mobile/android/base/GeckoViewsFactory.java
mobile/android/base/resources/layout/abouthome_topsite_item.xml
--- a/mobile/android/base/AboutHomeContent.java.in
+++ b/mobile/android/base/AboutHomeContent.java.in
@@ -598,94 +598,16 @@ public class AboutHomeContent extends Sc
             mRemoteTabs.addItem(row);
             row.setOnClickListener(mRemoteTabClickListener);
         }
         
         mRemoteTabs.setSubtitle(client);
         mRemoteTabs.show();
     }
 
-    // On Gingerbread TopSitesThumbnail doesn't receive onConfigurationChanged events
-    // Since the thumbnail size might change when orientation does, invalidate the
-    // thumbnail mask here
-    @Override
-    public void onConfigurationChanged(Configuration newConfig) {
-        super.onConfigurationChanged(newConfig);
-        TopSitesThumbnail.mRoundedCorners = null;
-    }
-
-    public static class TopSitesThumbnail extends RelativeLayout {
-        static private int sRadius = 0;
-        static private int sShadowOffset = 0;
-        static public Bitmap mRoundedCorners = null;
-        static private Paint mClipPaint = null;
-        static private Paint mShadowPaint = null;
-
-        public TopSitesThumbnail(Context context, AttributeSet attrs) {
-            super(context, attrs);
-
-            Resources res = context.getResources();
-            if (sRadius <= 0) {
-                sRadius = (int) (res.getDimension(R.dimen.abouthome_icon_radius));
-            }
-            if (sShadowOffset <= 0) {
-                sShadowOffset = (int) (res.getDimension(R.dimen.abouthome_topsite_shadow_offset));
-            }
-
-            if (mShadowPaint == null) {
-                mShadowPaint = new Paint();
-                mShadowPaint.setColor(res.getColor(R.color.abouthome_topsite_shadow));
-            }
-        }
-
-        // Override drawChild to mask the child nodes with a rounded rect
-        @Override
-        protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
-            // draw a shadow behind the thumbnail
-            canvas.drawRoundRect(new RectF(getPaddingLeft(),
-                                           getHeight() - getPaddingBottom() - 2*sShadowOffset,
-                                           getWidth() - getPaddingRight(),
-                                           getHeight()- getPaddingBottom()),
-                                 sRadius, sRadius,
-                                 mShadowPaint);
-
-            int count = canvas.saveLayer(0, 0, getWidth(), getHeight(), null,
-                                         Canvas.MATRIX_SAVE_FLAG |
-                                         Canvas.CLIP_SAVE_FLAG |
-                                         Canvas.HAS_ALPHA_LAYER_SAVE_FLAG |
-                                         Canvas.FULL_COLOR_LAYER_SAVE_FLAG |
-                                         Canvas.CLIP_TO_LAYER_SAVE_FLAG);
-
-            // cache the mask rect in a static variable so that we only have to draw it once
-            if (mRoundedCorners == null) {
-                Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
-                p.setColor(Color.WHITE);
-                mRoundedCorners = Bitmap.createBitmap(getWidth(),getHeight(),Bitmap.Config.ARGB_8888);
-                Canvas c2 = new Canvas(mRoundedCorners);
-                
-                c2.drawRoundRect(new RectF(getPaddingLeft(),
-                                           getPaddingTop(),
-                                           getWidth() - getPaddingRight(),
-                                           getHeight() - getPaddingBottom() - sShadowOffset), sRadius, sRadius, p);
-            }
-
-            if (mClipPaint == null) {
-                mClipPaint = new Paint();
-                mClipPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
-            }
-
-            super.drawChild(canvas, child, drawingTime);
-            canvas.drawBitmap(mRoundedCorners, 0, 0, mClipPaint);
-
-            canvas.restoreToCount(count);
-            return false;
-        }
-
-    }
-
     public static class TopSitesGridView extends GridView {
         public TopSitesGridView(Context context, AttributeSet attrs) {
             super(context, attrs);
         }
 
         public int getColumnWidth() {
             return getColumnWidth(getWidth());
         }
--- a/mobile/android/base/GeckoViewsFactory.java
+++ b/mobile/android/base/GeckoViewsFactory.java
@@ -39,18 +39,16 @@ public final class GeckoViewsFactory imp
             Log.i(LOGTAG, "Creating custom Gecko view: " + viewName);
 
             if (TextUtils.equals(viewName, "AboutHomePromoBox"))
                 return new AboutHomePromoBox(context, attrs);
             else if (TextUtils.equals(viewName, "AboutHomeContent"))
                 return new AboutHomeContent(context, attrs);
             else if (TextUtils.equals(viewName, "AboutHomeContent$TopSitesGridView"))
                 return new AboutHomeContent.TopSitesGridView(context, attrs);
-            else if (TextUtils.equals(viewName, "AboutHomeContent$TopSitesThumbnail"))
-                return new AboutHomeContent.TopSitesThumbnail(context, attrs);
             else if (TextUtils.equals(viewName, "AboutHomeSection"))
                 return new AboutHomeSection(context, attrs);
             else if (TextUtils.equals(viewName, "AwesomeBarTabs"))
                 return new AwesomeBarTabs(context, attrs);
             else if (TextUtils.equals(viewName, "BrowserToolbarBackground"))
                 return new BrowserToolbarBackground(context, attrs);
             else if (TextUtils.equals(viewName, "FormAssistPopup"))
                 return new FormAssistPopup(context, attrs);
--- a/mobile/android/base/resources/layout/abouthome_topsite_item.xml
+++ b/mobile/android/base/resources/layout/abouthome_topsite_item.xml
@@ -1,17 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
-<view class="org.mozilla.gecko.AboutHomeContent$TopSitesThumbnail"
-                xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 style="@style/AboutHome.Thumbnail">
 
     <ImageView
           android:id="@+id/thumbnail"
           style="@style/AboutHome.Thumbnail.Image"/>
 
     <TextView android:id="@+id/title"
               style="@style/AboutHome.Thumbnail.Label"/>
 
-</view>
+</RelativeLayout>