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

Side by Side Diff: ui/android/java/src/org/chromium/ui/DropdownDividerDrawable.java

Issue 2531223003: Expanded Autofill Credit Card Popup Layout Experiment in Android. (Closed)
Patch Set: Fixes compile error. Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.ui; 5 package org.chromium.ui;
6 6
7 import android.graphics.Canvas; 7 import android.graphics.Canvas;
8 import android.graphics.ColorFilter; 8 import android.graphics.ColorFilter;
9 import android.graphics.Paint; 9 import android.graphics.Paint;
10 import android.graphics.PixelFormat; 10 import android.graphics.PixelFormat;
11 import android.graphics.Rect; 11 import android.graphics.Rect;
12 import android.graphics.drawable.Drawable; 12 import android.graphics.drawable.Drawable;
13 13
14 class DropdownDividerDrawable extends Drawable { 14 class DropdownDividerDrawable extends Drawable {
15 15
16 private Paint mPaint; 16 private final Paint mPaint;
17 private Rect mDividerRect; 17 private final Rect mDividerRect;
18 private final Integer mBackgroundColor;
18 19
19 public DropdownDividerDrawable() { 20 /**
21 * Creates a drawable to draw a divider line that separates the list of {@li nk DropdownItem}
22 * and, optionally, paints the rectangular canvas.
23 * @param backgroundColor Popup background color. If {@code null}, does not paint the canvas.
24 */
25 public DropdownDividerDrawable(Integer backgroundColor) {
20 mPaint = new Paint(); 26 mPaint = new Paint();
21 mDividerRect = new Rect(); 27 mDividerRect = new Rect();
28 mBackgroundColor = backgroundColor;
22 } 29 }
23 30
24 @Override 31 @Override
25 public void draw(Canvas canvas) { 32 public void draw(Canvas canvas) {
33 if (mBackgroundColor != null) canvas.drawColor(mBackgroundColor);
26 canvas.drawRect(mDividerRect, mPaint); 34 canvas.drawRect(mDividerRect, mPaint);
27 } 35 }
28 36
29 @Override 37 @Override
30 public void onBoundsChange(Rect bounds) { 38 public void onBoundsChange(Rect bounds) {
31 mDividerRect.set(0, 0, bounds.width(), mDividerRect.height()); 39 mDividerRect.set(0, 0, bounds.width(), mDividerRect.height());
32 } 40 }
33 41
34 public void setHeight(int height) { 42 public void setHeight(int height) {
35 mDividerRect.set(0, 0, mDividerRect.right, height); 43 mDividerRect.set(0, 0, mDividerRect.right, height);
36 } 44 }
37 45
38 public void setColor(int color) { 46 public void setDividerColor(int color) {
39 mPaint.setColor(color); 47 mPaint.setColor(color);
40 } 48 }
41 49
42 @Override 50 @Override
43 public void setAlpha(int alpha) { 51 public void setAlpha(int alpha) {
44 } 52 }
45 53
46 @Override 54 @Override
47 public void setColorFilter(ColorFilter cf) { 55 public void setColorFilter(ColorFilter cf) {
48 } 56 }
49 57
50 @Override 58 @Override
51 public int getOpacity() { 59 public int getOpacity() {
52 return PixelFormat.TRANSPARENT; 60 return PixelFormat.TRANSPARENT;
53 } 61 }
54 } 62 }
OLDNEW
« no previous file with comments | « ui/android/java/src/org/chromium/ui/DropdownAdapter.java ('k') | ui/android/java/src/org/chromium/ui/DropdownItem.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698