-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into libraries_update
- Loading branch information
Showing
57 changed files
with
361 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
app/src/main/java/net/gsantner/markor/util/TextCasingUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package net.gsantner.markor.util; | ||
|
||
public class TextCasingUtils { | ||
public static String toggleCase(String text) { // Toggle all text to Uppercase or Lowercase | ||
if (text.equals(text.toUpperCase())) { | ||
return text.toLowerCase(); | ||
} else { | ||
return text.toUpperCase(); | ||
} | ||
} | ||
|
||
public static String switchCase(String text) { // Switch the text case of each character | ||
StringBuilder result = new StringBuilder(); | ||
for (char c : text.toCharArray()) { | ||
if (Character.isUpperCase(c)) { | ||
result.append(Character.toLowerCase(c)); | ||
} else if (Character.isLowerCase(c)) { | ||
result.append(Character.toUpperCase(c)); | ||
} else { | ||
result.append(c); | ||
} | ||
} | ||
return result.toString(); | ||
} | ||
|
||
public static String capitalizeWords(String text) { // Capitalize the first letter of each word | ||
StringBuilder result = new StringBuilder(); | ||
boolean capitalizeNext = true; | ||
for (char c : text.toCharArray()) { | ||
if (Character.isWhitespace(c)) { | ||
capitalizeNext = true; | ||
result.append(c); | ||
} else if (capitalizeNext) { | ||
result.append(Character.toUpperCase(c)); | ||
capitalizeNext = false; | ||
} else { | ||
result.append(Character.toLowerCase(c)); | ||
} | ||
} | ||
return result.toString(); | ||
} | ||
|
||
public static String capitalizeSentences(String text) { // Capitalize the first letter of each sentence | ||
StringBuilder result = new StringBuilder(); | ||
boolean capitalizeNext = true; | ||
for (char c : text.toCharArray()) { | ||
if (c == '.' || c == '!' || c == '?') { | ||
capitalizeNext = true; | ||
result.append(c); | ||
} else if (Character.isWhitespace(c)) { | ||
result.append(c); | ||
} else if (capitalizeNext) { | ||
result.append(Character.toUpperCase(c)); | ||
capitalizeNext = false; | ||
} else { | ||
result.append(c); | ||
} | ||
} | ||
return result.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.