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

Side by Side 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 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.enhancedbookmarks;
6
7 import android.content.Context;
8 import android.graphics.drawable.Drawable;
9 import android.graphics.drawable.LayerDrawable;
10 import android.util.AttributeSet;
11 import android.view.View;
12 import android.widget.Checkable;
13
14 import com.google.android.apps.chrome.R;
15
16 import org.chromium.base.ApiCompatibilityUtils;
17
18 /**
19 * Highlight overlay view for items on the main grid.
20 */
21 public class EnhancedBookmarkItemHighlightView extends View implements Checkable {
22 public static final int ANIMATION_DURATION_MS = 150;
23 private static final int[] CHECKED_STATE_SET = {android.R.attr.state_checked };
24 private boolean mIsChecked;
25
26 /**
27 * Constructor for inflating from XML.
28 */
29 public EnhancedBookmarkItemHighlightView(Context context, AttributeSet attrs ) {
30 super(context, attrs);
31 Drawable clickDrawable = context.obtainStyledAttributes(new int[] {
32 android.R.attr.selectableItemBackground }).getDrawable(0);
33 Drawable longClickDrawable = ApiCompatibilityUtils.getDrawable(context.g etResources(),
34 R.drawable.eb_item_highlight);
35 LayerDrawable ld = new LayerDrawable(new Drawable[] {clickDrawable, long ClickDrawable});
36 setBackground(ld);
37 }
38
39 @Override
40 public boolean isChecked() {
41 return mIsChecked;
42 }
43
44 @Override
45 public void toggle() {
46 setChecked(!mIsChecked);
47 }
48
49 @Override
50 public void setChecked(boolean checked) {
51 if (checked == mIsChecked) return;
52 mIsChecked = checked;
53 refreshDrawableState();
54 }
55
56 @Override
57 public int[] onCreateDrawableState(int extraSpace) {
58 final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
59 if (mIsChecked) {
60 mergeDrawableStates(drawableState, CHECKED_STATE_SET);
61 }
62 return drawableState;
63 }
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698