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:
parent
d5647c5d1f
commit
1772edd374
11 changed files with 41 additions and 30 deletions
|
@ -514,7 +514,7 @@ public class Algorithms {
|
|||
}
|
||||
|
||||
|
||||
public static String formatDuration(int seconds) {
|
||||
public static String formatDuration(int seconds, boolean fullForm) {
|
||||
String sec;
|
||||
if (seconds % 60 < 10) {
|
||||
sec = "0" + (seconds % 60);
|
||||
|
@ -522,7 +522,7 @@ public class Algorithms {
|
|||
sec = (seconds % 60) + "";
|
||||
}
|
||||
int minutes = seconds / 60;
|
||||
if (minutes < 60) {
|
||||
if ((!fullForm) && (minutes < 60)) {
|
||||
return minutes + ":" + sec;
|
||||
} else {
|
||||
String min;
|
||||
|
|
|
@ -227,7 +227,7 @@ public class GpxSelectionHelper {
|
|||
}
|
||||
if (name.length() != 0)
|
||||
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 (name.length() != 0)
|
||||
|
@ -265,7 +265,7 @@ public class GpxSelectionHelper {
|
|||
|
||||
private static String formatSecondarySplitName(double metricEnd, GpxDisplayGroup group, OsmandApplication app) {
|
||||
if (group.isSplitDistance()) {
|
||||
return Algorithms.formatDuration((int) metricEnd);
|
||||
return Algorithms.formatDuration((int) metricEnd, app.accessibilityEnabled());
|
||||
} else {
|
||||
return OsmAndFormatter.getFormattedDistance((float) metricEnd, app);
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ public class GpxSelectionHelper {
|
|||
return OsmAndFormatter.getFormattedDistance((float) metricEnd, app);
|
||||
}
|
||||
} else {
|
||||
return Algorithms.formatDuration((int) metricEnd);
|
||||
return Algorithms.formatDuration((int) metricEnd, app.accessibilityEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,8 +165,11 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private final int lastItemIndex;
|
||||
|
||||
RouteInfoAdapter(List<RouteDirectionInfo> list) {
|
||||
super(ShowRouteInfoActivity.this, R.layout.route_info_list_item, list);
|
||||
lastItemIndex = list.size() - 1;
|
||||
this.setNotifyOnChange(false);
|
||||
}
|
||||
|
||||
|
@ -190,14 +193,24 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
|
|||
drawable.setRouteType(model.getTurnType());
|
||||
icon.setImageDrawable(drawable);
|
||||
|
||||
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(
|
||||
model.distance, getMyApplication()));
|
||||
timeLabel.setText(getTimeDescription(model));
|
||||
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);
|
||||
cumulativeDistanceLabel.setText(OsmAndFormatter.getFormattedDistance(
|
||||
cumulativeInfo.distance, getMyApplication()));
|
||||
cumulativeTimeLabel.setText(Algorithms.formatDuration(cumulativeInfo.time));
|
||||
cumulativeTimeLabel.setText(Algorithms.formatDuration(cumulativeInfo.time, getMyApplication().accessibilityEnabled()));
|
||||
return row;
|
||||
}
|
||||
|
||||
|
@ -214,7 +227,7 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
|
|||
|
||||
private String getTimeDescription(RouteDirectionInfo model) {
|
||||
final int timeInSeconds = model.getExpectedTime();
|
||||
return Algorithms.formatDuration(timeInSeconds);
|
||||
return Algorithms.formatDuration(timeInSeconds, getMyApplication().accessibilityEnabled());
|
||||
}
|
||||
|
||||
void print() {
|
||||
|
@ -296,10 +309,10 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
|
|||
cumulativeInfo.distance + routeDirectionInfo.distance,
|
||||
getMyApplication()));
|
||||
sb.append(BR);
|
||||
sb.append(Algorithms.formatDuration(cumulativeInfo.time));
|
||||
sb.append(Algorithms.formatDuration(cumulativeInfo.time, getMyApplication().accessibilityEnabled()));
|
||||
sb.append(" - ");
|
||||
sb.append(Algorithms.formatDuration(cumulativeInfo.time
|
||||
+ routeDirectionInfo.getExpectedTime()));
|
||||
+ routeDirectionInfo.getExpectedTime(), getMyApplication().accessibilityEnabled()));
|
||||
String cumulativeTimeAndDistance = sb.toString().replaceAll("\\s", NBSP);
|
||||
html.append(cumulativeTimeAndDistance);
|
||||
html.append("</td>");
|
||||
|
@ -331,4 +344,3 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ public class AudioVideoNoteMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
public void updateData() {
|
||||
boolean accessibilityEnabled = getMapActivity().getMyApplication().accessibilityEnabled();
|
||||
rightTitleButtonController.visible = true;
|
||||
if (!recording.isPhoto()) {
|
||||
if (plugin.isPlaying(recording)) {
|
||||
|
@ -122,9 +123,9 @@ public class AudioVideoNoteMenuController extends MenuController {
|
|||
int pos = plugin.getPlayingPosition();
|
||||
String durationStr;
|
||||
if (pos == -1) {
|
||||
durationStr = recording.getPlainDuration();
|
||||
durationStr = recording.getPlainDuration(accessibilityEnabled);
|
||||
} else {
|
||||
durationStr = Algorithms.formatDuration(pos / 1000);
|
||||
durationStr = Algorithms.formatDuration(pos / 1000, accessibilityEnabled);
|
||||
}
|
||||
leftTitleButtonController.needRightText = true;
|
||||
leftTitleButtonController.rightTextCaption = "— " + durationStr;
|
||||
|
@ -132,7 +133,7 @@ public class AudioVideoNoteMenuController extends MenuController {
|
|||
} else {
|
||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.recording_context_menu_play);
|
||||
leftTitleButtonController.leftIconId = R.drawable.ic_play_dark;
|
||||
String durationStr = recording.getPlainDuration();
|
||||
String durationStr = recording.getPlainDuration(accessibilityEnabled);
|
||||
leftTitleButtonController.needRightText = true;
|
||||
leftTitleButtonController.rightTextCaption = "— " + durationStr;
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ public class AudioVideoNoteRecordingMenu {
|
|||
if (plugin.getCurrentRecording() != null) {
|
||||
TextView timeText = (TextView) view.findViewById(R.id.timeText);
|
||||
int duration = (int) ((System.currentTimeMillis() - startTime) / 1000);
|
||||
timeText.setText(Algorithms.formatDuration(duration));
|
||||
timeText.setText(Algorithms.formatDuration(duration, getMapActivity().getMyApplication().accessibilityEnabled()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -441,11 +441,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
|
||||
}
|
||||
|
||||
public String getPlainDuration() {
|
||||
public String getPlainDuration(boolean accessibilityEnabled) {
|
||||
updateInternalDescription();
|
||||
if (duration > 0) {
|
||||
int d = (int) (duration / 1000);
|
||||
return Algorithms.formatDuration(d);
|
||||
return Algorithms.formatDuration(d, accessibilityEnabled);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
String additional = "";
|
||||
if (duration > 0) {
|
||||
int d = (int) (duration / 1000);
|
||||
additional += "(" + Algorithms.formatDuration(d) + ")";
|
||||
additional += "(" + Algorithms.formatDuration(d, ((OsmandApplication)ctx.getApplicationContext()).accessibilityEnabled()) + ")";
|
||||
}
|
||||
if (!available) {
|
||||
additional += "[" + ctx.getString(R.string.recording_unavailable) + "]";
|
||||
|
|
|
@ -93,16 +93,14 @@ public class GpxUiHelper {
|
|||
|
||||
// 2. Time span
|
||||
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,
|
||||
getColorValue(timeSpanClr, formatDuration, html)));
|
||||
}
|
||||
|
||||
// 3. Time moving, if any
|
||||
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,
|
||||
getColorValue(timeSpanClr, formatDuration, html)));
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class GpxItemMenuBuilder extends MenuBuilder {
|
|||
buildTextView(ll, gpxSmallTextMargin, gpxTextSize, textColor,
|
||||
OsmAndFormatter.getFormattedDistance(item.analysis.totalDistance, app));
|
||||
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) {
|
||||
|
|
|
@ -1350,7 +1350,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
// if (analysis.isTimeMoving()) {
|
||||
// time.setText(Algorithms.formatDuration((int) (analysis.timeMoving / 1000)) + "");
|
||||
// } else {
|
||||
time.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000)) + "");
|
||||
time.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000), app.accessibilityEnabled()) + "");
|
||||
// }
|
||||
} else {
|
||||
time.setText("");
|
||||
|
|
|
@ -86,7 +86,7 @@ public class SettingsOsMoActivity extends SettingsBaseActivity {
|
|||
StringBuilder s = new StringBuilder();
|
||||
if(service.isConnected()) {
|
||||
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();
|
||||
if(si == null) {
|
||||
s.append(getString(R.string.osmo_auth_pending)).append("\n");
|
||||
|
|
|
@ -657,7 +657,7 @@ public class RoutingHelper {
|
|||
String msg = app.getString(R.string.new_route_calculated_dist) + ": "
|
||||
+ OsmAndFormatter.getFormattedDistance(res.getWholeDistance(), app);
|
||||
if (OsmandPlugin.isDevelopment() && res.getRoutingTime() != 0f) {
|
||||
msg += " (" + Algorithms.formatDuration((int) res.getRoutingTime()) + ")";
|
||||
msg += " (" + Algorithms.formatDuration((int) res.getRoutingTime(), app.accessibilityEnabled()) + ")";
|
||||
}
|
||||
app.showToastMessage(msg);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue