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

Unified Diff: ui/android/java/src/org/chromium/ui/HorizontalListDividerDrawable.java

Issue 2748793003: [Payments] Remove toggle of Android payment apps in settings (Closed)
Patch Set: keep the text Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/android/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/java/src/org/chromium/ui/HorizontalListDividerDrawable.java
diff --git a/ui/android/java/src/org/chromium/ui/HorizontalListDividerDrawable.java b/ui/android/java/src/org/chromium/ui/HorizontalListDividerDrawable.java
new file mode 100644
index 0000000000000000000000000000000000000000..5d31e1e3dcf88376827a18a5805ca382c65f4585
--- /dev/null
+++ b/ui/android/java/src/org/chromium/ui/HorizontalListDividerDrawable.java
@@ -0,0 +1,43 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.ui;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LayerDrawable;
+
+/**
+ * Draws a horizontal list divider line at the bottom of its drawing area.
+ *
+ * Because ?android:attr/listDivider may be a 9-patch, there's no way to achieve this drawing
+ * effect with the platform Drawable classes; hence this custom Drawable.
+ */
+public class HorizontalListDividerDrawable extends LayerDrawable {
+ /**
+ * Create a horizontal list divider drawable.
+ *
+ * @param context The context used to create drawable.
+ * @return The drawable.
+ */
+ public static HorizontalListDividerDrawable create(Context context) {
+ TypedArray a = context.obtainStyledAttributes(new int[] {android.R.attr.listDivider});
+ Drawable listDivider = a.getDrawable(0);
+ a.recycle();
+ return new HorizontalListDividerDrawable(new Drawable[] {listDivider});
+ }
+
+ private HorizontalListDividerDrawable(Drawable[] layers) {
+ super(layers);
+ }
+
+ @Override
+ protected void onBoundsChange(Rect bounds) {
+ int listDividerHeight = getDrawable(0).getIntrinsicHeight();
+ setLayerInset(0, 0, bounds.height() - listDividerHeight, 0, 0);
+ super.onBoundsChange(bounds);
+ }
+}
« no previous file with comments | « ui/android/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698