[android] capitalize/unCapitalize are added into Utils

This commit is contained in:
Arsentiy Milchakov 2017-05-25 14:51:37 +03:00
parent c1dd7576fc
commit c56af88f40
3 changed files with 25 additions and 3 deletions

View file

@ -9,6 +9,7 @@ import java.util.Locale;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.util.Utils;
public class TimeFormatUtils
{
@ -25,8 +26,7 @@ public class TimeFormatUtils
sShortWeekdays = DateFormatSymbols.getInstance().getShortWeekdays();
for (int i = 1; i < sShortWeekdays.length; i++)
{
sShortWeekdays[i] = Character.toUpperCase(sShortWeekdays[i].charAt(0)) +
sShortWeekdays[i].substring(1);
sShortWeekdays[i] = Utils.capitalize(sShortWeekdays[i]);
}
}
}

View file

@ -1290,7 +1290,7 @@ public class PlacePageView extends RelativeLayout
if (tt.isFullday)
{
String allDay = resources.getString(R.string.editor_time_allday);
workingTime = Character.toLowerCase(allDay.charAt(0)) + allDay.substring(1);
workingTime = Utils.unCapitalize(allDay);
}
else
{

View file

@ -423,4 +423,26 @@ public class Utils
.commit();
}
}
public static String capitalize(String src)
{
if (TextUtils.isEmpty(src))
return src;
if (src.length() == 1)
return Character.toString(Character.toUpperCase(src.charAt(0)));
return Character.toUpperCase(src.charAt(0)) + src.substring(1);
}
public static String unCapitalize(String src)
{
if (TextUtils.isEmpty(src))
return src;
if (src.length() == 1)
return Character.toString(Character.toLowerCase(src.charAt(0)));
return Character.toLowerCase(src.charAt(0)) + src.substring(1);
}
}