Minor fixes
This commit is contained in:
parent
f18ff499a4
commit
56d869389f
7 changed files with 299 additions and 332 deletions
|
@ -1,130 +1,132 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="vertical"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:orientation="vertical"
|
||||||
android:paddingBottom="@dimen/bottom_sheet_exit_button_margin">
|
android:paddingBottom="@dimen/bottom_sheet_exit_button_margin">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/announcement_time_title"
|
android:layout_marginStart="@dimen/content_padding"
|
||||||
android:gravity="center_vertical"
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:layout_marginTop="@dimen/content_padding_small"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
android:textStyle="bold"
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
android:gravity="center_vertical"
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
android:text="@string/announcement_time_title"
|
||||||
android:layout_marginTop="@dimen/content_padding_small"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
android:layout_marginStart="@dimen/content_padding"
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
android:layout_marginEnd="@dimen/content_padding"/>
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/announcement_time_descr"
|
android:layout_marginStart="@dimen/content_padding"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
android:lineSpacingMultiplier="1.1"
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
osmand:typeface="@string/font_roboto_regular"
|
android:lineSpacingMultiplier="1.1"
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
android:text="@string/announcement_time_descr"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:textColor="?android:textColorSecondary"
|
||||||
android:layout_marginStart="@dimen/content_padding"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
android:layout_marginEnd="@dimen/content_padding"/>
|
osmand:typeface="@string/font_roboto_regular" />
|
||||||
|
|
||||||
<ImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/iv_illustration"
|
android:id="@+id/iv_illustration"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:adjustViewBounds="true"
|
android:layout_marginStart="@dimen/content_padding"
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
android:layout_marginTop="@dimen/content_padding_small"
|
android:layout_marginTop="@dimen/content_padding_small"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
android:layout_marginStart="@dimen/content_padding"
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
android:layout_marginEnd="@dimen/content_padding"
|
android:adjustViewBounds="true"
|
||||||
tools:srcCompat="@drawable/img_help_announcement_time_day"/>
|
osmand:srcCompat="?attr/image_help_announcement_time" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/tv_seek_bar_label"
|
android:id="@+id/tv_seek_bar_label"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:layout_marginStart="@dimen/content_padding"
|
||||||
android:textColor="@color/active_color_primary_light"
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
android:layout_marginTop="@dimen/content_padding_small"
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
android:layout_marginTop="@dimen/content_padding_small"
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:textColor="?attr/active_color_basic"
|
||||||
android:layout_marginStart="@dimen/content_padding"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
android:layout_marginEnd="@dimen/content_padding"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:text="Normal" />
|
tools:text="Normal" />
|
||||||
|
|
||||||
<SeekBar
|
<SeekBar
|
||||||
android:id="@+id/seek_bar_arrival"
|
android:id="@+id/seek_bar_arrival"
|
||||||
style="@style/Widget.AppCompat.SeekBar.Discrete"
|
style="@style/Widget.AppCompat.SeekBar.Discrete"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:max="3"
|
android:layout_marginTop="@dimen/pages_item_margin"
|
||||||
android:maxHeight="2dp"
|
android:maxHeight="2dp"
|
||||||
android:progressDrawable="@drawable/seekbar_progress_announcement_time"
|
android:paddingTop="11dp"
|
||||||
android:thumb="@drawable/seekbar_thumb_announcement_time"
|
android:paddingBottom="11dp"
|
||||||
osmand:tickMark="@drawable/seekbar_tickmark_announcement_time"
|
android:progressDrawable="@drawable/seekbar_progress_announcement_time"
|
||||||
android:paddingTop="11dp"
|
android:thumb="@drawable/seekbar_thumb_announcement_time"
|
||||||
android:paddingBottom="11dp"
|
osmand:tickMark="@drawable/seekbar_tickmark_announcement_time"
|
||||||
android:layout_marginTop="@dimen/pages_item_margin"
|
tools:max="3"
|
||||||
tools:progress="1" />
|
tools:progress="1" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/divider"
|
android:id="@+id/divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginTop="@dimen/content_padding_small"
|
android:layout_marginTop="@dimen/content_padding_small"
|
||||||
tools:background="@color/divider_color" />
|
android:background="?attr/divider_color_basic" />
|
||||||
|
|
||||||
<FrameLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/description_container"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/content_padding_small"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:orientation="horizontal"
|
||||||
android:layout_marginStart="@dimen/content_padding"
|
android:paddingStart="@dimen/content_padding"
|
||||||
android:layout_marginEnd="@dimen/content_padding">
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingTop="@dimen/content_padding_small"
|
||||||
|
android:paddingEnd="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:paddingBottom="@dimen/content_padding_small">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/announcement_time_intervals"
|
android:layout_weight="1"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:text="@string/announcement_time_intervals"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
osmand:typeface="@string/font_roboto_regular" />
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_regular" />
|
||||||
|
|
||||||
<ImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/iv_arrow"
|
android:id="@+id/iv_arrow"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical|end"
|
android:tint="?attr/default_icon_color"
|
||||||
app:srcCompat="@drawable/ic_action_arrow_down"
|
app:srcCompat="@drawable/ic_action_arrow_down" />
|
||||||
app:tint="@color/icon_color_default_dark" />
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
</LinearLayout>
|
||||||
android:id="@+id/tv_interval_descr"
|
|
||||||
android:layout_width="wrap_content"
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:layout_height="wrap_content"
|
android:id="@+id/tv_interval_descr"
|
||||||
android:visibility="gone"
|
android:layout_width="wrap_content"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:layout_height="wrap_content"
|
||||||
android:lineSpacingMultiplier="1.2"
|
android:layout_marginStart="@dimen/content_padding"
|
||||||
osmand:typeface="@string/font_roboto_regular"
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
android:layout_marginTop="@dimen/content_padding_small"
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:lineSpacingMultiplier="@dimen/line_spacing_multiplier_description"
|
||||||
android:layout_marginStart="@dimen/content_padding"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
android:layout_marginEnd="@dimen/content_padding"
|
android:visibility="gone"
|
||||||
tools:visibility="visible"
|
osmand:typeface="@string/font_roboto_regular"
|
||||||
tools:text="Turn
|
tools:text="Turn
|
||||||
\n • Prepare: 315 - 320 m, 110 sec.
|
\n • Prepare: 315 - 320 m, 110 sec.
|
||||||
\n • Approach: 60 - 65 m, 20 sec.
|
\n • Approach: 60 - 65 m, 20 sec.
|
||||||
\n • Passing: 5 - 10 m, 3 sec.
|
\n • Passing: 5 - 10 m, 3 sec.
|
||||||
|
@ -135,6 +137,7 @@
|
||||||
\n • Passing: 15 - 20 m, 4 sec.
|
\n • Passing: 15 - 20 m, 4 sec.
|
||||||
\nWaypoint / Favourite / POI
|
\nWaypoint / Favourite / POI
|
||||||
\n • Approach: 80 - 85 m, 25 sec
|
\n • Approach: 80 - 85 m, 25 sec
|
||||||
\n • Passing: 20 - 25 m, 7 sec. "/>
|
\n • Passing: 20 - 25 m, 7 sec. "
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -140,6 +140,7 @@
|
||||||
<attr name="btn_radio_button_center" format="reference"/>
|
<attr name="btn_radio_button_center" format="reference"/>
|
||||||
<attr name="bg_dash_line" format="reference"/>
|
<attr name="bg_dash_line" format="reference"/>
|
||||||
<attr name="text_input_background" format="reference"/>
|
<attr name="text_input_background" format="reference"/>
|
||||||
|
<attr name="image_help_announcement_time" format="reference"/>
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="PagerSlidingTabStrip">
|
<declare-styleable name="PagerSlidingTabStrip">
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
<string name="announcement_time_title">Announcement time</string>
|
<string name="announcement_time_title">Announcement time</string>
|
||||||
<string name="announcement_time_descr">Announcement time of different voice prompts depends on prompt type, current navigation speed and default navigation speed.</string>
|
<string name="announcement_time_descr">Announcement time of different voice prompts depends on prompt type, current navigation speed and default navigation speed.</string>
|
||||||
<string name="announcement_time_intervals">Time and distance intervals</string>
|
<string name="announcement_time_intervals">Time and distance intervals</string>
|
||||||
<string name="announcement_time_turn">Turn</string>
|
<string name="shared_string_turn">Turn</string>
|
||||||
<string name="announcement_time_arrive">Arrive at destination</string>
|
<string name="announcement_time_arrive">Arrive at destination</string>
|
||||||
<string name="announcement_time_off_route">Off route</string>
|
<string name="announcement_time_off_route">Off route</string>
|
||||||
<string name="announcement_time_prepare">Prepare</string>
|
<string name="announcement_time_prepare">Prepare</string>
|
||||||
<string name="announcement_time_prepare_long">Long Prepare</string>
|
<string name="announcement_time_prepare_long">Long prepare</string>
|
||||||
<string name="announcement_time_approach">Approach</string>
|
<string name="announcement_time_approach">Approach</string>
|
||||||
<string name="announcement_time_passing">Passing</string>
|
<string name="announcement_time_passing">Passing</string>
|
||||||
<string name="shared_string_sec">sec</string>
|
<string name="shared_string_sec">sec</string>
|
||||||
|
|
|
@ -247,6 +247,7 @@
|
||||||
<item name="checkboxStyle">@style/CheckboxStyle</item>
|
<item name="checkboxStyle">@style/CheckboxStyle</item>
|
||||||
<item name="radioButtonStyle">@style/RadioButtonStyle</item>
|
<item name="radioButtonStyle">@style/RadioButtonStyle</item>
|
||||||
<item name="text_input_background">@color/text_input_background_light</item>
|
<item name="text_input_background">@color/text_input_background_light</item>
|
||||||
|
<item name="image_help_announcement_time">@drawable/img_help_announcement_time_day</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
|
<style name="ToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
|
||||||
|
@ -543,6 +544,7 @@
|
||||||
<item name="checkboxStyle">@style/CheckboxStyle</item>
|
<item name="checkboxStyle">@style/CheckboxStyle</item>
|
||||||
<item name="radioButtonStyle">@style/RadioButtonStyle</item>
|
<item name="radioButtonStyle">@style/RadioButtonStyle</item>
|
||||||
<item name="text_input_background">@color/text_input_background_dark</item>
|
<item name="text_input_background">@color/text_input_background_dark</item>
|
||||||
|
<item name="image_help_announcement_time">@drawable/img_help_announcement_time_night</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="FreeVersionBanner" parent="OsmandDarkTheme">
|
<style name="FreeVersionBanner" parent="OsmandDarkTheme">
|
||||||
|
|
|
@ -48,10 +48,6 @@ public class AnnounceTimeDistances {
|
||||||
private int LONG_ALARM_ANNOUNCE_RADIUS;
|
private int LONG_ALARM_ANNOUNCE_RADIUS;
|
||||||
private int SHORT_ALARM_ANNOUNCE_RADIUS;
|
private int SHORT_ALARM_ANNOUNCE_RADIUS;
|
||||||
|
|
||||||
private String format;
|
|
||||||
private String meter;
|
|
||||||
private String second;
|
|
||||||
|
|
||||||
public AnnounceTimeDistances(ApplicationMode appMode, OsmandSettings settings) {
|
public AnnounceTimeDistances(ApplicationMode appMode, OsmandSettings settings) {
|
||||||
if (appMode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
|
if (appMode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
|
||||||
// keep it as minimum 30 km/h for voice announcement
|
// keep it as minimum 30 km/h for voice announcement
|
||||||
|
@ -61,7 +57,6 @@ public class AnnounceTimeDistances {
|
||||||
DEFAULT_SPEED = (float) Math.max(0.3, appMode.getDefaultSpeed());
|
DEFAULT_SPEED = (float) Math.max(0.3, appMode.getDefaultSpeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 300 s: car 3750 m (113 s @ 120 km/h)
|
// 300 s: car 3750 m (113 s @ 120 km/h)
|
||||||
PREPARE_LONG_DISTANCE = (int) (DEFAULT_SPEED * 300);
|
PREPARE_LONG_DISTANCE = (int) (DEFAULT_SPEED * 300);
|
||||||
// 250 s: car 3125 m (94 s @ 120 km/h)
|
// 250 s: car 3125 m (94 s @ 120 km/h)
|
||||||
|
@ -89,8 +84,7 @@ public class AnnounceTimeDistances {
|
||||||
PREPARE_DISTANCE_END = PREPARE_DISTANCE * 2;
|
PREPARE_DISTANCE_END = PREPARE_DISTANCE * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ARRIVAL_DISTANCE_FACTOR = Math.max(settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(appMode), 0.1f);
|
setArrivalDistances(settings.ARRIVAL_DISTANCE_FACTOR.getModeValue(appMode));
|
||||||
setArrivalDistances(ARRIVAL_DISTANCE_FACTOR);
|
|
||||||
|
|
||||||
// Trigger close prompts earlier to allow BT SCO link being established, or when VOICE_PROMPT_DELAY is set >0 for the other stream types
|
// Trigger close prompts earlier to allow BT SCO link being established, or when VOICE_PROMPT_DELAY is set >0 for the other stream types
|
||||||
int ams = settings.AUDIO_MANAGER_STREAM.getModeValue(appMode);
|
int ams = settings.AUDIO_MANAGER_STREAM.getModeValue(appMode);
|
||||||
|
@ -214,12 +208,24 @@ public class AnnounceTimeDistances {
|
||||||
return (int) (dist - voicePromptDelayTimeSec * speed);
|
return (int) (dist - voicePromptDelayTimeSec * speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Spannable getIntervalsDescription(OsmandApplication app) {
|
private void appendTurnDesc(SpannableStringBuilder builder, String name, int dist, String meter, String second) {
|
||||||
format = "\n%s: %d - %d %s, %d %s.";
|
appendTurnDesc(builder, name, dist, DEFAULT_SPEED, meter, second);
|
||||||
meter = app.getString(R.string.m);
|
}
|
||||||
second = app.getString(R.string.shared_string_sec);
|
|
||||||
|
|
||||||
String turn = app.getString(R.string.announcement_time_turn);
|
private void appendTurnDesc(SpannableStringBuilder builder, String name, int dist, float speed, String meter, String second) {
|
||||||
|
int minDist = (dist / 5) * 5;
|
||||||
|
int time = (int) (dist / speed);
|
||||||
|
if (time > 15) {
|
||||||
|
// round to 5
|
||||||
|
time = (time / 5) * 5;
|
||||||
|
}
|
||||||
|
builder.append(String.format("\n%s: %d - %d %s, %d %s.", name, minDist, minDist + 5, meter, time, second));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Spannable getIntervalsDescription(OsmandApplication app) {
|
||||||
|
String meter = app.getString(R.string.m);
|
||||||
|
String second = app.getString(R.string.shared_string_sec);
|
||||||
|
String turn = app.getString(R.string.shared_string_turn);
|
||||||
String arrive = app.getString(R.string.announcement_time_arrive);
|
String arrive = app.getString(R.string.announcement_time_arrive);
|
||||||
String offRoute = app.getString(R.string.announcement_time_off_route);
|
String offRoute = app.getString(R.string.announcement_time_off_route);
|
||||||
String traffic = "\n" + app.getString(R.string.way_alarms);
|
String traffic = "\n" + app.getString(R.string.way_alarms);
|
||||||
|
@ -239,53 +245,39 @@ public class AnnounceTimeDistances {
|
||||||
builder.append(turn);
|
builder.append(turn);
|
||||||
makeBold(builder, turn);
|
makeBold(builder, turn);
|
||||||
if (PREPARE_DISTANCE_END <= PREPARE_DISTANCE) {
|
if (PREPARE_DISTANCE_END <= PREPARE_DISTANCE) {
|
||||||
appendDescr(builder, prepare, PREPARE_DISTANCE);;
|
appendTurnDesc(builder, prepare, PREPARE_DISTANCE, meter, second);
|
||||||
}
|
}
|
||||||
if (PREPARE_LONG_DISTANCE_END <= PREPARE_LONG_DISTANCE) {
|
if (PREPARE_LONG_DISTANCE_END <= PREPARE_LONG_DISTANCE) {
|
||||||
appendDescr(builder, longPrepare, PREPARE_LONG_DISTANCE);
|
appendTurnDesc(builder, longPrepare, PREPARE_LONG_DISTANCE, meter, second);
|
||||||
}
|
}
|
||||||
appendDescr(builder, approach, TURN_IN_DISTANCE);
|
appendTurnDesc(builder, approach, TURN_IN_DISTANCE, meter, second);
|
||||||
appendDescr(builder, passing, TURN_NOW_DISTANCE, TURN_NOW_SPEED);
|
appendTurnDesc(builder, passing, TURN_NOW_DISTANCE, TURN_NOW_SPEED, meter, second);
|
||||||
|
|
||||||
// Arrive at destination
|
// Arrive at destination
|
||||||
appendDescr(builder, arrive, (int) (getArrivalDistance()));
|
appendTurnDesc(builder, arrive, (int) (getArrivalDistance()), meter, second);
|
||||||
makeBoldFormatted(builder, arrive);
|
makeBoldFormatted(builder, arrive);
|
||||||
|
|
||||||
// Off-route
|
// Off-route
|
||||||
if (getOffRouteDistance() > 0) {
|
if (getOffRouteDistance() > 0) {
|
||||||
appendDescr(builder, offRoute, (int) getOffRouteDistance());
|
appendTurnDesc(builder, offRoute, (int) getOffRouteDistance(), meter, second);
|
||||||
makeBoldFormatted(builder, offRoute);
|
makeBoldFormatted(builder, offRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Traffic warnings
|
// Traffic warnings
|
||||||
builder.append(traffic);
|
builder.append(traffic);
|
||||||
makeBold(builder, traffic);
|
makeBold(builder, traffic);
|
||||||
appendDescr(builder, approach, LONG_ALARM_ANNOUNCE_RADIUS);
|
appendTurnDesc(builder, approach, LONG_ALARM_ANNOUNCE_RADIUS, meter, second);
|
||||||
appendDescr(builder, passing, SHORT_ALARM_ANNOUNCE_RADIUS);
|
appendTurnDesc(builder, passing, SHORT_ALARM_ANNOUNCE_RADIUS, meter, second);
|
||||||
|
|
||||||
// Waypoint / Favorite / POI
|
// Waypoint / Favorite / POI
|
||||||
builder.append(point);
|
builder.append(point);
|
||||||
makeBold(builder, point);
|
makeBold(builder, point);
|
||||||
appendDescr(builder, approach, LONG_PNT_ANNOUNCE_RADIUS);
|
appendTurnDesc(builder, approach, LONG_PNT_ANNOUNCE_RADIUS, meter, second);
|
||||||
appendDescr(builder, passing, SHORT_PNT_ANNOUNCE_RADIUS);
|
appendTurnDesc(builder, passing, SHORT_PNT_ANNOUNCE_RADIUS, meter, second);
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendDescr(SpannableStringBuilder b, String word, int dist) {
|
|
||||||
appendDescr(b, word, dist, DEFAULT_SPEED);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void appendDescr(SpannableStringBuilder b, String word, int dist, float speed) {
|
|
||||||
int minDist = (dist / 5) * 5;
|
|
||||||
int time = (int) (dist / speed);
|
|
||||||
if(time > 15) {
|
|
||||||
// round to 5
|
|
||||||
time = (time / 5) * 5;
|
|
||||||
}
|
|
||||||
b.append(String.format(format, word, minDist, minDist + 5, meter, time, second));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void makeBold(SpannableStringBuilder b, String word) {
|
private void makeBold(SpannableStringBuilder b, String word) {
|
||||||
int end = b.length();
|
int end = b.length();
|
||||||
int start = end - word.length();
|
int start = end - word.length();
|
||||||
|
@ -299,5 +291,4 @@ public class AnnounceTimeDistances {
|
||||||
b.setSpan(new StyleSpan(Typeface.BOLD), start, end,
|
b.setSpan(new StyleSpan(Typeface.BOLD), start, end,
|
||||||
SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,17 @@ import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.routing.data.AnnounceTimeDistances;
|
import net.osmand.plus.routing.data.AnnounceTimeDistances;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.settings.fragments.OnPreferenceChanged;
|
import net.osmand.plus.settings.fragments.OnPreferenceChanged;
|
||||||
|
@ -18,192 +24,159 @@ import net.osmand.plus.widgets.TextViewEx;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import static net.osmand.plus.settings.bottomsheets.SingleSelectPreferenceBottomSheet.SELECTED_ENTRY_INDEX_KEY;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
|
|
||||||
|
|
||||||
public class AnnouncementTimeBottomSheet extends BasePreferenceBottomSheet
|
public class AnnouncementTimeBottomSheet extends BasePreferenceBottomSheet
|
||||||
implements SeekBar.OnSeekBarChangeListener {
|
implements SeekBar.OnSeekBarChangeListener {
|
||||||
|
|
||||||
public static final String SELECTED_ENTRY_INDEX_KEY = "selected_entry_index_key";
|
public static final String TAG = AnnouncementTimeBottomSheet.class.getSimpleName();
|
||||||
public static final String TAG = AnnouncementTimeBottomSheet.class.getSimpleName();
|
private static final Log LOG = PlatformUtil.getLog(AnnouncementTimeBottomSheet.class);
|
||||||
private static final Log LOG = PlatformUtil.getLog(AnnouncementTimeBottomSheet.class);
|
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
private AnnounceTimeDistances announceTimeDistances;
|
||||||
|
|
||||||
private AnnounceTimeDistances announceTimeDistances;
|
private ListPreferenceEx listPreference;
|
||||||
|
private int selectedEntryIndex = -1;
|
||||||
|
|
||||||
private ListPreferenceEx listPreference;
|
private TextViewEx tvSeekBarLabel;
|
||||||
private int selectedEntryIndex = -1;
|
private SeekBar seekBarArrival;
|
||||||
|
private ImageView ivArrow;
|
||||||
|
private TextViewEx tvIntervalsDescr;
|
||||||
|
|
||||||
private View rootView;
|
private boolean collapsed = true;
|
||||||
private TextViewEx tvSeekBarLabel;
|
|
||||||
private SeekBar seekBarArrival;
|
|
||||||
private ImageView ivArrow;
|
|
||||||
private TextViewEx tvIntervalsDescr;
|
|
||||||
|
|
||||||
private boolean collapsed = false;
|
@Override
|
||||||
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
|
app = requiredMyApplication();
|
||||||
|
announceTimeDistances = new AnnounceTimeDistances(getAppMode(), app.getSettings());
|
||||||
|
|
||||||
@Override
|
listPreference = getListPreference();
|
||||||
public void createMenuItems(Bundle savedInstanceState) {
|
if (listPreference == null || listPreference.getEntries() == null ||
|
||||||
app = getMyApplication();
|
listPreference.getEntryValues() == null) {
|
||||||
if (app == null) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if (savedInstanceState != null) {
|
||||||
|
selectedEntryIndex = savedInstanceState.getInt(SELECTED_ENTRY_INDEX_KEY);
|
||||||
|
} else {
|
||||||
|
selectedEntryIndex = listPreference.findIndexOfValue(listPreference.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
announceTimeDistances = new AnnounceTimeDistances(getAppMode(), app.getSettings());
|
items.add(createBottomSheetItem());
|
||||||
|
}
|
||||||
|
|
||||||
listPreference = getListPreference();
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
updateViews();
|
||||||
|
}
|
||||||
|
|
||||||
if (listPreference == null || listPreference.getEntries() == null ||
|
@Override
|
||||||
listPreference.getEntryValues() == null) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
return;
|
super.onSaveInstanceState(outState);
|
||||||
}
|
outState.putInt(SELECTED_ENTRY_INDEX_KEY, selectedEntryIndex);
|
||||||
|
}
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
@Override
|
||||||
selectedEntryIndex = savedInstanceState.getInt(SELECTED_ENTRY_INDEX_KEY);
|
protected int getDismissButtonTextId() {
|
||||||
} else {
|
return R.string.shared_string_cancel;
|
||||||
selectedEntryIndex = listPreference.findIndexOfValue(listPreference.getValue());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
items.add(createBottomSheetItem());
|
@Override
|
||||||
}
|
protected int getRightBottomButtonTextId() {
|
||||||
|
return R.string.shared_string_apply;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
protected void onRightBottomButtonClick() {
|
||||||
super.onResume();
|
Object[] entryValues = listPreference.getEntryValues();
|
||||||
updateViews();
|
if (entryValues != null && selectedEntryIndex >= 0) {
|
||||||
}
|
Object value = entryValues[selectedEntryIndex];
|
||||||
|
if (listPreference.callChangeListener(value)) {
|
||||||
|
listPreference.setValue(value);
|
||||||
|
}
|
||||||
|
Fragment target = getTargetFragment();
|
||||||
|
if (target instanceof OnPreferenceChanged) {
|
||||||
|
((OnPreferenceChanged) target).onPreferenceChanged(listPreference.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
dismiss();
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
}
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
outState.putInt(SELECTED_ENTRY_INDEX_KEY, selectedEntryIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getDismissButtonTextId() {
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
return R.string.shared_string_cancel;
|
if (progress != selectedEntryIndex) {
|
||||||
}
|
selectedEntryIndex = progress;
|
||||||
|
updateViews();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getRightBottomButtonTextId() {
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||||
return R.string.shared_string_apply;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onRightBottomButtonClick() {
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
Object[] entryValues = listPreference.getEntryValues();
|
}
|
||||||
if (entryValues != null && selectedEntryIndex >= 0) {
|
|
||||||
Object value = entryValues[selectedEntryIndex];
|
|
||||||
if (listPreference.callChangeListener(value)) {
|
|
||||||
listPreference.setValue(value);
|
|
||||||
}
|
|
||||||
Fragment target = getTargetFragment();
|
|
||||||
if (target instanceof OnPreferenceChanged) {
|
|
||||||
((OnPreferenceChanged) target).onPreferenceChanged(listPreference.getKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dismiss();
|
private ListPreferenceEx getListPreference() {
|
||||||
}
|
return (ListPreferenceEx) getPreference();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private BaseBottomSheetItem createBottomSheetItem() {
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
View rootView = UiUtilities.getInflater(getContext(), nightMode)
|
||||||
if (progress != selectedEntryIndex) {
|
.inflate(R.layout.bottom_sheet_announcement_time, null);
|
||||||
selectedEntryIndex = progress;
|
|
||||||
updateViews();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
tvSeekBarLabel = rootView.findViewById(R.id.tv_seek_bar_label);
|
||||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
seekBarArrival = rootView.findViewById(R.id.seek_bar_arrival);
|
||||||
}
|
ivArrow = rootView.findViewById(R.id.iv_arrow);
|
||||||
|
tvIntervalsDescr = rootView.findViewById(R.id.tv_interval_descr);
|
||||||
|
|
||||||
@Override
|
seekBarArrival.setOnSeekBarChangeListener(this);
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
seekBarArrival.setMax(listPreference.getEntries().length - 1);
|
||||||
}
|
rootView.findViewById(R.id.description_container).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
toggleDescriptionVisibility();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
private ListPreferenceEx getListPreference() {
|
return new BaseBottomSheetItem.Builder()
|
||||||
return (ListPreferenceEx) getPreference();
|
.setCustomView(rootView)
|
||||||
}
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
private BaseBottomSheetItem createBottomSheetItem() {
|
private void updateViews() {
|
||||||
rootView = UiUtilities.getInflater(getContext(), nightMode)
|
seekBarArrival.setProgress(selectedEntryIndex);
|
||||||
.inflate(R.layout.bottom_sheet_announcement_time, null);
|
tvSeekBarLabel.setText(listPreference.getEntries()[selectedEntryIndex]);
|
||||||
|
|
||||||
tvSeekBarLabel = rootView.findViewById(R.id.tv_seek_bar_label);
|
float value = (float) listPreference.getEntryValues()[selectedEntryIndex];
|
||||||
seekBarArrival = rootView.findViewById(R.id.seek_bar_arrival);
|
announceTimeDistances.setArrivalDistances(value);
|
||||||
ivArrow = rootView.findViewById(R.id.iv_arrow);
|
tvIntervalsDescr.setText(announceTimeDistances.getIntervalsDescription(app));
|
||||||
tvIntervalsDescr = rootView.findViewById(R.id.tv_interval_descr);
|
}
|
||||||
|
|
||||||
seekBarArrival.setOnSeekBarChangeListener(this);
|
private void toggleDescriptionVisibility() {
|
||||||
ivArrow.setOnClickListener(new View.OnClickListener() {
|
collapsed = !collapsed;
|
||||||
@Override
|
ivArrow.setImageResource(collapsed ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up);
|
||||||
public void onClick(View v) {
|
AndroidUiHelper.updateVisibility(tvIntervalsDescr, !collapsed);
|
||||||
toggleViews();
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setupIvIllustration();
|
public static void showInstance(@NonNull FragmentManager fm, String prefKey, Fragment target,
|
||||||
setDividerColor();
|
@Nullable ApplicationMode appMode, boolean usedOnMap) {
|
||||||
|
try {
|
||||||
return new BaseBottomSheetItem.Builder()
|
if (!fm.isStateSaved()) {
|
||||||
.setCustomView(rootView)
|
Bundle args = new Bundle();
|
||||||
.create();
|
args.putString(PREFERENCE_ID, prefKey);
|
||||||
}
|
AnnouncementTimeBottomSheet fragment = new AnnouncementTimeBottomSheet();
|
||||||
|
fragment.setArguments(args);
|
||||||
private void setupIvIllustration() {
|
fragment.setAppMode(appMode);
|
||||||
int drawableId = nightMode ? R.drawable.img_help_announcement_time_night
|
fragment.setUsedOnMap(usedOnMap);
|
||||||
: R.drawable.img_help_announcement_time_day;
|
fragment.setTargetFragment(target, 0);
|
||||||
|
fragment.show(fm, TAG);
|
||||||
ImageView ivIllustration = rootView.findViewById(R.id.iv_illustration);
|
}
|
||||||
ivIllustration.setImageResource(drawableId);
|
} catch (RuntimeException e) {
|
||||||
}
|
LOG.error("showInstance", e);
|
||||||
|
}
|
||||||
private void setDividerColor() {
|
}
|
||||||
int colorId = nightMode ? R.color.divider_color_dark : R.color.divider_color_light;
|
|
||||||
View divider = rootView.findViewById(R.id.divider);
|
|
||||||
divider.setBackgroundColor(getResources().getColor(colorId));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateViews() {
|
|
||||||
seekBarArrival.setProgress(selectedEntryIndex);
|
|
||||||
tvSeekBarLabel.setText(listPreference.getEntries()[selectedEntryIndex]);
|
|
||||||
|
|
||||||
float value = (float) listPreference.getEntryValues()[selectedEntryIndex];
|
|
||||||
announceTimeDistances.setArrivalDistances(value);
|
|
||||||
tvIntervalsDescr.setText(announceTimeDistances.getIntervalsDescription(app));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleViews() {
|
|
||||||
int drawableId = collapsed ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up;
|
|
||||||
collapsed = !collapsed;
|
|
||||||
ivArrow.setImageResource(drawableId);
|
|
||||||
|
|
||||||
if (tvIntervalsDescr.getVisibility() == View.VISIBLE) {
|
|
||||||
tvIntervalsDescr.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
tvIntervalsDescr.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showInstance(@NonNull FragmentManager fm, String prefKey, Fragment target,
|
|
||||||
@Nullable ApplicationMode appMode) {
|
|
||||||
try {
|
|
||||||
if (!fm.isStateSaved()) {
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString(PREFERENCE_ID, prefKey);
|
|
||||||
AnnouncementTimeBottomSheet fragment = new AnnouncementTimeBottomSheet();
|
|
||||||
fragment.setArguments(args);
|
|
||||||
fragment.setAppMode(appMode);
|
|
||||||
fragment.setTargetFragment(target, 0);
|
|
||||||
fragment.show(fm, TAG);
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
LOG.error("showInstance", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -42,23 +42,6 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr
|
||||||
public static final String TAG = VoiceAnnouncesFragment.class.getSimpleName();
|
public static final String TAG = VoiceAnnouncesFragment.class.getSimpleName();
|
||||||
|
|
||||||
private static final String MORE_VALUE = "MORE_VALUE";
|
private static final String MORE_VALUE = "MORE_VALUE";
|
||||||
private static final String ARRIVAL_DISTANCE_FACTOR = "arrival_distance_factor";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisplayPreferenceDialog(Preference preference) {
|
|
||||||
String prefId = preference.getKey();
|
|
||||||
|
|
||||||
if (prefId.equals(ARRIVAL_DISTANCE_FACTOR)) {
|
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
|
||||||
if (fragmentManager != null) {
|
|
||||||
AnnouncementTimeBottomSheet.showInstance(
|
|
||||||
fragmentManager, preference.getKey(), this, getSelectedAppMode()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
super.onDisplayPreferenceDialog(preference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createToolbar(LayoutInflater inflater, View view) {
|
protected void createToolbar(LayoutInflater inflater, View view) {
|
||||||
|
@ -319,6 +302,20 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment implements OnPr
|
||||||
return super.onPreferenceClick(preference);
|
return super.onPreferenceClick(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisplayPreferenceDialog(Preference preference) {
|
||||||
|
String prefId = preference.getKey();
|
||||||
|
|
||||||
|
if (settings.ARRIVAL_DISTANCE_FACTOR.getId().equals(prefId)) {
|
||||||
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
|
if (fragmentManager != null) {
|
||||||
|
AnnouncementTimeBottomSheet.showInstance(fragmentManager, preference.getKey(), this, getSelectedAppMode(), false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
super.onDisplayPreferenceDialog(preference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPreferenceChanged(String prefId) {
|
public void onPreferenceChanged(String prefId) {
|
||||||
if (prefId.equals(settings.SPEED_CAMERAS_UNINSTALLED.getId())) {
|
if (prefId.equals(settings.SPEED_CAMERAS_UNINSTALLED.getId())) {
|
||||||
|
|
Loading…
Reference in a new issue