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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkItemHighlightView.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/enhancedbookmarks/EnhancedBookmarkItemHighlightView.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkItemHighlightView.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkItemHighlightView.java
new file mode 100644
index 0000000000000000000000000000000000000000..0ba9c26a856589abbbf77a4f40e30a9649629358
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkItemHighlightView.java
@@ -0,0 +1,64 @@
+// 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.enhancedbookmarks;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LayerDrawable;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.Checkable;
+
+import com.google.android.apps.chrome.R;
+
+import org.chromium.base.ApiCompatibilityUtils;
+
+/**
+ * Highlight overlay view for items on the main grid.
+ */
+public class EnhancedBookmarkItemHighlightView extends View implements Checkable {
+ public static final int ANIMATION_DURATION_MS = 150;
+ private static final int[] CHECKED_STATE_SET = {android.R.attr.state_checked};
+ private boolean mIsChecked;
+
+ /**
+ * Constructor for inflating from XML.
+ */
+ public EnhancedBookmarkItemHighlightView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ Drawable clickDrawable = context.obtainStyledAttributes(new int[] {
+ android.R.attr.selectableItemBackground }).getDrawable(0);
+ Drawable longClickDrawable = ApiCompatibilityUtils.getDrawable(context.getResources(),
+ R.drawable.eb_item_highlight);
+ LayerDrawable ld = new LayerDrawable(new Drawable[] {clickDrawable, longClickDrawable});
+ setBackground(ld);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return mIsChecked;
+ }
+
+ @Override
+ public void toggle() {
+ setChecked(!mIsChecked);
+ }
+
+ @Override
+ public void setChecked(boolean checked) {
+ if (checked == mIsChecked) return;
+ mIsChecked = checked;
+ refreshDrawableState();
+ }
+
+ @Override
+ public int[] onCreateDrawableState(int extraSpace) {
+ final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
+ if (mIsChecked) {
+ mergeDrawableStates(drawableState, CHECKED_STATE_SET);
+ }
+ return drawableState;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698