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

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

Issue 2423173002: [PaymentRequest] Persistent 'save card to device' checkbox status (Closed)
Patch Set: address comments Created 4 years, 2 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 | « chrome/android/java/src/org/chromium/chrome/browser/payments/CardEditor.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorFieldModel.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorFieldModel.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorFieldModel.java
index 38de271c0f0b5a99745b08bc016fca59c57c6921..c299f081a92d33bb59c43d224602aef2a68fa412 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorFieldModel.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorFieldModel.java
@@ -8,6 +8,7 @@ import android.text.TextUtils;
import android.util.Pair;
import org.chromium.base.Callback;
+import org.chromium.base.ContextUtils;
import org.chromium.chrome.browser.preferences.autofill.AutofillProfileBridge.DropdownKeyValue;
import java.util.ArrayList;
@@ -109,7 +110,6 @@ public class EditorFieldModel {
private int mLabelIconResourceId;
private int mActionIconResourceId;
private int mActionDescriptionForAccessibility;
- private boolean mIsChecked = false;
private boolean mIsFullLine = true;
/**
@@ -139,14 +139,18 @@ public class EditorFieldModel {
}
/**
- * Constructs a checkbox to show in the editor. It's unchecked by default.
+ * Constructs a checkbox to show in the editor. It's checked by default.
*
- * @param checkboxLabel The label for the checkbox.
+ * @param checkboxLabel The label for the checkbox.
+ * @param checkboxPreference The shared preference for the checkbox status.
*/
- public static EditorFieldModel createCheckbox(CharSequence checkboxLabel) {
+ public static EditorFieldModel createCheckbox(
+ CharSequence checkboxLabel, CharSequence checkboxPreference) {
assert checkboxLabel != null;
+ assert checkboxPreference != null;
EditorFieldModel result = new EditorFieldModel(INPUT_TYPE_HINT_CHECKBOX);
result.mLabel = checkboxLabel;
+ result.mValue = checkboxPreference;
return result;
}
@@ -288,13 +292,16 @@ public class EditorFieldModel {
/** @return Whether the checkbox is checked. */
public boolean isChecked() {
assert mInputTypeHint == INPUT_TYPE_HINT_CHECKBOX;
- return mIsChecked;
+ return ContextUtils.getAppSharedPreferences().getBoolean(mValue.toString(), true);
}
/** Sets the checkbox state. */
public void setIsChecked(boolean isChecked) {
assert mInputTypeHint == INPUT_TYPE_HINT_CHECKBOX;
- mIsChecked = isChecked;
+ ContextUtils.getAppSharedPreferences()
+ .edit()
+ .putBoolean(mValue.toString(), isChecked)
+ .apply();
}
/** @return The list of icons resource identifiers to display. */
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/payments/CardEditor.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698