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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IconMostVisitedItemView.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IconMostVisitedItemView.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IconMostVisitedItemView.java
new file mode 100644
index 0000000000000000000000000000000000000000..510406125fc4d5c4f3174d8c096deefda1fa8890
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/ntp/IconMostVisitedItemView.java
@@ -0,0 +1,73 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.ntp;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.RectF;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.google.android.apps.chrome.R;
+
+/**
+ * A new-fangled most visited item. Displays the title of the page beneath a large icon. If a large
+ * icon isn't available, displays a rounded rectangle with a single letter in its place.
+ */
+public class IconMostVisitedItemView extends FrameLayout {
+
+ private static final int HIGHLIGHT_COLOR = 0x550099cc;
+
+ private boolean mLastDrawnPressed;
+
+ /**
+ * Constructor for inflating from XML.
+ */
+ public IconMostVisitedItemView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ /**
+ * Sets the title text.
+ */
+ public void setTitle(String title) {
+ ((TextView) findViewById(R.id.most_visited_title)).setText(title);
+ }
+
+ /**
+ * Sets the icon.
+ */
+ public void setIcon(Drawable icon) {
+ ImageView iconView = (ImageView) findViewById(R.id.most_visited_icon);
+ iconView.setImageDrawable(icon);
+ }
+
+ @Override
+ public void setPressed(boolean pressed) {
+ super.setPressed(pressed);
+ if (isPressed() != mLastDrawnPressed) invalidate();
+ }
+
+ @Override
+ protected void dispatchDraw(Canvas canvas) {
+ super.dispatchDraw(canvas);
+
+ // Draw highlight overlay over the child views when this view is pressed.
+ if (isPressed()) {
+ Paint highlightPaint = new Paint();
+ highlightPaint.setColor(HIGHLIGHT_COLOR);
+ highlightPaint.setAntiAlias(true);
+ RectF highlightRect = new RectF(0, 0, getWidth(), getHeight());
+ int cornerRadius = getResources().getDimensionPixelOffset(
+ R.dimen.most_visited_bg_corner_radius);
+ canvas.drawRoundRect(highlightRect, cornerRadius, cornerRadius, highlightPaint);
+ }
+ mLastDrawnPressed = isPressed();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698