Merge pull request #9549 from osmandapp/track_appearance
Track appearance custom colors
This commit is contained in:
commit
1e22187dde
13 changed files with 584 additions and 150 deletions
|
@ -343,10 +343,8 @@ public class Algorithms {
|
||||||
* exception. Supported formats are:
|
* exception. Supported formats are:
|
||||||
* #RRGGBB
|
* #RRGGBB
|
||||||
* #AARRGGBB
|
* #AARRGGBB
|
||||||
* 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta',
|
|
||||||
* 'yellow', 'lightgray', 'darkgray'
|
|
||||||
*/
|
*/
|
||||||
public static int parseColor(String colorString) {
|
public static int parseColor(String colorString) throws IllegalArgumentException {
|
||||||
if (colorString.charAt(0) == '#') {
|
if (colorString.charAt(0) == '#') {
|
||||||
// Use a long to avoid rollovers on #ffXXXXXX
|
// Use a long to avoid rollovers on #ffXXXXXX
|
||||||
if (colorString.length() == 4) {
|
if (colorString.length() == 4) {
|
||||||
|
|
|
@ -563,6 +563,7 @@ dependencies {
|
||||||
implementation ("com.github.HITGIF:TextFieldBoxes:1.4.5"){
|
implementation ("com.github.HITGIF:TextFieldBoxes:1.4.5"){
|
||||||
exclude group: 'com.android.support'
|
exclude group: 'com.android.support'
|
||||||
}
|
}
|
||||||
|
implementation 'com.jaredrummler:colorpicker:1.1.0'
|
||||||
|
|
||||||
huaweiImplementation files('libs/huawei-android-drm_v2.5.2.300.jar')
|
huaweiImplementation files('libs/huawei-android-drm_v2.5.2.300.jar')
|
||||||
freehuaweiImplementation files('libs/huawei-android-drm_v2.5.2.300.jar')
|
freehuaweiImplementation files('libs/huawei-android-drm_v2.5.2.300.jar')
|
||||||
|
|
63
OsmAnd/res/layout/custom_color_picker.xml
Normal file
63
OsmAnd/res/layout/custom_color_picker.xml
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding">
|
||||||
|
|
||||||
|
<com.jaredrummler.android.colorpicker.ColorPickerView
|
||||||
|
android:id="@+id/color_picker_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
|
||||||
|
android:paddingBottom="@dimen/content_padding_small"
|
||||||
|
app:cpv_alphaChannelVisible="true" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<com.jaredrummler.android.colorpicker.ColorPanelView
|
||||||
|
android:id="@+id/color_panel_new"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
app:cpv_colorShape="square" />
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="@dimen/content_padding"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/color_hex_text_input"
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
app:boxBackgroundColor="@color/material_text_input_layout_bg"
|
||||||
|
app:hintEnabled="false"
|
||||||
|
app:prefixText="#">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/color_hex_edit_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
android:maxLines="4"
|
||||||
|
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||||
|
android:paddingStart="@dimen/content_padding_small"
|
||||||
|
android:paddingLeft="@dimen/content_padding_small"
|
||||||
|
android:paddingEnd="@dimen/content_padding_small"
|
||||||
|
android:paddingRight="@dimen/content_padding_small"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
tools:text="F1FF00" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -50,7 +50,7 @@
|
||||||
osmand:typeface="@string/font_roboto_medium" />
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/appearance_icon"
|
android:id="@+id/track_icon"
|
||||||
android:layout_width="@dimen/standard_icon_size"
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
android:layout_height="@dimen/standard_icon_size"
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
@ -94,7 +94,8 @@
|
||||||
android:id="@+id/map_controls_container"
|
android:id="@+id/map_controls_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom">
|
android:layout_gravity="bottom"
|
||||||
|
tools:visibility="invisible">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/map_ruler"
|
layout="@layout/map_ruler"
|
||||||
|
@ -104,8 +105,7 @@
|
||||||
android:layout_marginStart="@dimen/fab_margin_right"
|
android:layout_marginStart="@dimen/fab_margin_right"
|
||||||
android:layout_marginLeft="@dimen/fab_margin_right"
|
android:layout_marginLeft="@dimen/fab_margin_right"
|
||||||
android:layout_marginEnd="@dimen/fab_margin_right"
|
android:layout_marginEnd="@dimen/fab_margin_right"
|
||||||
android:layout_marginRight="@dimen/fab_margin_right"
|
android:layout_marginRight="@dimen/fab_margin_right" />
|
||||||
tools:visibility="invisible" />
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/map_hud_controls"
|
layout="@layout/map_hud_controls"
|
||||||
|
@ -115,8 +115,7 @@
|
||||||
android:layout_marginStart="@dimen/fab_margin_right"
|
android:layout_marginStart="@dimen/fab_margin_right"
|
||||||
android:layout_marginLeft="@dimen/fab_margin_right"
|
android:layout_marginLeft="@dimen/fab_margin_right"
|
||||||
android:layout_marginEnd="@dimen/fab_margin_right"
|
android:layout_marginEnd="@dimen/fab_margin_right"
|
||||||
android:layout_marginRight="@dimen/fab_margin_right"
|
android:layout_marginRight="@dimen/fab_margin_right" />
|
||||||
tools:visibility="invisible" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<net.osmand.plus.widgets.FlowLayout
|
<com.google.android.material.internal.FlowLayout
|
||||||
android:id="@+id/select_color"
|
android:id="@+id/select_color"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -520,12 +520,12 @@ public class GpxSelectionHelper {
|
||||||
}
|
}
|
||||||
GPXFile gpx = GPXUtilities.loadGPXFile(fl);
|
GPXFile gpx = GPXUtilities.loadGPXFile(fl);
|
||||||
if (obj.has(COLOR)) {
|
if (obj.has(COLOR)) {
|
||||||
int clr = Algorithms.parseColor(obj.getString(COLOR));
|
int clr = parseColor(obj.getString(COLOR));
|
||||||
gpx.setColor(clr);
|
gpx.setColor(clr);
|
||||||
}
|
}
|
||||||
for (GradientScaleType scaleType : GradientScaleType.values()) {
|
for (GradientScaleType scaleType : GradientScaleType.values()) {
|
||||||
if (obj.has(scaleType.getColorTypeName())) {
|
if (obj.has(scaleType.getColorTypeName())) {
|
||||||
int clr = Algorithms.parseColor(obj.getString(scaleType.getColorTypeName()));
|
int clr = parseColor(obj.getString(scaleType.getColorTypeName()));
|
||||||
gpx.setGradientScaleColor(scaleType.getColorTypeName(), clr);
|
gpx.setGradientScaleColor(scaleType.getColorTypeName(), clr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -567,6 +567,14 @@ public class GpxSelectionHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int parseColor(String color) {
|
||||||
|
try {
|
||||||
|
return Algorithms.isEmpty(color) ? 0 : Algorithms.parseColor(color);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void saveCurrentSelections() {
|
private void saveCurrentSelections() {
|
||||||
JSONArray ar = new JSONArray();
|
JSONArray ar = new JSONArray();
|
||||||
for (SelectedGpxFile s : selectedGPXFiles) {
|
for (SelectedGpxFile s : selectedGPXFiles) {
|
||||||
|
|
|
@ -2194,6 +2194,10 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<Long> LAST_UPDATES_CARD_REFRESH = new LongPreference("last_updates_card_refresh", 0).makeGlobal();
|
public final OsmandPreference<Long> LAST_UPDATES_CARD_REFRESH = new LongPreference("last_updates_card_refresh", 0).makeGlobal();
|
||||||
|
|
||||||
public final CommonPreference<Integer> CURRENT_TRACK_COLOR = new IntPreference("current_track_color", 0).makeGlobal().cache();
|
public final CommonPreference<Integer> CURRENT_TRACK_COLOR = new IntPreference("current_track_color", 0).makeGlobal().cache();
|
||||||
|
public final CommonPreference<String> CURRENT_TRACK_WIDTH = new StringPreference("current_track_width", "").makeGlobal().cache();
|
||||||
|
public final CommonPreference<Boolean> CURRENT_TRACK_SHOW_ARROWS = new BooleanPreference("current_track_show_arrows", false).makeGlobal().cache();
|
||||||
|
public final CommonPreference<Boolean> CURRENT_TRACK_SHOW_START_FINISH = new BooleanPreference("current_track_show_start_finish", true).makeGlobal().cache();
|
||||||
|
public final ListStringPreference CUSTOM_TRACK_COLORS = (ListStringPreference) new ListStringPreference("custom_track_colors", null, ",").makeGlobal();
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public final CommonPreference<Integer> SAVE_TRACK_INTERVAL = new IntPreference("save_track_interval", 5000).makeProfile();
|
public final CommonPreference<Integer> SAVE_TRACK_INTERVAL = new IntPreference("save_track_interval", 5000).makeProfile();
|
||||||
|
|
181
OsmAnd/src/net/osmand/plus/track/CustomColorBottomSheet.java
Normal file
181
OsmAnd/src/net/osmand/plus/track/CustomColorBottomSheet.java
Normal file
|
@ -0,0 +1,181 @@
|
||||||
|
package net.osmand.plus.track;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import androidx.annotation.ColorInt;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
import com.jaredrummler.android.colorpicker.ColorPanelView;
|
||||||
|
import com.jaredrummler.android.colorpicker.ColorPickerView;
|
||||||
|
import com.jaredrummler.android.colorpicker.ColorPickerView.OnColorChangedListener;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
public class CustomColorBottomSheet extends MenuBottomSheetDialogFragment implements OnColorChangedListener {
|
||||||
|
|
||||||
|
private static final String TAG = CustomColorBottomSheet.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final Log log = PlatformUtil.getLog(CustomColorBottomSheet.class);
|
||||||
|
|
||||||
|
private static final String NEW_SELECTED_COLOR = "new_selected_color";
|
||||||
|
private static final String PREV_SELECTED_COLOR = "prev_selected_color";
|
||||||
|
|
||||||
|
private ColorPickerView colorPicker;
|
||||||
|
private ColorPanelView newColorPanel;
|
||||||
|
|
||||||
|
private EditText hexEditText;
|
||||||
|
private boolean fromEditText;
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
private int prevColor;
|
||||||
|
@ColorInt
|
||||||
|
private int newColor;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
newColor = savedInstanceState.getInt(NEW_SELECTED_COLOR);
|
||||||
|
prevColor = savedInstanceState.getInt(PREV_SELECTED_COLOR);
|
||||||
|
} else {
|
||||||
|
Bundle args = getArguments();
|
||||||
|
if (args != null) {
|
||||||
|
prevColor = args.getInt(PREV_SELECTED_COLOR);
|
||||||
|
newColor = prevColor != -1 ? prevColor : Color.RED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items.add(new TitleItem(getString(R.string.select_color)));
|
||||||
|
|
||||||
|
BaseBottomSheetItem item = new SimpleBottomSheetItem.Builder()
|
||||||
|
.setCustomView(createPickerView())
|
||||||
|
.create();
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
outState.putInt(NEW_SELECTED_COLOR, newColor);
|
||||||
|
outState.putInt(PREV_SELECTED_COLOR, prevColor);
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private View createPickerView() {
|
||||||
|
LayoutInflater themedInflater = UiUtilities.getMaterialInflater(getActivity(), nightMode);
|
||||||
|
View colorView = themedInflater.inflate(R.layout.custom_color_picker, null);
|
||||||
|
colorPicker = colorView.findViewById(R.id.color_picker_view);
|
||||||
|
newColorPanel = colorView.findViewById(R.id.color_panel_new);
|
||||||
|
hexEditText = colorView.findViewById(R.id.color_hex_edit_text);
|
||||||
|
|
||||||
|
setHex(newColor);
|
||||||
|
newColorPanel.setColor(newColor);
|
||||||
|
colorPicker.setColor(newColor, true);
|
||||||
|
colorPicker.setOnColorChangedListener(this);
|
||||||
|
hexEditText.addTextChangedListener(new TextWatcher() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
if (hexEditText.isFocused()) {
|
||||||
|
int color = colorPicker.getColor();
|
||||||
|
try {
|
||||||
|
color = Algorithms.parseColor("#" + s.toString());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
hexEditText.setError(getString(R.string.wrong_input));
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
if (color != colorPicker.getColor()) {
|
||||||
|
fromEditText = true;
|
||||||
|
colorPicker.setColor(color, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return colorView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onColorChanged(int newColor) {
|
||||||
|
this.newColor = newColor;
|
||||||
|
if (newColorPanel != null) {
|
||||||
|
newColorPanel.setColor(newColor);
|
||||||
|
}
|
||||||
|
if (!fromEditText && hexEditText != null) {
|
||||||
|
setHex(newColor);
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity != null && hexEditText.hasFocus()) {
|
||||||
|
AndroidUtils.hideSoftKeyboard(activity, hexEditText);
|
||||||
|
hexEditText.clearFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fromEditText = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setHex(int color) {
|
||||||
|
hexEditText.setText(String.format("%08X", color));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getRightBottomButtonTextId() {
|
||||||
|
return R.string.shared_string_apply;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRightBottomButtonClick() {
|
||||||
|
Fragment target = getTargetFragment();
|
||||||
|
if (target instanceof ColorPickerListener) {
|
||||||
|
((ColorPickerListener) target).onColorSelected(prevColor, newColor);
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showInstance(@NonNull FragmentManager fragmentManager, Fragment target, int prevColor) {
|
||||||
|
try {
|
||||||
|
if (!fragmentManager.isStateSaved() && fragmentManager.findFragmentByTag(CustomColorBottomSheet.TAG) == null) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt(PREV_SELECTED_COLOR, prevColor);
|
||||||
|
|
||||||
|
CustomColorBottomSheet customColorBottomSheet = new CustomColorBottomSheet();
|
||||||
|
customColorBottomSheet.setArguments(args);
|
||||||
|
customColorBottomSheet.setTargetFragment(target, 0);
|
||||||
|
customColorBottomSheet.show(fragmentManager, CustomColorBottomSheet.TAG);
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ColorPickerListener {
|
||||||
|
|
||||||
|
void onColorSelected(@ColorInt int prevColor, @ColorInt int newColor);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,6 @@ import com.google.android.material.slider.Slider;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -30,6 +29,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -310,17 +310,11 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public List<GpxDisplayGroup> getDisplayGroups() {
|
public List<GpxDisplayGroup> getDisplayGroups() {
|
||||||
List<GpxDisplayGroup> groups = new ArrayList<>();
|
|
||||||
Fragment target = getTargetFragment();
|
Fragment target = getTargetFragment();
|
||||||
if (target instanceof TrackAppearanceFragment) {
|
if (target instanceof TrackAppearanceFragment) {
|
||||||
List<GpxDisplayGroup> result = ((TrackAppearanceFragment) target).getGpxDisplayGroups();
|
return ((TrackAppearanceFragment) target).getDisplaySegmentGroups();
|
||||||
for (GpxDisplayGroup group : result) {
|
|
||||||
if (GpxDisplayItemType.TRACK_SEGMENT == group.getType()) {
|
|
||||||
groups.add(group);
|
|
||||||
}
|
}
|
||||||
}
|
return Collections.emptyList();
|
||||||
}
|
|
||||||
return groups;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showInstance(@NonNull FragmentManager fragmentManager, TrackDrawInfo trackDrawInfo, Fragment target) {
|
public static void showInstance(@NonNull FragmentManager fragmentManager, TrackDrawInfo trackDrawInfo, Fragment target) {
|
||||||
|
|
|
@ -9,9 +9,11 @@ import android.view.Gravity;
|
||||||
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.view.ViewTreeObserver;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ScrollView;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -26,6 +28,7 @@ import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -38,6 +41,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
|
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
|
||||||
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
|
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -54,9 +58,9 @@ import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR;
|
||||||
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_BOLD;
|
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_BOLD;
|
||||||
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_MEDIUM;
|
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_MEDIUM;
|
||||||
|
|
||||||
public class TrackAppearanceFragment extends ContextMenuScrollFragment implements CardListener {
|
public class TrackAppearanceFragment extends ContextMenuScrollFragment implements CardListener, ColorPickerListener {
|
||||||
|
|
||||||
public static final String TAG = TrackAppearanceFragment.class.getSimpleName();
|
public static final String TAG = TrackAppearanceFragment.class.getName();
|
||||||
|
|
||||||
private static final Log log = PlatformUtil.getLog(TrackAppearanceFragment.class);
|
private static final Log log = PlatformUtil.getLog(TrackAppearanceFragment.class);
|
||||||
|
|
||||||
|
@ -73,8 +77,9 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
|
|
||||||
private TrackWidthCard trackWidthCard;
|
private TrackWidthCard trackWidthCard;
|
||||||
private SplitIntervalCard splitIntervalCard;
|
private SplitIntervalCard splitIntervalCard;
|
||||||
|
private TrackColoringCard trackColoringCard;
|
||||||
|
|
||||||
private ImageView appearanceIcon;
|
private ImageView trackIcon;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMainLayoutId() {
|
public int getMainLayoutId() {
|
||||||
|
@ -131,6 +136,10 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
}
|
}
|
||||||
if (currentRecording) {
|
if (currentRecording) {
|
||||||
trackDrawInfo = new TrackDrawInfo(true);
|
trackDrawInfo = new TrackDrawInfo(true);
|
||||||
|
trackDrawInfo.setColor(app.getSettings().CURRENT_TRACK_COLOR.get());
|
||||||
|
trackDrawInfo.setWidth(app.getSettings().CURRENT_TRACK_WIDTH.get());
|
||||||
|
trackDrawInfo.setShowArrows(app.getSettings().CURRENT_TRACK_SHOW_ARROWS.get());
|
||||||
|
trackDrawInfo.setShowStartFinish(app.getSettings().CURRENT_TRACK_SHOW_START_FINISH.get());
|
||||||
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||||
} else {
|
} else {
|
||||||
gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFilePath));
|
gpxDataItem = app.getGpxDbHelper().getItem(new File(gpxFilePath));
|
||||||
|
@ -163,13 +172,14 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
appearanceIcon = view.findViewById(R.id.appearance_icon);
|
trackIcon = view.findViewById(R.id.track_icon);
|
||||||
|
|
||||||
if (isPortrait()) {
|
if (isPortrait()) {
|
||||||
updateCardsLayout();
|
updateCardsLayout();
|
||||||
}
|
}
|
||||||
updateCards();
|
setupCards();
|
||||||
updateButtons(view);
|
setupButtons(view);
|
||||||
|
setupScrollShadow();
|
||||||
updateAppearanceIcon();
|
updateAppearanceIcon();
|
||||||
if (!isPortrait()) {
|
if (!isPortrait()) {
|
||||||
int widthNoShadow = getLandscapeNoShadowWidth();
|
int widthNoShadow = getLandscapeNoShadowWidth();
|
||||||
|
@ -316,6 +326,11 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onColorSelected(int prevColor, int newColor) {
|
||||||
|
trackColoringCard.onColorSelected(prevColor, newColor);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int applyPosY(int currentY, boolean needCloseMenu, boolean needMapAdjust, int previousMenuState, int newMenuState, int dZoom, boolean animated) {
|
protected int applyPosY(int currentY, boolean needCloseMenu, boolean needMapAdjust, int previousMenuState, int newMenuState, int dZoom, boolean animated) {
|
||||||
int y = super.applyPosY(currentY, needCloseMenu, needMapAdjust, previousMenuState, newMenuState, dZoom, animated);
|
int y = super.applyPosY(currentY, needCloseMenu, needMapAdjust, previousMenuState, newMenuState, dZoom, animated);
|
||||||
|
@ -327,7 +342,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
|
|
||||||
private void updateAppearanceIcon() {
|
private void updateAppearanceIcon() {
|
||||||
Drawable icon = getTrackIcon(app, trackDrawInfo.getWidth(), trackDrawInfo.isShowArrows(), trackDrawInfo.getColor());
|
Drawable icon = getTrackIcon(app, trackDrawInfo.getWidth(), trackDrawInfo.isShowArrows(), trackDrawInfo.getColor());
|
||||||
appearanceIcon.setImageDrawable(icon);
|
trackIcon.setImageDrawable(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void adjustMapPosition(int y) {
|
private void adjustMapPosition(int y) {
|
||||||
|
@ -387,7 +402,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateButtons(View view) {
|
private void setupButtons(View view) {
|
||||||
View buttonsContainer = view.findViewById(R.id.buttons_container);
|
View buttonsContainer = view.findViewById(R.id.buttons_container);
|
||||||
buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.route_info_bg));
|
buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.route_info_bg));
|
||||||
View saveButton = view.findViewById(R.id.right_bottom_button);
|
View saveButton = view.findViewById(R.id.right_bottom_button);
|
||||||
|
@ -418,6 +433,26 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true);
|
AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupScrollShadow() {
|
||||||
|
int shadowIconId = isNightMode() ? R.drawable.bg_contextmenu_shadow : R.drawable.bg_contextmenu_shadow;
|
||||||
|
final Drawable shadowIcon = app.getUIUtilities().getIcon(shadowIconId);
|
||||||
|
|
||||||
|
final ScrollView scrollView = getBottomScrollView();
|
||||||
|
final FrameLayout bottomContainer = getBottomContainer();
|
||||||
|
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScrollChanged() {
|
||||||
|
int scrollY = scrollView.getScrollY();
|
||||||
|
if (scrollY <= 0 && bottomContainer.getForeground() != null) {
|
||||||
|
bottomContainer.setForeground(null);
|
||||||
|
} else if (scrollY > 0 && bottomContainer.getForeground() == null) {
|
||||||
|
bottomContainer.setForeground(shadowIcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void saveTrackInfo() {
|
private void saveTrackInfo() {
|
||||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||||
|
|
||||||
|
@ -440,6 +475,9 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
|
|
||||||
if (gpxFile.showCurrentTrack) {
|
if (gpxFile.showCurrentTrack) {
|
||||||
app.getSettings().CURRENT_TRACK_COLOR.set(trackDrawInfo.getColor());
|
app.getSettings().CURRENT_TRACK_COLOR.set(trackDrawInfo.getColor());
|
||||||
|
app.getSettings().CURRENT_TRACK_WIDTH.set(trackDrawInfo.getWidth());
|
||||||
|
app.getSettings().CURRENT_TRACK_SHOW_ARROWS.set(trackDrawInfo.isShowArrows());
|
||||||
|
app.getSettings().CURRENT_TRACK_SHOW_START_FINISH.set(trackDrawInfo.isShowStartFinish());
|
||||||
} else {
|
} else {
|
||||||
if (gpxDataItem != null) {
|
if (gpxDataItem != null) {
|
||||||
gpxDataItem = new GpxDataItem(new File(gpxFile.path), gpxFile);
|
gpxDataItem = new GpxDataItem(new File(gpxFile.path), gpxFile);
|
||||||
|
@ -508,13 +546,13 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCards() {
|
private void setupCards() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
ViewGroup cardsContainer = getCardsContainer();
|
ViewGroup cardsContainer = getCardsContainer();
|
||||||
cardsContainer.removeAllViews();
|
cardsContainer.removeAllViews();
|
||||||
|
|
||||||
if (!selectedGpxFile.isShowCurrentTrack()) {
|
if (!selectedGpxFile.isShowCurrentTrack() && !Algorithms.isEmpty(getDisplaySegmentGroups())) {
|
||||||
splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo);
|
splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo);
|
||||||
splitIntervalCard.setListener(this);
|
splitIntervalCard.setListener(this);
|
||||||
cardsContainer.addView(splitIntervalCard.build(mapActivity));
|
cardsContainer.addView(splitIntervalCard.build(mapActivity));
|
||||||
|
@ -524,7 +562,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
directionArrowsCard.setListener(this);
|
directionArrowsCard.setListener(this);
|
||||||
cardsContainer.addView(directionArrowsCard.build(mapActivity));
|
cardsContainer.addView(directionArrowsCard.build(mapActivity));
|
||||||
|
|
||||||
TrackColoringCard trackColoringCard = new TrackColoringCard(mapActivity, trackDrawInfo);
|
trackColoringCard = new TrackColoringCard(mapActivity, trackDrawInfo, this);
|
||||||
trackColoringCard.setListener(this);
|
trackColoringCard.setListener(this);
|
||||||
cardsContainer.addView(trackColoringCard.build(mapActivity));
|
cardsContainer.addView(trackColoringCard.build(mapActivity));
|
||||||
|
|
||||||
|
@ -549,6 +587,17 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
||||||
return displayGroups;
|
return displayGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public List<GpxDisplayGroup> getDisplaySegmentGroups() {
|
||||||
|
List<GpxDisplayGroup> groups = new ArrayList<>();
|
||||||
|
for (GpxDisplayGroup group : getGpxDisplayGroups()) {
|
||||||
|
if (GpxDisplayItemType.TRACK_SEGMENT == group.getType()) {
|
||||||
|
groups.add(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
public void dismissImmediate() {
|
public void dismissImmediate() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package net.osmand.plus.track;
|
package net.osmand.plus.track;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.GradientDrawable;
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Build;
|
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.FrameLayout;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
|
@ -14,10 +15,14 @@ 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;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.google.android.material.internal.FlowLayout;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
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;
|
||||||
|
@ -25,16 +30,22 @@ import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem;
|
||||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType;
|
import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
import net.osmand.plus.widgets.FlowLayout;
|
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
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 implements ColorPickerListener {
|
||||||
|
|
||||||
|
public static final int INVALID_VALUE = -1;
|
||||||
|
|
||||||
private final static String SOLID_COLOR = "solid_color";
|
private final static String SOLID_COLOR = "solid_color";
|
||||||
|
private static final Log log = PlatformUtil.getLog(TrackColoringCard.class);
|
||||||
|
|
||||||
private TrackDrawInfo trackDrawInfo;
|
private TrackDrawInfo trackDrawInfo;
|
||||||
|
|
||||||
|
@ -42,10 +53,15 @@ public class TrackColoringCard extends BaseCard {
|
||||||
private TrackAppearanceItem selectedAppearanceItem;
|
private TrackAppearanceItem selectedAppearanceItem;
|
||||||
private List<TrackAppearanceItem> appearanceItems;
|
private List<TrackAppearanceItem> appearanceItems;
|
||||||
|
|
||||||
public TrackColoringCard(MapActivity mapActivity, TrackDrawInfo trackDrawInfo) {
|
private List<Integer> customColors;
|
||||||
|
private Fragment target;
|
||||||
|
|
||||||
|
public TrackColoringCard(MapActivity mapActivity, TrackDrawInfo trackDrawInfo, Fragment target) {
|
||||||
super(mapActivity);
|
super(mapActivity);
|
||||||
|
this.target = target;
|
||||||
this.trackDrawInfo = trackDrawInfo;
|
this.trackDrawInfo = trackDrawInfo;
|
||||||
appearanceItems = getGradientAppearanceItems();
|
appearanceItems = getGradientAppearanceItems();
|
||||||
|
customColors = getCustomColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -67,6 +83,25 @@ 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<Integer> getCustomColors() {
|
||||||
|
List<Integer> colors = new ArrayList<>();
|
||||||
|
List<String> colorNames = app.getSettings().CUSTOM_TRACK_COLORS.getStringsList();
|
||||||
|
if (colorNames != null) {
|
||||||
|
for (String colorHex : colorNames) {
|
||||||
|
try {
|
||||||
|
if (!Algorithms.isEmpty(colorHex)) {
|
||||||
|
int color = Algorithms.parseColor(colorHex);
|
||||||
|
colors.add(color);
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return colors;
|
||||||
|
}
|
||||||
|
|
||||||
private List<TrackAppearanceItem> getGradientAppearanceItems() {
|
private List<TrackAppearanceItem> getGradientAppearanceItems() {
|
||||||
List<TrackAppearanceItem> items = new ArrayList<>();
|
List<TrackAppearanceItem> items = new ArrayList<>();
|
||||||
items.add(new TrackAppearanceItem(SOLID_COLOR, app.getString(R.string.track_coloring_solid), R.drawable.ic_action_circle));
|
items.add(new TrackAppearanceItem(SOLID_COLOR, app.getString(R.string.track_coloring_solid), R.drawable.ic_action_circle));
|
||||||
|
@ -80,6 +115,16 @@ public class TrackColoringCard extends BaseCard {
|
||||||
|
|
||||||
private void createColorSelector() {
|
private void createColorSelector() {
|
||||||
FlowLayout selectColor = view.findViewById(R.id.select_color);
|
FlowLayout selectColor = view.findViewById(R.id.select_color);
|
||||||
|
selectColor.removeAllViews();
|
||||||
|
|
||||||
|
for (int color : customColors) {
|
||||||
|
selectColor.addView(createColorItemView(color, selectColor, true));
|
||||||
|
}
|
||||||
|
if (customColors.size() < 6) {
|
||||||
|
selectColor.addView(createAddCustomColorItemView(selectColor));
|
||||||
|
}
|
||||||
|
selectColor.addView(createDividerView(selectColor));
|
||||||
|
|
||||||
List<Integer> colors = new ArrayList<>();
|
List<Integer> colors = new ArrayList<>();
|
||||||
for (AppearanceListItem appearanceListItem : getAppearanceItems(app, GpxAppearanceAdapterType.TRACK_COLOR)) {
|
for (AppearanceListItem appearanceListItem : getAppearanceItems(app, GpxAppearanceAdapterType.TRACK_COLOR)) {
|
||||||
if (!colors.contains(appearanceListItem.getColor())) {
|
if (!colors.contains(appearanceListItem.getColor())) {
|
||||||
|
@ -87,20 +132,13 @@ 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, false));
|
||||||
}
|
}
|
||||||
updateColorSelector(trackDrawInfo.getColor(), selectColor);
|
updateColorSelector(trackDrawInfo.getColor(), selectColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private View createColorItemView(@ColorInt final int color, final FlowLayout rootView) {
|
private View createColorItemView(@ColorInt final int color, final FlowLayout rootView, boolean customColor) {
|
||||||
FrameLayout colorItemView = (FrameLayout) UiUtilities.getInflater(rootView.getContext(), nightMode)
|
View colorItemView = createCircleView(rootView);
|
||||||
.inflate(R.layout.point_editor_button, rootView, false);
|
|
||||||
ImageView outline = colorItemView.findViewById(R.id.outline);
|
|
||||||
outline.setImageDrawable(
|
|
||||||
UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, R.drawable.bg_point_circle_contour),
|
|
||||||
ContextCompat.getColor(app,
|
|
||||||
nightMode ? R.color.stroked_buttons_and_links_outline_dark
|
|
||||||
: R.color.stroked_buttons_and_links_outline_light)));
|
|
||||||
ImageView backgroundCircle = colorItemView.findViewById(R.id.background);
|
ImageView backgroundCircle = colorItemView.findViewById(R.id.background);
|
||||||
backgroundCircle.setImageDrawable(UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, R.drawable.bg_point_circle), color));
|
backgroundCircle.setImageDrawable(UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, R.drawable.bg_point_circle), color));
|
||||||
backgroundCircle.setOnClickListener(new View.OnClickListener() {
|
backgroundCircle.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -116,10 +154,68 @@ public class TrackColoringCard extends BaseCard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (customColor) {
|
||||||
|
backgroundCircle.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
CustomColorBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), target, color);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
colorItemView.setTag(color);
|
colorItemView.setTag(color);
|
||||||
return colorItemView;
|
return colorItemView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private View createAddCustomColorItemView(FlowLayout rootView) {
|
||||||
|
View colorItemView = createCircleView(rootView);
|
||||||
|
ImageView backgroundCircle = colorItemView.findViewById(R.id.background);
|
||||||
|
|
||||||
|
int bgColorId = nightMode ? R.color.activity_background_color_dark : R.color.activity_background_color_light;
|
||||||
|
Drawable backgroundIcon = app.getUIUtilities().getIcon(R.drawable.bg_point_circle, bgColorId);
|
||||||
|
|
||||||
|
ImageView icon = colorItemView.findViewById(R.id.icon);
|
||||||
|
icon.setVisibility(View.VISIBLE);
|
||||||
|
int activeColorResId = nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light;
|
||||||
|
icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_add, activeColorResId));
|
||||||
|
|
||||||
|
backgroundCircle.setImageDrawable(backgroundIcon);
|
||||||
|
backgroundCircle.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
CustomColorBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), target, TrackColoringCard.INVALID_VALUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return colorItemView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private View createDividerView(FlowLayout rootView) {
|
||||||
|
LayoutInflater themedInflater = UiUtilities.getInflater(view.getContext(), nightMode);
|
||||||
|
View divider = themedInflater.inflate(R.layout.simple_divider_item, rootView, false);
|
||||||
|
|
||||||
|
LinearLayout dividerContainer = new LinearLayout(view.getContext());
|
||||||
|
dividerContainer.addView(divider);
|
||||||
|
dividerContainer.setPadding(0, AndroidUtils.dpToPx(app, 1), 0, AndroidUtils.dpToPx(app, 5));
|
||||||
|
|
||||||
|
return dividerContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private View createCircleView(ViewGroup rootView) {
|
||||||
|
LayoutInflater themedInflater = UiUtilities.getInflater(view.getContext(), nightMode);
|
||||||
|
View circleView = themedInflater.inflate(R.layout.point_editor_button, rootView, false);
|
||||||
|
ImageView outline = circleView.findViewById(R.id.outline);
|
||||||
|
int colorId = nightMode ? R.color.stroked_buttons_and_links_outline_dark : R.color.stroked_buttons_and_links_outline_light;
|
||||||
|
Drawable contourIcon = app.getUIUtilities().getIcon(R.drawable.bg_point_circle_contour, colorId);
|
||||||
|
outline.setImageDrawable(contourIcon);
|
||||||
|
return circleView;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateColorSelector(int color, View rootView) {
|
private void updateColorSelector(int color, View rootView) {
|
||||||
View oldColor = rootView.findViewWithTag(trackDrawInfo.getColor());
|
View oldColor = rootView.findViewWithTag(trackDrawInfo.getColor());
|
||||||
if (oldColor != null) {
|
if (oldColor != null) {
|
||||||
|
@ -175,6 +271,29 @@ public class TrackColoringCard extends BaseCard {
|
||||||
updateColorSelector();
|
updateColorSelector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onColorSelected(int prevColor, int newColor) {
|
||||||
|
if (prevColor == INVALID_VALUE && customColors.size() < 6) {
|
||||||
|
customColors.add(newColor);
|
||||||
|
} else if (!Algorithms.isEmpty(customColors)) {
|
||||||
|
int index = customColors.indexOf(prevColor);
|
||||||
|
if (index != INVALID_VALUE) {
|
||||||
|
customColors.set(index, newColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
saveCustomColors();
|
||||||
|
updateContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveCustomColors() {
|
||||||
|
List<String> colorNames = new ArrayList<>();
|
||||||
|
for (Integer color : customColors) {
|
||||||
|
String colorHex = Algorithms.colorToString(color);
|
||||||
|
colorNames.add(colorHex);
|
||||||
|
}
|
||||||
|
app.getSettings().CUSTOM_TRACK_COLORS.setStringsList(colorNames);
|
||||||
|
}
|
||||||
|
|
||||||
private class TrackColoringAdapter extends RecyclerView.Adapter<TrackAppearanceViewHolder> {
|
private class TrackColoringAdapter extends RecyclerView.Adapter<TrackAppearanceViewHolder> {
|
||||||
|
|
||||||
private List<TrackAppearanceItem> items;
|
private List<TrackAppearanceItem> items;
|
||||||
|
|
|
@ -109,6 +109,10 @@ public class TrackDrawInfo {
|
||||||
this.showArrows = showArrows;
|
this.showArrows = showArrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShowStartFinish(boolean showStartFinish) {
|
||||||
|
this.showStartFinish = showStartFinish;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isShowStartFinish() {
|
public boolean isShowStartFinish() {
|
||||||
return showStartFinish;
|
return showStartFinish;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,9 +89,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
private Paint paint;
|
private Paint paint;
|
||||||
private Paint shadowPaint;
|
private Paint shadowPaint;
|
||||||
private Paint paintIcon;
|
private Paint paintIcon;
|
||||||
|
|
||||||
private int cachedHash;
|
private int cachedHash;
|
||||||
|
@ColorInt
|
||||||
private int cachedColor;
|
private int cachedColor;
|
||||||
private int currentTrackColor;
|
|
||||||
private float defaultTrackWidth;
|
private float defaultTrackWidth;
|
||||||
private Map<String, Float> cachedTrackWidth = new HashMap<>();
|
private Map<String, Float> cachedTrackWidth = new HashMap<>();
|
||||||
|
|
||||||
|
@ -129,8 +130,13 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
@ColorInt
|
@ColorInt
|
||||||
private int grayColor;
|
private int grayColor;
|
||||||
|
|
||||||
private CommonPreference<String> currentTrackColorPref;
|
private CommonPreference<String> defaultTrackColorPref;
|
||||||
|
private CommonPreference<String> defaultTrackWidthPref;
|
||||||
|
|
||||||
|
private CommonPreference<Integer> currentTrackColorPref;
|
||||||
private CommonPreference<String> currentTrackWidthPref;
|
private CommonPreference<String> currentTrackWidthPref;
|
||||||
|
private CommonPreference<Boolean> currentTrackShowArrowsPref;
|
||||||
|
private CommonPreference<Boolean> currentTrackShowStartFinishPref;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initLayer(OsmandMapTileView view) {
|
public void initLayer(OsmandMapTileView view) {
|
||||||
|
@ -138,8 +144,14 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
selectedGpxHelper = view.getApplication().getSelectedGpxHelper();
|
selectedGpxHelper = view.getApplication().getSelectedGpxHelper();
|
||||||
mapMarkersHelper = view.getApplication().getMapMarkersHelper();
|
mapMarkersHelper = view.getApplication().getMapMarkersHelper();
|
||||||
osmandRenderer = view.getApplication().getResourceManager().getRenderer().getRenderer();
|
osmandRenderer = view.getApplication().getResourceManager().getRenderer().getRenderer();
|
||||||
currentTrackColorPref = view.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR);
|
|
||||||
currentTrackWidthPref = view.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR);
|
currentTrackColorPref = view.getSettings().CURRENT_TRACK_COLOR;
|
||||||
|
currentTrackWidthPref = view.getSettings().CURRENT_TRACK_WIDTH;
|
||||||
|
currentTrackShowArrowsPref = view.getSettings().CURRENT_TRACK_SHOW_ARROWS;
|
||||||
|
currentTrackShowStartFinishPref = view.getSettings().CURRENT_TRACK_SHOW_START_FINISH;
|
||||||
|
defaultTrackColorPref = view.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR).cache();
|
||||||
|
defaultTrackWidthPref = view.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR).cache();
|
||||||
|
|
||||||
initUI();
|
initUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +240,6 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
|
List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
|
||||||
cache.clear();
|
cache.clear();
|
||||||
currentTrackColor = view.getSettings().CURRENT_TRACK_COLOR.get();
|
|
||||||
if (!selectedGPXFiles.isEmpty()) {
|
if (!selectedGPXFiles.isEmpty()) {
|
||||||
drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
|
drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
|
||||||
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||||
|
@ -249,7 +260,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
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(),
|
||||||
currentTrackColorPref.get(), currentTrackWidthPref.get());
|
defaultTrackColorPref.get(), defaultTrackWidthPref.get());
|
||||||
if (hash != cachedHash) {
|
if (hash != cachedHash) {
|
||||||
cachedHash = hash;
|
cachedHash = hash;
|
||||||
cachedColor = ContextCompat.getColor(view.getApplication(), R.color.gpx_track);
|
cachedColor = ContextCompat.getColor(view.getApplication(), R.color.gpx_track);
|
||||||
|
@ -257,16 +268,16 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
if (rrs != null) {
|
if (rrs != null) {
|
||||||
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
|
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
|
||||||
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode);
|
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode);
|
||||||
if (currentTrackColorPref != null && currentTrackColorPref.isSet()) {
|
if (defaultTrackColorPref != null && defaultTrackColorPref.isSet()) {
|
||||||
RenderingRuleProperty ctColor = rrs.PROPS.get(CURRENT_TRACK_COLOR_ATTR);
|
RenderingRuleProperty ctColor = rrs.PROPS.get(CURRENT_TRACK_COLOR_ATTR);
|
||||||
if (ctColor != null) {
|
if (ctColor != null) {
|
||||||
req.setStringFilter(ctColor, currentTrackColorPref.get());
|
req.setStringFilter(ctColor, defaultTrackColorPref.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentTrackWidthPref != null && currentTrackWidthPref.isSet()) {
|
if (defaultTrackWidthPref != null && defaultTrackWidthPref.isSet()) {
|
||||||
RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR);
|
RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR);
|
||||||
if (ctWidth != null) {
|
if (ctWidth != null) {
|
||||||
req.setStringFilter(ctWidth, currentTrackWidthPref.get());
|
req.setStringFilter(ctWidth, defaultTrackWidthPref.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String additional = "";
|
String additional = "";
|
||||||
|
@ -305,10 +316,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
paint.setColor(color == 0 ? cachedColor : color);
|
paint.setColor(color == 0 ? cachedColor : color);
|
||||||
Float strikeWidth = cachedTrackWidth.get(width);
|
paint.setStrokeWidth(getTrackWidth(width, defaultTrackWidth));
|
||||||
if (strikeWidth != null) {
|
|
||||||
paint.setStrokeWidth(strikeWidth);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) {
|
private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) {
|
||||||
|
@ -342,17 +350,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
if (tileBox.getZoom() >= START_ZOOM) {
|
if (tileBox.getZoom() >= START_ZOOM) {
|
||||||
// request to load
|
// request to load
|
||||||
OsmandApplication app = view.getApplication();
|
OsmandApplication app = view.getApplication();
|
||||||
for (SelectedGpxFile g : selectedGPXFiles) {
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
List<GpxDisplayGroup> groups = g.getDisplayGroups(app);
|
List<GpxDisplayGroup> groups = selectedGpxFile.getDisplayGroups(app);
|
||||||
if (groups != null && !groups.isEmpty()) {
|
if (!Algorithms.isEmpty(groups)) {
|
||||||
int color = g.getGpxFile().getColor(0);
|
int color = getTrackColor(selectedGpxFile.getGpxFile(), cachedColor);
|
||||||
if (color == 0) {
|
|
||||||
color = g.getModifiableGpxFile().getColor(0);
|
|
||||||
}
|
|
||||||
if (color == 0) {
|
|
||||||
color = cachedColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
paintInnerRect.setColor(color);
|
paintInnerRect.setColor(color);
|
||||||
paintInnerRect.setAlpha(179);
|
paintInnerRect.setAlpha(179);
|
||||||
|
|
||||||
|
@ -373,15 +374,15 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
int r = (int) (12 * tileBox.getDensity());
|
int r = (int) (12 * tileBox.getDensity());
|
||||||
paintTextIcon.setTextSize(r);
|
paintTextIcon.setTextSize(r);
|
||||||
int dr = r * 3 / 2;
|
int dr = r * 3 / 2;
|
||||||
int px = -1;
|
float px = -1;
|
||||||
int py = -1;
|
float py = -1;
|
||||||
for (int k = 0; k < items.size(); k++) {
|
for (int k = 0; k < items.size(); k++) {
|
||||||
GpxDisplayItem i = items.get(k);
|
GpxDisplayItem i = items.get(k);
|
||||||
WptPt o = i.locationEnd;
|
WptPt point = i.locationEnd;
|
||||||
if (o != null && o.lat >= latLonBounds.bottom && o.lat <= latLonBounds.top && o.lon >= latLonBounds.left
|
if (point != null && point.lat >= latLonBounds.bottom && point.lat <= latLonBounds.top
|
||||||
&& o.lon <= latLonBounds.right) {
|
&& point.lon >= latLonBounds.left && point.lon <= latLonBounds.right) {
|
||||||
int x = (int) tileBox.getPixXFromLatLon(o.lat, o.lon);
|
float x = tileBox.getPixXFromLatLon(point.lat, point.lon);
|
||||||
int y = (int) tileBox.getPixYFromLatLon(o.lat, o.lon);
|
float y = tileBox.getPixYFromLatLon(point.lat, point.lon);
|
||||||
if (px != -1 || py != -1) {
|
if (px != -1 || py != -1) {
|
||||||
if (Math.abs(x - px) <= dr && Math.abs(y - py) <= dr) {
|
if (Math.abs(x - px) <= dr && Math.abs(y - py) <= dr) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -389,25 +390,26 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
px = x;
|
px = x;
|
||||||
py = y;
|
py = y;
|
||||||
String nm = i.splitName;
|
String name = i.splitName;
|
||||||
if (nm != null) {
|
if (name != null) {
|
||||||
int ind = nm.indexOf(' ');
|
int ind = name.indexOf(' ');
|
||||||
if (ind > 0) {
|
if (ind > 0) {
|
||||||
nm = nm.substring(0, ind);
|
name = name.substring(0, ind);
|
||||||
}
|
}
|
||||||
Rect bounds = new Rect();
|
Rect bounds = new Rect();
|
||||||
paintTextIcon.getTextBounds(nm, 0, nm.length(), bounds);
|
paintTextIcon.getTextBounds(name, 0, name.length(), bounds);
|
||||||
int nmWidth = bounds.width();
|
|
||||||
int nmHeight = bounds.height();
|
float nameHalfWidth = bounds.width() / 2f;
|
||||||
RectF rect = new RectF(x - nmWidth / 2 - 2 * (float) Math.ceil(tileBox.getDensity()),
|
float nameHalfHeight = bounds.height() / 2f;
|
||||||
y + nmHeight / 2 + 3 * (float) Math.ceil(tileBox.getDensity()),
|
float density = (float) Math.ceil(tileBox.getDensity());
|
||||||
x + nmWidth / 2 + 3 * (float) Math.ceil(tileBox.getDensity()),
|
RectF rect = new RectF(x - nameHalfWidth - 2 * density,
|
||||||
y - nmHeight / 2 - 2 * (float) Math.ceil(tileBox.getDensity()));
|
y + nameHalfHeight + 3 * density,
|
||||||
|
x + nameHalfWidth + 3 * density,
|
||||||
|
y - nameHalfHeight - 2 * density);
|
||||||
|
|
||||||
canvas.drawRoundRect(rect, 0, 0, paintInnerRect);
|
canvas.drawRoundRect(rect, 0, 0, paintInnerRect);
|
||||||
canvas.drawRoundRect(rect, 0, 0, paintOuterRect);
|
canvas.drawRoundRect(rect, 0, 0, paintOuterRect);
|
||||||
// canvas.drawRect(rect, paintInnerRect);
|
canvas.drawText(name, x, y + nameHalfHeight, paintTextIcon);
|
||||||
// canvas.drawRect(rect, paintOuterRect);
|
|
||||||
canvas.drawText(nm, x, y + nmHeight / 2, paintTextIcon);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,25 +418,12 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
private void drawDirectionArrows(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
private void drawDirectionArrows(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
|
||||||
if (!tileBox.isZoomAnimated()) {
|
if (!tileBox.isZoomAnimated()) {
|
||||||
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
boolean showArrows = selectedGpxFile.getGpxFile().isShowArrows();
|
boolean showArrows = isShowArrowsForTrack(selectedGpxFile.getGpxFile());
|
||||||
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
|
||||||
showArrows = trackDrawInfo.isShowArrows();
|
|
||||||
}
|
|
||||||
if (showArrows) {
|
if (showArrows) {
|
||||||
QuadRect correctedQuadRect = getCorrectedQuadRect(tileBox.getLatLonBounds());
|
QuadRect correctedQuadRect = getCorrectedQuadRect(tileBox.getLatLonBounds());
|
||||||
String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get());
|
String width = getTrackWidthName(selectedGpxFile.getGpxFile(), "");
|
||||||
int color = selectedGpxFile.getGpxFile().getColor(cachedColor);
|
float trackWidth = getTrackWidth(width, defaultTrackWidth);
|
||||||
if (selectedGpxFile.isShowCurrentTrack()) {
|
int color = getTrackColor(selectedGpxFile.getGpxFile(), cachedColor);
|
||||||
color = currentTrackColor;
|
|
||||||
}
|
|
||||||
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
|
||||||
color = trackDrawInfo.getColor();
|
|
||||||
width = trackDrawInfo.getWidth();
|
|
||||||
}
|
|
||||||
Float trackWidth = cachedTrackWidth.get(width);
|
|
||||||
if (trackWidth == null) {
|
|
||||||
trackWidth = defaultTrackWidth;
|
|
||||||
}
|
|
||||||
int contrastColor = UiUtilities.getContrastColor(view.getApplication(), color, false);
|
int contrastColor = UiUtilities.getContrastColor(view.getApplication(), color, false);
|
||||||
GeometryWayStyle arrowsWayStyle = new GeometryArrowsWayStyle(wayContext, arrowBitmap, contrastColor, color, trackWidth);
|
GeometryWayStyle arrowsWayStyle = new GeometryArrowsWayStyle(wayContext, arrowBitmap, contrastColor, color, trackWidth);
|
||||||
for (TrkSegment segment : selectedGpxFile.getPointsToDisplay()) {
|
for (TrkSegment segment : selectedGpxFile.getPointsToDisplay()) {
|
||||||
|
@ -587,10 +576,7 @@ 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) {
|
||||||
boolean showStartFinish = selectedGpxFile.getGpxFile().isShowStartFinish();
|
boolean showStartFinish = isShowStartFinishForTrack(selectedGpxFile.getGpxFile());
|
||||||
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
|
||||||
showStartFinish = trackDrawInfo.isShowStartFinish();
|
|
||||||
}
|
|
||||||
if (showStartFinish) {
|
if (showStartFinish) {
|
||||||
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
||||||
for (TrkSegment segment : segments) {
|
for (TrkSegment segment : segments) {
|
||||||
|
@ -605,11 +591,6 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasTrackDrawInfoForSelectedGpx(SelectedGpxFile selectedGpxFile) {
|
|
||||||
return trackDrawInfo != null && (trackDrawInfo.isCurrentRecording() && selectedGpxFile.isShowCurrentTrack()
|
|
||||||
|| selectedGpxFile.getGpxFile().path.equals(trackDrawInfo.getFilePath()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawStartEndPoints(Canvas canvas, RotatedTileBox tileBox, WptPt start, WptPt end) {
|
private void drawStartEndPoints(Canvas canvas, RotatedTileBox tileBox, WptPt start, WptPt end) {
|
||||||
int startX = (int) tileBox.getPixXFromLatLon(start.lat, start.lon);
|
int startX = (int) tileBox.getPixXFromLatLon(start.lat, start.lon);
|
||||||
int startY = (int) tileBox.getPixYFromLatLon(start.lat, start.lon);
|
int startY = (int) tileBox.getPixYFromLatLon(start.lat, start.lon);
|
||||||
|
@ -717,13 +698,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) {
|
private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) {
|
||||||
int color = trackChartPoints.getSegmentColor();
|
int color = trackChartPoints.getSegmentColor();
|
||||||
if (color == 0) {
|
if (color == 0) {
|
||||||
color = trackChartPoints.getGpx().getColor(0);
|
color = getTrackColor(trackChartPoints.getGpx(), cachedColor);
|
||||||
if (trackChartPoints.getGpx().showCurrentTrack) {
|
|
||||||
color = currentTrackColor;
|
|
||||||
}
|
|
||||||
if (color == 0) {
|
|
||||||
color = cachedColor;
|
|
||||||
}
|
|
||||||
trackChartPoints.setSegmentColor(color);
|
trackChartPoints.setSegmentColor(color);
|
||||||
}
|
}
|
||||||
paintGridCircle.setColor(color);
|
paintGridCircle.setColor(color);
|
||||||
|
@ -782,21 +757,16 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
|
|
||||||
private void drawSelectedFilesSegments(Canvas canvas, RotatedTileBox tileBox,
|
private void drawSelectedFilesSegments(Canvas canvas, RotatedTileBox tileBox,
|
||||||
List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
|
List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
|
||||||
|
SelectedGpxFile currentTrack = null;
|
||||||
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
|
||||||
String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get());
|
String width = getTrackWidthName(selectedGpxFile.getGpxFile(), "");
|
||||||
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
|
|
||||||
width = trackDrawInfo.getWidth();
|
|
||||||
}
|
|
||||||
if (!cachedTrackWidth.containsKey(width)) {
|
if (!cachedTrackWidth.containsKey(width)) {
|
||||||
cachedTrackWidth.put(width, null);
|
cachedTrackWidth.put(width, null);
|
||||||
}
|
}
|
||||||
}
|
if (selectedGpxFile.isShowCurrentTrack()) {
|
||||||
SelectedGpxFile currentTrack = null;
|
currentTrack = selectedGpxFile;
|
||||||
for (SelectedGpxFile g : selectedGPXFiles) {
|
|
||||||
if (g.isShowCurrentTrack()) {
|
|
||||||
currentTrack = g;
|
|
||||||
} else {
|
} else {
|
||||||
drawSelectedFileSegments(g, false, canvas, tileBox, settings);
|
drawSelectedFileSegments(selectedGpxFile, false, canvas, tileBox, settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentTrack != null) {
|
if (currentTrack != null) {
|
||||||
|
@ -808,18 +778,8 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
RotatedTileBox tileBox, DrawSettings settings) {
|
RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
||||||
for (TrkSegment ts : segments) {
|
for (TrkSegment ts : segments) {
|
||||||
String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get());
|
String width = getTrackWidthName(selectedGpxFile.getGpxFile(), "");
|
||||||
int color = selectedGpxFile.getGpxFile().getColor(0);
|
int color = getTrackColor(selectedGpxFile.getGpxFile(), ts.getColor(cachedColor));
|
||||||
if (currentTrack) {
|
|
||||||
color = currentTrackColor;
|
|
||||||
}
|
|
||||||
if (color == 0) {
|
|
||||||
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);
|
||||||
|
@ -834,6 +794,60 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float getTrackWidth(String width, float defaultTrackWidth) {
|
||||||
|
Float trackWidth = cachedTrackWidth.get(width);
|
||||||
|
return trackWidth != null ? trackWidth : defaultTrackWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getTrackColor(GPXFile gpxFile, int defaultColor) {
|
||||||
|
int color;
|
||||||
|
if (hasTrackDrawInfoForTrack(gpxFile)) {
|
||||||
|
color = trackDrawInfo.getColor();
|
||||||
|
} else if (gpxFile.showCurrentTrack) {
|
||||||
|
color = currentTrackColorPref.get();
|
||||||
|
} else {
|
||||||
|
color = gpxFile.getColor(defaultColor);
|
||||||
|
}
|
||||||
|
return color != 0 ? color : defaultColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getTrackWidthName(GPXFile gpxFile, String defaultWidth) {
|
||||||
|
String width;
|
||||||
|
if (hasTrackDrawInfoForTrack(gpxFile)) {
|
||||||
|
width = trackDrawInfo.getWidth();
|
||||||
|
} else if (gpxFile.showCurrentTrack) {
|
||||||
|
width = currentTrackWidthPref.get();
|
||||||
|
} else {
|
||||||
|
width = gpxFile.getWidth(defaultWidth);
|
||||||
|
}
|
||||||
|
return width != null ? width : defaultWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isShowArrowsForTrack(GPXFile gpxFile) {
|
||||||
|
if (hasTrackDrawInfoForTrack(gpxFile)) {
|
||||||
|
return trackDrawInfo.isShowArrows();
|
||||||
|
} else if (gpxFile.showCurrentTrack) {
|
||||||
|
return currentTrackShowArrowsPref.get();
|
||||||
|
} else {
|
||||||
|
return gpxFile.isShowArrows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isShowStartFinishForTrack(GPXFile gpxFile) {
|
||||||
|
if (hasTrackDrawInfoForTrack(gpxFile)) {
|
||||||
|
return trackDrawInfo.isShowStartFinish();
|
||||||
|
} else if (gpxFile.showCurrentTrack) {
|
||||||
|
return currentTrackShowStartFinishPref.get();
|
||||||
|
} else {
|
||||||
|
return gpxFile.isShowStartFinish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasTrackDrawInfoForTrack(GPXFile gpxFile) {
|
||||||
|
return trackDrawInfo != null && (trackDrawInfo.isCurrentRecording() && gpxFile.showCurrentTrack
|
||||||
|
|| gpxFile.path.equals(trackDrawInfo.getFilePath()));
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isPointVisited(WptPt o) {
|
private boolean isPointVisited(WptPt o) {
|
||||||
boolean visit = false;
|
boolean visit = false;
|
||||||
String visited = o.getExtensionsToRead().get("VISITED_KEY");
|
String visited = o.getExtensionsToRead().get("VISITED_KEY");
|
||||||
|
|
Loading…
Reference in a new issue