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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/history/HistoryItemView.java

Issue 2703463002: [List UI Unification] Basic list unification for phones (Closed)
Patch Set: [List UI Unification] Basic list unification for phones Created 3 years, 10 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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.history; 5 package org.chromium.chrome.browser.history;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.graphics.drawable.BitmapDrawable; 9 import android.graphics.drawable.BitmapDrawable;
10 import android.support.graphics.drawable.VectorDrawableCompat; 10 import android.support.graphics.drawable.VectorDrawableCompat;
11 import android.support.v4.graphics.drawable.RoundedBitmapDrawable; 11 import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
12 import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory; 12 import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
13 import android.util.AttributeSet; 13 import android.util.AttributeSet;
14 import android.view.View; 14 import android.view.View;
15 import android.widget.ImageView; 15 import android.widget.ImageView;
16 import android.widget.TextView; 16 import android.widget.TextView;
17 17
18 import org.chromium.base.ApiCompatibilityUtils; 18 import org.chromium.base.ApiCompatibilityUtils;
19 import org.chromium.chrome.R; 19 import org.chromium.chrome.R;
20 import org.chromium.chrome.browser.favicon.LargeIconBridge.LargeIconCallback; 20 import org.chromium.chrome.browser.favicon.LargeIconBridge.LargeIconCallback;
21 import org.chromium.chrome.browser.preferences.PrefServiceBridge; 21 import org.chromium.chrome.browser.preferences.PrefServiceBridge;
22 import org.chromium.chrome.browser.widget.RoundedIconGenerator; 22 import org.chromium.chrome.browser.widget.RoundedIconGenerator;
23 import org.chromium.chrome.browser.widget.TintedImageButton; 23 import org.chromium.chrome.browser.widget.TintedImageButton;
24 import org.chromium.chrome.browser.widget.displaystyle.MarginResizer; 24 import org.chromium.chrome.browser.widget.displaystyle.MarginResizer;
25 import org.chromium.chrome.browser.widget.selection.SelectableItemView; 25 import org.chromium.chrome.browser.widget.selection.SelectableItemView;
26 import org.chromium.chrome.browser.widget.selection.SelectableListLayout;
26 27
27 /** 28 /**
28 * The SelectableItemView for items displayed in the browsing history UI. 29 * The SelectableItemView for items displayed in the browsing history UI.
29 */ 30 */
30 public class HistoryItemView extends SelectableItemView<HistoryItem> implements LargeIconCallback { 31 public class HistoryItemView extends SelectableItemView<HistoryItem> implements LargeIconCallback {
31 private TextView mTitle; 32 private TextView mTitle;
32 private TextView mDomain; 33 private TextView mDomain;
33 private TintedImageButton mRemoveButton; 34 private TintedImageButton mRemoveButton;
34 private ImageView mIconImageView; 35 private ImageView mIconImageView;
35 private VectorDrawableCompat mBlockedVisitDrawable; 36 private VectorDrawableCompat mBlockedVisitDrawable;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 */ 121 */
121 public void setHistoryManager(HistoryManager manager) { 122 public void setHistoryManager(HistoryManager manager) {
122 getItem().setHistoryManager(manager); 123 getItem().setHistoryManager(manager);
123 if (mHistoryManager == manager) return; 124 if (mHistoryManager == manager) return;
124 125
125 mHistoryManager = manager; 126 mHistoryManager = manager;
126 if (!getItem().wasBlockedVisit()) requestIcon(); 127 if (!getItem().wasBlockedVisit()) requestIcon();
127 128
128 MarginResizer.createWithViewAdapter(this, 129 MarginResizer.createWithViewAdapter(this,
129 mHistoryManager.getSelectableListLayout().getUiConfig(), 130 mHistoryManager.getSelectableListLayout().getUiConfig(),
130 mHistoryManager.getDefaultLateralListItemMarginPx(), 0); 131 SelectableListLayout.getDefaultListItemLateralMarginPx(getResour ces()), 0);
131 } 132 }
132 133
133 /** 134 /**
134 * Removes the item associated with this view. 135 * Removes the item associated with this view.
135 */ 136 */
136 public void remove() { 137 public void remove() {
137 // If the remove button is double tapped, this method may be called twic e. 138 // If the remove button is double tapped, this method may be called twic e.
138 if (getItem() == null || mIsItemRemoved) return; 139 if (getItem() == null || mIsItemRemoved) return;
139 140
140 mIsItemRemoved = true; 141 mIsItemRemoved = true;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 int endPadding = removeButtonVisibility == View.GONE ? mEndPadding : 0; 197 int endPadding = removeButtonVisibility == View.GONE ? mEndPadding : 0;
197 ApiCompatibilityUtils.setPaddingRelative(mContentView, 198 ApiCompatibilityUtils.setPaddingRelative(mContentView,
198 ApiCompatibilityUtils.getPaddingStart(mContentView), 199 ApiCompatibilityUtils.getPaddingStart(mContentView),
199 mContentView.getPaddingTop(), endPadding, mContentView.getPaddin gBottom()); 200 mContentView.getPaddingTop(), endPadding, mContentView.getPaddin gBottom());
200 } 201 }
201 202
202 /** 203 /**
203 * Sets the background resource for this view using the item's positioning i n its group. 204 * Sets the background resource for this view using the item's positioning i n its group.
204 */ 205 */
205 public void setBackgroundResourceForGroupPosition() { 206 public void setBackgroundResourceForGroupPosition() {
206 int backgroundResource; 207 setBackgroundResourceForGroupPosition(
207 208 getItem().isFirstInGroup(), getItem().isLastInGroup());
208 boolean isLastInGroup = getItem().isLastInGroup();
209 boolean isFirstInGroup = getItem().isFirstInGroup();
210 if (!isLastInGroup && !isFirstInGroup) {
211 backgroundResource = R.drawable.list_item_middle;
212 } else if (!isLastInGroup) {
213 backgroundResource = R.drawable.list_item_top;
214 } else if (!isFirstInGroup) {
215 backgroundResource = R.drawable.list_item_bottom;
216 } else {
217 backgroundResource = R.drawable.list_item_single;
218 }
219
220 setBackgroundResource(backgroundResource);
221 } 209 }
222 } 210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698