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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorIconsField.java

Issue 2163693002: [Merge M-53] Credit card editor for PaymentRequest UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 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
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorIconsField.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorIconsField.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorIconsField.java
new file mode 100644
index 0000000000000000000000000000000000000000..cc531029429101ce7fe582608b94a9e8fc912306
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorIconsField.java
@@ -0,0 +1,58 @@
+// Copyright 2016 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.chrome.browser.payments.ui;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import org.chromium.chrome.R;
+
+/**
+ * Helper class for creating a horizontal list of icons with a title.
+ */
+class EditorIconsField {
+ private final View mLayout;
+
+ /**
+ * Builds a horizontal list of icons.
+ *
+ * @param context The application context to use when creating widgets.
+ * @param root The object that provides a set of LayoutParams values for the view.
+ * @param fieldModel The data model of the icon list.
+ */
+ public EditorIconsField(Context context, ViewGroup root, EditorFieldModel fieldModel) {
+ assert fieldModel.getInputTypeHint() == EditorFieldModel.INPUT_TYPE_HINT_ICONS;
+
+ mLayout = LayoutInflater.from(context).inflate(
+ R.layout.payment_request_editor_icons, root, false);
+
+ ((TextView) mLayout.findViewById(R.id.label)).setText(fieldModel.getLabel());
+
+ LinearLayout container = (LinearLayout) mLayout.findViewById(R.id.icons_container);
+ int size = context.getResources().getDimensionPixelSize(
+ R.dimen.payments_editor_icon_list_size);
+ for (int i = 0; i < fieldModel.getIconResourceIds().size(); i++) {
+ ImageView icon = new ImageView(context);
+ icon.setImageResource(fieldModel.getIconResourceIds().get(i));
+ icon.setContentDescription(context.getString(
+ fieldModel.getIconDescriptionsForAccessibility().get(i)));
+ icon.setAdjustViewBounds(true);
+ icon.setMaxWidth(size);
+ icon.setMaxHeight(size);
+ container.addView(icon, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ }
+ }
+
+ /** @return The View containing everything. */
+ public View getLayout() {
+ return mLayout;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698