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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AndroidPaymentAppsFragment.java

Issue 2647573005: [Payments] Allow users enable and disable Android payment apps in payment request (Closed)
Patch Set: rename Created 3 years, 11 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/preferences/autofill/AndroidPaymentAppsFragment.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AndroidPaymentAppsFragment.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AndroidPaymentAppsFragment.java
new file mode 100644
index 0000000000000000000000000000000000000000..d02492bf7241302d758f0564670ea618ed1ddc50
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/autofill/AndroidPaymentAppsFragment.java
@@ -0,0 +1,62 @@
+// 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.chrome.browser.preferences.autofill;
+
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+import android.util.Pair;
+
+import org.chromium.chrome.R;
+import org.chromium.chrome.browser.payments.AndroidPaymentAppFactory;
+import org.chromium.chrome.browser.payments.PaymentPreferencesUtil;
+import org.chromium.chrome.browser.preferences.TextMessagePreference;
+
+import java.util.Map;
+
+/**
+ * Preference fragment to allow users to control use of the Android payment apps on device.
+ */
+public class AndroidPaymentAppsFragment extends PreferenceFragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.autofill_and_payments_preference_fragment_screen);
+ getActivity().setTitle(R.string.payment_apps_title);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ rebuildPaymentAppsList();
+ }
+
+ private void rebuildPaymentAppsList() {
+ getPreferenceScreen().removeAll();
+ getPreferenceScreen().setOrderingAsAdded(true);
+
+ Map<String, Pair<String, Drawable>> appsInfo =
+ AndroidPaymentAppFactory.getAndroidPaymentAppsInfo();
+ if (appsInfo.isEmpty()) return;
+
+ AndroidPaymentAppPreference pref = null;
+ for (Map.Entry<String, Pair<String, Drawable>> app : appsInfo.entrySet()) {
+ pref = new AndroidPaymentAppPreference(getActivity());
+ pref.setTitle(app.getValue().first);
+ pref.setIcon(app.getValue().second);
+ pref.setDefaultValue(true);
+ pref.setKey(
+ PaymentPreferencesUtil.getAndroidPaymentAppEnabledPreferenceKey(app.getKey()));
+ getPreferenceScreen().addPreference(pref);
+ }
+ // Add a divider line at the bottom of the last preference to separate it from below
+ // TextMessagePreference.
+ if (pref != null) pref.setDrawDivider(true);
+
+ TextMessagePreference textPreference = new TextMessagePreference(getActivity(), null);
+ textPreference.setTitle(getActivity().getString(R.string.payment_apps_control_message));
+ getPreferenceScreen().addPreference(textPreference);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698