Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/utils.java
/* | |||||
BusTO (backend components) | |||||
Copyright (C) 2019 Fabio Mazza | |||||
This program is free software: you can redistribute it and/or modify | |||||
it under the terms of the GNU General Public License as published by | |||||
the Free Software Foundation, either version 3 of the License, or | |||||
(at your option) any later version. | |||||
This program is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | |||||
*/ | |||||
package it.reyboz.bustorino.backend; | package it.reyboz.bustorino.backend; | ||||
import android.content.Context; | import android.content.Context; | ||||
import android.content.Intent; | import android.content.Intent; | ||||
import android.net.ConnectivityManager; | import android.net.ConnectivityManager; | ||||
import android.net.NetworkInfo; | import android.net.NetworkInfo; | ||||
import android.net.Uri; | import android.net.Uri; | ||||
import android.util.Log; | import android.util.Log; | ||||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | public static String toTitleCase(String givenString, boolean lowercaseRest) { | ||||
if (addPoint) sb.append("."); | if (addPoint) sb.append("."); | ||||
sb.append(" "); | sb.append(" "); | ||||
} | } | ||||
if(isRomanNumber(subs)){ | if(isRomanNumber(subs)){ | ||||
//add and skip the rest | //add and skip the rest | ||||
sb.append(subs); | sb.append(subs); | ||||
continue; | continue; | ||||
} | } | ||||
sb.append(Character.toUpperCase(subs.charAt(0))); | //SPLIT ON ', check if contains "D'" | ||||
if(subs.toLowerCase(Locale.ROOT).startsWith("d'")){ | |||||
sb.append("D'"); | |||||
subs = subs.substring(2); | |||||
} | |||||
int index = 0; | |||||
char c = subs.charAt(index); | |||||
if(subs.length() > 1 && c=='('){ | |||||
sb.append(c); | |||||
index += 1; | |||||
c = subs.charAt(index); | |||||
} | |||||
sb.append(Character.toUpperCase(c)); | |||||
if (lowercaseRest) | if (lowercaseRest) | ||||
sb.append(subs.substring(1).toLowerCase(Locale.ROOT)); | sb.append(subs.substring(index+1).toLowerCase(Locale.ROOT)); | ||||
else | else | ||||
sb.append(subs.substring(1)); | sb.append(subs.substring(index+1)); | ||||
} | } | ||||
if(addPoint && allsubs.length == 1) sb.append('.'); | |||||
sb.append(" "); | sb.append(" "); | ||||
/*sb.append(Character.toUpperCase(arr[i].charAt(0))); | /*sb.append(Character.toUpperCase(arr[i].charAt(0))); | ||||
if (lowercaseRest) | if (lowercaseRest) | ||||
sb.append(arr[i].substring(1).toLowerCase(Locale.ROOT)); | sb.append(arr[i].substring(1).toLowerCase(Locale.ROOT)); | ||||
else | else | ||||
sb.append(arr[i].substring(1)); | sb.append(arr[i].substring(1)); | ||||
sb.append(" "); | sb.append(" "); | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register