forked from organicmaps/organicmaps
Merge pull request #6068 from milchakov/opening_hours_fixes
[android] Opening hours fixes
This commit is contained in:
commit
f87e622b33
3 changed files with 47 additions and 3 deletions
|
@ -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
|
||||
{
|
||||
|
@ -23,6 +24,10 @@ public class TimeFormatUtils
|
|||
{
|
||||
sCurrentLocale = Locale.getDefault();
|
||||
sShortWeekdays = DateFormatSymbols.getInstance().getShortWeekdays();
|
||||
for (int i = 0; i < sShortWeekdays.length; i++)
|
||||
{
|
||||
sShortWeekdays[i] = Utils.capitalize(sShortWeekdays[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,9 +68,10 @@ public class TimeFormatUtils
|
|||
|
||||
public static String formatTimetables(@NonNull Timetable[] timetables)
|
||||
{
|
||||
final Resources resources = MwmApplication.get().getResources();
|
||||
|
||||
if (timetables[0].isFullWeek())
|
||||
{
|
||||
final Resources resources = MwmApplication.get().getResources();
|
||||
return timetables[0].isFullday ? resources.getString(R.string.twentyfour_seven)
|
||||
: resources.getString(R.string.daily) + " " + timetables[0].workingTimespan;
|
||||
}
|
||||
|
@ -73,8 +79,11 @@ public class TimeFormatUtils
|
|||
final StringBuilder builder = new StringBuilder();
|
||||
for (Timetable tt : timetables)
|
||||
{
|
||||
String workingTime = tt.isFullday ? resources.getString(R.string.editor_time_allday)
|
||||
: tt.workingTimespan.toString();
|
||||
|
||||
builder.append(String.format(Locale.getDefault(), "%-21s", formatWeekdays(tt))).append(" ")
|
||||
.append(tt.workingTimespan)
|
||||
.append(workingTime)
|
||||
.append("\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -1309,8 +1309,21 @@ public class PlacePageView extends RelativeLayout
|
|||
if (tt.containsWeekday(currentDay))
|
||||
{
|
||||
containsCurrentWeekday = true;
|
||||
refreshTodayOpeningHours(resources.getString(R.string.today) + " " + tt.workingTimespan,
|
||||
String workingTime;
|
||||
|
||||
if (tt.isFullday)
|
||||
{
|
||||
String allDay = resources.getString(R.string.editor_time_allday);
|
||||
workingTime = Utils.unCapitalize(allDay);
|
||||
}
|
||||
else
|
||||
{
|
||||
workingTime = tt.workingTimespan.toString();
|
||||
}
|
||||
|
||||
refreshTodayOpeningHours(resources.getString(R.string.today) + " " + workingTime,
|
||||
ThemeUtils.getColor(getContext(), android.R.attr.textColorPrimary));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -423,4 +423,26 @@ public class Utils
|
|||
.commit();
|
||||
}
|
||||
}
|
||||
|
||||
public static String capitalize(@Nullable 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(@Nullable 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue