Merge remote-tracking branch 'origin/r3.8'
This commit is contained in:
commit
5118ddebbe
9 changed files with 122 additions and 85 deletions
|
@ -22,7 +22,9 @@
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingLeft="@dimen/content_padding"
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingStart="@dimen/content_padding"
|
||||||
android:paddingRight="@dimen/content_padding"
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:paddingEnd="@dimen/content_padding"
|
||||||
android:paddingTop="@dimen/content_padding_small"
|
android:paddingTop="@dimen/content_padding_small"
|
||||||
android:paddingBottom="@dimen/content_padding_small"
|
android:paddingBottom="@dimen/content_padding_small"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
|
9
OsmAnd/res/menu/track_sort_menu_item.xml
Normal file
9
OsmAnd/res/menu/track_sort_menu_item.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_sort"
|
||||||
|
android:icon="@drawable/ic_action_time_start"
|
||||||
|
app:showAsAction="always"
|
||||||
|
android:title="@string/sort_last_modified" />
|
||||||
|
</menu>
|
|
@ -12,6 +12,8 @@ import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
|
|
||||||
import static net.osmand.plus.SimplePopUpMenuItemAdapter.SimplePopUpMenuItem;
|
import static net.osmand.plus.SimplePopUpMenuItemAdapter.SimplePopUpMenuItem;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -50,6 +52,10 @@ public class SimplePopUpMenuItemAdapter
|
||||||
} else {
|
} else {
|
||||||
ivIcon.setVisibility(View.GONE);
|
ivIcon.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
if (item.selected) {
|
||||||
|
convertView.setBackgroundColor(UiUtilities.getColorWithAlpha(
|
||||||
|
AndroidUtils.getColorFromAttr(getContext(), R.attr.active_color_basic), 0.1f));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
@ -64,6 +70,7 @@ public class SimplePopUpMenuItemAdapter
|
||||||
private CharSequence title;
|
private CharSequence title;
|
||||||
private Drawable icon;
|
private Drawable icon;
|
||||||
private View.OnClickListener onClickListener;
|
private View.OnClickListener onClickListener;
|
||||||
|
boolean selected;
|
||||||
|
|
||||||
public SimplePopUpMenuItem(CharSequence title, Drawable icon) {
|
public SimplePopUpMenuItem(CharSequence title, Drawable icon) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -75,6 +82,12 @@ public class SimplePopUpMenuItemAdapter
|
||||||
this.onClickListener = onClickListener;
|
this.onClickListener = onClickListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SimplePopUpMenuItem(CharSequence title, Drawable icon, View.OnClickListener onClickListener,
|
||||||
|
boolean selected) {
|
||||||
|
this(title, icon, onClickListener);
|
||||||
|
this.selected = selected;
|
||||||
|
}
|
||||||
|
|
||||||
public CharSequence getTitle() {
|
public CharSequence getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
|
@ -784,7 +784,7 @@ public class UiUtilities {
|
||||||
titles.add(String.valueOf(item.getTitle()));
|
titles.add(String.valueOf(item.getTitle()));
|
||||||
hasIcon = hasIcon || item.getIcon() != null;
|
hasIcon = hasIcon || item.getIcon() != null;
|
||||||
}
|
}
|
||||||
float itemWidth = AndroidUtils.getTextMaxWidth(defaultListTextSize, titles) + contentPadding;
|
float itemWidth = AndroidUtils.getTextMaxWidth(defaultListTextSize, titles) + contentPadding * 2;
|
||||||
float iconPartWidth = hasIcon ? standardIconSize + contentPaddingHalf : 0;
|
float iconPartWidth = hasIcon ? standardIconSize + contentPaddingHalf : 0;
|
||||||
int totalWidth = (int) (Math.max(itemWidth, minWidth) + iconPartWidth);
|
int totalWidth = (int) (Math.max(itemWidth, minWidth) + iconPartWidth);
|
||||||
|
|
||||||
|
@ -808,4 +808,19 @@ public class UiUtilities {
|
||||||
});
|
});
|
||||||
return listPopupWindow;
|
return listPopupWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showPopUpMenu(View v, final List<SimplePopUpMenuItemAdapter.SimplePopUpMenuItem> items) {
|
||||||
|
UiUtilities.createListPopupWindow(
|
||||||
|
v.getContext(), v, v.getWidth(), items, new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
if (position < items.size()) {
|
||||||
|
View.OnClickListener listener = items.get(position).getOnClickListener();
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onClick(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -3,8 +3,6 @@ package net.osmand.plus.measurementtool;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -19,6 +17,7 @@ import net.osmand.AndroidUtils;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.base.BottomSheetBehaviourDialogFragment;
|
import net.osmand.plus.base.BottomSheetBehaviourDialogFragment;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
import net.osmand.plus.helpers.GpxTrackAdapter;
|
import net.osmand.plus.helpers.GpxTrackAdapter;
|
||||||
|
@ -26,7 +25,6 @@ import net.osmand.plus.helpers.GpxTrackAdapter.OnItemClickListener;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
|
||||||
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
|
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
|
||||||
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener;
|
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener;
|
||||||
import net.osmand.plus.widgets.IconPopupMenu;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -36,6 +34,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static net.osmand.plus.SimplePopUpMenuItemAdapter.*;
|
||||||
import static net.osmand.plus.helpers.GpxUiHelper.getSortedGPXFilesInfo;
|
import static net.osmand.plus.helpers.GpxUiHelper.getSortedGPXFilesInfo;
|
||||||
import static net.osmand.plus.settings.backend.OsmandSettings.*;
|
import static net.osmand.plus.settings.backend.OsmandSettings.*;
|
||||||
import static net.osmand.util.Algorithms.collectDirs;
|
import static net.osmand.util.Algorithms.collectDirs;
|
||||||
|
@ -73,7 +72,7 @@ public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment {
|
||||||
private Mode fragmentMode;
|
private Mode fragmentMode;
|
||||||
private String selectedFolder;
|
private String selectedFolder;
|
||||||
private String allFilesFolder;
|
private String allFilesFolder;
|
||||||
TracksSortByMode tracksSortBy = TracksSortByMode.BY_DATE;
|
TracksSortByMode sortByMode = TracksSortByMode.BY_DATE;
|
||||||
|
|
||||||
public void setFragmentMode(Mode fragmentMode) {
|
public void setFragmentMode(Mode fragmentMode) {
|
||||||
this.fragmentMode = fragmentMode;
|
this.fragmentMode = fragmentMode;
|
||||||
|
@ -105,30 +104,29 @@ public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment {
|
||||||
? R.color.inactive_buttons_and_links_bg_dark
|
? R.color.inactive_buttons_and_links_bg_dark
|
||||||
: R.color.inactive_buttons_and_links_bg_light);
|
: R.color.inactive_buttons_and_links_bg_light);
|
||||||
AndroidUtils.setBackground(sortButton, background);
|
AndroidUtils.setBackground(sortButton, background);
|
||||||
sortButton.setImageResource(tracksSortBy.getIconId());
|
sortButton.setImageResource(sortByMode.getIconId());
|
||||||
sortButton.setVisibility(View.VISIBLE);
|
sortButton.setVisibility(View.VISIBLE);
|
||||||
sortButton.setOnClickListener(new View.OnClickListener() {
|
sortButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
IconPopupMenu popup = new IconPopupMenu(v.getContext(), v);
|
final List<SimplePopUpMenuItem> items = new ArrayList<>();
|
||||||
final Menu menu = popup.getMenu();
|
|
||||||
MenuItem mi;
|
|
||||||
for (final TracksSortByMode mode : TracksSortByMode.values()) {
|
for (final TracksSortByMode mode : TracksSortByMode.values()) {
|
||||||
mi = createMenuItem(app, menu, mode.getNameId(), mode.getNameId(), mode.getIconId(),
|
items.add(new SimplePopUpMenuItem(
|
||||||
MenuItem.SHOW_AS_ACTION_ALWAYS, false, R.color.icon_color_default_light);
|
getString(mode.getNameId()),
|
||||||
mi.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
app.getUIUtilities().getThemedIcon(mode.getIconId()),
|
||||||
|
new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public void onClick(View v) {
|
||||||
tracksSortBy = mode;
|
sortByMode = mode;
|
||||||
sortButton.setImageResource(mode.getIconId());
|
sortButton.setImageResource(mode.getIconId());
|
||||||
updateDescription(descriptionView);
|
updateDescription(descriptionView);
|
||||||
sortFileList();
|
sortFileList();
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
}, sortByMode == mode
|
||||||
|
));
|
||||||
}
|
}
|
||||||
popup.show();
|
UiUtilities.showPopUpMenu(v, items);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -202,25 +200,12 @@ public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDescription(TextView descriptionView) {
|
private void updateDescription(TextView descriptionView) {
|
||||||
String string = getString(tracksSortBy.getNameId());
|
String string = getString(sortByMode.getNameId());
|
||||||
descriptionView.setText(String.format(getString(R.string.ltr_or_rtl_combine_via_space),
|
descriptionView.setText(String.format(getString(R.string.ltr_or_rtl_combine_via_space),
|
||||||
getString(fragmentMode.description),
|
getString(fragmentMode.description),
|
||||||
Character.toLowerCase(string.charAt(0)) + string.substring(1)));
|
Character.toLowerCase(string.charAt(0)) + string.substring(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public MenuItem createMenuItem(OsmandApplication app, Menu m, int id, int titleRes, int iconId, int menuItemType,
|
|
||||||
boolean flipIconForRtl, int iconColor) {
|
|
||||||
Drawable d = iconId == 0 ? null : app.getUIUtilities().getIcon(iconId, iconColor);
|
|
||||||
MenuItem menuItem = m.add(0, id, 0, titleRes);
|
|
||||||
if (d != null) {
|
|
||||||
if (flipIconForRtl) {
|
|
||||||
d = AndroidUtils.getDrawableForDirection(app, d);
|
|
||||||
}
|
|
||||||
menuItem.setIcon(d);
|
|
||||||
}
|
|
||||||
return menuItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateFileList(HorizontalSelectionAdapter folderAdapter) {
|
private void updateFileList(HorizontalSelectionAdapter folderAdapter) {
|
||||||
sortFileList();
|
sortFileList();
|
||||||
adapter.setShowFolderName(showFoldersName());
|
adapter.setShowFolderName(showFoldersName());
|
||||||
|
@ -238,9 +223,9 @@ public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment {
|
||||||
Collections.sort(gpxInfoList, new Comparator<GPXInfo>() {
|
Collections.sort(gpxInfoList, new Comparator<GPXInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(GPXInfo i1, GPXInfo i2) {
|
public int compare(GPXInfo i1, GPXInfo i2) {
|
||||||
if (tracksSortBy == TracksSortByMode.BY_NAME_ASCENDING) {
|
if (sortByMode == TracksSortByMode.BY_NAME_ASCENDING) {
|
||||||
return i1.getFileName().toLowerCase().compareTo(i2.getFileName().toLowerCase());
|
return i1.getFileName().toLowerCase().compareTo(i2.getFileName().toLowerCase());
|
||||||
} else if (tracksSortBy == TracksSortByMode.BY_NAME_DESCENDING) {
|
} else if (sortByMode == TracksSortByMode.BY_NAME_DESCENDING) {
|
||||||
return -i1.getFileName().toLowerCase().compareTo(i2.getFileName().toLowerCase());
|
return -i1.getFileName().toLowerCase().compareTo(i2.getFileName().toLowerCase());
|
||||||
} else {
|
} else {
|
||||||
long time1 = i1.getLastModified();
|
long time1 = i1.getLastModified();
|
||||||
|
|
|
@ -19,7 +19,6 @@ import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.SubMenu;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
@ -70,7 +69,7 @@ import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.SimplePopUpMenuItemAdapter;
|
import net.osmand.plus.SimplePopUpMenuItemAdapter.SimplePopUpMenuItem;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
||||||
|
@ -475,25 +474,12 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
menu.addSubMenu(Menu.NONE, R.string.shared_string_sort, Menu.NONE, R.string.shared_string_sort);
|
inflater.inflate(R.menu.track_sort_menu_item, menu);
|
||||||
final SubMenu sortMenu = menu.findItem(R.string.shared_string_sort).getSubMenu();
|
mi = menu.findItem(R.id.action_sort);
|
||||||
mi = sortMenu.getItem();
|
|
||||||
mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||||
final int iconColorId = isLightActionBar() ? R.color.active_buttons_and_links_text_light
|
int iconColorId = isLightActionBar() ? R.color.active_buttons_and_links_text_light
|
||||||
: R.color.active_buttons_and_links_text_dark;
|
: R.color.active_buttons_and_links_text_dark;
|
||||||
mi.setIcon(getIcon(sortByMode.getIconId(), iconColorId));
|
mi.setIcon(getIcon(sortByMode.getIconId(), iconColorId));
|
||||||
for (final TracksSortByMode mode : TracksSortByMode.values()) {
|
|
||||||
mi = createMenuItem(sortMenu, mode.getNameId(), mode.getNameId(), mode.getIconId(),
|
|
||||||
MenuItem.SHOW_AS_ACTION_ALWAYS, false, R.color.icon_color_default_light);
|
|
||||||
mi.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
|
||||||
updateTracksSort(mode);
|
|
||||||
sortMenu.setIcon(getIcon(mode.getIconId(), iconColorId));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
|
if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
|
||||||
menu = ((FavoritesActivity) getActivity()).getClearToolbar(true).getMenu();
|
menu = ((FavoritesActivity) getActivity()).getClearToolbar(true).getMenu();
|
||||||
|
@ -578,7 +564,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
for (int i = 0; i < optionsMenuAdapter.length(); i++) {
|
for (int i = 0; i < optionsMenuAdapter.length(); i++) {
|
||||||
ContextMenuItem contextMenuItem = optionsMenuAdapter.getItem(i);
|
ContextMenuItem contextMenuItem = optionsMenuAdapter.getItem(i);
|
||||||
|
@ -587,6 +573,29 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (itemId == R.id.action_sort) {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
View menuSortItemView = getActivity().findViewById(R.id.action_sort);
|
||||||
|
final List<SimplePopUpMenuItem> items = new ArrayList<>();
|
||||||
|
for (final TracksSortByMode mode : TracksSortByMode.values()) {
|
||||||
|
items.add(new SimplePopUpMenuItem(
|
||||||
|
getString(mode.getNameId()),
|
||||||
|
app.getUIUtilities().getThemedIcon(mode.getIconId()),
|
||||||
|
new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
updateTracksSort(mode);
|
||||||
|
int iconColorId = isLightActionBar() ? R.color.active_buttons_and_links_text_light
|
||||||
|
: R.color.active_buttons_and_links_text_dark;
|
||||||
|
item.setIcon(getIcon(mode.getIconId(), iconColorId));
|
||||||
|
}
|
||||||
|
}, sortByMode == mode
|
||||||
|
));
|
||||||
|
}
|
||||||
|
UiUtilities.showPopUpMenu(menuSortItemView, items);
|
||||||
|
}
|
||||||
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1492,10 +1501,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openPopUpMenu(View v, final GpxInfo gpxInfo) {
|
private void openPopUpMenu(View v, final GpxInfo gpxInfo) {
|
||||||
final List<SimplePopUpMenuItemAdapter.SimplePopUpMenuItem> items = new ArrayList<>();
|
final List<SimplePopUpMenuItem> items = new ArrayList<>();
|
||||||
UiUtilities iconsCache = getMyApplication().getUIUtilities();
|
UiUtilities iconsCache = getMyApplication().getUIUtilities();
|
||||||
|
|
||||||
items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem(
|
items.add(new SimplePopUpMenuItem(
|
||||||
getString(R.string.shared_string_show_on_map),
|
getString(R.string.shared_string_show_on_map),
|
||||||
iconsCache.getThemedIcon(R.drawable.ic_show_on_map),
|
iconsCache.getThemedIcon(R.drawable.ic_show_on_map),
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
|
@ -1509,7 +1518,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
||||||
GPXTrackAnalysis analysis;
|
GPXTrackAnalysis analysis;
|
||||||
if ((analysis = getGpxTrackAnalysis(gpxInfo, app, null)) != null) {
|
if ((analysis = getGpxTrackAnalysis(gpxInfo, app, null)) != null) {
|
||||||
if (analysis.totalDistance != 0 && !gpxInfo.currentlyRecordingTrack) {
|
if (analysis.totalDistance != 0 && !gpxInfo.currentlyRecordingTrack) {
|
||||||
items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem(
|
items.add(new SimplePopUpMenuItem(
|
||||||
getString(R.string.analyze_on_map),
|
getString(R.string.analyze_on_map),
|
||||||
iconsCache.getThemedIcon(R.drawable.ic_action_info_dark),
|
iconsCache.getThemedIcon(R.drawable.ic_action_info_dark),
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
|
@ -1522,7 +1531,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem(
|
items.add(new SimplePopUpMenuItem(
|
||||||
getString(R.string.shared_string_move),
|
getString(R.string.shared_string_move),
|
||||||
iconsCache.getThemedIcon(R.drawable.ic_action_folder_stroke),
|
iconsCache.getThemedIcon(R.drawable.ic_action_folder_stroke),
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
|
@ -1533,7 +1542,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem(
|
items.add(new SimplePopUpMenuItem(
|
||||||
getString(R.string.shared_string_rename),
|
getString(R.string.shared_string_rename),
|
||||||
iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark),
|
iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark),
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
|
@ -1551,7 +1560,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
||||||
));
|
));
|
||||||
|
|
||||||
Drawable shareIcon = iconsCache.getThemedIcon((R.drawable.ic_action_gshare_dark));
|
Drawable shareIcon = iconsCache.getThemedIcon((R.drawable.ic_action_gshare_dark));
|
||||||
items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem(
|
items.add(new SimplePopUpMenuItem(
|
||||||
getString(R.string.shared_string_share),
|
getString(R.string.shared_string_share),
|
||||||
AndroidUtils.getDrawableForDirection(app, shareIcon),
|
AndroidUtils.getDrawableForDirection(app, shareIcon),
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
|
@ -1569,7 +1578,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
||||||
|
|
||||||
final OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
|
final OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
|
||||||
if (osmEditingPlugin != null && osmEditingPlugin.isActive()) {
|
if (osmEditingPlugin != null && osmEditingPlugin.isActive()) {
|
||||||
items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem(
|
items.add(new SimplePopUpMenuItem(
|
||||||
getString(R.string.shared_string_export),
|
getString(R.string.shared_string_export),
|
||||||
iconsCache.getThemedIcon(R.drawable.ic_action_export),
|
iconsCache.getThemedIcon(R.drawable.ic_action_export),
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
|
@ -1581,7 +1590,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
items.add(new SimplePopUpMenuItemAdapter.SimplePopUpMenuItem(
|
items.add(new SimplePopUpMenuItem(
|
||||||
getString(R.string.shared_string_delete),
|
getString(R.string.shared_string_delete),
|
||||||
iconsCache.getThemedIcon(R.drawable.ic_action_delete_dark),
|
iconsCache.getThemedIcon(R.drawable.ic_action_delete_dark),
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class GpxGeometryWay extends GeometryWay<GpxGeometryWayContext, GeometryW
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getPointStepPx(double zoomCoef) {
|
public double getPointStepPx(double zoomCoef) {
|
||||||
return getPointBitmap().getHeight() * DIRECTION_ARROW_DISTANCE_MULTIPLIER * zoomCoef;
|
return getPointBitmap().getHeight() + trackWidth * 1.5f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,6 +15,6 @@ public class GpxGeometryWayContext extends GeometryWayContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getArrowBitmapResId() {
|
protected int getArrowBitmapResId() {
|
||||||
return R.drawable.mm_special_arrow_up;
|
return R.drawable.ic_action_direction_arrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
package net.osmand.plus.views.layers.geometry;
|
package net.osmand.plus.views.layers.geometry;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.PorterDuffColorFilter;
|
||||||
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
|
||||||
import net.osmand.plus.views.layers.geometry.GeometryWayDrawer.PathPoint;
|
|
||||||
import net.osmand.plus.views.layers.geometry.GpxGeometryWay.GeometryArrowsStyle;
|
import net.osmand.plus.views.layers.geometry.GpxGeometryWay.GeometryArrowsStyle;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GpxGeometryWayDrawer extends GeometryWayDrawer<GpxGeometryWayContext> {
|
public class GpxGeometryWayDrawer extends GeometryWayDrawer<GpxGeometryWayContext> {
|
||||||
|
|
||||||
private static final float DIRECTION_ARROW_CIRCLE_MULTIPLIER = 1.5f;
|
|
||||||
|
|
||||||
public GpxGeometryWayDrawer(GpxGeometryWayContext context) {
|
public GpxGeometryWayDrawer(GpxGeometryWayContext context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
@ -33,16 +30,23 @@ public class GpxGeometryWayDrawer extends GeometryWayDrawer<GpxGeometryWayContex
|
||||||
void draw(Canvas canvas, GeometryWayContext context) {
|
void draw(Canvas canvas, GeometryWayContext context) {
|
||||||
if (style instanceof GeometryArrowsStyle) {
|
if (style instanceof GeometryArrowsStyle) {
|
||||||
GeometryArrowsStyle arrowsWayStyle = (GeometryArrowsStyle) style;
|
GeometryArrowsStyle arrowsWayStyle = (GeometryArrowsStyle) style;
|
||||||
|
Bitmap bitmap = style.getPointBitmap();
|
||||||
|
|
||||||
float arrowWidth = style.getPointBitmap().getWidth();
|
float newWidth = arrowsWayStyle.getTrackWidth() / 2f;
|
||||||
if (arrowWidth > arrowsWayStyle.getTrackWidth()) {
|
float paintH2 = bitmap.getHeight() / 2f;
|
||||||
Paint paint = context.getPaintIcon();
|
float paintW2 = newWidth / 2f;
|
||||||
paint.setColor(arrowsWayStyle.getTrackColor());
|
|
||||||
paint.setStrokeWidth(arrowWidth * DIRECTION_ARROW_CIRCLE_MULTIPLIER);
|
Matrix matrix = getMatrix();
|
||||||
canvas.drawPoint(x, y, paint);
|
matrix.reset();
|
||||||
|
matrix.postScale(newWidth / bitmap.getWidth(), 1);
|
||||||
|
matrix.postRotate((float) angle, paintW2, paintH2);
|
||||||
|
matrix.postTranslate(x - paintW2, y - paintH2);
|
||||||
|
|
||||||
|
Paint paint = context.getPaintIconCustom();
|
||||||
|
Integer pointColor = style.getPointColor();
|
||||||
|
paint.setColorFilter(new PorterDuffColorFilter(pointColor, PorterDuff.Mode.SRC_IN));
|
||||||
|
canvas.drawBitmap(bitmap, matrix, paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.draw(canvas, context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue