Skip to content
This repository was archived by the owner on May 3, 2021. It is now read-only.

Twelveish 10 #22

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
40 changes: 34 additions & 6 deletions app/src/main/java/com/layoutxml/twelveish/WordClockTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,22 @@ private String capitalise0(int hours, int minutes, int index) {
String mainPrefix = "";
StringBuilder prefix;
if ((minutes > 0) && (!Prefixes[index].equals("")) && (Prefixes[index] != null)) {
String[] prefixArray = Prefixes[index].split(" ");

//Split the prefix with non-break spaces and capitalise each word
StringBuilder preString = new StringBuilder();
String[] preArray = Prefixes[index].split("\\u00A0");

for (String word : preArray){
if(preString.length() != 0)
preString.append("\u00A0");

String capitalised = word.substring(0, 1).toUpperCase() + word.substring(1);
preString.append(capitalised);
}

// Do the same with spaces

String[] prefixArray = preString.toString().split(" ");
prefix = new StringBuilder();
for (String word : prefixArray) {
if (prefix.length() != 0)
Expand Down Expand Up @@ -403,8 +418,21 @@ private String capitalise0(int hours, int minutes, int index) {
if (showSuffixes) {
StringBuilder suffix;
if ((minutes > 0) && (!Suffixes[index].equals("")) && (Suffixes[index] != null)) {

//We first need to replace non-break spaces with regular spaces
StringBuilder suffString = new StringBuilder();
String[] suffArray = Suffixes[index].split("\\u00A0");

for (String word : suffArray){
if(suffString.length() != 0)
suffString.append("\u00A0");

String capitalised = word.substring(0, 1).toUpperCase() + word.substring(1);
suffString.append(capitalised);
}

if (SuffixNewLine[index]) {
String[] suffixArray = Suffixes[index].split(" ");
String[] suffixArray = suffString.toString().split(" ");
suffix = new StringBuilder();
for (String word : suffixArray) {
if (suffix.length() != 0)
Expand All @@ -414,7 +442,7 @@ private String capitalise0(int hours, int minutes, int index) {
}
mainSuffix = suffix.toString();
} else {
mainSuffix = Suffixes[index].toLowerCase();
mainSuffix = suffString.toString().toLowerCase();
}
}
}
Expand Down Expand Up @@ -478,7 +506,7 @@ private String capitalise2(int hours, int minutes, int index) {
+ middle
+ ((minutes > 0) ? (SuffixNewLine[index] ? " " : "") : "")
+ ((showSuffixes) ? ((minutes > 0) ? Suffixes[index] : "") : "");
return arrangeWords(text);
return arrangeWords(text).toLowerCase();
}
}

Expand All @@ -498,15 +526,15 @@ private String capitalise3(int hours, int minutes, int index) {
+ middle
+ ((minutes > 0) ? (SuffixNewLine[index] ? "\n" : "") : "")
+ ((showSuffixes) ? ((minutes > 0) ? Suffixes[index] : "") : "");
return text20.substring(0, 1).toUpperCase() + text20.substring(1).toLowerCase();
return text20.substring(0, 1).toUpperCase() + text20.substring(1);
} else {
String text20 =
((minutes > 0) ? Prefixes[index] : "")
+ ((minutes > 0) ? (PrefixNewLine[index] ? " " : "") : "")
+ middle
+ ((minutes > 0) ? (SuffixNewLine[index] ? " " : "") : "")
+ ((showSuffixes) ? ((minutes > 0) ? Suffixes[index] : "") : "");
return arrangeWords(text20.substring(0, 1).toUpperCase() + text20.substring(1).toLowerCase());
return arrangeWords(text20.substring(0, 1).toUpperCase() + text20.substring(1));
}
}

Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,15 @@
</string-array>
<string-array name="PrefixesDE">
<item>kurz nach</item>
<item>bald viertel\u00A0nach</item>
<item>fast viertel\u00A0nach</item>
<item>viertel\u00A0nach</item>
<item>bald Viertel\u00A0nach</item>
<item>fast Viertel\u00A0nach</item>
<item>Viertel\u00A0nach</item>
<item>bald halb</item>
<item>kurz vor halb</item>
<item>kurz nach halb</item>
<item>bald viertel\u00A0vor</item>
<item>fast viertel\u00A0vor</item>
<item>viertel\u00A0vor</item>
<item>bald Viertel\u00A0vor</item>
<item>fast Viertel\u00A0vor</item>
<item>Viertel\u00A0vor</item>
<item>bald</item>
<item>fast</item>
</string-array>
Expand Down