OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.bookmarks; | 5 package org.chromium.chrome.browser.bookmarks; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.util.AttributeSet; | 8 import android.util.AttributeSet; |
9 import android.view.View; | 9 import android.view.View; |
10 import android.view.ViewGroup; | 10 import android.view.ViewGroup; |
11 import android.widget.AdapterView; | 11 import android.widget.AdapterView; |
12 import android.widget.AdapterView.OnItemClickListener; | 12 import android.widget.AdapterView.OnItemClickListener; |
13 import android.widget.ArrayAdapter; | 13 import android.widget.ArrayAdapter; |
14 import android.widget.ImageView; | 14 import android.widget.ImageView; |
15 import android.widget.ListPopupWindow; | 15 import android.widget.ListPopupWindow; |
16 import android.widget.TextView; | 16 import android.widget.TextView; |
17 | 17 |
18 import org.chromium.chrome.R; | 18 import org.chromium.chrome.R; |
19 import org.chromium.chrome.browser.bookmarks.BookmarkBridge.BookmarkItem; | 19 import org.chromium.chrome.browser.bookmarks.BookmarkBridge.BookmarkItem; |
20 import org.chromium.chrome.browser.widget.TintedImageButton; | 20 import org.chromium.chrome.browser.widget.TintedImageButton; |
21 import org.chromium.chrome.browser.widget.selection.SelectableItemView; | 21 import org.chromium.chrome.browser.widget.selection.SelectableItemView; |
22 import org.chromium.components.bookmarks.BookmarkId; | 22 import org.chromium.components.bookmarks.BookmarkId; |
| 23 import org.chromium.ui.base.DeviceFormFactor; |
23 | 24 |
24 import java.util.List; | 25 import java.util.List; |
25 | 26 |
26 /** | 27 /** |
27 * Common logic for bookmark and folder rows. | 28 * Common logic for bookmark and folder rows. |
28 */ | 29 */ |
29 abstract class BookmarkRow extends SelectableItemView<BookmarkId> implements Boo
kmarkUIObserver { | 30 abstract class BookmarkRow extends SelectableItemView<BookmarkId> implements Boo
kmarkUIObserver { |
30 | 31 |
31 protected ImageView mIconImageView; | 32 protected ImageView mIconImageView; |
32 protected TextView mTitleView; | 33 protected TextView mTitleView; |
33 protected TintedImageButton mMoreIcon; | 34 protected TintedImageButton mMoreIcon; |
34 | 35 |
35 protected BookmarkDelegate mDelegate; | 36 protected BookmarkDelegate mDelegate; |
36 protected BookmarkId mBookmarkId; | 37 protected BookmarkId mBookmarkId; |
37 private ListPopupWindow mPopupMenu; | 38 private ListPopupWindow mPopupMenu; |
38 private boolean mIsAttachedToWindow; | 39 private boolean mIsAttachedToWindow; |
| 40 private boolean mShouldUseListItemBackground; |
39 | 41 |
40 /** | 42 /** |
41 * Constructor for inflating from XML. | 43 * Constructor for inflating from XML. |
42 */ | 44 */ |
43 public BookmarkRow(Context context, AttributeSet attrs) { | 45 public BookmarkRow(Context context, AttributeSet attrs) { |
44 super(context, attrs); | 46 super(context, attrs); |
45 } | 47 } |
46 | 48 |
47 /** | 49 /** |
48 * Updates this row for the given {@link BookmarkId}. | 50 * Updates this row for the given {@link BookmarkId}. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 if (isSelectable()) { | 181 if (isSelectable()) { |
180 mMoreIcon = (TintedImageButton) findViewById(R.id.more); | 182 mMoreIcon = (TintedImageButton) findViewById(R.id.more); |
181 mMoreIcon.setVisibility(VISIBLE); | 183 mMoreIcon.setVisibility(VISIBLE); |
182 mMoreIcon.setOnClickListener(new OnClickListener() { | 184 mMoreIcon.setOnClickListener(new OnClickListener() { |
183 @Override | 185 @Override |
184 public void onClick(View view) { | 186 public void onClick(View view) { |
185 showMenu(view); | 187 showMenu(view); |
186 } | 188 } |
187 }); | 189 }); |
188 } | 190 } |
| 191 |
| 192 // TODO(twellington): remove this after the bookmarks 720dp layout is re
styled |
| 193 // to match the < 720dp style and BookmarkSearchView
is refactored. |
| 194 // Currently BookmarkSearchRow extends BookmarkRow bu
t is not selectable. |
| 195 mShouldUseListItemBackground = |
| 196 isSelectable() && !DeviceFormFactor.isLargeTablet(getContext()); |
| 197 |
| 198 // TODO(twellington): Replace this with a MarginResizer after the bookma
rks layout is width |
| 199 // constrained to 600dp. |
| 200 if (mShouldUseListItemBackground) { |
| 201 setLateralMarginsForDefaultDisplay(findViewById(R.id.bookmark_row)); |
| 202 } |
189 } | 203 } |
190 | 204 |
191 @Override | 205 @Override |
192 protected void onAttachedToWindow() { | 206 protected void onAttachedToWindow() { |
193 super.onAttachedToWindow(); | 207 super.onAttachedToWindow(); |
194 mIsAttachedToWindow = true; | 208 mIsAttachedToWindow = true; |
195 if (mDelegate != null) { | 209 if (mDelegate != null) { |
196 initialize(); | 210 initialize(); |
197 } | 211 } |
198 } | 212 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 259 |
246 @Override | 260 @Override |
247 public void onDestroy() { | 261 public void onDestroy() { |
248 cleanup(); | 262 cleanup(); |
249 } | 263 } |
250 | 264 |
251 @Override | 265 @Override |
252 public void onFolderStateSet(BookmarkId folder) { | 266 public void onFolderStateSet(BookmarkId folder) { |
253 } | 267 } |
254 | 268 |
| 269 @Override |
| 270 public void setBackgroundResourceForGroupPosition( |
| 271 boolean isFirstInGroup, boolean isLastInGroup) { |
| 272 if (!mShouldUseListItemBackground) return; |
| 273 super.setBackgroundResourceForGroupPosition(isFirstInGroup, isLastInGrou
p); |
| 274 } |
255 } | 275 } |
OLD | NEW |