Better accessibility feedback in the route description screen.

Distance information is not duplicated by the accessibility
feedback. Added particular items for arrival points. Fully qualified
time format is used in accessibility mode since it is treated by
speech synthesizers more correctly.
This commit is contained in:
Igor B. Poretsky 2014-04-03 06:12:20 +04:00
parent d5647c5d1f
commit 1772edd374
11 changed files with 41 additions and 30 deletions

View file

@ -514,7 +514,7 @@ public class Algorithms {
} }
public static String formatDuration(int seconds) { public static String formatDuration(int seconds, boolean fullForm) {
String sec; String sec;
if (seconds % 60 < 10) { if (seconds % 60 < 10) {
sec = "0" + (seconds % 60); sec = "0" + (seconds % 60);
@ -522,7 +522,7 @@ public class Algorithms {
sec = (seconds % 60) + ""; sec = (seconds % 60) + "";
} }
int minutes = seconds / 60; int minutes = seconds / 60;
if (minutes < 60) { if ((!fullForm) && (minutes < 60)) {
return minutes + ":" + sec; return minutes + ":" + sec;
} else { } else {
String min; String min;

View file

@ -227,7 +227,7 @@ public class GpxSelectionHelper {
} }
if (name.length() != 0) if (name.length() != 0)
name += ", "; name += ", ";
name += GpxUiHelper.getColorValue(timeSpanClr, Algorithms.formatDuration((int) (tm / 1000))); name += GpxUiHelper.getColorValue(timeSpanClr, Algorithms.formatDuration((int) (tm / 1000), app.accessibilityEnabled()));
} }
if (analysis.isSpeedSpecified()) { if (analysis.isSpeedSpecified()) {
if (name.length() != 0) if (name.length() != 0)
@ -265,7 +265,7 @@ public class GpxSelectionHelper {
private static String formatSecondarySplitName(double metricEnd, GpxDisplayGroup group, OsmandApplication app) { private static String formatSecondarySplitName(double metricEnd, GpxDisplayGroup group, OsmandApplication app) {
if (group.isSplitDistance()) { if (group.isSplitDistance()) {
return Algorithms.formatDuration((int) metricEnd); return Algorithms.formatDuration((int) metricEnd, app.accessibilityEnabled());
} else { } else {
return OsmAndFormatter.getFormattedDistance((float) metricEnd, app); return OsmAndFormatter.getFormattedDistance((float) metricEnd, app);
} }
@ -290,7 +290,7 @@ public class GpxSelectionHelper {
return OsmAndFormatter.getFormattedDistance((float) metricEnd, app); return OsmAndFormatter.getFormattedDistance((float) metricEnd, app);
} }
} else { } else {
return Algorithms.formatDuration((int) metricEnd); return Algorithms.formatDuration((int) metricEnd, app.accessibilityEnabled());
} }
} }

View file

@ -165,8 +165,11 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
} }
} }
private final int lastItemIndex;
RouteInfoAdapter(List<RouteDirectionInfo> list) { RouteInfoAdapter(List<RouteDirectionInfo> list) {
super(ShowRouteInfoActivity.this, R.layout.route_info_list_item, list); super(ShowRouteInfoActivity.this, R.layout.route_info_list_item, list);
lastItemIndex = list.size() - 1;
this.setNotifyOnChange(false); this.setNotifyOnChange(false);
} }
@ -190,14 +193,24 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
drawable.setRouteType(model.getTurnType()); drawable.setRouteType(model.getTurnType());
icon.setImageDrawable(drawable); icon.setImageDrawable(drawable);
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(
model.distance, getMyApplication()));
timeLabel.setText(getTimeDescription(model));
label.setText(model.getDescriptionRoutePart()); label.setText(model.getDescriptionRoutePart());
if (model.distance > 0) {
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(
model.distance, getMyApplication()));
timeLabel.setText(getTimeDescription(model));
row.setContentDescription(label.getText() + " " + timeLabel.getText()); //$NON-NLS-1$
} else {
if (label.getText().length() == 0) {
label.setText(getString((position != lastItemIndex) ? R.string.arrived_at_intermediate_point : R.string.arrived_at_destination));
}
distanceLabel.setText(""); //$NON-NLS-1$
timeLabel.setText(""); //$NON-NLS-1$
row.setContentDescription(""); //$NON-NLS-1$
}
CumulativeInfo cumulativeInfo = getRouteDirectionCumulativeInfo(position); CumulativeInfo cumulativeInfo = getRouteDirectionCumulativeInfo(position);
cumulativeDistanceLabel.setText(OsmAndFormatter.getFormattedDistance( cumulativeDistanceLabel.setText(OsmAndFormatter.getFormattedDistance(
cumulativeInfo.distance, getMyApplication())); cumulativeInfo.distance, getMyApplication()));
cumulativeTimeLabel.setText(Algorithms.formatDuration(cumulativeInfo.time)); cumulativeTimeLabel.setText(Algorithms.formatDuration(cumulativeInfo.time, getMyApplication().accessibilityEnabled()));
return row; return row;
} }
@ -214,7 +227,7 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
private String getTimeDescription(RouteDirectionInfo model) { private String getTimeDescription(RouteDirectionInfo model) {
final int timeInSeconds = model.getExpectedTime(); final int timeInSeconds = model.getExpectedTime();
return Algorithms.formatDuration(timeInSeconds); return Algorithms.formatDuration(timeInSeconds, getMyApplication().accessibilityEnabled());
} }
void print() { void print() {
@ -296,10 +309,10 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
cumulativeInfo.distance + routeDirectionInfo.distance, cumulativeInfo.distance + routeDirectionInfo.distance,
getMyApplication())); getMyApplication()));
sb.append(BR); sb.append(BR);
sb.append(Algorithms.formatDuration(cumulativeInfo.time)); sb.append(Algorithms.formatDuration(cumulativeInfo.time, getMyApplication().accessibilityEnabled()));
sb.append(" - "); sb.append(" - ");
sb.append(Algorithms.formatDuration(cumulativeInfo.time sb.append(Algorithms.formatDuration(cumulativeInfo.time
+ routeDirectionInfo.getExpectedTime())); + routeDirectionInfo.getExpectedTime(), getMyApplication().accessibilityEnabled()));
String cumulativeTimeAndDistance = sb.toString().replaceAll("\\s", NBSP); String cumulativeTimeAndDistance = sb.toString().replaceAll("\\s", NBSP);
html.append(cumulativeTimeAndDistance); html.append(cumulativeTimeAndDistance);
html.append("</td>"); html.append("</td>");
@ -331,4 +344,3 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
} }
} }

View file

@ -114,6 +114,7 @@ public class AudioVideoNoteMenuController extends MenuController {
@Override @Override
public void updateData() { public void updateData() {
boolean accessibilityEnabled = getMapActivity().getMyApplication().accessibilityEnabled();
rightTitleButtonController.visible = true; rightTitleButtonController.visible = true;
if (!recording.isPhoto()) { if (!recording.isPhoto()) {
if (plugin.isPlaying(recording)) { if (plugin.isPlaying(recording)) {
@ -122,9 +123,9 @@ public class AudioVideoNoteMenuController extends MenuController {
int pos = plugin.getPlayingPosition(); int pos = plugin.getPlayingPosition();
String durationStr; String durationStr;
if (pos == -1) { if (pos == -1) {
durationStr = recording.getPlainDuration(); durationStr = recording.getPlainDuration(accessibilityEnabled);
} else { } else {
durationStr = Algorithms.formatDuration(pos / 1000); durationStr = Algorithms.formatDuration(pos / 1000, accessibilityEnabled);
} }
leftTitleButtonController.needRightText = true; leftTitleButtonController.needRightText = true;
leftTitleButtonController.rightTextCaption = "" + durationStr; leftTitleButtonController.rightTextCaption = "" + durationStr;
@ -132,7 +133,7 @@ public class AudioVideoNoteMenuController extends MenuController {
} else { } else {
leftTitleButtonController.caption = getMapActivity().getString(R.string.recording_context_menu_play); leftTitleButtonController.caption = getMapActivity().getString(R.string.recording_context_menu_play);
leftTitleButtonController.leftIconId = R.drawable.ic_play_dark; leftTitleButtonController.leftIconId = R.drawable.ic_play_dark;
String durationStr = recording.getPlainDuration(); String durationStr = recording.getPlainDuration(accessibilityEnabled);
leftTitleButtonController.needRightText = true; leftTitleButtonController.needRightText = true;
leftTitleButtonController.rightTextCaption = "" + durationStr; leftTitleButtonController.rightTextCaption = "" + durationStr;
} }

View file

@ -196,7 +196,7 @@ public class AudioVideoNoteRecordingMenu {
if (plugin.getCurrentRecording() != null) { if (plugin.getCurrentRecording() != null) {
TextView timeText = (TextView) view.findViewById(R.id.timeText); TextView timeText = (TextView) view.findViewById(R.id.timeText);
int duration = (int) ((System.currentTimeMillis() - startTime) / 1000); int duration = (int) ((System.currentTimeMillis() - startTime) / 1000);
timeText.setText(Algorithms.formatDuration(duration)); timeText.setText(Algorithms.formatDuration(duration, getMapActivity().getMyApplication().accessibilityEnabled()));
} }
} }

View file

@ -441,11 +441,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
} }
public String getPlainDuration() { public String getPlainDuration(boolean accessibilityEnabled) {
updateInternalDescription(); updateInternalDescription();
if (duration > 0) { if (duration > 0) {
int d = (int) (duration / 1000); int d = (int) (duration / 1000);
return Algorithms.formatDuration(d); return Algorithms.formatDuration(d, accessibilityEnabled);
} else { } else {
return ""; return "";
} }
@ -455,7 +455,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
String additional = ""; String additional = "";
if (duration > 0) { if (duration > 0) {
int d = (int) (duration / 1000); int d = (int) (duration / 1000);
additional += "(" + Algorithms.formatDuration(d) + ")"; additional += "(" + Algorithms.formatDuration(d, ((OsmandApplication)ctx.getApplicationContext()).accessibilityEnabled()) + ")";
} }
if (!available) { if (!available) {
additional += "[" + ctx.getString(R.string.recording_unavailable) + "]"; additional += "[" + ctx.getString(R.string.recording_unavailable) + "]";

View file

@ -93,16 +93,14 @@ public class GpxUiHelper {
// 2. Time span // 2. Time span
if (analysis.timeSpan > 0 && analysis.timeSpan / 1000 != analysis.timeMoving / 1000) { if (analysis.timeSpan > 0 && analysis.timeSpan / 1000 != analysis.timeMoving / 1000) {
final String formatDuration = Algorithms.formatDuration((int) (analysis.timeSpan / 1000) final String formatDuration = Algorithms.formatDuration((int) (analysis.timeSpan / 1000), app.accessibilityEnabled());
);
description.append(nl).append(app.getString(R.string.gpx_timespan, description.append(nl).append(app.getString(R.string.gpx_timespan,
getColorValue(timeSpanClr, formatDuration, html))); getColorValue(timeSpanClr, formatDuration, html)));
} }
// 3. Time moving, if any // 3. Time moving, if any
if (analysis.isTimeMoving()) { if (analysis.isTimeMoving()) {
final String formatDuration = Algorithms.formatDuration((int) (analysis.timeMoving / 1000) final String formatDuration = Algorithms.formatDuration((int) (analysis.timeMoving / 1000), app.accessibilityEnabled());
);
description.append(nl).append(app.getString(R.string.gpx_timemoving, description.append(nl).append(app.getString(R.string.gpx_timemoving,
getColorValue(timeSpanClr, formatDuration, html))); getColorValue(timeSpanClr, formatDuration, html)));
} }

View file

@ -56,7 +56,7 @@ public class GpxItemMenuBuilder extends MenuBuilder {
buildTextView(ll, gpxSmallTextMargin, gpxTextSize, textColor, buildTextView(ll, gpxSmallTextMargin, gpxTextSize, textColor,
OsmAndFormatter.getFormattedDistance(item.analysis.totalDistance, app)); OsmAndFormatter.getFormattedDistance(item.analysis.totalDistance, app));
buildIcon(ll, gpxSmallIconMargin, R.drawable.ic_small_time); buildIcon(ll, gpxSmallIconMargin, R.drawable.ic_small_time);
buildTextView(ll, gpxSmallTextMargin, gpxTextSize, textColor, Algorithms.formatDuration((int) (item.analysis.timeSpan / 1000)) + ""); buildTextView(ll, gpxSmallTextMargin, gpxTextSize, textColor, Algorithms.formatDuration((int) (item.analysis.timeSpan / 1000), app.accessibilityEnabled()) + "");
} }
private void buildIcon(LinearLayout ll, int gpxSmallIconMargin, int iconId) { private void buildIcon(LinearLayout ll, int gpxSmallIconMargin, int iconId) {

View file

@ -1350,7 +1350,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
// if (analysis.isTimeMoving()) { // if (analysis.isTimeMoving()) {
// time.setText(Algorithms.formatDuration((int) (analysis.timeMoving / 1000)) + ""); // time.setText(Algorithms.formatDuration((int) (analysis.timeMoving / 1000)) + "");
// } else { // } else {
time.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000)) + ""); time.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000), app.accessibilityEnabled()) + "");
// } // }
} else { } else {
time.setText(""); time.setText("");

View file

@ -86,7 +86,7 @@ public class SettingsOsMoActivity extends SettingsBaseActivity {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
if(service.isConnected()) { if(service.isConnected()) {
int seconds = (int) ((System.currentTimeMillis() - service.getConnectionTime()) / 1000); int seconds = (int) ((System.currentTimeMillis() - service.getConnectionTime()) / 1000);
s.append(getString(R.string.osmo_conn_successfull, Algorithms.formatDuration(seconds))).append("\n"); s.append(getString(R.string.osmo_conn_successfull, Algorithms.formatDuration(seconds, getMyApplication().accessibilityEnabled()))).append("\n");
SessionInfo si = service.getCurrentSessionInfo(); SessionInfo si = service.getCurrentSessionInfo();
if(si == null) { if(si == null) {
s.append(getString(R.string.osmo_auth_pending)).append("\n"); s.append(getString(R.string.osmo_auth_pending)).append("\n");

View file

@ -657,7 +657,7 @@ public class RoutingHelper {
String msg = app.getString(R.string.new_route_calculated_dist) + ": " String msg = app.getString(R.string.new_route_calculated_dist) + ": "
+ OsmAndFormatter.getFormattedDistance(res.getWholeDistance(), app); + OsmAndFormatter.getFormattedDistance(res.getWholeDistance(), app);
if (OsmandPlugin.isDevelopment() && res.getRoutingTime() != 0f) { if (OsmandPlugin.isDevelopment() && res.getRoutingTime() != 0f) {
msg += " (" + Algorithms.formatDuration((int) res.getRoutingTime()) + ")"; msg += " (" + Algorithms.formatDuration((int) res.getRoutingTime(), app.accessibilityEnabled()) + ")";
} }
app.showToastMessage(msg); app.showToastMessage(msg);
} }