Let's talk like a Roman

This commit is contained in:
M66B 2021-10-14 19:53:53 +02:00
parent 65403e2df1
commit a9585547e9
5 changed files with 31 additions and 8 deletions

View File

@ -6,7 +6,7 @@
### Next version
* Added support for alphabetical lists (view only)
* Added support for latin and roman numbered lists (view only)
* Report new messages in same thread when composing a new message
* Use account categories for identities
* Small improvements and minor bug fixes

View File

@ -6,7 +6,7 @@
### Next version
* Added support for alphabetical lists (view only)
* Added support for latin and roman numbered lists (view only)
* Report new messages in same thread when composing a new message
* Use account categories for identities
* Small improvements and minor bug fixes

View File

@ -174,6 +174,11 @@ public class Helper {
// https://developer.android.com/distribute/marketing-tools/linking-to-google-play#PerformingSearch
private static final String PLAY_STORE_SEARCH = "https://play.google.com/store/search";
private static final String[] ROMAN_1000 = {"", "M", "MM", "MMM"};
private static final String[] ROMAN_100 = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
private static final String[] ROMAN_10 = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
private static final String[] ROMAN_1 = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
static final Pattern EMAIL_ADDRESS
= Pattern.compile(
"[\\S]{1,256}" +
@ -1526,6 +1531,15 @@ public class Helper {
}
}
public static String toRoman(int value) {
if (value < 0 || value >= 4000)
return Integer.toString(value);
return ROMAN_1000[value / 1000] +
ROMAN_100[(value % 1000) / 100] +
ROMAN_10[(value % 100) / 10] +
ROMAN_1[value % 10];
}
// Files
static String sanitizeFilename(String name) {

View File

@ -45,7 +45,8 @@ public class NumberSpan extends BulletSpan {
private static final List<String> SUPPORTED_TYPES = Collections.unmodifiableList(Arrays.asList(
"lower-alpha", "lower-latin",
"upper-alpha", "upper-latin"
"upper-alpha", "upper-latin",
"lower-roman", "upper-roman"
));
// https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-type
@ -76,19 +77,27 @@ public class NumberSpan extends BulletSpan {
if (TextUtils.isEmpty(type))
number = index + ".";
else
else {
switch (type) {
case "lower-alpha":
case "lower-latin":
number = ((char) ((int) 'a' + index)) + ".";
number = Character.toString((char) ((int) 'a' + index));
break;
case "upper-alpha":
case "upper-latin":
number = ((char) ((int) 'A' + index)) + ".";
number = Character.toString((char) ((int) 'A' + index));
break;
case "lower-roman":
number = Helper.toRoman(index).toLowerCase(Locale.ROOT);
break;
case "upper-roman":
number = Helper.toRoman(index);
break;
default:
number = index + ".";
number = Integer.toString(index);
}
number += '.';
}
numberWidth = Math.round(tp.measureText(number));
margin = numberWidth + gapWidth;

View File

@ -6,7 +6,7 @@
### Next version
* Added support for alphabetical lists (view only)
* Added support for latin and roman numbered lists (view only)
* Report new messages in same thread when composing a new message
* Use account categories for identities
* Small improvements and minor bug fixes