Bug 1393477 - Resize favicon shown in doorhanger. r?nechen
MozReview-Commit-ID: I8vFxePDOeF
--- 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);
}