Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(584)

Side by Side Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IconMostVisitedItemView.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.ntp;
6
7 import android.content.Context;
8 import android.graphics.Canvas;
9 import android.graphics.Paint;
10 import android.graphics.RectF;
11 import android.graphics.drawable.Drawable;
12 import android.util.AttributeSet;
13 import android.widget.FrameLayout;
14 import android.widget.ImageView;
15 import android.widget.TextView;
16
17 import com.google.android.apps.chrome.R;
18
19 /**
20 * A new-fangled most visited item. Displays the title of the page beneath a lar ge icon. If a large
21 * icon isn't available, displays a rounded rectangle with a single letter in it s place.
22 */
23 public class IconMostVisitedItemView extends FrameLayout {
24
25 private static final int HIGHLIGHT_COLOR = 0x550099cc;
26
27 private boolean mLastDrawnPressed;
28
29 /**
30 * Constructor for inflating from XML.
31 */
32 public IconMostVisitedItemView(Context context, AttributeSet attrs) {
33 super(context, attrs);
34 }
35
36 /**
37 * Sets the title text.
38 */
39 public void setTitle(String title) {
40 ((TextView) findViewById(R.id.most_visited_title)).setText(title);
41 }
42
43 /**
44 * Sets the icon.
45 */
46 public void setIcon(Drawable icon) {
47 ImageView iconView = (ImageView) findViewById(R.id.most_visited_icon);
48 iconView.setImageDrawable(icon);
49 }
50
51 @Override
52 public void setPressed(boolean pressed) {
53 super.setPressed(pressed);
54 if (isPressed() != mLastDrawnPressed) invalidate();
55 }
56
57 @Override
58 protected void dispatchDraw(Canvas canvas) {
59 super.dispatchDraw(canvas);
60
61 // Draw highlight overlay over the child views when this view is pressed .
62 if (isPressed()) {
63 Paint highlightPaint = new Paint();
64 highlightPaint.setColor(HIGHLIGHT_COLOR);
65 highlightPaint.setAntiAlias(true);
66 RectF highlightRect = new RectF(0, 0, getWidth(), getHeight());
67 int cornerRadius = getResources().getDimensionPixelOffset(
68 R.dimen.most_visited_bg_corner_radius);
69 canvas.drawRoundRect(highlightRect, cornerRadius, cornerRadius, high lightPaint);
70 }
71 mLastDrawnPressed = isPressed();
72 }
73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698