From 7fe469beeadafc696551883e3ddce380d4677bd3 Mon Sep 17 00:00:00 2001 From: Sriram Ramasubramanian Date: Tue, 17 Sep 2013 13:39:18 -0400 Subject: [PATCH] Bug 833800: Change the pin to be an image. [r=wesj] --- mobile/android/base/Makefile.in | 3 ++ .../base/home/TopBookmarkItemView.java | 38 ++---------------- .../base/resources/drawable-hdpi/pin.png | Bin 0 -> 249 bytes .../base/resources/drawable-mdpi/pin.png | Bin 0 -> 192 bytes .../base/resources/drawable-xhdpi/pin.png | Bin 0 -> 285 bytes .../layout/top_bookmark_item_view.xml | 12 +----- .../android/base/resources/values/colors.xml | 1 - .../android/base/resources/values/dimens.xml | 1 - 8 files changed, 8 insertions(+), 47 deletions(-) create mode 100644 mobile/android/base/resources/drawable-hdpi/pin.png create mode 100644 mobile/android/base/resources/drawable-mdpi/pin.png create mode 100644 mobile/android/base/resources/drawable-xhdpi/pin.png diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index 4be661122203..14c3ad0109d5 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -711,6 +711,7 @@ RES_DRAWABLE_MDPI = \ res/drawable-mdpi/menu_item_check.png \ res/drawable-mdpi/menu_item_more.png \ res/drawable-mdpi/menu_item_uncheck.png \ + res/drawable-mdpi/pin.png \ res/drawable-mdpi/shield.png \ res/drawable-mdpi/shield_doorhanger.png \ res/drawable-mdpi/tabs_normal.png \ @@ -819,6 +820,7 @@ RES_DRAWABLE_HDPI = \ res/drawable-hdpi/menu_item_check.png \ res/drawable-hdpi/menu_item_more.png \ res/drawable-hdpi/menu_item_uncheck.png \ + res/drawable-hdpi/pin.png \ res/drawable-hdpi/shield.png \ res/drawable-hdpi/shield_doorhanger.png \ res/drawable-hdpi/tabs_normal.png \ @@ -917,6 +919,7 @@ RES_DRAWABLE_XHDPI = \ res/drawable-xhdpi/menu_item_check.png \ res/drawable-xhdpi/menu_item_more.png \ res/drawable-xhdpi/menu_item_uncheck.png \ + res/drawable-xhdpi/pin.png \ res/drawable-xhdpi/shield.png \ res/drawable-xhdpi/shield_doorhanger.png \ res/drawable-xhdpi/tab_indicator_divider.9.png \ diff --git a/mobile/android/base/home/TopBookmarkItemView.java b/mobile/android/base/home/TopBookmarkItemView.java index a6b21f4ddc1b..bdf76a0152c1 100644 --- a/mobile/android/base/home/TopBookmarkItemView.java +++ b/mobile/android/base/home/TopBookmarkItemView.java @@ -10,18 +10,13 @@ import org.mozilla.gecko.R; import android.content.Context; import android.graphics.Bitmap; -import android.graphics.Paint; -import android.graphics.Path; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.ShapeDrawable; -import android.graphics.drawable.shapes.PathShape; import android.text.TextUtils; import android.util.AttributeSet; import android.view.LayoutInflater; import android.widget.ImageView; -import android.widget.RelativeLayout; -import android.widget.TextView; import android.widget.ImageView.ScaleType; +import android.widget.LinearLayout; +import android.widget.TextView; /** * A view that displays the thumbnail and the title/url for a bookmark. @@ -35,13 +30,9 @@ public class TopBookmarkItemView extends RelativeLayout { // Empty state, to denote there is no valid url. private static final int[] STATE_EMPTY = { android.R.attr.state_empty }; - // A Pin Drawable to denote pinned sites. - private static Drawable sPinDrawable = null; - // Child views. private final TextView mTitleView; private final ImageView mThumbnailView; - private final ImageView mPinView; // Data backing this view. private String mTitle; @@ -68,7 +59,6 @@ public class TopBookmarkItemView extends RelativeLayout { mTitleView = (TextView) findViewById(R.id.title); mThumbnailView = (ImageView) findViewById(R.id.thumbnail); - mPinView = (ImageView) findViewById(R.id.pin); } /** @@ -135,7 +125,7 @@ public class TopBookmarkItemView extends RelativeLayout { */ public void setPinned(boolean pinned) { mIsPinned = pinned; - mPinView.setBackgroundDrawable(pinned ? getPinDrawable() : null); + mTitleView.setCompoundDrawablesWithIntrinsicBounds(pinned ? R.drawable.pin : 0, 0, 0, 0); } /** @@ -200,26 +190,4 @@ public class TopBookmarkItemView extends RelativeLayout { // Refresh for state change. refreshDrawableState(); } - - /** - * @return Drawable to be used as a pin. - */ - private Drawable getPinDrawable() { - if (sPinDrawable == null) { - int size = getResources().getDimensionPixelSize(R.dimen.top_bookmark_pinsize); - - // Draw a little triangle in the upper right corner. - Path path = new Path(); - path.moveTo(0, 0); - path.lineTo(size, 0); - path.lineTo(size, size); - path.close(); - - sPinDrawable = new ShapeDrawable(new PathShape(path, size, size)); - Paint p = ((ShapeDrawable) sPinDrawable).getPaint(); - p.setColor(getResources().getColor(R.color.top_bookmark_pin)); - } - - return sPinDrawable; - } } diff --git a/mobile/android/base/resources/drawable-hdpi/pin.png b/mobile/android/base/resources/drawable-hdpi/pin.png new file mode 100644 index 0000000000000000000000000000000000000000..0c69abab085379cb02d5a307434a1c8b38707f89 GIT binary patch literal 249 zcmV|BDA)_wIP?Zi&oA)cg@p9e;_xR>(jU!BD-o%j zbF2>aXjR&y5Je^==%&~r=!7Kd9LjP@5tIQz##-M*~5ST|f-g zXhgE0KK-HtdVl%yOVd97;}$#K%N q%x8#w@leXm?@v!6i`5&67IpT3OC6KQX^VuL2w)>kWwWr1>7K#*#Z=#wX#@`6ywUCk^LMw z=Xxc|^E{Lc96+M>`U6_t00&MKF$QL>98km_7=jWw5ivc{7B~-QkXQo+iA6*Ngj_^a zAOkxPlRO~80se{?5(Gqifn_T$Q=00000NkvXXu0mjfRZ(ar literal 0 HcmV?d00001 diff --git a/mobile/android/base/resources/layout/top_bookmark_item_view.xml b/mobile/android/base/resources/layout/top_bookmark_item_view.xml index 00a7a0ebafae..50bec658d5c2 100644 --- a/mobile/android/base/resources/layout/top_bookmark_item_view.xml +++ b/mobile/android/base/resources/layout/top_bookmark_item_view.xml @@ -9,23 +9,15 @@ + android:layout_height="wrap_content"/> - - diff --git a/mobile/android/base/resources/values/colors.xml b/mobile/android/base/resources/values/colors.xml index b0165f0794f8..cf1e411820cd 100644 --- a/mobile/android/base/resources/values/colors.xml +++ b/mobile/android/base/resources/values/colors.xml @@ -75,7 +75,6 @@ #dddddd #bbbbbb #4D000000 - #55000000 #ffffff #FFF diff --git a/mobile/android/base/resources/values/dimens.xml b/mobile/android/base/resources/values/dimens.xml index b077d591c2d0..9484b71357b6 100644 --- a/mobile/android/base/resources/values/dimens.xml +++ b/mobile/android/base/resources/values/dimens.xml @@ -71,7 +71,6 @@ 47dp 58dp 11dp - 20dp 50dp 6dp -13dip