diff --git a/resources/settings/properties.xml b/resources/settings/properties.xml
index 7784192..832538a 100644
--- a/resources/settings/properties.xml
+++ b/resources/settings/properties.xml
@@ -4,6 +4,9 @@
0xFFFFFF
0x109AD7
false
+ 0
+ 0
+ 0
false
false
diff --git a/resources/settings/settings.xml b/resources/settings/settings.xml
index 760703d..6fc9b98 100644
--- a/resources/settings/settings.xml
+++ b/resources/settings/settings.xml
@@ -28,6 +28,35 @@
+
+
+ @Strings.OTPFormatFor6_xxxxxx
+ @Strings.OTPFormatFor6_xxx_xxx
+ @Strings.OTPFormatFor6_xx_xx_xx
+
+
+
+
+
+ @Strings.OTPFormatFor7_yyyyyyy
+ @Strings.OTPFormatFor7_yyy_yyyy
+ @Strings.OTPFormatFor7_yyyy_yyy
+ @Strings.OTPFormatFor7_yyy_y_yyy
+ @Strings.OTPFormatFor7_yy_yyy_yy
+
+
+
+
+
+ @Strings.OTPFormatFor8_zzzzzzzz
+ @Strings.OTPFormatFor8_zzzz_zzzz
+ @Strings.OTPFormatFor8_zzz_zz_zzz
+ @Strings.OTPFormatFor8_zz_zzzz_zz
+ @Strings.OTPFormatFor8_zz_zz_zz_zz
+
+
+
+
diff --git a/resources/strings/strings.xml b/resources/strings/strings.xml
index aa6739b..55e85ec 100644
--- a/resources/strings/strings.xml
+++ b/resources/strings/strings.xml
@@ -7,6 +7,26 @@
Time Circle Color
Use Arrows in Circle Timer
+ The format for 6-numeric OTP
+ The format for 7-numeric OTP
+ The format for 8-numeric OTP
+
+ 123456
+ 123 456
+ 12 34 56
+
+ 1234567
+ 123 4567
+ 1234 567
+ 123 4 567
+ 12 345 67
+
+ 12345678
+ 1234 5678
+ 123 45 678
+ 12 3456 78
+ 12 34 56 78
+
Black
Dark Gray
Light Gray
diff --git a/source/OtpDataProvider.mc b/source/OtpDataProvider.mc
index eb8a66d..e005783 100644
--- a/source/OtpDataProvider.mc
+++ b/source/OtpDataProvider.mc
@@ -166,13 +166,12 @@ class OtpDataProvider {
}
function formatToken(token) {
- var formattedToken = "";
- switch(token.length()) {
- case 6: formattedToken = token.substring(0, 3) + " " + token.substring(3, 7); break;
- case 7: formattedToken = token.substring(0, 2) + " " + token.substring(2, 5) + " " + token.substring(5, 8); break;
- case 8: formattedToken = token.substring(0, 3) + " " + token.substring(3, 5) + " " + token.substring(5, 9); break;
- }
- return formattedToken;
+ var tokenLength = token.length();
+ var formatIndex = AppData.readProperty("OTPFormatFor" + tokenLength);
+ var formatPattern = Constants.OTP_FORMAT.get(tokenLength).get(formatIndex);
+
+ Sys.println("Formatting token " + token + " with pattern " + formatPattern);
+ return Lang.format(formatPattern, token.toCharArray());
}
function getCurrentOtp() {
diff --git a/source/util/Constants.mc b/source/util/Constants.mc
index 84a8eb9..e4a4321 100644
--- a/source/util/Constants.mc
+++ b/source/util/Constants.mc
@@ -18,4 +18,26 @@ module Constants {
const FG_COLOR_PROP = "ForegroundColor";
const CIRCLE_TIMER_COLOR_PROP = "CircleTimerColor";
const CIRCLE_TIMER_ARROWS_PROP = "CircleTimerArrows";
+
+ const OTP_FORMAT = {
+ 6 => {
+ 0 => "$1$$2$$3$$4$$5$$6$", // OTPFormatFor6_xxxxxx
+ 1 => "$1$$2$$3$ $4$$5$$6$", // OTPFormatFor6_xxx_xxx
+ 2 => "$1$$2$ $3$$4$ $5$$6$" // OTPFormatFor6_xx_xx_xx
+ },
+ 7 => {
+ 0 => "$1$$2$$3$$4$$5$$6$$7$", // OTPFormatFor7_yyyyyyy
+ 1 => "$1$$2$$3$ $4$$5$$6$$7$", // OTPFormatFor7_yyy_yyyy
+ 2 => "$1$$2$$3$$4$ $5$$6$$7$", // OTPFormatFor7_yyyy_yyy
+ 3 => "$1$$2$$3$ $4$ $5$$6$$7$", // OTPFormatFor7_yyy_y_yyy
+ 4 => "$1$$2$ $3$$4$$5$ $6$$7$" // OTPFormatFor7_yy_yyy_yy
+ },
+ 8 => {
+ 0 => "$1$$2$$3$$4$$5$$6$$7$$8$", // OTPFormatFor8_zzzzzzzz
+ 1 => "$1$$2$$3$$4$ $5$$6$$7$$8$", // OTPFormatFor8_zzzz_zzzz
+ 2 => "$1$$2$$3$ $4$$5$ $6$$7$$8$", // OTPFormatFor8_zzz_zz_zzz
+ 3 => "$1$$2$ $3$$4$$5$$6$ $7$$8$", // OTPFormatFor8_zz_zzzz_zz
+ 4 => "$1$$2$ $3$$4$ $5$$6$ $7$$8$" // OTPFormatFor8_zz_zz_zz_zz
+ }
+ };
}
\ No newline at end of file