OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.chrome.browser.preferences.autofill; | 5 package org.chromium.chrome.browser.preferences.autofill; |
6 | 6 |
7 import android.text.Editable; | 7 import android.text.Editable; |
8 import android.text.TextUtils; | 8 import android.text.TextUtils; |
9 import android.text.TextWatcher; | 9 import android.text.TextWatcher; |
10 | 10 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 int index = TextUtils.indexOf(s, SEPARATOR); | 85 int index = TextUtils.indexOf(s, SEPARATOR); |
86 while (index >= 0) { | 86 while (index >= 0) { |
87 s.delete(index, index + 1); | 87 s.delete(index, index + 1); |
88 index = TextUtils.indexOf(s, SEPARATOR, index + 1); | 88 index = TextUtils.indexOf(s, SEPARATOR, index + 1); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 public static void insertSeparators(Editable s) { | 92 public static void insertSeparators(Editable s) { |
93 int[] positions; | 93 int[] positions; |
94 if (PersonalDataManager.getInstance() | 94 if (PersonalDataManager.getInstance() |
95 .getBasicCardPaymentType(s.toString(), false) | 95 .getBasicCardIssuerNetwork(s.toString(), false) |
96 .equals("amex")) { | 96 .equals("amex")) { |
97 positions = new int[2]; | 97 positions = new int[2]; |
98 positions[0] = 4; | 98 positions[0] = 4; |
99 positions[1] = 11; | 99 positions[1] = 11; |
100 } else { | 100 } else { |
101 positions = new int[3]; | 101 positions = new int[3]; |
102 positions[0] = 4; | 102 positions[0] = 4; |
103 positions[1] = 9; | 103 positions[1] = 9; |
104 positions[2] = 14; | 104 positions[2] = 14; |
105 } | 105 } |
106 for (int i : positions) { | 106 for (int i : positions) { |
107 if (s.length() > i) { | 107 if (s.length() > i) { |
108 s.insert(i, SEPARATOR); | 108 s.insert(i, SEPARATOR); |
109 } | 109 } |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 public static boolean hasDashOrSpace(final CharSequence s, final int start, | 113 public static boolean hasDashOrSpace(final CharSequence s, final int start, |
114 final int count) { | 114 final int count) { |
115 return TextUtils.indexOf(s, " ", start, start + count) != -1 | 115 return TextUtils.indexOf(s, " ", start, start + count) != -1 |
116 || TextUtils.indexOf(s, "-", start, start + count) != -1; | 116 || TextUtils.indexOf(s, "-", start, start + count) != -1; |
117 } | 117 } |
118 } | 118 } |
OLD | NEW |