Merge "CharSequenceTransformation should not change anything when comparision fails." into oc-mr1-dev
am: 0edb324403
Change-Id: I2840d5d2fb5f71ad2f6dda8788e62c5343d0a65f
This commit is contained in:
@@ -31,6 +31,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,7 +54,8 @@ import java.util.regex.Pattern;
|
|||||||
* fields (month and year) would be:
|
* fields (month and year) would be:
|
||||||
*
|
*
|
||||||
* <pre class="prettyprint">
|
* <pre class="prettyprint">
|
||||||
* new CharSequenceTransformation.Builder(ccExpMonthId, Pattern.compile("^(\\d\\d)$"), "Exp: $1")
|
* new CharSequenceTransformation
|
||||||
|
* .Builder(ccExpMonthId, Pattern.compile("^(\\d\\d)$"), "Exp: $1")
|
||||||
* .addField(ccExpYearId, Pattern.compile("^(\\d\\d\\d\\d)$"), " / $1");
|
* .addField(ccExpYearId, Pattern.compile("^(\\d\\d\\d\\d)$"), " / $1");
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
@@ -83,8 +85,13 @@ public final class CharSequenceTransformation extends InternalTransformation imp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
final Matcher matcher = field.first.matcher(value);
|
||||||
|
if (!matcher.matches()) {
|
||||||
|
if (sDebug) Log.d(TAG, "match for " + field.first + " failed on id " + id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// replaceAll throws an exception if the subst is invalid
|
// replaceAll throws an exception if the subst is invalid
|
||||||
final String convertedValue = field.first.matcher(value).replaceAll(field.second);
|
final String convertedValue = matcher.replaceAll(field.second);
|
||||||
converted.append(convertedValue);
|
converted.append(convertedValue);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Do not log full exception to avoid PII leaking
|
// Do not log full exception to avoid PII leaking
|
||||||
|
|||||||
@@ -78,8 +78,7 @@ public final class ImageTransformation extends InternalTransformation implements
|
|||||||
}
|
}
|
||||||
final int size = mOptions.size();
|
final int size = mOptions.size();
|
||||||
if (sDebug) {
|
if (sDebug) {
|
||||||
Log.d(TAG, size + " multiple options on id " + childViewId + " to compare against "
|
Log.d(TAG, size + " multiple options on id " + childViewId + " to compare against");
|
||||||
+ value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user