Track appearance fixes
This commit is contained in:
parent
5be8902e02
commit
de5e161095
51 changed files with 694 additions and 302 deletions
|
@ -1559,6 +1559,10 @@ public class GPXUtilities {
|
||||||
getExtensionsToWrite().put("gradient_scale_type", gradientScaleType);
|
getExtensionsToWrite().put("gradient_scale_type", gradientScaleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeGradientScaleType() {
|
||||||
|
getExtensionsToWrite().remove("gradient_scale_type");
|
||||||
|
}
|
||||||
|
|
||||||
public String getSplitType() {
|
public String getSplitType() {
|
||||||
if (extensions != null) {
|
if (extensions != null) {
|
||||||
return extensions.get("split_type");
|
return extensions.get("split_type");
|
||||||
|
|
5
OsmAnd/res/drawable/radio_button_center_dark.xml
Normal file
5
OsmAnd/res/drawable/radio_button_center_dark.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@drawable/radio_button_selected_center_dark" android:state_checked="true" />
|
||||||
|
<item android:drawable="@drawable/radio_button_regular_center_dark" />
|
||||||
|
</selector>
|
5
OsmAnd/res/drawable/radio_button_center_light.xml
Normal file
5
OsmAnd/res/drawable/radio_button_center_light.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@drawable/radio_button_selected_center_light" android:state_checked="true" />
|
||||||
|
<item android:drawable="@drawable/radio_button_regular_center_light" />
|
||||||
|
</selector>
|
5
OsmAnd/res/drawable/radio_button_left_dark.xml
Normal file
5
OsmAnd/res/drawable/radio_button_left_dark.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@drawable/radio_button_selected_left_dark" android:state_checked="true" />
|
||||||
|
<item android:drawable="@drawable/radio_button_regular_left_dark" />
|
||||||
|
</selector>
|
5
OsmAnd/res/drawable/radio_button_left_light.xml
Normal file
5
OsmAnd/res/drawable/radio_button_left_light.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@drawable/radio_button_selected_left_light" android:state_checked="true" />
|
||||||
|
<item android:drawable="@drawable/radio_button_regular_left_light" />
|
||||||
|
</selector>
|
7
OsmAnd/res/drawable/radio_button_regular_center_dark.xml
Normal file
7
OsmAnd/res/drawable/radio_button_regular_center_dark.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/stroked_buttons_and_links_outline_dark" />
|
||||||
|
</shape>
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/stroked_buttons_and_links_outline_light" />
|
||||||
|
</shape>
|
10
OsmAnd/res/drawable/radio_button_regular_left_dark.xml
Normal file
10
OsmAnd/res/drawable/radio_button_regular_left_dark.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners
|
||||||
|
android:bottomLeftRadius="4dp"
|
||||||
|
android:topLeftRadius="4dp" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/stroked_buttons_and_links_outline_dark" />
|
||||||
|
</shape>
|
10
OsmAnd/res/drawable/radio_button_regular_left_light.xml
Normal file
10
OsmAnd/res/drawable/radio_button_regular_left_light.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners
|
||||||
|
android:bottomLeftRadius="4dp"
|
||||||
|
android:topLeftRadius="4dp" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/stroked_buttons_and_links_outline_light" />
|
||||||
|
</shape>
|
10
OsmAnd/res/drawable/radio_button_regular_right_dark.xml
Normal file
10
OsmAnd/res/drawable/radio_button_regular_right_dark.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners
|
||||||
|
android:bottomRightRadius="4dp"
|
||||||
|
android:topRightRadius="4dp" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/stroked_buttons_and_links_outline_dark" />
|
||||||
|
</shape>
|
10
OsmAnd/res/drawable/radio_button_regular_right_light.xml
Normal file
10
OsmAnd/res/drawable/radio_button_regular_right_light.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners
|
||||||
|
android:bottomRightRadius="4dp"
|
||||||
|
android:topRightRadius="4dp" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/stroked_buttons_and_links_outline_light" />
|
||||||
|
</shape>
|
5
OsmAnd/res/drawable/radio_button_right_dark.xml
Normal file
5
OsmAnd/res/drawable/radio_button_right_dark.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@drawable/radio_button_selected_right_dark" android:state_checked="true" />
|
||||||
|
<item android:drawable="@drawable/radio_button_regular_right_dark" />
|
||||||
|
</selector>
|
5
OsmAnd/res/drawable/radio_button_right_light.xml
Normal file
5
OsmAnd/res/drawable/radio_button_right_light.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@drawable/radio_button_selected_right_light" android:state_checked="true" />
|
||||||
|
<item android:drawable="@drawable/radio_button_regular_right_light" />
|
||||||
|
</selector>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="@color/switch_button_active_dark" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/switch_button_active_stroke_dark" />
|
||||||
|
</shape>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="@color/switch_button_active_light" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/switch_button_active_stroke_light" />
|
||||||
|
</shape>
|
11
OsmAnd/res/drawable/radio_button_selected_left_dark.xml
Normal file
11
OsmAnd/res/drawable/radio_button_selected_left_dark.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners
|
||||||
|
android:bottomLeftRadius="4dp"
|
||||||
|
android:topLeftRadius="4dp" />
|
||||||
|
<solid android:color="@color/switch_button_active_dark" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/switch_button_active_stroke_dark" />
|
||||||
|
</shape>
|
11
OsmAnd/res/drawable/radio_button_selected_left_light.xml
Normal file
11
OsmAnd/res/drawable/radio_button_selected_left_light.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners
|
||||||
|
android:bottomLeftRadius="4dp"
|
||||||
|
android:topLeftRadius="4dp" />
|
||||||
|
<solid android:color="@color/switch_button_active_light" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/switch_button_active_stroke_light" />
|
||||||
|
</shape>
|
11
OsmAnd/res/drawable/radio_button_selected_right_dark.xml
Normal file
11
OsmAnd/res/drawable/radio_button_selected_right_dark.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners
|
||||||
|
android:bottomRightRadius="4dp"
|
||||||
|
android:topRightRadius="4dp" />
|
||||||
|
<solid android:color="@color/switch_button_active_dark" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/switch_button_active_stroke_dark" />
|
||||||
|
</shape>
|
11
OsmAnd/res/drawable/radio_button_selected_right_light.xml
Normal file
11
OsmAnd/res/drawable/radio_button_selected_right_light.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners
|
||||||
|
android:bottomRightRadius="4dp"
|
||||||
|
android:topRightRadius="4dp" />
|
||||||
|
<solid android:color="@color/switch_button_active_light" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/switch_button_active_stroke_light" />
|
||||||
|
</shape>
|
5
OsmAnd/res/drawable/radio_flat_text_selector_dark.xml
Normal file
5
OsmAnd/res/drawable/radio_flat_text_selector_dark.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:color="@color/active_color_primary_dark" android:state_checked="false" />
|
||||||
|
<item android:color="@color/text_color_primary_dark" android:state_checked="true" />
|
||||||
|
</selector>
|
5
OsmAnd/res/drawable/radio_flat_text_selector_light.xml
Normal file
5
OsmAnd/res/drawable/radio_flat_text_selector_light.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:color="@color/active_color_primary_light" android:state_checked="false" />
|
||||||
|
<item android:color="@color/text_color_primary_light" android:state_checked="true" />
|
||||||
|
</selector>
|
|
@ -22,37 +22,37 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="@drawable/radio_button_left"
|
android:background="?attr/btn_radio_button_left"
|
||||||
android:button="@android:color/transparent"
|
android:button="@android:color/transparent"
|
||||||
android:checked="true"
|
android:checked="true"
|
||||||
android:foreground="?attr/selectableItemBackground"
|
android:foreground="?attr/selectableItemBackground"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/shared_string_none"
|
android:text="@string/shared_string_none"
|
||||||
android:textColor="@drawable/radio_flat_text_selector" />
|
android:textColor="@drawable/radio_flat_text_selector_light" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/time_split"
|
android:id="@+id/time_split"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="@drawable/radio_button_center"
|
android:background="?attr/btn_radio_button_center"
|
||||||
android:button="@android:color/transparent"
|
android:button="@android:color/transparent"
|
||||||
android:foreground="?attr/selectableItemBackground"
|
android:foreground="?attr/selectableItemBackground"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/shared_string_time"
|
android:text="@string/shared_string_time"
|
||||||
android:textColor="@drawable/radio_flat_text_selector" />
|
android:textColor="@drawable/radio_flat_text_selector_light" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/distance_split"
|
android:id="@+id/distance_split"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="@drawable/radio_button_right"
|
android:background="?attr/btn_radio_button_right"
|
||||||
android:button="@android:color/transparent"
|
android:button="@android:color/transparent"
|
||||||
android:foreground="?attr/selectableItemBackground"
|
android:foreground="?attr/selectableItemBackground"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/distance"
|
android:text="@string/distance"
|
||||||
android:textColor="@drawable/radio_flat_text_selector"
|
android:textColor="@drawable/radio_flat_text_selector_light"
|
||||||
android:textSize="@dimen/default_desc_text_size" />
|
android:textSize="@dimen/default_desc_text_size" />
|
||||||
|
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
|
@ -3823,4 +3823,6 @@
|
||||||
<string name="set_working_days_to_continue">Необходимо указать рабочие дни для продолжения</string>
|
<string name="set_working_days_to_continue">Необходимо указать рабочие дни для продолжения</string>
|
||||||
<string name="route_between_points">Маршрут между пунктами</string>
|
<string name="route_between_points">Маршрут между пунктами</string>
|
||||||
<string name="plan_a_route">План маршрута</string>
|
<string name="plan_a_route">План маршрута</string>
|
||||||
|
<string name="gpx_split_interval_none_descr">Выберите нужный вариант разбиения: по времени или по расстоянию.</string>
|
||||||
|
<string name="gpx_split_interval_descr">Выберите интервал с которым будут отображаться метки с расстоянием или временем на треке.</string>
|
||||||
</resources>
|
</resources>
|
|
@ -133,6 +133,9 @@
|
||||||
<attr name="profile_save_btn" format="reference"/>
|
<attr name="profile_save_btn" format="reference"/>
|
||||||
<attr name="profile_cancel_btn" format="reference"/>
|
<attr name="profile_cancel_btn" format="reference"/>
|
||||||
<attr name="btn_bg_border_inactive" format="reference"/>
|
<attr name="btn_bg_border_inactive" format="reference"/>
|
||||||
|
<attr name="btn_radio_button_left" format="reference"/>
|
||||||
|
<attr name="btn_radio_button_right" format="reference"/>
|
||||||
|
<attr name="btn_radio_button_center" format="reference"/>
|
||||||
<attr name="bg_dash_line" format="reference"/>
|
<attr name="bg_dash_line" format="reference"/>
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
|
|
|
@ -471,7 +471,8 @@
|
||||||
|
|
||||||
<color name="switch_button_active_light">#1A237BFF</color>
|
<color name="switch_button_active_light">#1A237BFF</color>
|
||||||
<color name="switch_button_active_dark">#1AD28521</color>
|
<color name="switch_button_active_dark">#1AD28521</color>
|
||||||
<color name="switch_button_active_stroke">#80237BFF</color>
|
<color name="switch_button_active_stroke_light">#80237BFF</color>
|
||||||
|
<color name="switch_button_active_stroke_dark">#80D28521</color>
|
||||||
<color name="empty_hint_bg">#80000000</color>
|
<color name="empty_hint_bg">#80000000</color>
|
||||||
<color name="input_layout_bg_color">#4DCCCCCC</color>
|
<color name="input_layout_bg_color">#4DCCCCCC</color>
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,13 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="track_coloring_solid">Solid</string>
|
||||||
|
<string name="gpx_direction_arrows">Direction arrows</string>
|
||||||
|
<string name="shared_string_custom">Custom</string>
|
||||||
|
<string name="gpx_split_interval_none_descr">Select the desired splitting option: by time or by distance.</string>
|
||||||
|
<string name="gpx_split_interval_descr">Select the interval at which marks with distance or time on the track will be displayed.</string>
|
||||||
|
<string name="select_track_width">Select width</string>
|
||||||
|
<string name="track_show_start_finish_icons">Show start finish icons</string>
|
||||||
<string name="add_to_a_track">Add to a Track</string>
|
<string name="add_to_a_track">Add to a Track</string>
|
||||||
<string name="plan_a_route">Plan a route</string>
|
<string name="plan_a_route">Plan a route</string>
|
||||||
<string name="route_between_points">Route between points</string>
|
<string name="route_between_points">Route between points</string>
|
||||||
|
|
|
@ -297,6 +297,9 @@
|
||||||
<item name="android:toolbarStyle">@style/ToolbarStyle</item>
|
<item name="android:toolbarStyle">@style/ToolbarStyle</item>
|
||||||
<item name="toolbarStyle">@style/ToolbarStyle</item>
|
<item name="toolbarStyle">@style/ToolbarStyle</item>
|
||||||
<item name="bg_dash_line">@drawable/bg_dash_line_light</item>
|
<item name="bg_dash_line">@drawable/bg_dash_line_light</item>
|
||||||
|
<item name="btn_radio_button_left">@drawable/radio_button_left_light</item>
|
||||||
|
<item name="btn_radio_button_right">@drawable/radio_button_right_light</item>
|
||||||
|
<item name="btn_radio_button_center">@drawable/radio_button_center_light</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
|
<style name="ToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
|
||||||
|
@ -578,6 +581,9 @@
|
||||||
<item name="android:toolbarStyle">@style/ToolbarStyle</item>
|
<item name="android:toolbarStyle">@style/ToolbarStyle</item>
|
||||||
<item name="toolbarStyle">@style/ToolbarStyle</item>
|
<item name="toolbarStyle">@style/ToolbarStyle</item>
|
||||||
<item name="bg_dash_line">@drawable/bg_dash_line_dark</item>
|
<item name="bg_dash_line">@drawable/bg_dash_line_dark</item>
|
||||||
|
<item name="btn_radio_button_left">@drawable/radio_button_left_dark</item>
|
||||||
|
<item name="btn_radio_button_right">@drawable/radio_button_right_dark</item>
|
||||||
|
<item name="btn_radio_button_center">@drawable/radio_button_center_dark</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="FreeVersionBanner" parent="OsmandDarkTheme">
|
<style name="FreeVersionBanner" parent="OsmandDarkTheme">
|
||||||
|
|
|
@ -539,7 +539,7 @@ public class GPXDatabase {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateGradientScaleType(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType) {
|
public boolean updateGradientScaleType(@NonNull GpxDataItem item, @Nullable GradientScaleType gradientScaleType) {
|
||||||
SQLiteConnection db = openConnection(false);
|
SQLiteConnection db = openConnection(false);
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -547,7 +547,7 @@ public class GPXDatabase {
|
||||||
String fileDir = getFileDir(item.file);
|
String fileDir = getFileDir(item.file);
|
||||||
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_GRADIENT_SCALE_TYPE + " = ? " +
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_GRADIENT_SCALE_TYPE + " = ? " +
|
||||||
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||||
new Object[] {gradientScaleType.name(), fileName, fileDir});
|
new Object[] {(gradientScaleType == null ? "" : gradientScaleType.name()), fileName, fileDir});
|
||||||
item.gradientScaleType = gradientScaleType;
|
item.gradientScaleType = gradientScaleType;
|
||||||
} finally {
|
} finally {
|
||||||
db.close();
|
db.close();
|
||||||
|
@ -723,7 +723,7 @@ public class GPXDatabase {
|
||||||
} else {
|
} else {
|
||||||
color = Algorithms.colorToString(item.color);
|
color = Algorithms.colorToString(item.color);
|
||||||
}
|
}
|
||||||
String gradientScaleType = item.gradientScaleType != null ? item.gradientScaleType.name() : GradientScaleType.SOLID.name();
|
String gradientScaleType = item.gradientScaleType != null ? item.gradientScaleType.name() : null;
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
db.execSQL(
|
db.execSQL(
|
||||||
"INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
"INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
|
@ -891,7 +891,7 @@ public class GPXDatabase {
|
||||||
try {
|
try {
|
||||||
item.gradientScaleType = Algorithms.isEmpty(gradientScaleType) ? null : GradientScaleType.valueOf(gradientScaleType);
|
item.gradientScaleType = Algorithms.isEmpty(gradientScaleType) ? null : GradientScaleType.valueOf(gradientScaleType);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
item.gradientScaleType = GradientScaleType.SOLID;
|
item.gradientScaleType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class GpxDbHelper {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateGradientScaleType(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType) {
|
public boolean updateGradientScaleType(@NonNull GpxDataItem item, @Nullable GradientScaleType gradientScaleType) {
|
||||||
boolean res = db.updateGradientScaleType(item, gradientScaleType);
|
boolean res = db.updateGradientScaleType(item, gradientScaleType);
|
||||||
putToCache(item);
|
putToCache(item);
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -528,16 +528,13 @@ public class GpxSelectionHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (obj.has(SHOW_ARROWS)) {
|
if (obj.has(SHOW_ARROWS)) {
|
||||||
boolean showArrows = obj.optBoolean(SHOW_ARROWS, false);
|
gpx.setShowArrows(obj.optBoolean(SHOW_ARROWS, false));
|
||||||
gpx.setShowArrows(showArrows);
|
|
||||||
}
|
}
|
||||||
if (obj.has(GRADIENT_SCALE_TYPE)) {
|
if (obj.has(GRADIENT_SCALE_TYPE)) {
|
||||||
String gradientScaleTypeName = obj.optString(GRADIENT_SCALE_TYPE);
|
gpx.setGradientScaleType(obj.optString(GRADIENT_SCALE_TYPE));
|
||||||
gpx.setGradientScaleType(gradientScaleTypeName);
|
|
||||||
}
|
}
|
||||||
if (obj.has(SHOW_START_FINISH)) {
|
if (obj.has(SHOW_START_FINISH)) {
|
||||||
boolean showStartFinish = obj.optBoolean(SHOW_START_FINISH, false);
|
gpx.setShowStartFinish(obj.optBoolean(SHOW_START_FINISH, false));
|
||||||
gpx.setShowStartFinish(showStartFinish);
|
|
||||||
}
|
}
|
||||||
if (obj.has(WIDTH)) {
|
if (obj.has(WIDTH)) {
|
||||||
gpx.setWidth(obj.getString(WIDTH));
|
gpx.setWidth(obj.getString(WIDTH));
|
||||||
|
|
|
@ -178,7 +178,7 @@ public class TrackActivity extends TabActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GpxDisplayGroup> getGpxDisplayGroups(boolean useDisplayGroups) {
|
public List<GpxDisplayGroup> getGpxFile(boolean useDisplayGroups) {
|
||||||
if (gpxFile == null) {
|
if (gpxFile == null) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.Appe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
private void init() {
|
||||||
addAll(getAppearanceItems(app, adapterType));
|
addAll(getAppearanceItems(app, adapterType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@ import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
import net.osmand.plus.base.PointImageDrawable;
|
import net.osmand.plus.base.PointImageDrawable;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
|
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
|
||||||
import net.osmand.plus.myplaces.SaveGpxAsyncTask;
|
import net.osmand.plus.track.SaveGpxAsyncTask;
|
||||||
import net.osmand.plus.myplaces.SaveGpxAsyncTask.SaveGpxListener;
|
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
@ -30,8 +30,8 @@ import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
import net.osmand.plus.base.PointImageDrawable;
|
import net.osmand.plus.base.PointImageDrawable;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
|
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
|
||||||
import net.osmand.plus.myplaces.SaveGpxAsyncTask;
|
import net.osmand.plus.track.SaveGpxAsyncTask;
|
||||||
import net.osmand.plus.myplaces.SaveGpxAsyncTask.SaveGpxListener;
|
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -380,7 +380,7 @@ public class SplitSegmentDialogFragment extends DialogFragment {
|
||||||
private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
|
private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
|
||||||
List<GpxDisplayGroup> groups = new ArrayList<>();
|
List<GpxDisplayGroup> groups = new ArrayList<>();
|
||||||
if (getTrackActivity() != null) {
|
if (getTrackActivity() != null) {
|
||||||
List<GpxDisplayGroup> result = getTrackActivity().getGpxDisplayGroups(useDisplayGroups);
|
List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(useDisplayGroups);
|
||||||
for (GpxDisplayGroup group : result) {
|
for (GpxDisplayGroup group : result) {
|
||||||
boolean add = hasFilterType(group.getType());
|
boolean add = hasFilterType(group.getType());
|
||||||
if (add) {
|
if (add) {
|
||||||
|
@ -397,7 +397,7 @@ public class SplitSegmentDialogFragment extends DialogFragment {
|
||||||
TrackActivity trackActivity = getTrackActivity();
|
TrackActivity trackActivity = getTrackActivity();
|
||||||
List<GpxDisplayItem> splitSegments = new ArrayList<>();
|
List<GpxDisplayItem> splitSegments = new ArrayList<>();
|
||||||
if (trackActivity != null) {
|
if (trackActivity != null) {
|
||||||
List<GpxDisplayGroup> result = trackActivity.getGpxDisplayGroups(true);
|
List<GpxDisplayGroup> result = trackActivity.getGpxFile(true);
|
||||||
if (result != null && result.size() > 0 && trkSegment.points.size() > 0) {
|
if (result != null && result.size() > 0 && trkSegment.points.size() > 0) {
|
||||||
for (GpxDisplayGroup group : result) {
|
for (GpxDisplayGroup group : result) {
|
||||||
splitSegments.addAll(collectDisplayItemsFromGroup(group));
|
splitSegments.addAll(collectDisplayItemsFromGroup(group));
|
||||||
|
|
|
@ -54,7 +54,8 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.TrackActivity;
|
import net.osmand.plus.activities.TrackActivity;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData;
|
import net.osmand.plus.measurementtool.NewGpxData;
|
||||||
import net.osmand.plus.myplaces.SplitTrackAsyncTask.SplitTrackListener;
|
import net.osmand.plus.track.SplitTrackAsyncTask;
|
||||||
|
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
|
||||||
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.track.GpxSplitType;
|
import net.osmand.plus.track.GpxSplitType;
|
||||||
|
@ -352,6 +353,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
showTemporaryObjectOnMap(getGpx());
|
showTemporaryObjectOnMap(getGpx());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
appearanceView.setVisibility(View.VISIBLE);
|
||||||
splitColorView.setVisibility(View.VISIBLE);
|
splitColorView.setVisibility(View.VISIBLE);
|
||||||
divider.setVisibility(View.VISIBLE);
|
divider.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -368,7 +370,8 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
GPXFile gpx = getGpx();
|
GPXFile gpx = getGpx();
|
||||||
WptPt pointToShow = gpx != null ? gpx.findPointToShow() : null;
|
WptPt pointToShow = gpx != null ? gpx.findPointToShow() : null;
|
||||||
if (activity != null && pointToShow != null) {
|
if (activity != null && pointToShow != null) {
|
||||||
if (!isGpxFileSelected(gpx)) {
|
boolean gpxFileSelected = isGpxFileSelected(gpx);
|
||||||
|
if (!gpxFileSelected) {
|
||||||
Intent intent = activity.getIntent();
|
Intent intent = activity.getIntent();
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
intent.putExtra(TrackActivity.SHOW_TEMPORARILY, true);
|
intent.putExtra(TrackActivity.SHOW_TEMPORARILY, true);
|
||||||
|
@ -376,6 +379,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
}
|
}
|
||||||
setTrackVisibilityOnMap(true);
|
setTrackVisibilityOnMap(true);
|
||||||
|
|
||||||
|
final OsmandSettings settings = app.getSettings();
|
||||||
String trackName;
|
String trackName;
|
||||||
if (gpx.showCurrentTrack) {
|
if (gpx.showCurrentTrack) {
|
||||||
trackName = app.getString(R.string.shared_string_currently_recording_track);
|
trackName = app.getString(R.string.shared_string_currently_recording_track);
|
||||||
|
@ -384,7 +388,6 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
} else {
|
} else {
|
||||||
trackName = gpx.path;
|
trackName = gpx.path;
|
||||||
}
|
}
|
||||||
OsmandSettings settings = app.getSettings();
|
|
||||||
settings.setMapLocationToShow(pointToShow.getLatitude(), pointToShow.getLongitude(),
|
settings.setMapLocationToShow(pointToShow.getLatitude(), pointToShow.getLongitude(),
|
||||||
settings.getLastKnownMapZoom(),
|
settings.getLastKnownMapZoom(),
|
||||||
new PointDescription(PointDescription.POINT_TYPE_WPT, trackName),
|
new PointDescription(PointDescription.POINT_TYPE_WPT, trackName),
|
||||||
|
@ -394,6 +397,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
MapActivity.launchMapActivityMoveToTop(activity);
|
MapActivity.launchMapActivityMoveToTop(activity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ListPopupWindow createPopupWindow(Activity activity, View anchorView, ListAdapter adapter, OnItemClickListener itemClickListener) {
|
private ListPopupWindow createPopupWindow(Activity activity, View anchorView, ListAdapter adapter, OnItemClickListener itemClickListener) {
|
||||||
ListPopupWindow popupWindow = new ListPopupWindow(activity);
|
ListPopupWindow popupWindow = new ListPopupWindow(activity);
|
||||||
popupWindow.setAnchorView(anchorView);
|
popupWindow.setAnchorView(anchorView);
|
||||||
|
@ -646,7 +650,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
List<GpxDisplayGroup> groups = new ArrayList<>();
|
List<GpxDisplayGroup> groups = new ArrayList<>();
|
||||||
TrackActivity activity = getTrackActivity();
|
TrackActivity activity = getTrackActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
List<GpxDisplayGroup> result = activity.getGpxDisplayGroups(useDisplayGroups);
|
List<GpxDisplayGroup> result = activity.getGpxFile(useDisplayGroups);
|
||||||
for (GpxDisplayGroup group : result) {
|
for (GpxDisplayGroup group : result) {
|
||||||
boolean add = hasFilterType(group.getType());
|
boolean add = hasFilterType(group.getType());
|
||||||
if (add) {
|
if (add) {
|
||||||
|
@ -746,9 +750,9 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSplit(@NonNull List<GpxDisplayGroup> groups, @Nullable final SelectedGpxFile selectedGpx) {
|
private void updateSplit(@NonNull List<GpxDisplayGroup> groups, @Nullable final SelectedGpxFile selectedGpx) {
|
||||||
|
GPXFile gpxFile = getGpx();
|
||||||
TrackActivity activity = getTrackActivity();
|
TrackActivity activity = getTrackActivity();
|
||||||
GpxSplitType gpxSplitType = getGpxSplitType();
|
GpxSplitType gpxSplitType = getGpxSplitType();
|
||||||
GPXFile gpxFile = getGpx();
|
|
||||||
if (activity != null && gpxSplitType != null && gpxFile != null) {
|
if (activity != null && gpxSplitType != null && gpxFile != null) {
|
||||||
int timeSplit = 0;
|
int timeSplit = 0;
|
||||||
double distanceSplit = 0;
|
double distanceSplit = 0;
|
||||||
|
|
|
@ -68,7 +68,8 @@ import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData;
|
import net.osmand.plus.measurementtool.NewGpxData;
|
||||||
import net.osmand.plus.myplaces.SaveGpxAsyncTask.SaveGpxListener;
|
import net.osmand.plus.track.SaveGpxAsyncTask;
|
||||||
|
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
|
||||||
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||||
|
|
48
OsmAnd/src/net/osmand/plus/track/DirectionArrowsCard.java
Normal file
48
OsmAnd/src/net/osmand/plus/track/DirectionArrowsCard.java
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
package net.osmand.plus.track;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
|
|
||||||
|
public class DirectionArrowsCard extends BaseCard {
|
||||||
|
|
||||||
|
private TrackDrawInfo trackDrawInfo;
|
||||||
|
|
||||||
|
public DirectionArrowsCard(@NonNull MapActivity mapActivity, @NonNull TrackDrawInfo trackDrawInfo) {
|
||||||
|
super(mapActivity);
|
||||||
|
this.trackDrawInfo = trackDrawInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCardLayoutId() {
|
||||||
|
return R.layout.bottom_sheet_item_with_switch;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateContent() {
|
||||||
|
AndroidUiHelper.updateVisibility(view.findViewById(R.id.icon), false);
|
||||||
|
|
||||||
|
TextView titleView = view.findViewById(R.id.title);
|
||||||
|
titleView.setText(R.string.gpx_direction_arrows);
|
||||||
|
|
||||||
|
final CompoundButton compoundButton = view.findViewById(R.id.compound_button);
|
||||||
|
compoundButton.setChecked(trackDrawInfo.isShowArrows());
|
||||||
|
|
||||||
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
boolean checked = !compoundButton.isChecked();
|
||||||
|
compoundButton.setChecked(checked);
|
||||||
|
trackDrawInfo.setShowArrows(checked);
|
||||||
|
mapActivity.refreshMap();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,6 @@ import net.osmand.plus.R;
|
||||||
|
|
||||||
public enum GradientScaleType {
|
public enum GradientScaleType {
|
||||||
|
|
||||||
SOLID("gradient_solid_color", R.string.track_coloring_solid, R.drawable.ic_action_circle),
|
|
||||||
SPEED("gradient_speed_color", R.string.map_widget_speed, R.drawable.ic_action_speed),
|
SPEED("gradient_speed_color", R.string.map_widget_speed, R.drawable.ic_action_speed),
|
||||||
ALTITUDE("gradient_altitude_color", R.string.altitude, R.drawable.ic_action_altitude_average),
|
ALTITUDE("gradient_altitude_color", R.string.altitude, R.drawable.ic_action_altitude_average),
|
||||||
SLOPE("gradient_slope_color", R.string.shared_string_slope, R.drawable.ic_action_altitude_ascent);
|
SLOPE("gradient_slope_color", R.string.shared_string_slope, R.drawable.ic_action_altitude_ascent);
|
||||||
|
|
49
OsmAnd/src/net/osmand/plus/track/SaveGpxAsyncTask.java
Normal file
49
OsmAnd/src/net/osmand/plus/track/SaveGpxAsyncTask.java
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
package net.osmand.plus.track;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.osmand.GPXUtilities;
|
||||||
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class SaveGpxAsyncTask extends AsyncTask<Void, Void, Exception> {
|
||||||
|
|
||||||
|
private final GPXFile gpx;
|
||||||
|
private final SaveGpxListener saveGpxListener;
|
||||||
|
|
||||||
|
public SaveGpxAsyncTask(@NonNull GPXFile gpx,
|
||||||
|
@Nullable SaveGpxListener saveGpxListener) {
|
||||||
|
this.gpx = gpx;
|
||||||
|
this.saveGpxListener = saveGpxListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
if (saveGpxListener != null) {
|
||||||
|
saveGpxListener.gpxSavingStarted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Exception doInBackground(Void... params) {
|
||||||
|
return GPXUtilities.writeGpxFile(new File(gpx.path), gpx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Exception errorMessage) {
|
||||||
|
if (saveGpxListener != null) {
|
||||||
|
saveGpxListener.gpxSavingFinished(errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface SaveGpxListener {
|
||||||
|
|
||||||
|
void gpxSavingStarted();
|
||||||
|
|
||||||
|
void gpxSavingFinished(Exception errorMessage);
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,8 +27,7 @@ import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.myplaces.SplitTrackAsyncTask;
|
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
|
||||||
import net.osmand.plus.myplaces.SplitTrackAsyncTask.SplitTrackListener;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -13,13 +12,8 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
|
|
||||||
public class SplitIntervalCard extends BaseCard {
|
public class SplitIntervalCard extends BaseCard {
|
||||||
|
|
||||||
private TrackDrawInfo trackDrawInfo;
|
public SplitIntervalCard(@NonNull MapActivity mapActivity) {
|
||||||
private Fragment targetFragment;
|
|
||||||
|
|
||||||
public SplitIntervalCard(@NonNull MapActivity mapActivity, TrackDrawInfo trackDrawInfo, Fragment targetFragment) {
|
|
||||||
super(mapActivity);
|
super(mapActivity);
|
||||||
this.trackDrawInfo = trackDrawInfo;
|
|
||||||
this.targetFragment = targetFragment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,12 +28,13 @@ public class SplitIntervalCard extends BaseCard {
|
||||||
TextView titleView = view.findViewById(R.id.title);
|
TextView titleView = view.findViewById(R.id.title);
|
||||||
titleView.setText(R.string.gpx_split_interval);
|
titleView.setText(R.string.gpx_split_interval);
|
||||||
|
|
||||||
TextView descriptionView = view.findViewById(R.id.description);
|
|
||||||
|
|
||||||
view.setOnClickListener(new View.OnClickListener() {
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), trackDrawInfo, targetFragment);
|
CardListener listener = getListener();
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onCardPressed(SplitIntervalCard.this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
75
OsmAnd/src/net/osmand/plus/track/SplitTrackAsyncTask.java
Normal file
75
OsmAnd/src/net/osmand/plus/track/SplitTrackAsyncTask.java
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
package net.osmand.plus.track;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SplitTrackAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
private GpxSplitType gpxSplitType;
|
||||||
|
private List<GpxDisplayGroup> groups;
|
||||||
|
private SplitTrackListener splitTrackListener;
|
||||||
|
|
||||||
|
private boolean joinSegments;
|
||||||
|
private int timeSplitInterval;
|
||||||
|
private double distanceSplitInterval;
|
||||||
|
|
||||||
|
public SplitTrackAsyncTask(@NonNull OsmandApplication app,
|
||||||
|
@NonNull GpxSplitType gpxSplitType,
|
||||||
|
@NonNull List<GpxDisplayGroup> groups,
|
||||||
|
@Nullable SplitTrackListener splitTrackListener,
|
||||||
|
boolean joinSegments,
|
||||||
|
int timeSplitInterval,
|
||||||
|
double distanceSplitInterval) {
|
||||||
|
this.app = app;
|
||||||
|
this.groups = groups;
|
||||||
|
this.gpxSplitType = gpxSplitType;
|
||||||
|
this.splitTrackListener = splitTrackListener;
|
||||||
|
this.joinSegments = joinSegments;
|
||||||
|
this.timeSplitInterval = timeSplitInterval;
|
||||||
|
this.distanceSplitInterval = distanceSplitInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
if (splitTrackListener != null) {
|
||||||
|
splitTrackListener.trackSplittingStarted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params) {
|
||||||
|
for (GpxSelectionHelper.GpxDisplayGroup model : groups) {
|
||||||
|
if (gpxSplitType == GpxSplitType.NO_SPLIT) {
|
||||||
|
model.noSplit(app);
|
||||||
|
} else if (gpxSplitType == GpxSplitType.DISTANCE && distanceSplitInterval > 0) {
|
||||||
|
model.splitByDistance(app, distanceSplitInterval, joinSegments);
|
||||||
|
} else if (gpxSplitType == GpxSplitType.TIME && timeSplitInterval > 0) {
|
||||||
|
model.splitByTime(app, timeSplitInterval, joinSegments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void result) {
|
||||||
|
if (splitTrackListener != null) {
|
||||||
|
splitTrackListener.trackSplittingFinished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface SplitTrackListener {
|
||||||
|
|
||||||
|
void trackSplittingStarted();
|
||||||
|
|
||||||
|
void trackSplittingFinished();
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,11 +27,12 @@ import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.UiUtilities.DialogButtonType;
|
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.ContextMenuFragment;
|
import net.osmand.plus.base.ContextMenuFragment;
|
||||||
|
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.myplaces.DirectionArrowsCard;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
import net.osmand.plus.myplaces.SaveGpxAsyncTask;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
||||||
import net.osmand.plus.myplaces.SplitTrackAsyncTask;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.track.TrackDrawInfo.OnTrackAppearanceChangedListener;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -40,9 +41,10 @@ import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR;
|
||||||
import static net.osmand.plus.track.TrackDrawInfo.TRACK_FILE_PATH;
|
import static net.osmand.plus.track.TrackDrawInfo.TRACK_FILE_PATH;
|
||||||
|
|
||||||
public class TrackAppearanceFragment extends ContextMenuFragment {
|
public class TrackAppearanceFragment extends ContextMenuFragment implements CardListener {
|
||||||
|
|
||||||
public static final String TAG = TrackAppearanceFragment.class.getName();
|
public static final String TAG = TrackAppearanceFragment.class.getName();
|
||||||
|
|
||||||
|
@ -60,15 +62,7 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
||||||
private int menuTitleHeight;
|
private int menuTitleHeight;
|
||||||
private long modifiedTime = -1;
|
private long modifiedTime = -1;
|
||||||
|
|
||||||
private OnTrackAppearanceChangedListener trackAppearanceListener;
|
|
||||||
|
|
||||||
private TrackWidthCard trackWidthCard;
|
private TrackWidthCard trackWidthCard;
|
||||||
private SplitIntervalCard splitIntervalCard;
|
|
||||||
|
|
||||||
private void updateAppearanceIcon() {
|
|
||||||
Drawable icon = getPaintedContentIcon(R.drawable.ic_action_gpx_width_bold, trackDrawInfo.getColor());
|
|
||||||
appearanceIcon.setImageDrawable(icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMainLayoutId() {
|
public int getMainLayoutId() {
|
||||||
|
@ -115,8 +109,26 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
||||||
File file = new File(selectedGpxFile.getGpxFile().path);
|
File file = new File(selectedGpxFile.getGpxFile().path);
|
||||||
gpxDataItem = app.getGpxDbHelper().getItem(file);
|
gpxDataItem = app.getGpxDbHelper().getItem(file);
|
||||||
trackDrawInfo = new TrackDrawInfo(gpxDataItem);
|
trackDrawInfo = new TrackDrawInfo(gpxDataItem);
|
||||||
|
updateTrackColor();
|
||||||
}
|
}
|
||||||
trackDrawInfo.setTrackAppearanceListener(getTrackAppearanceListener());
|
}
|
||||||
|
|
||||||
|
private void updateTrackColor() {
|
||||||
|
int color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
|
||||||
|
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||||
|
if (color == 0 && gpxFile != null) {
|
||||||
|
if (gpxFile.showCurrentTrack) {
|
||||||
|
color = app.getSettings().CURRENT_TRACK_COLOR.get();
|
||||||
|
} else {
|
||||||
|
color = gpxFile.getColor(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (color == 0) {
|
||||||
|
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||||
|
OsmandSettings.CommonPreference<String> prefColor = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR);
|
||||||
|
color = GpxAppearanceAdapter.parseTrackColor(renderer, prefColor.get());
|
||||||
|
}
|
||||||
|
trackDrawInfo.setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -130,6 +142,7 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
||||||
}
|
}
|
||||||
updateCards();
|
updateCards();
|
||||||
updateButtons(view);
|
updateButtons(view);
|
||||||
|
updateAppearanceIcon();
|
||||||
if (!isPortrait()) {
|
if (!isPortrait()) {
|
||||||
int widthNoShadow = getLandscapeNoShadowWidth();
|
int widthNoShadow = getLandscapeNoShadowWidth();
|
||||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT);
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
@ -185,25 +198,60 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
||||||
trackDrawInfo.saveToBundle(outState);
|
trackDrawInfo.saveToBundle(outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private OnTrackAppearanceChangedListener getTrackAppearanceListener() {
|
@Override
|
||||||
if (trackAppearanceListener == null) {
|
public int getStatusBarColorId() {
|
||||||
trackAppearanceListener = new OnTrackAppearanceChangedListener() {
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
boolean nightMode = isNightMode();
|
||||||
|
if (getViewY() <= getFullScreenTopPosY() || !isPortrait()) {
|
||||||
|
if (Build.VERSION.SDK_INT >= 23 && !nightMode) {
|
||||||
|
view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
return nightMode ? R.color.divider_color_dark : R.color.divider_color_light;
|
||||||
|
} else {
|
||||||
|
if (Build.VERSION.SDK_INT >= 23 && !nightMode) {
|
||||||
|
view.setSystemUiVisibility(view.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStatusBarColor() {
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
mapActivity.updateStatusBarColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrackColorChanged() {
|
public void onCardLayoutNeeded(@NonNull BaseCard card) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCardPressed(@NonNull BaseCard card) {
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
if (card instanceof SplitIntervalCard) {
|
||||||
|
SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), trackDrawInfo, this);
|
||||||
|
} else if (card instanceof TrackColoringCard) {
|
||||||
updateAppearanceIcon();
|
updateAppearanceIcon();
|
||||||
if (trackWidthCard != null) {
|
if (trackWidthCard != null) {
|
||||||
trackWidthCard.updateItems();
|
trackWidthCard.updateItems();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrackWidthChanged() {
|
public void onCardButtonPressed(@NonNull BaseCard card, int buttonIndex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
private void updateAppearanceIcon() {
|
||||||
return trackAppearanceListener;
|
Drawable icon = getPaintedContentIcon(R.drawable.ic_action_gpx_width_bold, trackDrawInfo.getColor());
|
||||||
|
appearanceIcon.setImageDrawable(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCardsLayout() {
|
private void updateCardsLayout() {
|
||||||
|
@ -256,7 +304,11 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
||||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||||
|
|
||||||
gpxFile.setWidth(trackDrawInfo.getWidth());
|
gpxFile.setWidth(trackDrawInfo.getWidth());
|
||||||
|
if (trackDrawInfo.getGradientScaleType() != null) {
|
||||||
gpxFile.setGradientScaleType(trackDrawInfo.getGradientScaleType().name());
|
gpxFile.setGradientScaleType(trackDrawInfo.getGradientScaleType().name());
|
||||||
|
} else {
|
||||||
|
gpxFile.removeGradientScaleType();
|
||||||
|
}
|
||||||
gpxFile.setColor(trackDrawInfo.getColor());
|
gpxFile.setColor(trackDrawInfo.getColor());
|
||||||
|
|
||||||
for (GpxSplitType gpxSplitType : GpxSplitType.values()) {
|
for (GpxSplitType gpxSplitType : GpxSplitType.values()) {
|
||||||
|
@ -282,13 +334,14 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
||||||
int timeSplit = (int) gpxDataItem.getSplitInterval();
|
int timeSplit = (int) gpxDataItem.getSplitInterval();
|
||||||
double distanceSplit = gpxDataItem.getSplitInterval();
|
double distanceSplit = gpxDataItem.getSplitInterval();
|
||||||
|
|
||||||
GpxSplitType splitType = null;
|
GpxSplitType splitType;
|
||||||
if (gpxDataItem.getSplitType() == GpxSplitType.DISTANCE.getType()) {
|
if (gpxDataItem.getSplitType() == GpxSplitType.DISTANCE.getType()) {
|
||||||
splitType = GpxSplitType.DISTANCE;
|
splitType = GpxSplitType.DISTANCE;
|
||||||
} else if (gpxDataItem.getSplitType() == GpxSplitType.TIME.getType()) {
|
} else if (gpxDataItem.getSplitType() == GpxSplitType.TIME.getType()) {
|
||||||
splitType = GpxSplitType.TIME;
|
splitType = GpxSplitType.TIME;
|
||||||
|
} else {
|
||||||
|
splitType = GpxSplitType.NO_SPLIT;
|
||||||
}
|
}
|
||||||
if (splitType != null) {
|
|
||||||
SplitTrackAsyncTask.SplitTrackListener splitTrackListener = new SplitTrackAsyncTask.SplitTrackListener() {
|
SplitTrackAsyncTask.SplitTrackListener splitTrackListener = new SplitTrackAsyncTask.SplitTrackListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -309,7 +362,6 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
||||||
timeSplit, distanceSplit).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
timeSplit, distanceSplit).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void saveGpx(final GPXFile gpxFile) {
|
private void saveGpx(final GPXFile gpxFile) {
|
||||||
new SaveGpxAsyncTask(gpxFile, new SaveGpxAsyncTask.SaveGpxListener() {
|
new SaveGpxAsyncTask(gpxFile, new SaveGpxAsyncTask.SaveGpxListener() {
|
||||||
|
@ -333,13 +385,15 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
||||||
ViewGroup cardsContainer = getCardsContainer();
|
ViewGroup cardsContainer = getCardsContainer();
|
||||||
cardsContainer.removeAllViews();
|
cardsContainer.removeAllViews();
|
||||||
|
|
||||||
splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo, this);
|
SplitIntervalCard splitIntervalCard = new SplitIntervalCard(mapActivity);
|
||||||
|
splitIntervalCard.setListener(this);
|
||||||
cardsContainer.addView(splitIntervalCard.build(mapActivity));
|
cardsContainer.addView(splitIntervalCard.build(mapActivity));
|
||||||
|
|
||||||
DirectionArrowsCard directionArrowsCard = new DirectionArrowsCard(mapActivity, trackDrawInfo);
|
DirectionArrowsCard directionArrowsCard = new DirectionArrowsCard(mapActivity, trackDrawInfo);
|
||||||
cardsContainer.addView(directionArrowsCard.build(mapActivity));
|
cardsContainer.addView(directionArrowsCard.build(mapActivity));
|
||||||
|
|
||||||
TrackColoringCard trackColoringCard = new TrackColoringCard(mapActivity, selectedGpxFile, trackDrawInfo);
|
TrackColoringCard trackColoringCard = new TrackColoringCard(mapActivity, trackDrawInfo);
|
||||||
|
trackColoringCard.setListener(this);
|
||||||
cardsContainer.addView(trackColoringCard.build(mapActivity));
|
cardsContainer.addView(trackColoringCard.build(mapActivity));
|
||||||
|
|
||||||
trackWidthCard = new TrackWidthCard(mapActivity, trackDrawInfo);
|
trackWidthCard = new TrackWidthCard(mapActivity, trackDrawInfo);
|
||||||
|
@ -362,32 +416,6 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
||||||
return displayGroups;
|
return displayGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateStatusBarColor() {
|
|
||||||
MapActivity mapActivity = getMapActivity();
|
|
||||||
if (mapActivity != null) {
|
|
||||||
mapActivity.updateStatusBarColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getStatusBarColorId() {
|
|
||||||
View view = getView();
|
|
||||||
if (view != null) {
|
|
||||||
boolean nightMode = isNightMode();
|
|
||||||
if (getViewY() <= getFullScreenTopPosY() || !isPortrait()) {
|
|
||||||
if (Build.VERSION.SDK_INT >= 23 && !nightMode) {
|
|
||||||
view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
|
||||||
}
|
|
||||||
return nightMode ? R.color.divider_color_dark : R.color.divider_color_light;
|
|
||||||
} else {
|
|
||||||
if (Build.VERSION.SDK_INT >= 23 && !nightMode) {
|
|
||||||
view.setSystemUiVisibility(view.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dismissImmediate() {
|
public void dismissImmediate() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package net.osmand.plus.track;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
|
public class TrackAppearanceViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
final TextView title;
|
||||||
|
final ImageView icon;
|
||||||
|
final ImageView button;
|
||||||
|
|
||||||
|
TrackAppearanceViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
title = itemView.findViewById(R.id.groupName);
|
||||||
|
icon = itemView.findViewById(R.id.groupIcon);
|
||||||
|
button = itemView.findViewById(R.id.outlineRect);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
|
import androidx.annotation.DrawableRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
@ -17,7 +18,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -28,27 +28,24 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
import net.osmand.plus.widgets.FlowLayout;
|
import net.osmand.plus.widgets.FlowLayout;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.getAppearanceItems;
|
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.getAppearanceItems;
|
||||||
|
|
||||||
public class TrackColoringCard extends BaseCard {
|
public class TrackColoringCard extends BaseCard {
|
||||||
|
|
||||||
private TrackDrawInfo trackDrawInfo;
|
private final static String SOLID_COLOR = "solid_color";
|
||||||
private SelectedGpxFile selectedGpxFile;
|
|
||||||
|
|
||||||
private GradientScaleType selectedScaleType;
|
private TrackDrawInfo trackDrawInfo;
|
||||||
|
|
||||||
private TrackColoringAdapter coloringAdapter;
|
private TrackColoringAdapter coloringAdapter;
|
||||||
|
private TrackAppearanceItem selectedAppearanceItem;
|
||||||
|
private List<TrackAppearanceItem> appearanceItems;
|
||||||
|
|
||||||
@ColorInt
|
public TrackColoringCard(MapActivity mapActivity, TrackDrawInfo trackDrawInfo) {
|
||||||
private int selectedColor;
|
|
||||||
|
|
||||||
public TrackColoringCard(MapActivity mapActivity, SelectedGpxFile selectedGpxFile, TrackDrawInfo trackDrawInfo) {
|
|
||||||
super(mapActivity);
|
super(mapActivity);
|
||||||
this.trackDrawInfo = trackDrawInfo;
|
this.trackDrawInfo = trackDrawInfo;
|
||||||
this.selectedGpxFile = selectedGpxFile;
|
appearanceItems = getGradientAppearanceItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,7 +59,7 @@ public class TrackColoringCard extends BaseCard {
|
||||||
createColorSelector();
|
createColorSelector();
|
||||||
updateColorSelector();
|
updateColorSelector();
|
||||||
|
|
||||||
coloringAdapter = new TrackColoringAdapter(Arrays.asList(GradientScaleType.values()));
|
coloringAdapter = new TrackColoringAdapter(appearanceItems);
|
||||||
RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view);
|
RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view);
|
||||||
groupRecyclerView.setAdapter(coloringAdapter);
|
groupRecyclerView.setAdapter(coloringAdapter);
|
||||||
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
||||||
|
@ -70,6 +67,17 @@ public class TrackColoringCard extends BaseCard {
|
||||||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider());
|
AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<TrackAppearanceItem> getGradientAppearanceItems() {
|
||||||
|
List<TrackAppearanceItem> items = new ArrayList<>();
|
||||||
|
items.add(new TrackAppearanceItem(SOLID_COLOR, app.getString(R.string.track_coloring_solid), R.drawable.ic_action_circle));
|
||||||
|
|
||||||
|
// for (GradientScaleType scaleType : GradientScaleType.values()) {
|
||||||
|
// items.add(new TrackAppearanceItem(scaleType.name(), scaleType.getHumanString(app), scaleType.getIconId()));
|
||||||
|
// }
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
private void createColorSelector() {
|
private void createColorSelector() {
|
||||||
FlowLayout selectColor = view.findViewById(R.id.select_color);
|
FlowLayout selectColor = view.findViewById(R.id.select_color);
|
||||||
List<Integer> colors = new ArrayList<>();
|
List<Integer> colors = new ArrayList<>();
|
||||||
|
@ -81,13 +89,7 @@ public class TrackColoringCard extends BaseCard {
|
||||||
for (int color : colors) {
|
for (int color : colors) {
|
||||||
selectColor.addView(createColorItemView(color, selectColor), new FlowLayout.LayoutParams(0, 0));
|
selectColor.addView(createColorItemView(color, selectColor), new FlowLayout.LayoutParams(0, 0));
|
||||||
}
|
}
|
||||||
|
updateColorSelector(trackDrawInfo.getColor(), selectColor);
|
||||||
if (selectedGpxFile.isShowCurrentTrack()) {
|
|
||||||
selectedColor = app.getSettings().CURRENT_TRACK_COLOR.get();
|
|
||||||
} else {
|
|
||||||
selectedColor = selectedGpxFile.getGpxFile().getColor(0);
|
|
||||||
}
|
|
||||||
updateColorSelector(selectedColor, selectColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private View createColorItemView(@ColorInt final int color, final FlowLayout rootView) {
|
private View createColorItemView(@ColorInt final int color, final FlowLayout rootView) {
|
||||||
|
@ -106,6 +108,12 @@ public class TrackColoringCard extends BaseCard {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
updateColorSelector(color, rootView);
|
updateColorSelector(color, rootView);
|
||||||
coloringAdapter.notifyDataSetChanged();
|
coloringAdapter.notifyDataSetChanged();
|
||||||
|
trackDrawInfo.setColor(color);
|
||||||
|
|
||||||
|
CardListener listener = getListener();
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onCardPressed(TrackColoringCard.this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
colorItemView.setTag(color);
|
colorItemView.setTag(color);
|
||||||
|
@ -113,7 +121,7 @@ public class TrackColoringCard extends BaseCard {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateColorSelector(int color, View rootView) {
|
private void updateColorSelector(int color, View rootView) {
|
||||||
View oldColor = rootView.findViewWithTag(selectedColor);
|
View oldColor = rootView.findViewWithTag(trackDrawInfo.getColor());
|
||||||
if (oldColor != null) {
|
if (oldColor != null) {
|
||||||
oldColor.findViewById(R.id.outline).setVisibility(View.INVISIBLE);
|
oldColor.findViewById(R.id.outline).setVisibility(View.INVISIBLE);
|
||||||
ImageView icon = oldColor.findViewById(R.id.icon);
|
ImageView icon = oldColor.findViewById(R.id.icon);
|
||||||
|
@ -123,19 +131,21 @@ public class TrackColoringCard extends BaseCard {
|
||||||
if (newColor != null) {
|
if (newColor != null) {
|
||||||
newColor.findViewById(R.id.outline).setVisibility(View.VISIBLE);
|
newColor.findViewById(R.id.outline).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
selectedColor = color;
|
|
||||||
trackDrawInfo.setColor(color);
|
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
private GradientScaleType getSelectedScaleType() {
|
private TrackAppearanceItem getSelectedAppearanceItem() {
|
||||||
if (selectedScaleType == null) {
|
if (selectedAppearanceItem == null) {
|
||||||
selectedScaleType = trackDrawInfo.getGradientScaleType();
|
GradientScaleType scaleType = trackDrawInfo.getGradientScaleType();
|
||||||
if (selectedScaleType == null) {
|
for (TrackAppearanceItem item : appearanceItems) {
|
||||||
selectedScaleType = GradientScaleType.SOLID;
|
if (scaleType == null && item.getAttrName().equals(SOLID_COLOR)
|
||||||
|
|| scaleType != null && scaleType.name().equals(item.getAttrName())) {
|
||||||
|
selectedAppearanceItem = item;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return selectedScaleType;
|
}
|
||||||
|
return selectedAppearanceItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateHeader() {
|
private void updateHeader() {
|
||||||
|
@ -145,31 +155,43 @@ public class TrackColoringCard extends BaseCard {
|
||||||
titleView.setText(R.string.select_color);
|
titleView.setText(R.string.select_color);
|
||||||
|
|
||||||
TextView descriptionView = view.findViewById(R.id.description);
|
TextView descriptionView = view.findViewById(R.id.description);
|
||||||
descriptionView.setText(getSelectedScaleType().getHumanString(view.getContext()));
|
descriptionView.setText(getSelectedAppearanceItem().getLocalizedValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateColorSelector() {
|
private void updateColorSelector() {
|
||||||
boolean visible = GradientScaleType.SOLID == getSelectedScaleType();
|
boolean visible = getSelectedAppearanceItem().getAttrName().equals(SOLID_COLOR);
|
||||||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.select_color), visible);
|
AndroidUiHelper.updateVisibility(view.findViewById(R.id.select_color), visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TrackColoringAdapter extends RecyclerView.Adapter<TrackColoringViewHolder> {
|
public void setGradientScaleType(TrackAppearanceItem item) {
|
||||||
|
if (item.getAttrName().equals(SOLID_COLOR)) {
|
||||||
|
trackDrawInfo.setGradientScaleType(null);
|
||||||
|
} else {
|
||||||
|
trackDrawInfo.setGradientScaleType(GradientScaleType.valueOf(item.getAttrName()));
|
||||||
|
}
|
||||||
|
mapActivity.refreshMap();
|
||||||
|
|
||||||
private List<GradientScaleType> items;
|
updateHeader();
|
||||||
|
updateColorSelector();
|
||||||
|
}
|
||||||
|
|
||||||
private TrackColoringAdapter(List<GradientScaleType> items) {
|
private class TrackColoringAdapter extends RecyclerView.Adapter<TrackAppearanceViewHolder> {
|
||||||
|
|
||||||
|
private List<TrackAppearanceItem> items;
|
||||||
|
|
||||||
|
private TrackColoringAdapter(List<TrackAppearanceItem> items) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public TrackColoringViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public TrackAppearanceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
LayoutInflater themedInflater = UiUtilities.getInflater(parent.getContext(), nightMode);
|
LayoutInflater themedInflater = UiUtilities.getInflater(parent.getContext(), nightMode);
|
||||||
View view = themedInflater.inflate(R.layout.point_editor_group_select_item, parent, false);
|
View view = themedInflater.inflate(R.layout.point_editor_group_select_item, parent, false);
|
||||||
view.getLayoutParams().width = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_width);
|
view.getLayoutParams().width = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_width);
|
||||||
view.getLayoutParams().height = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_height);
|
view.getLayoutParams().height = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_height);
|
||||||
|
|
||||||
TrackColoringViewHolder holder = new TrackColoringViewHolder(view);
|
TrackAppearanceViewHolder holder = new TrackAppearanceViewHolder(view);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
AndroidUtils.setBackground(app, holder.button, nightMode, R.drawable.ripple_solid_light_6dp,
|
AndroidUtils.setBackground(app, holder.button, nightMode, R.drawable.ripple_solid_light_6dp,
|
||||||
R.drawable.ripple_solid_dark_6dp);
|
R.drawable.ripple_solid_dark_6dp);
|
||||||
|
@ -178,16 +200,16 @@ public class TrackColoringCard extends BaseCard {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull final TrackColoringViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull final TrackAppearanceViewHolder holder, int position) {
|
||||||
GradientScaleType item = items.get(position);
|
TrackAppearanceItem item = items.get(position);
|
||||||
holder.colorKey.setText(item.getHumanString(holder.itemView.getContext()));
|
holder.title.setText(item.getLocalizedValue());
|
||||||
|
|
||||||
updateButtonBg(holder, item);
|
updateButtonBg(holder, item);
|
||||||
|
|
||||||
int colorId;
|
int colorId;
|
||||||
if (item == GradientScaleType.SOLID) {
|
if (item.getAttrName().equals(SOLID_COLOR)) {
|
||||||
colorId = trackDrawInfo.getColor();
|
colorId = trackDrawInfo.getColor();
|
||||||
} else if (item.equals(getSelectedScaleType())) {
|
} else if (item.getAttrName().equals(getSelectedAppearanceItem().getAttrName())) {
|
||||||
colorId = ContextCompat.getColor(app, nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light);
|
colorId = ContextCompat.getColor(app, nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light);
|
||||||
} else {
|
} else {
|
||||||
colorId = AndroidUtils.getColorFromAttr(holder.itemView.getContext(), R.attr.default_icon_color);
|
colorId = AndroidUtils.getColorFromAttr(holder.itemView.getContext(), R.attr.default_icon_color);
|
||||||
|
@ -198,24 +220,20 @@ public class TrackColoringCard extends BaseCard {
|
||||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
int prevSelectedPosition = getItemPosition(getSelectedScaleType());
|
int prevSelectedPosition = getItemPosition(getSelectedAppearanceItem());
|
||||||
selectedScaleType = items.get(holder.getAdapterPosition());
|
selectedAppearanceItem = items.get(holder.getAdapterPosition());
|
||||||
notifyItemChanged(holder.getAdapterPosition());
|
notifyItemChanged(holder.getAdapterPosition());
|
||||||
notifyItemChanged(prevSelectedPosition);
|
notifyItemChanged(prevSelectedPosition);
|
||||||
|
|
||||||
trackDrawInfo.setGradientScaleType(selectedScaleType);
|
setGradientScaleType(selectedAppearanceItem);
|
||||||
mapActivity.refreshMap();
|
|
||||||
|
|
||||||
updateHeader();
|
|
||||||
updateColorSelector();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateButtonBg(TrackColoringViewHolder holder, GradientScaleType item) {
|
private void updateButtonBg(TrackAppearanceViewHolder holder, TrackAppearanceItem item) {
|
||||||
GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_group_button_outline);
|
GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_group_button_outline);
|
||||||
if (rectContourDrawable != null) {
|
if (rectContourDrawable != null) {
|
||||||
if (getSelectedScaleType() != null && getSelectedScaleType().equals(item)) {
|
if (getSelectedAppearanceItem() != null && getSelectedAppearanceItem().equals(item)) {
|
||||||
int strokeColor = ContextCompat.getColor(app, nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
|
int strokeColor = ContextCompat.getColor(app, nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
|
||||||
rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 2), strokeColor);
|
rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 2), strokeColor);
|
||||||
} else {
|
} else {
|
||||||
|
@ -232,22 +250,35 @@ public class TrackColoringCard extends BaseCard {
|
||||||
return items.size();
|
return items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getItemPosition(GradientScaleType name) {
|
int getItemPosition(TrackAppearanceItem name) {
|
||||||
return items.indexOf(name);
|
return items.indexOf(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TrackColoringViewHolder extends RecyclerView.ViewHolder {
|
public static class TrackAppearanceItem {
|
||||||
|
|
||||||
final TextView colorKey;
|
private String attrName;
|
||||||
final ImageView icon;
|
private String localizedValue;
|
||||||
final ImageView button;
|
|
||||||
|
|
||||||
TrackColoringViewHolder(View itemView) {
|
@DrawableRes
|
||||||
super(itemView);
|
private int iconId;
|
||||||
colorKey = itemView.findViewById(R.id.groupName);
|
|
||||||
icon = itemView.findViewById(R.id.groupIcon);
|
public TrackAppearanceItem(String attrName, String localizedValue, int iconId) {
|
||||||
button = itemView.findViewById(R.id.outlineRect);
|
this.attrName = attrName;
|
||||||
|
this.localizedValue = localizedValue;
|
||||||
|
this.iconId = iconId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAttrName() {
|
||||||
|
return attrName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedValue() {
|
||||||
|
return localizedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIconId() {
|
||||||
|
return iconId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
public class TrackDrawInfo {
|
public class TrackDrawInfo {
|
||||||
|
|
||||||
|
@ -12,9 +13,6 @@ public class TrackDrawInfo {
|
||||||
private static final String TRACK_WIDTH = "track_width";
|
private static final String TRACK_WIDTH = "track_width";
|
||||||
private static final String TRACK_GRADIENT_SCALE_TYPE = "track_gradient_scale_type";
|
private static final String TRACK_GRADIENT_SCALE_TYPE = "track_gradient_scale_type";
|
||||||
private static final String TRACK_COLOR = "track_color";
|
private static final String TRACK_COLOR = "track_color";
|
||||||
private static final String TRACK_GRADIENT_SPEED_COLOR = "track_gradient_speed_color";
|
|
||||||
private static final String TRACK_GRADIENT_ALTITUDE_COLOR = "track_gradient_altitude_color";
|
|
||||||
private static final String TRACK_GRADIENT_SLOPE_COLOR = "track_gradient_slope_color";
|
|
||||||
private static final String TRACK_SPLIT_TYPE = "track_split_type";
|
private static final String TRACK_SPLIT_TYPE = "track_split_type";
|
||||||
private static final String TRACK_SPLIT_INTERVAL = "track_split_interval";
|
private static final String TRACK_SPLIT_INTERVAL = "track_split_interval";
|
||||||
private static final String TRACK_JOIN_SEGMENTS = "track_join_segments";
|
private static final String TRACK_JOIN_SEGMENTS = "track_join_segments";
|
||||||
|
@ -25,17 +23,12 @@ public class TrackDrawInfo {
|
||||||
private String width;
|
private String width;
|
||||||
private GradientScaleType gradientScaleType;
|
private GradientScaleType gradientScaleType;
|
||||||
private int color;
|
private int color;
|
||||||
private int gradientSpeedColor;
|
|
||||||
private int gradientAltitudeColor;
|
|
||||||
private int gradientSlopeColor;
|
|
||||||
private int splitType;
|
private int splitType;
|
||||||
private double splitInterval;
|
private double splitInterval;
|
||||||
private boolean joinSegments;
|
private boolean joinSegments;
|
||||||
private boolean showArrows;
|
private boolean showArrows;
|
||||||
private boolean showStartFinish;
|
private boolean showStartFinish;
|
||||||
|
|
||||||
private OnTrackAppearanceChangedListener trackAppearanceListener;
|
|
||||||
|
|
||||||
public TrackDrawInfo() {
|
public TrackDrawInfo() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,9 +38,6 @@ public class TrackDrawInfo {
|
||||||
width = gpxDataItem.getWidth();
|
width = gpxDataItem.getWidth();
|
||||||
gradientScaleType = gpxDataItem.getGradientScaleType();
|
gradientScaleType = gpxDataItem.getGradientScaleType();
|
||||||
color = gpxDataItem.getColor();
|
color = gpxDataItem.getColor();
|
||||||
gradientSpeedColor = gpxDataItem.getGradientSpeedColor();
|
|
||||||
gradientAltitudeColor = gpxDataItem.getGradientAltitudeColor();
|
|
||||||
gradientSlopeColor = gpxDataItem.getGradientSlopeColor();
|
|
||||||
splitType = gpxDataItem.getSplitType();
|
splitType = gpxDataItem.getSplitType();
|
||||||
splitInterval = gpxDataItem.getSplitInterval();
|
splitInterval = gpxDataItem.getSplitInterval();
|
||||||
joinSegments = gpxDataItem.isJoinSegments();
|
joinSegments = gpxDataItem.isJoinSegments();
|
||||||
|
@ -55,10 +45,6 @@ public class TrackDrawInfo {
|
||||||
showStartFinish = gpxDataItem.isShowStartFinish();
|
showStartFinish = gpxDataItem.isShowStartFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTrackAppearanceListener(OnTrackAppearanceChangedListener trackAppearanceListener) {
|
|
||||||
this.trackAppearanceListener = trackAppearanceListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFilePath() {
|
public String getFilePath() {
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
@ -69,9 +55,6 @@ public class TrackDrawInfo {
|
||||||
|
|
||||||
public void setWidth(String width) {
|
public void setWidth(String width) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
if (trackAppearanceListener != null) {
|
|
||||||
trackAppearanceListener.onTrackWidthChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GradientScaleType getGradientScaleType() {
|
public GradientScaleType getGradientScaleType() {
|
||||||
|
@ -88,9 +71,6 @@ public class TrackDrawInfo {
|
||||||
|
|
||||||
public void setColor(int color) {
|
public void setColor(int color) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
if (trackAppearanceListener != null) {
|
|
||||||
trackAppearanceListener.onTrackColorChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSplitType() {
|
public int getSplitType() {
|
||||||
|
@ -128,11 +108,11 @@ public class TrackDrawInfo {
|
||||||
protected void readBundle(@NonNull Bundle bundle) {
|
protected void readBundle(@NonNull Bundle bundle) {
|
||||||
filePath = bundle.getString(TRACK_FILE_PATH);
|
filePath = bundle.getString(TRACK_FILE_PATH);
|
||||||
width = bundle.getString(TRACK_WIDTH);
|
width = bundle.getString(TRACK_WIDTH);
|
||||||
gradientScaleType = GradientScaleType.valueOf(bundle.getString(TRACK_GRADIENT_SCALE_TYPE));
|
String gradientScaleTypeName = bundle.getString(TRACK_GRADIENT_SCALE_TYPE);
|
||||||
|
if (!Algorithms.isEmpty(gradientScaleTypeName)) {
|
||||||
|
gradientScaleType = GradientScaleType.valueOf(gradientScaleTypeName);
|
||||||
|
}
|
||||||
color = bundle.getInt(TRACK_COLOR);
|
color = bundle.getInt(TRACK_COLOR);
|
||||||
gradientSpeedColor = bundle.getInt(TRACK_GRADIENT_SPEED_COLOR);
|
|
||||||
gradientAltitudeColor = bundle.getInt(TRACK_GRADIENT_ALTITUDE_COLOR);
|
|
||||||
gradientSlopeColor = bundle.getInt(TRACK_GRADIENT_SLOPE_COLOR);
|
|
||||||
splitType = bundle.getInt(TRACK_SPLIT_TYPE);
|
splitType = bundle.getInt(TRACK_SPLIT_TYPE);
|
||||||
splitInterval = bundle.getDouble(TRACK_SPLIT_INTERVAL);
|
splitInterval = bundle.getDouble(TRACK_SPLIT_INTERVAL);
|
||||||
joinSegments = bundle.getBoolean(TRACK_JOIN_SEGMENTS);
|
joinSegments = bundle.getBoolean(TRACK_JOIN_SEGMENTS);
|
||||||
|
@ -143,22 +123,12 @@ public class TrackDrawInfo {
|
||||||
protected void saveToBundle(@NonNull Bundle bundle) {
|
protected void saveToBundle(@NonNull Bundle bundle) {
|
||||||
bundle.putString(TRACK_FILE_PATH, filePath);
|
bundle.putString(TRACK_FILE_PATH, filePath);
|
||||||
bundle.putString(TRACK_WIDTH, width);
|
bundle.putString(TRACK_WIDTH, width);
|
||||||
bundle.putString(TRACK_GRADIENT_SCALE_TYPE, gradientScaleType.name());
|
bundle.putString(TRACK_GRADIENT_SCALE_TYPE, gradientScaleType != null ? gradientScaleType.name() : "");
|
||||||
bundle.putInt(TRACK_COLOR, color);
|
bundle.putInt(TRACK_COLOR, color);
|
||||||
bundle.putInt(TRACK_GRADIENT_SPEED_COLOR, gradientSpeedColor);
|
|
||||||
bundle.putInt(TRACK_GRADIENT_ALTITUDE_COLOR, gradientAltitudeColor);
|
|
||||||
bundle.putInt(TRACK_GRADIENT_SLOPE_COLOR, gradientSlopeColor);
|
|
||||||
bundle.putInt(TRACK_SPLIT_TYPE, splitType);
|
bundle.putInt(TRACK_SPLIT_TYPE, splitType);
|
||||||
bundle.putDouble(TRACK_SPLIT_INTERVAL, splitInterval);
|
bundle.putDouble(TRACK_SPLIT_INTERVAL, splitInterval);
|
||||||
bundle.putBoolean(TRACK_JOIN_SEGMENTS, joinSegments);
|
bundle.putBoolean(TRACK_JOIN_SEGMENTS, joinSegments);
|
||||||
bundle.putBoolean(TRACK_SHOW_ARROWS, showArrows);
|
bundle.putBoolean(TRACK_SHOW_ARROWS, showArrows);
|
||||||
bundle.putBoolean(TRACK_SHOW_START_FINISH, showStartFinish);
|
bundle.putBoolean(TRACK_SHOW_START_FINISH, showStartFinish);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnTrackAppearanceChangedListener {
|
|
||||||
|
|
||||||
void onTrackColorChanged();
|
|
||||||
|
|
||||||
void onTrackWidthChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -5,7 +5,6 @@ import android.os.Build;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -77,8 +76,8 @@ public class TrackWidthCard extends BaseCard {
|
||||||
String selectedWidth = trackDrawInfo.getWidth();
|
String selectedWidth = trackDrawInfo.getWidth();
|
||||||
for (AppearanceListItem item : appearanceItems) {
|
for (AppearanceListItem item : appearanceItems) {
|
||||||
if (Algorithms.objectEquals(item.getValue(), selectedWidth)
|
if (Algorithms.objectEquals(item.getValue(), selectedWidth)
|
||||||
|| ((Algorithms.isEmpty(selectedWidth) || Algorithms.isInt(selectedWidth))
|
|| Algorithms.isEmpty(selectedWidth) && Algorithms.isEmpty(item.getValue())
|
||||||
&& CUSTOM_WIDTH.equals(item.getAttrName()))) {
|
|| Algorithms.isInt(selectedWidth) && CUSTOM_WIDTH.equals(item.getAttrName())) {
|
||||||
selectedItem = item;
|
selectedItem = item;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +151,7 @@ public class TrackWidthCard extends BaseCard {
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GpxWidthAdapter extends RecyclerView.Adapter<GpxWidthViewHolder> {
|
private class GpxWidthAdapter extends RecyclerView.Adapter<TrackAppearanceViewHolder> {
|
||||||
|
|
||||||
private List<AppearanceListItem> items;
|
private List<AppearanceListItem> items;
|
||||||
|
|
||||||
|
@ -162,24 +161,24 @@ public class TrackWidthCard extends BaseCard {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public GpxWidthViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public TrackAppearanceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
LayoutInflater themedInflater = UiUtilities.getInflater(parent.getContext(), nightMode);
|
LayoutInflater themedInflater = UiUtilities.getInflater(parent.getContext(), nightMode);
|
||||||
View view = themedInflater.inflate(R.layout.point_editor_group_select_item, parent, false);
|
View view = themedInflater.inflate(R.layout.point_editor_group_select_item, parent, false);
|
||||||
view.getLayoutParams().width = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_width);
|
view.getLayoutParams().width = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_width);
|
||||||
view.getLayoutParams().height = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_height);
|
view.getLayoutParams().height = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_height);
|
||||||
|
|
||||||
GpxWidthViewHolder holder = new GpxWidthViewHolder(view);
|
TrackAppearanceViewHolder holder = new TrackAppearanceViewHolder(view);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
AndroidUtils.setBackground(app, holder.widthButton, nightMode, R.drawable.ripple_solid_light_6dp,
|
AndroidUtils.setBackground(app, holder.button, nightMode, R.drawable.ripple_solid_light_6dp,
|
||||||
R.drawable.ripple_solid_dark_6dp);
|
R.drawable.ripple_solid_dark_6dp);
|
||||||
}
|
}
|
||||||
return holder;
|
return holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull final GpxWidthViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull final TrackAppearanceViewHolder holder, int position) {
|
||||||
AppearanceListItem item = items.get(position);
|
AppearanceListItem item = items.get(position);
|
||||||
holder.widthAttrName.setText(item.getLocalizedValue());
|
holder.title.setText(item.getLocalizedValue());
|
||||||
|
|
||||||
updateButtonBg(holder, item);
|
updateButtonBg(holder, item);
|
||||||
updateWidthIcon(holder, item);
|
updateWidthIcon(holder, item);
|
||||||
|
@ -200,7 +199,7 @@ public class TrackWidthCard extends BaseCard {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateWidthIcon(GpxWidthViewHolder holder, AppearanceListItem item) {
|
private void updateWidthIcon(TrackAppearanceViewHolder holder, AppearanceListItem item) {
|
||||||
int color = trackDrawInfo.getColor();
|
int color = trackDrawInfo.getColor();
|
||||||
|
|
||||||
int iconId;
|
int iconId;
|
||||||
|
@ -210,10 +209,10 @@ public class TrackWidthCard extends BaseCard {
|
||||||
} else {
|
} else {
|
||||||
iconId = GpxAppearanceAdapter.getWidthIconId(item.getValue());
|
iconId = GpxAppearanceAdapter.getWidthIconId(item.getValue());
|
||||||
}
|
}
|
||||||
holder.widthIcon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconId, color));
|
holder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconId, color));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateButtonBg(GpxWidthViewHolder holder, AppearanceListItem item) {
|
private void updateButtonBg(TrackAppearanceViewHolder holder, AppearanceListItem item) {
|
||||||
GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_group_button_outline);
|
GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_group_button_outline);
|
||||||
if (rectContourDrawable != null) {
|
if (rectContourDrawable != null) {
|
||||||
if (getSelectedItem() != null && getSelectedItem().equals(item)) {
|
if (getSelectedItem() != null && getSelectedItem().equals(item)) {
|
||||||
|
@ -224,7 +223,7 @@ public class TrackWidthCard extends BaseCard {
|
||||||
: R.color.stroked_buttons_and_links_outline_light);
|
: R.color.stroked_buttons_and_links_outline_light);
|
||||||
rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 1), strokeColor);
|
rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 1), strokeColor);
|
||||||
}
|
}
|
||||||
holder.widthButton.setImageDrawable(rectContourDrawable);
|
holder.button.setImageDrawable(rectContourDrawable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,18 +236,4 @@ public class TrackWidthCard extends BaseCard {
|
||||||
return items.indexOf(name);
|
return items.indexOf(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class GpxWidthViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
final TextView widthAttrName;
|
|
||||||
final ImageView widthIcon;
|
|
||||||
final ImageView widthButton;
|
|
||||||
|
|
||||||
GpxWidthViewHolder(View itemView) {
|
|
||||||
super(itemView);
|
|
||||||
widthAttrName = itemView.findViewById(R.id.groupName);
|
|
||||||
widthIcon = itemView.findViewById(R.id.groupIcon);
|
|
||||||
widthButton = itemView.findViewById(R.id.outlineRect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -48,9 +48,11 @@ import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.base.PointImageDrawable;
|
import net.osmand.plus.base.PointImageDrawable;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
|
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
|
||||||
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
||||||
|
import net.osmand.plus.track.SaveGpxAsyncTask;
|
||||||
import net.osmand.plus.render.OsmandRenderer;
|
import net.osmand.plus.render.OsmandRenderer;
|
||||||
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
||||||
|
import net.osmand.plus.track.TrackDrawInfo;
|
||||||
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
||||||
import net.osmand.plus.views.ContextMenuLayer.IMoveObjectProvider;
|
import net.osmand.plus.views.ContextMenuLayer.IMoveObjectProvider;
|
||||||
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
||||||
|
@ -62,7 +64,6 @@ import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -94,6 +95,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
private Drawable startPointIcon;
|
private Drawable startPointIcon;
|
||||||
private Drawable finishPointIcon;
|
private Drawable finishPointIcon;
|
||||||
private LayerDrawable selectedPoint;
|
private LayerDrawable selectedPoint;
|
||||||
|
private TrackDrawInfo trackDrawInfo;
|
||||||
private TrackChartPoints trackChartPoints;
|
private TrackChartPoints trackChartPoints;
|
||||||
|
|
||||||
private GpxSelectionHelper selectedGpxHelper;
|
private GpxSelectionHelper selectedGpxHelper;
|
||||||
|
@ -141,6 +143,14 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
this.trackChartPoints = trackChartPoints;
|
this.trackChartPoints = trackChartPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInTrackAppearanceMode() {
|
||||||
|
return trackDrawInfo != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrackDrawInfo(TrackDrawInfo trackDrawInfo) {
|
||||||
|
this.trackDrawInfo = trackDrawInfo;
|
||||||
|
}
|
||||||
|
|
||||||
private void initUI() {
|
private void initUI() {
|
||||||
paint = new Paint();
|
paint = new Paint();
|
||||||
paint.setStyle(Style.STROKE);
|
paint.setStyle(Style.STROKE);
|
||||||
|
@ -224,10 +234,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
if (textLayer != null && isTextVisible()) {
|
if (textLayer != null && isTextVisible()) {
|
||||||
textLayer.putData(this, cache);
|
textLayer.putData(this, cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int updatePaints(int color, String width, boolean routePoints, boolean currentTrack, DrawSettings drawSettings, RotatedTileBox tileBox) {
|
private void updatePaints(int color, String width, boolean routePoints, boolean currentTrack, DrawSettings drawSettings, RotatedTileBox tileBox) {
|
||||||
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||||
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
|
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
|
||||||
int hash = calculateHash(rrs, cachedTrackWidth, routePoints, nightMode, tileBox.getMapDensity(), tileBox.getZoom(),
|
int hash = calculateHash(rrs, cachedTrackWidth, routePoints, nightMode, tileBox.getMapDensity(), tileBox.getZoom(),
|
||||||
|
@ -291,7 +300,6 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
if (strikeWidth != null) {
|
if (strikeWidth != null) {
|
||||||
paint.setStrokeWidth(strikeWidth);
|
paint.setStrokeWidth(strikeWidth);
|
||||||
}
|
}
|
||||||
return cachedColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) {
|
private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) {
|
||||||
|
@ -324,8 +332,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
DrawSettings settings) {
|
DrawSettings settings) {
|
||||||
if (tileBox.getZoom() >= START_ZOOM) {
|
if (tileBox.getZoom() >= START_ZOOM) {
|
||||||
// request to load
|
// request to load
|
||||||
|
OsmandApplication app = view.getApplication();
|
||||||
for (SelectedGpxFile g : selectedGPXFiles) {
|
for (SelectedGpxFile g : selectedGPXFiles) {
|
||||||
List<GpxDisplayGroup> groups = g.getDisplayGroups(view.getApplication());
|
List<GpxDisplayGroup> groups = g.getDisplayGroups(app);
|
||||||
if (groups != null && !groups.isEmpty()) {
|
if (groups != null && !groups.isEmpty()) {
|
||||||
int color = g.getGpxFile().getColor(0);
|
int color = g.getGpxFile().getColor(0);
|
||||||
if (color == 0) {
|
if (color == 0) {
|
||||||
|
@ -338,8 +347,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
paintInnerRect.setColor(color);
|
paintInnerRect.setColor(color);
|
||||||
paintInnerRect.setAlpha(179);
|
paintInnerRect.setAlpha(179);
|
||||||
|
|
||||||
paintTextIcon.setColor(txtlabelColor(color));
|
int contrastColor = UiUtilities.getContrastColor(app, color, false);
|
||||||
paintOuterRect.setColor(txtlabelColor(color));
|
paintTextIcon.setColor(contrastColor);
|
||||||
|
paintOuterRect.setColor(contrastColor);
|
||||||
|
|
||||||
List<GpxDisplayItem> items = groups.get(0).getModifiableList();
|
List<GpxDisplayItem> items = groups.get(0).getModifiableList();
|
||||||
|
|
||||||
|
@ -349,14 +359,6 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int txtlabelColor(int color) {
|
|
||||||
//Hardy, 2020-03-16: Contrast logic for text labels on tracks
|
|
||||||
if (((int) Color.red(color) * .299 + Color.green(color) * .587 + Color.blue(color) * .114) > 149) {
|
|
||||||
return Color.BLACK;
|
|
||||||
}
|
|
||||||
return Color.WHITE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawSplitItems(Canvas canvas, RotatedTileBox tileBox, List<GpxDisplayItem> items, DrawSettings settings) {
|
private void drawSplitItems(Canvas canvas, RotatedTileBox tileBox, List<GpxDisplayItem> items, DrawSettings settings) {
|
||||||
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||||
int r = (int) (12 * tileBox.getDensity());
|
int r = (int) (12 * tileBox.getDensity());
|
||||||
|
@ -406,12 +408,18 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
if (!tileBox.isZoomAnimated()) {
|
if (!tileBox.isZoomAnimated()) {
|
||||||
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
boolean showArrows = selectedGpxFile.getGpxFile().isShowArrows();
|
boolean showArrows = selectedGpxFile.getGpxFile().isShowArrows();
|
||||||
|
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
||||||
|
showArrows = trackDrawInfo.isShowArrows();
|
||||||
|
}
|
||||||
if (showArrows) {
|
if (showArrows) {
|
||||||
QuadRect correctedQuadRect = getCorrectedQuadRect(tileBox.getLatLonBounds());
|
QuadRect correctedQuadRect = getCorrectedQuadRect(tileBox.getLatLonBounds());
|
||||||
int color = selectedGpxFile.getGpxFile().getColor(cachedColor);
|
int color = selectedGpxFile.getGpxFile().getColor(cachedColor);
|
||||||
if (selectedGpxFile.isShowCurrentTrack()) {
|
if (selectedGpxFile.isShowCurrentTrack()) {
|
||||||
color = currentTrackColor;
|
color = currentTrackColor;
|
||||||
}
|
}
|
||||||
|
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
||||||
|
color = trackDrawInfo.getColor();
|
||||||
|
}
|
||||||
int contrastColor = UiUtilities.getContrastColor(view.getApplication(), color, false);
|
int contrastColor = UiUtilities.getContrastColor(view.getApplication(), color, false);
|
||||||
GeometryWayStyle arrowsWayStyle = new GeometryArrowsWayStyle(wayContext, contrastColor);
|
GeometryWayStyle arrowsWayStyle = new GeometryArrowsWayStyle(wayContext, contrastColor);
|
||||||
for (TrkSegment segment : selectedGpxFile.getPointsToDisplay()) {
|
for (TrkSegment segment : selectedGpxFile.getPointsToDisplay()) {
|
||||||
|
@ -526,12 +534,16 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
private void drawSelectedFilesStartEndPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
private void drawSelectedFilesStartEndPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
||||||
if (tileBox.getZoom() >= START_ZOOM) {
|
if (tileBox.getZoom() >= START_ZOOM) {
|
||||||
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
if (selectedGpxFile.getGpxFile().isShowStartFinish()) {
|
boolean showStartFinish = selectedGpxFile.getGpxFile().isShowStartFinish();
|
||||||
|
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
||||||
|
showStartFinish = trackDrawInfo.isShowStartFinish();
|
||||||
|
}
|
||||||
|
if (showStartFinish) {
|
||||||
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
||||||
TrkSegment endSegment = segments.get(segments.size() - 1);
|
for (TrkSegment segment : segments) {
|
||||||
|
if (segment.points.size() >= 2) {
|
||||||
WptPt start = segments.get(0).points.get(0);
|
WptPt start = segment.points.get(0);
|
||||||
WptPt end = endSegment.points.get(endSegment.points.size() - 1);
|
WptPt end = segment.points.get(segment.points.size() - 1);
|
||||||
|
|
||||||
drawPoint(canvas, tileBox, start, startPointIcon);
|
drawPoint(canvas, tileBox, start, startPointIcon);
|
||||||
drawPoint(canvas, tileBox, end, finishPointIcon);
|
drawPoint(canvas, tileBox, end, finishPointIcon);
|
||||||
|
@ -539,6 +551,12 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasTrackDrawInfoForSelectedGpx(SelectedGpxFile selectedGpxFile) {
|
||||||
|
return trackDrawInfo != null && trackDrawInfo.getFilePath().equals(selectedGpxFile.getGpxFile().path);
|
||||||
|
}
|
||||||
|
|
||||||
private void drawPoint(Canvas canvas, RotatedTileBox tileBox, WptPt wptPt, Drawable icon) {
|
private void drawPoint(Canvas canvas, RotatedTileBox tileBox, WptPt wptPt, Drawable icon) {
|
||||||
int pointX = (int) tileBox.getPixXFromLatLon(wptPt.lat, wptPt.lon);
|
int pointX = (int) tileBox.getPixXFromLatLon(wptPt.lat, wptPt.lon);
|
||||||
|
@ -703,6 +721,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
|
List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
|
||||||
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get());
|
String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get());
|
||||||
|
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
||||||
|
width = trackDrawInfo.getWidth();
|
||||||
|
}
|
||||||
if (!cachedTrackWidth.containsKey(width)) {
|
if (!cachedTrackWidth.containsKey(width)) {
|
||||||
cachedTrackWidth.put(width, null);
|
cachedTrackWidth.put(width, null);
|
||||||
}
|
}
|
||||||
|
@ -732,6 +753,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
if (color == 0) {
|
if (color == 0) {
|
||||||
color = ts.getColor(cachedColor);
|
color = ts.getColor(cachedColor);
|
||||||
}
|
}
|
||||||
|
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
||||||
|
color = trackDrawInfo.getColor();
|
||||||
|
width = trackDrawInfo.getWidth();
|
||||||
|
}
|
||||||
if (ts.renderer == null && !ts.points.isEmpty()) {
|
if (ts.renderer == null && !ts.points.isEmpty()) {
|
||||||
if (currentTrack) {
|
if (currentTrack) {
|
||||||
ts.renderer = new Renderable.CurrentTrack(ts.points);
|
ts.renderer = new Renderable.CurrentTrack(ts.points);
|
||||||
|
@ -1010,10 +1035,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
@Override
|
@Override
|
||||||
public void applyNewObjectPosition(@NonNull Object o,
|
public void applyNewObjectPosition(@NonNull Object o,
|
||||||
@NonNull LatLon position,
|
@NonNull LatLon position,
|
||||||
@Nullable ContextMenuLayer.ApplyMovedObjectCallback callback) {
|
@Nullable final ContextMenuLayer.ApplyMovedObjectCallback callback) {
|
||||||
|
|
||||||
if (o instanceof WptPt) {
|
if (o instanceof WptPt) {
|
||||||
WptPt objectInMotion = (WptPt) o;
|
final WptPt objectInMotion = (WptPt) o;
|
||||||
SelectedGpxFile selectedGpxFile = pointFileMap.get(objectInMotion);
|
SelectedGpxFile selectedGpxFile = pointFileMap.get(objectInMotion);
|
||||||
if (selectedGpxFile != null) {
|
if (selectedGpxFile != null) {
|
||||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||||
|
@ -1027,7 +1051,20 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
callback.onApplyMovedObject(true, objectInMotion);
|
callback.onApplyMovedObject(true, objectInMotion);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
new SaveGpxFileAsyncTask(view.getApplication(), callback, objectInMotion).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, gpxFile);
|
new SaveGpxAsyncTask(gpxFile, new SaveGpxAsyncTask.SaveGpxListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gpxSavingStarted() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gpxSavingFinished(Exception errorMessage) {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onApplyMovedObject(errorMessage == null, objectInMotion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (callback != null) {
|
} else if (callback != null) {
|
||||||
|
@ -1041,33 +1078,4 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
mapMarkersHelper.runSynchronization(group);
|
mapMarkersHelper.runSynchronization(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class SaveGpxFileAsyncTask extends AsyncTask<GPXFile, Void, Exception> {
|
|
||||||
private final OsmandApplication app;
|
|
||||||
@Nullable
|
|
||||||
private final ContextMenuLayer.ApplyMovedObjectCallback callback;
|
|
||||||
@Nullable
|
|
||||||
private final WptPt point;
|
|
||||||
|
|
||||||
SaveGpxFileAsyncTask(OsmandApplication app,
|
|
||||||
@Nullable ContextMenuLayer.ApplyMovedObjectCallback callback,
|
|
||||||
@Nullable WptPt point) {
|
|
||||||
this.app = app;
|
|
||||||
this.callback = callback;
|
|
||||||
this.point = point;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Exception doInBackground(GPXFile... params) {
|
|
||||||
GPXFile gpxFile = params[0];
|
|
||||||
return GPXUtilities.writeGpxFile(new File(gpxFile.path), gpxFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(Exception errorMessage) {
|
|
||||||
if (callback != null) {
|
|
||||||
callback.onApplyMovedObject(errorMessage == null, point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -906,7 +906,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
backToLocationControl.iv.setContentDescription(mapActivity.getString(R.string.map_widget_back_to_loc));
|
backToLocationControl.iv.setContentDescription(mapActivity.getString(R.string.map_widget_back_to_loc));
|
||||||
}
|
}
|
||||||
boolean visible = !(tracked && rh.isFollowingMode());
|
boolean visible = !(tracked && rh.isFollowingMode());
|
||||||
backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode() && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait));
|
backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode()
|
||||||
|
&& !isInTrackAppearanceMode() && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait));
|
||||||
if (app.accessibilityEnabled()) {
|
if (app.accessibilityEnabled()) {
|
||||||
backToLocationControl.iv.setClickable(enabled && visible);
|
backToLocationControl.iv.setClickable(enabled && visible);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
private final ContextMenuLayer contextMenuLayer;
|
private final ContextMenuLayer contextMenuLayer;
|
||||||
private final MeasurementToolLayer measurementToolLayer;
|
private final MeasurementToolLayer measurementToolLayer;
|
||||||
private final MapMarkersLayer mapMarkersLayer;
|
private final MapMarkersLayer mapMarkersLayer;
|
||||||
|
private final GPXLayer gpxLayer;
|
||||||
private ImageView contextMarker;
|
private ImageView contextMarker;
|
||||||
private final MapActivity mapActivity;
|
private final MapActivity mapActivity;
|
||||||
private final OsmandApplication app;
|
private final OsmandApplication app;
|
||||||
|
@ -84,9 +85,9 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
quickActionRegistry = app.getQuickActionRegistry();
|
quickActionRegistry = app.getQuickActionRegistry();
|
||||||
measurementToolLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
measurementToolLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
||||||
mapMarkersLayer = mapActivity.getMapLayers().getMapMarkersLayer();
|
mapMarkersLayer = mapActivity.getMapLayers().getMapMarkersLayer();
|
||||||
|
gpxLayer = mapActivity.getMapLayers().getGpxLayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initLayer(OsmandMapTileView view) {
|
public void initLayer(OsmandMapTileView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
@ -410,6 +411,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
contextMenuLayer.isInGpxDetailsMode() ||
|
contextMenuLayer.isInGpxDetailsMode() ||
|
||||||
measurementToolLayer.isInMeasurementMode() ||
|
measurementToolLayer.isInMeasurementMode() ||
|
||||||
mapMarkersLayer.isInPlanRouteMode() ||
|
mapMarkersLayer.isInPlanRouteMode() ||
|
||||||
|
gpxLayer.isInTrackAppearanceMode() ||
|
||||||
mapRouteInfoMenu.isVisible() ||
|
mapRouteInfoMenu.isVisible() ||
|
||||||
MapRouteInfoMenu.chooseRoutesVisible ||
|
MapRouteInfoMenu.chooseRoutesVisible ||
|
||||||
MapRouteInfoMenu.waypointsVisible ||
|
MapRouteInfoMenu.waypointsVisible ||
|
||||||
|
|
Loading…
Reference in a new issue