mirror of
https://github.com/revanced/Apktool.git
synced 2025-04-30 22:24:25 +02:00
parent
f0f87c844e
commit
bc00cce9bd
@ -143,12 +143,12 @@ public final class ResXmlEncoders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasMultipleNonPositionalSubstitutions(String str) {
|
public static boolean hasMultipleNonPositionalSubstitutions(String str) {
|
||||||
Duo<List<Integer>, List<Integer>> tuple = findSubstitutions(str, 3);
|
Duo<List<Integer>, List<Integer>> tuple = findSubstitutions(str, 4);
|
||||||
return ! tuple.m1.isEmpty() && tuple.m1.size() + tuple.m2.size() > 1;
|
return ! tuple.m1.isEmpty() && tuple.m1.size() + tuple.m2.size() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String enumerateNonPositionalSubstitutionsIfRequired(String str) {
|
public static String enumerateNonPositionalSubstitutionsIfRequired(String str) {
|
||||||
Duo<List<Integer>, List<Integer>> tuple = findSubstitutions(str, 3);
|
Duo<List<Integer>, List<Integer>> tuple = findSubstitutions(str, 4);
|
||||||
if (tuple.m1.isEmpty() || tuple.m1.size() + tuple.m2.size() < 2) {
|
if (tuple.m1.isEmpty() || tuple.m1.size() + tuple.m2.size() < 2) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,16 @@ public class PositionalEnumerationTest {
|
|||||||
assertEquals(" %1$s, %2$s and %3$d other", enumerateArguments(" %1$s, %2$s and %3$d other"));
|
assertEquals(" %1$s, %2$s and %3$d other", enumerateArguments(" %1$s, %2$s and %3$d other"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void fourArgumentsTest() {
|
||||||
|
assertEquals("%1$s, %2$s, and %3$d other and %4$d.", enumerateArguments("%s, %s, and %d other and %d."));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void fourPositionalArgumentsTest() {
|
||||||
|
assertEquals(" %1$s, %2$s and %3$d other and %4$d.", enumerateArguments(" %1$s, %2$s and %3$d other and %4$d."));
|
||||||
|
}
|
||||||
|
|
||||||
private String enumerateArguments(String value) {
|
private String enumerateArguments(String value) {
|
||||||
return ResXmlEncoders.enumerateNonPositionalSubstitutionsIfRequired(value);
|
return ResXmlEncoders.enumerateNonPositionalSubstitutionsIfRequired(value);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user