Bug 833800: Change the pin to be an image. [r=wesj]

This commit is contained in:
Sriram Ramasubramanian 2013-09-17 13:39:18 -04:00
parent 5bb5082359
commit e2658d0ba4
8 changed files with 8 additions and 47 deletions

View File

@ -711,6 +711,7 @@ RES_DRAWABLE_MDPI = \
res/drawable-mdpi/menu_item_check.png \ res/drawable-mdpi/menu_item_check.png \
res/drawable-mdpi/menu_item_more.png \ res/drawable-mdpi/menu_item_more.png \
res/drawable-mdpi/menu_item_uncheck.png \ res/drawable-mdpi/menu_item_uncheck.png \
res/drawable-mdpi/pin.png \
res/drawable-mdpi/shield.png \ res/drawable-mdpi/shield.png \
res/drawable-mdpi/shield_doorhanger.png \ res/drawable-mdpi/shield_doorhanger.png \
res/drawable-mdpi/tabs_normal.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_check.png \
res/drawable-hdpi/menu_item_more.png \ res/drawable-hdpi/menu_item_more.png \
res/drawable-hdpi/menu_item_uncheck.png \ res/drawable-hdpi/menu_item_uncheck.png \
res/drawable-hdpi/pin.png \
res/drawable-hdpi/shield.png \ res/drawable-hdpi/shield.png \
res/drawable-hdpi/shield_doorhanger.png \ res/drawable-hdpi/shield_doorhanger.png \
res/drawable-hdpi/tabs_normal.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_check.png \
res/drawable-xhdpi/menu_item_more.png \ res/drawable-xhdpi/menu_item_more.png \
res/drawable-xhdpi/menu_item_uncheck.png \ res/drawable-xhdpi/menu_item_uncheck.png \
res/drawable-xhdpi/pin.png \
res/drawable-xhdpi/shield.png \ res/drawable-xhdpi/shield.png \
res/drawable-xhdpi/shield_doorhanger.png \ res/drawable-xhdpi/shield_doorhanger.png \
res/drawable-xhdpi/tab_indicator_divider.9.png \ res/drawable-xhdpi/tab_indicator_divider.9.png \

View File

@ -10,18 +10,13 @@ import org.mozilla.gecko.R;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; 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.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.ImageView.ScaleType; 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. * 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. // Empty state, to denote there is no valid url.
private static final int[] STATE_EMPTY = { android.R.attr.state_empty }; 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. // Child views.
private final TextView mTitleView; private final TextView mTitleView;
private final ImageView mThumbnailView; private final ImageView mThumbnailView;
private final ImageView mPinView;
// Data backing this view. // Data backing this view.
private String mTitle; private String mTitle;
@ -68,7 +59,6 @@ public class TopBookmarkItemView extends RelativeLayout {
mTitleView = (TextView) findViewById(R.id.title); mTitleView = (TextView) findViewById(R.id.title);
mThumbnailView = (ImageView) findViewById(R.id.thumbnail); 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) { public void setPinned(boolean pinned) {
mIsPinned = 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. // Refresh for state change.
refreshDrawableState(); 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;
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

View File

@ -9,23 +9,15 @@
<org.mozilla.gecko.home.BookmarkThumbnailView <org.mozilla.gecko.home.BookmarkThumbnailView
android:id="@+id/thumbnail" android:id="@+id/thumbnail"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"/>
android:layout_alignParentTop="true"/>
<org.mozilla.gecko.home.FadedTextView <org.mozilla.gecko.home.FadedTextView
android:id="@+id/title" android:id="@+id/title"
style="@style/Widget.TopBookmarkItemTitle" style="@style/Widget.TopBookmarkItemTitle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/thumbnail"
android:duplicateParentState="true" android:duplicateParentState="true"
android:drawablePadding="4dip"
gecko:fadeWidth="20dip"/> gecko:fadeWidth="20dip"/>
<ImageView android:id="@+id/pin"
style="@style/Widget.TopBookmarkItemPin"
android:layout_width="@dimen/top_bookmark_pinsize"
android:layout_height="@dimen/top_bookmark_pinsize"
android:layout_alignTop="@id/thumbnail"
android:layout_alignRight="@id/thumbnail"/>
</merge> </merge>

View File

@ -75,7 +75,6 @@
<color name="suggestion_primary">#dddddd</color> <color name="suggestion_primary">#dddddd</color>
<color name="suggestion_pressed">#bbbbbb</color> <color name="suggestion_pressed">#bbbbbb</color>
<color name="tab_row_pressed">#4D000000</color> <color name="tab_row_pressed">#4D000000</color>
<color name="top_bookmark_pin">#55000000</color>
<color name="dialogtitle_textcolor">#ffffff</color> <color name="dialogtitle_textcolor">#ffffff</color>
<color name="textbox_background">#FFF</color> <color name="textbox_background">#FFF</color>

View File

@ -71,7 +71,6 @@
<dimen name="text_selection_handle_width">47dp</dimen> <dimen name="text_selection_handle_width">47dp</dimen>
<dimen name="text_selection_handle_height">58dp</dimen> <dimen name="text_selection_handle_height">58dp</dimen>
<dimen name="text_selection_handle_shadow">11dp</dimen> <dimen name="text_selection_handle_shadow">11dp</dimen>
<dimen name="top_bookmark_pinsize">20dp</dimen>
<dimen name="validation_message_height">50dp</dimen> <dimen name="validation_message_height">50dp</dimen>
<dimen name="validation_message_margin_top">6dp</dimen> <dimen name="validation_message_margin_top">6dp</dimen>
<dimen name="forward_default_offset">-13dip</dimen> <dimen name="forward_default_offset">-13dip</dimen>