Bug 1393477 - Resize favicon shown in doorhanger. r?nechen draft
authorJing-wei Wu <topwu.tw@gmail.com>
Thu, 31 Aug 2017 16:29:13 +0800
changeset 656464 273c4d2abf427c5b245037b5353cd105c64a9e8e
parent 656463 cc785cde0944af279860e79b4060d46f4e842402
child 729161 873fbbd5f8c75e45c4785616d9947e6d62de9045
push id77235
push userbmo:topwu.tw@gmail.com
push dateThu, 31 Aug 2017 08:30:14 +0000
reviewersnechen
bugs1393477
milestone57.0a1
Bug 1393477 - Resize favicon shown in doorhanger. r?nechen MozReview-Commit-ID: I8vFxePDOeF
mobile/android/base/java/org/mozilla/gecko/widget/DoorHanger.java
--- a/mobile/android/base/java/org/mozilla/gecko/widget/DoorHanger.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/DoorHanger.java
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.widget;
 
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
 import android.support.annotation.Nullable;
 import android.support.v4.content.ContextCompat;
 import android.support.v4.widget.TextViewCompat;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewStub;
 import android.widget.Button;
 import android.widget.ImageView;
@@ -222,18 +223,23 @@ public abstract class DoorHanger extends
             return false;
         }
 
         return true;
     }
 
     public void showTitle(@Nullable Bitmap favicon, String title) {
         mDoorhangerTitle.setText(title);
-        TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(mDoorhangerTitle, new BitmapDrawable(getResources(), favicon), null, null, null);
+
         if (favicon != null) {
+            final Drawable faviconDrawable = new BitmapDrawable(mResources, favicon);
+            final int dimen = (int) mResources.getDimension(R.dimen.browser_toolbar_favicon_size);
+            faviconDrawable.setBounds(0, 0, dimen, dimen);
+
+            TextViewCompat.setCompoundDrawablesRelative(mDoorhangerTitle, faviconDrawable, null, null, null);
             mDoorhangerTitle.setCompoundDrawablePadding((int) mContext.getResources().getDimension(R.dimen.doorhanger_drawable_padding));
         }
         mDoorhangerTitle.setVisibility(VISIBLE);
     }
 
     public void hideTitle() {
         mDoorhangerTitle.setVisibility(GONE);
     }