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

Side by Side Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkFolder.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.annotation.SuppressLint;
8 import android.content.Context;
9 import android.graphics.BitmapFactory;
10 import android.graphics.drawable.BitmapDrawable;
11 import android.util.AttributeSet;
12 import android.view.View;
13 import android.widget.FrameLayout;
14 import android.widget.TextView;
15
16 import com.google.android.apps.chrome.R;
17
18 import org.chromium.base.ApiCompatibilityUtils;
19 import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkItemsAdapte r.BookmarkGrid;
20 import org.chromium.chrome.browser.widget.CustomShapeDrawable.DarkBackgroundCirc ularDrawable;
21 import org.chromium.chrome.browser.widget.TintedDrawable;
22 import org.chromium.components.bookmarks.BookmarkId;
23
24 /**
25 * A view that shows a bookmark folder's title, in the enhanced bookmarks UI.
26 */
27 abstract class EnhancedBookmarkFolder extends FrameLayout implements BookmarkGri d {
28
29 @SuppressLint("Instantiatable")
30 static class EnhancedBookmarkListFolder extends EnhancedBookmarkFolder {
31 public EnhancedBookmarkListFolder(Context context, AttributeSet attrs) {
32 super(context, attrs);
33 }
34
35 @Override
36 protected void setupIcon() {
37 DarkBackgroundCircularDrawable icon = new DarkBackgroundCircularDraw able(
38 BitmapFactory.decodeResource(getResources(), R.drawable.eb_f older));
39 int size = getResources().getDimensionPixelSize(
40 R.dimen.enhanced_bookmark_folder_item_icon_size);
41 icon.setBounds(0, 0, size, size);
42 ApiCompatibilityUtils.setCompoundDrawablesRelative(mTitle, icon, nul l, null, null);
43 }
44 }
45
46 @SuppressLint("Instantiatable")
47 static class EnhancedBookmarkGridFolder extends EnhancedBookmarkFolder {
48 public EnhancedBookmarkGridFolder(Context context, AttributeSet attrs) {
49 super(context, attrs);
50 }
51
52 @Override
53 protected void setupIcon() {
54 BitmapDrawable icon = TintedDrawable.constructTintedDrawable(
55 getResources(), R.drawable.eb_folder);
56 ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBound s(
57 mTitle, icon, null, null, null);
58 }
59 }
60
61 private BookmarkId mBookmarkId;
62 private EnhancedBookmarkItemHighlightView mHighlightView;
63 private EnhancedBookmarkDelegate mDelegate;
64 protected TextView mTitle;
65
66 /**
67 * Constructor for inflating from XML.
68 */
69 public EnhancedBookmarkFolder(Context context, AttributeSet attrs) {
70 super(context, attrs);
71 }
72
73 @Override
74 protected void onFinishInflate() {
75 super.onFinishInflate();
76 mHighlightView = (EnhancedBookmarkItemHighlightView) findViewById(R.id.h ighlight);
77 mTitle = (TextView) findViewById(R.id.title);
78 setupIcon();
79 }
80
81 protected abstract void setupIcon();
82
83 @Override
84 public void setBookmarkId(BookmarkId bookmarkId) {
85 mBookmarkId = bookmarkId;
86 mTitle.setText(mDelegate.getModel().getBookmarkTitle(bookmarkId));
87 }
88
89 @Override
90 public BookmarkId getBookmarkId() {
91 return mBookmarkId;
92 }
93
94 /**
95 * Sets the delegate the folder holds.
96 */
97 void setDelegate(EnhancedBookmarkDelegate delegate) {
98 mDelegate = delegate;
99 }
100
101 @Override
102 public boolean isChecked() {
103 return mHighlightView.isChecked();
104 }
105
106 @Override
107 public void toggle() {
108 setChecked(!isChecked());
109 }
110
111 @Override
112 public void setChecked(boolean checked) {
113 mHighlightView.setChecked(checked);
114 }
115
116 @Override
117 public void onClick(View v) {
118 mDelegate.openFolder(mBookmarkId);
119 }
120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698