Bug 1293790 - WIP: miscellaneous AS layout and FaviconView improvements draft
authorAndrzej Hunt <ahunt@mozilla.com>
Tue, 23 Aug 2016 14:36:58 -0700
changeset 405106 46d198ad9bc0936cf92e8662a56095db9f54ae0c
parent 405105 de4a93f4ec1731875d08febd666215a0f1b5c555
child 405107 91eee7000c1a4395c14aa4e8ccffeae62e8e59e9
push id27385
push userahunt@mozilla.com
push dateWed, 24 Aug 2016 18:42:24 +0000
bugs1293790
milestone51.0a1
Bug 1293790 - WIP: miscellaneous AS layout and FaviconView improvements MozReview-Commit-ID: 2ChLHNcHXp2
mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
mobile/android/base/resources/layout/activity_stream.xml
mobile/android/base/resources/layout/activity_stream_main_toppanel.xml
--- a/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
@@ -89,17 +89,17 @@ public class FaviconView extends ImageVi
 
         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);
+        mBackgroundCornerRadius = 0; //TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_CORNER_RADIUS_DP, metrics);
     }
 
     @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.
         if (w == mActualWidth && h == mActualHeight) {
@@ -133,29 +133,32 @@ public class FaviconView extends ImageVi
      */
     private void formatImage() {
         // We're waiting for both onSizeChanged and updateImage to be called before scaling.
         if (mIconBitmap == null || mActualWidth == 0 || mActualHeight == 0) {
             showNoImage();
             return;
         }
 
-        if (mScalingExpected && mActualWidth != mIconBitmap.getWidth()) {
+        // TODO: don't scale image if it's a default?
+        if (mScalingExpected && mActualWidth != mIconBitmap.getWidth()
+                && !mIconKey.equals(DEFAULT_FAVICON_KEY)) {
             scaleBitmap();
             // Don't scale the image every time something changes.
             mScalingExpected = false;
         }
 
         setImageBitmap(mIconBitmap);
 
         // After scaling, determine if we have empty space around the scaled image which we need to
         // fill with the coloured background. If applicable, show it.
         // We assume Favicons are still squares and only bother with the background if more than 3px
         // of it would be displayed.
         if (Math.abs(mIconBitmap.getWidth() - mActualWidth) > 3) {
+            // TODO: this doesn't work for generated favicons, but we still want some form of colour here
             mDominantColor = Favicons.getFaviconColor(mIconKey);
             if (mDominantColor == -1) {
                 mDominantColor = 0;
             }
         } else {
             mDominantColor = 0;
         }
     }
--- a/mobile/android/base/resources/layout/activity_stream.xml
+++ b/mobile/android/base/resources/layout/activity_stream.xml
@@ -1,15 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <org.mozilla.gecko.home.activitystream.ActivityStream xmlns:android="http://schemas.android.com/apk/res/android"
                                                       android:orientation="vertical"
                                                       android:layout_width="match_parent"
                                                       android:layout_height="match_parent"
                                                       android:background="#FAFAFA">
     <android.support.v7.widget.RecyclerView
         android:id="@+id/activity_stream_main_recyclerview"
-        android:layout_marginTop="12dp"
-        android:layout_marginLeft="12dp"
-        android:layout_marginStart="12dp"
         android:layout_width="match_parent"
         android:layout_height="match_parent"/>
 
 </org.mozilla.gecko.home.activitystream.ActivityStream>
--- a/mobile/android/base/resources/layout/activity_stream_main_toppanel.xml
+++ b/mobile/android/base/resources/layout/activity_stream_main_toppanel.xml
@@ -1,15 +1,15 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 xmlns:tools="http://schemas.android.com/tools"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:orientation="vertical">
-
+                android:orientation="vertical"
+                android:padding="4dp">
 
     <TextView
         android:id="@+id/title_topsites"
         android:text="@string/activity_stream_topsites"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
         android:layout_alignParentStart="true"