Refactoring

pull/212/head
M66B 2 years ago
parent fb9696d538
commit c7ce39cb54

@ -1954,6 +1954,22 @@ public class Helper {
}
// https://issuetracker.google.com/issues/37054851
static String getPrintableString(String value) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < value.length(); i++) {
char kar = value.charAt(i);
if (kar == '\n')
result.append('|');
else if (kar == ' ')
result.append('_');
else if (!Helper.isPrintableChar(kar) || kar == '\u00a0')
result.append('{').append(Integer.toHexString(kar)).append('}');
else
result.append(kar);
}
return result.toString();
}
static DateFormat getTimeInstance(Context context) {
return getTimeInstance(context, SimpleDateFormat.MEDIUM);
}

@ -665,7 +665,7 @@ public class Log {
else if (element instanceof Spanned)
elements[i] = "<redacted>";
else
elements[i] = (element == null ? "<null>" : printableString(element.toString()));
elements[i] = (element == null ? "<null>" : Helper.getPrintableString(element.toString()));
}
value = TextUtils.join(",", elements);
if (length > 10)
@ -728,22 +728,6 @@ public class Log {
return result;
}
static String printableString(String value) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < value.length(); i++) {
char kar = value.charAt(i);
if (kar == '\n')
result.append('|');
else if (kar == ' ')
result.append('_');
else if (!Helper.isPrintableChar(kar))
result.append('{').append(Integer.toHexString(kar)).append('}');
else
result.append(kar);
}
return result.toString();
}
static void logMemory(Context context, String message) {
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
ActivityManager activityManager = Helper.getSystemService(context, ActivityManager.class);

Loading…
Cancel
Save