From 355dd82908b4cc517ffefe8dacf5a199509e433b Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Mon, 5 Mar 2018 17:36:30 +0200 Subject: [PATCH 01/29] Make the multi-selection menu scrollable --- .../menu_obj_selection_fragment.xml | 2 +- .../layout/menu_obj_selection_fragment.xml | 5 +- .../other/MapMultiSelectionMenuFragment.java | 152 ++++++++++++------ .../other/MultiSelectionArrayAdapter.java | 4 + 4 files changed, 113 insertions(+), 50 deletions(-) diff --git a/OsmAnd/res/layout-land/menu_obj_selection_fragment.xml b/OsmAnd/res/layout-land/menu_obj_selection_fragment.xml index 5102244cbd..0b54849f1c 100644 --- a/OsmAnd/res/layout-land/menu_obj_selection_fragment.xml +++ b/OsmAnd/res/layout-land/menu_obj_selection_fragment.xml @@ -15,7 +15,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + android:foreground="?attr/selectableItemBackground"> = 21) { AndroidUtils.addStatusBarPadding21v(getActivity(), listView); } - View headerView = inflater.inflate(R.layout.menu_obj_selection_header, listView, false); - headerView.setOnClickListener(null); - listView.addHeaderView(headerView); listAdapter = createAdapter(); listAdapter.setListener(this); listView.setAdapter(listAdapter); - runLayoutListener(); + if (!menu.isLandscapeLayout()) { + final Context context = getContext(); + + FrameLayout paddingView = new FrameLayout(context); + paddingView.setLayoutParams(new AbsListView.LayoutParams( + AbsListView.LayoutParams.MATCH_PARENT, getPaddingViewHeight()) + ); + paddingView.setClickable(true); + paddingView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dismissMenu(); + } + }); + + FrameLayout shadowContainer = new FrameLayout(context); + shadowContainer.setLayoutParams(new FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT, Gravity.BOTTOM + )); + + ImageView shadow = new ImageView(context); + shadow.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.bg_shadow_onmap)); + shadow.setLayoutParams(new FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM + )); + shadow.setScaleType(ImageView.ScaleType.FIT_XY); + + shadowContainer.addView(shadow); + paddingView.addView(shadowContainer); + listView.addHeaderView(paddingView); + + view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + float titleHeight = getResources().getDimension(R.dimen.multi_selection_header_height); + int maxHeight = (int) (titleHeight); + for (int i = 0; i < 3 && i < listAdapter.getCount(); i++) { + View childView = listAdapter.getView(0, null, (ListView) view.findViewById(R.id.list)); + childView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), + View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); + maxHeight += childView.getMeasuredHeight(); + } + + listView.setSelectionFromTop(0, -maxHeight); + + ViewTreeObserver obs = view.getViewTreeObserver(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + obs.removeOnGlobalLayoutListener(this); + } else { + obs.removeGlobalOnLayoutListener(this); + } + } + }); + + ((ObservableListView) listView).setScrollViewCallbacks(new ObservableScrollViewCallbacks() { + + boolean initialScroll = true; + + @Override + public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { + if (scrollY <= 0) { + if (initialScroll) { + initialScroll = false; + } else { + dismissMenu(); + } + } + } + + @Override + public void onDownMotionEvent() { + + } + + @Override + public void onUpOrCancelMotionEvent(ScrollState scrollState) { + + } + }); + } + + View headerView = inflater.inflate(R.layout.menu_obj_selection_header, listView, false); + if (!menu.isLandscapeLayout()) { + AndroidUtils.setBackground(getContext(), headerView, !menu.isLight(), R.color.ctx_menu_bg_light, R.color.ctx_menu_bg_dark); + } + headerView.setOnClickListener(null); + listView.addHeaderView(headerView); view.findViewById(R.id.divider).setBackgroundColor(ContextCompat.getColor(getContext(), menu.isLight() ? R.color.multi_selection_menu_divider_light : R.color.multi_selection_menu_divider_dark)); @@ -111,6 +204,12 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele menu.getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(true); } + private int getPaddingViewHeight() { + Activity activity = getActivity(); + return AndroidUtils.getScreenHeight(activity) + - activity.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); + } + public static void showInstance(final MapActivity mapActivity) { if (mapActivity.isActivityDestroyed()) { @@ -137,45 +236,6 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele .addToBackStack(TAG).commitAllowingStateLoss(); } - private void runLayoutListener() { - ViewTreeObserver vto = view.getViewTreeObserver(); - vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - - @Override - public void onGlobalLayout() { - - if (!menu.isLandscapeLayout() && listAdapter.getCount() > 3) { - View contentView = view.findViewById(R.id.content); - float headerHeight = contentView.getResources().getDimension(R.dimen.multi_selection_header_height); - float cancelRowHeight = contentView.getResources().getDimension(R.dimen.bottom_sheet_cancel_button_height); - int maxHeight = (int) (headerHeight + cancelRowHeight); - for (int i = 0; i < 3; i++) { - View childView = listAdapter.getView(0, null, (ListView) contentView.findViewById(R.id.list)); - childView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), - View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); - maxHeight += childView.getMeasuredHeight(); - } - int height = contentView.getHeight(); - - if (height > maxHeight) { - ViewGroup.LayoutParams lp = contentView.getLayoutParams(); - lp.height = maxHeight; - contentView.setLayoutParams(lp); - contentView.requestLayout(); - } - } - - ViewTreeObserver obs = view.getViewTreeObserver(); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - obs.removeOnGlobalLayoutListener(this); - } else { - obs.removeGlobalOnLayoutListener(this); - } - } - }); - } - private MultiSelectionArrayAdapter createAdapter() { final List items = new LinkedList<>(menu.getObjects()); return new MultiSelectionArrayAdapter(menu, R.layout.menu_obj_list_item, items); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java index c98342c0e2..d714caf0e2 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MultiSelectionArrayAdapter.java @@ -38,6 +38,10 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter Date: Mon, 5 Mar 2018 18:17:04 +0200 Subject: [PATCH 02/29] Increase the height for hiding the multi-selection menu --- .../mapcontextmenu/other/MapMultiSelectionMenuFragment.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java index 8a56d19393..b0b35d545f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java @@ -120,10 +120,12 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele ((ObservableListView) listView).setScrollViewCallbacks(new ObservableScrollViewCallbacks() { boolean initialScroll = true; + int minHeight = getResources().getDimensionPixelSize(R.dimen.multi_selection_header_height) + + getResources().getDimensionPixelSize(R.dimen.list_item_height); @Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { - if (scrollY <= 0) { + if (scrollY <= minHeight) { if (initialScroll) { initialScroll = false; } else { From 98077a92ed5520362c5283b46a83b602ed8345e8 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 6 Mar 2018 10:28:51 +0200 Subject: [PATCH 03/29] Set initialScroll = false in onDownMotionEvent() --- .../other/MapMultiSelectionMenuFragment.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java index b0b35d545f..44546d08a4 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java @@ -125,18 +125,14 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele @Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { - if (scrollY <= minHeight) { - if (initialScroll) { - initialScroll = false; - } else { - dismissMenu(); - } + if (scrollY <= minHeight && !initialScroll) { + dismissMenu(); } } @Override public void onDownMotionEvent() { - + initialScroll = false; } @Override From 9fe01ced66f5fa7d8785f285ec7b1a4082b3b3b6 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 11:11:51 +0200 Subject: [PATCH 04/29] added new ButtomSheet to editFavouriteGroup --- OsmAnd/res/layout/change_fav_color.xml | 37 +++ .../EditFavoriteGroupDialogFragment.java | 279 +++++++++--------- 2 files changed, 183 insertions(+), 133 deletions(-) create mode 100644 OsmAnd/res/layout/change_fav_color.xml diff --git a/OsmAnd/res/layout/change_fav_color.xml b/OsmAnd/res/layout/change_fav_color.xml new file mode 100644 index 0000000000..99abc2ab3f --- /dev/null +++ b/OsmAnd/res/layout/change_fav_color.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index d543ce8405..1a6f776953 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -9,7 +9,7 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v7.app.AlertDialog; import android.support.v7.widget.ListPopupWindow; -import android.support.v7.widget.SwitchCompat; +import android.view.ContextThemeWrapper; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -30,11 +30,16 @@ import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.base.BottomSheetDialogFragment; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.helpers.ColorDialogs; import net.osmand.util.Algorithms; -public class EditFavoriteGroupDialogFragment extends BottomSheetDialogFragment { +public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragment { public static final String TAG = "EditFavoriteGroupDialogFragment"; private static final String GROUP_NAME_KEY = "group_name_key"; @@ -56,7 +61,7 @@ public class EditFavoriteGroupDialogFragment extends BottomSheetDialogFragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public void createMenuItems(Bundle savedInstanceState) { final Activity activity = getActivity(); app = (OsmandApplication) activity.getApplicationContext(); @@ -75,159 +80,167 @@ public class EditFavoriteGroupDialogFragment extends BottomSheetDialogFragment { group = helper.getGroup(groupName); } } - - final View view = inflater.inflate(R.layout.edit_fav_fragment, container, - false); - if (group == null) { - return view; - } - + items.add(new TitleItem(Algorithms.isEmpty(group.name) ? app.getString(R.string.shared_string_favorites) : group.name)); IconsCache ic = app.getIconsCache(); - final TextView title = (TextView) view.findViewById(R.id.title); - title.setText(Algorithms.isEmpty(group.name) ? app.getString(R.string.shared_string_favorites) : group.name); - View editNameView = view.findViewById(R.id.edit_name_view); - ((ImageView) view.findViewById(R.id.edit_name_icon)) - .setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_edit_dark)); - editNameView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - AlertDialog.Builder b = new AlertDialog.Builder(activity); - b.setTitle(R.string.favorite_group_name); - final EditText nameEditText = new EditText(activity); - nameEditText.setText(group.name); - int leftPadding = AndroidUtils.dpToPx(activity, 24f); - int topPadding = AndroidUtils.dpToPx(activity, 4f); - b.setView(nameEditText, leftPadding, topPadding, leftPadding, topPadding); - b.setNegativeButton(R.string.shared_string_cancel, null); - b.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() { + BaseBottomSheetItem byTypeItem = new SimpleBottomSheetItem.Builder() + .setIcon(ic.getThemedIcon(R.drawable.ic_action_edit_dark)) + .setTitle(getString(R.string.edit_name)) + .setLayoutId(R.layout.bottom_sheet_item_simple) + .setOnClickListener(new View.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int which) { - String name = nameEditText.getText().toString(); - boolean nameChanged = !Algorithms.objectEquals(group.name, name); - if (nameChanged) { - getMyApplication().getFavorites() - .editFavouriteGroup(group, name, group.color, group.visible); - updateParentFragment(); - } - dismiss(); + public void onClick(View v) { + AlertDialog.Builder b = new AlertDialog.Builder(getContext()); + b.setTitle(R.string.favorite_group_name); + final EditText nameEditText = new EditText(getContext()); + nameEditText.setText(group.name); + int leftPadding = AndroidUtils.dpToPx(getContext(), 24f); + int topPadding = AndroidUtils.dpToPx(getContext(), 4f); + b.setView(nameEditText, leftPadding, topPadding, leftPadding, topPadding); + b.setNegativeButton(R.string.shared_string_cancel, null); + b.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + String name = nameEditText.getText().toString(); + boolean nameChanged = !Algorithms.objectEquals(group.name, name); + if (nameChanged) { + getMyApplication().getFavorites() + .editFavouriteGroup(group, name, group.color, group.visible); + updateParentFragment(); + } + dismiss(); + } + }); + b.show(); } - }); - b.show(); - } - }); + }) + .create(); + items.add(byTypeItem); - final View changeColorView = view.findViewById(R.id.change_color_view); - ((ImageView) view.findViewById(R.id.change_color_icon)) + final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + + final View changeColorView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), + R.layout.change_fav_color, null); + ((ImageView) changeColorView.findViewById(R.id.change_color_icon)) .setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_appearance)); updateColorView(changeColorView); - changeColorView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final ListPopupWindow popup = new ListPopupWindow(getActivity()); - popup.setAnchorView(changeColorView); - popup.setContentWidth(AndroidUtils.dpToPx(app, 200f)); - popup.setModal(true); - popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP); - popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f)); - popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f)); - final FavoriteColorAdapter colorAdapter = new FavoriteColorAdapter(getActivity()); - popup.setAdapter(colorAdapter); - popup.setOnItemClickListener(new AdapterView.OnItemClickListener() { + BaseBottomSheetItem changeColorItem = new BaseBottomSheetItem.Builder().setCustomView(changeColorView) + .setOnClickListener(new View.OnClickListener() { @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - Integer color = colorAdapter.getItem(position); - if (color != null) { - if (color != group.color) { - getMyApplication().getFavorites() - .editFavouriteGroup(group, group.name, color, group.visible); - updateParentFragment(); - } - } - popup.dismiss(); - dismiss(); - } - }); - popup.show(); - } - }); + public void onClick(View v) { + final ListPopupWindow popup = new ListPopupWindow(getActivity()); + popup.setAnchorView(changeColorView); + popup.setContentWidth(AndroidUtils.dpToPx(app, 200f)); + popup.setModal(true); + popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP); + popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f)); + popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f)); + final FavoriteColorAdapter colorAdapter = new FavoriteColorAdapter(getActivity()); + popup.setAdapter(colorAdapter); + popup.setOnItemClickListener(new AdapterView.OnItemClickListener() { + + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + Integer color = colorAdapter.getItem(position); + if (color != null) { + if (color != group.color) { + getMyApplication().getFavorites() + .editFavouriteGroup(group, group.name, color, group.visible); + updateParentFragment(); + } + } + popup.dismiss(); + dismiss(); + } + }); + popup.show(); + } + }).create(); + items.add(changeColorItem); + + BaseBottomSheetItem showOnMapItem = new BottomSheetItemWithCompoundButton.Builder() + .setChecked(group.visible) + .setIcon(ic.getThemedIcon(R.drawable.ic_map)) + .setTitle(getString(R.string.shared_string_show_on_map)) + .setLayoutId(R.layout.bottom_sheet_item_with_switch) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean visible = !group.visible; +// showOnMapItem.setChecked(visible); + getMyApplication().getFavorites() + .editFavouriteGroup(group, group.name, group.color, visible); + updateParentFragment(); + } + }) + .create(); + items.add(showOnMapItem); + + if (group.points.size() > 0) { + items.add(new DividerItem(getContext())); + } - View showOnMapView = view.findViewById(R.id.show_on_map_view); - ((ImageView) view.findViewById(R.id.show_on_map_icon)) - .setImageDrawable(ic.getThemedIcon(R.drawable.ic_map)); - final SwitchCompat checkbox = (SwitchCompat) view.findViewById(R.id.show_on_map_switch); - checkbox.setChecked(group.visible); - showOnMapView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - boolean visible = !group.visible; - checkbox.setChecked(visible); - getMyApplication().getFavorites() - .editFavouriteGroup(group, group.name, group.color, visible); - updateParentFragment(); - } - }); final MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper(); final MarkersSyncGroup syncGroup = new MarkersSyncGroup(group.name, group.name, MarkersSyncGroup.FAVORITES_TYPE, group.color); boolean groupSyncedWithMarkers = markersHelper.isGroupSynced(syncGroup.getId()); - View addToMarkersView = view.findViewById(R.id.add_to_markers_view); if (app.getSettings().USE_MAP_MARKERS.get() && group.points.size() > 0 && !groupSyncedWithMarkers) { - ((ImageView) view.findViewById(R.id.add_to_markers_icon)) - .setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_flag_dark)); - addToMarkersView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - markersHelper.addMarkersSyncGroup(syncGroup); - markersHelper.syncGroupAsync(syncGroup); - dismiss(); - MapActivity.launchMapActivityMoveToTop(getActivity()); - } - }); - } else { - addToMarkersView.setVisibility(View.GONE); + BaseBottomSheetItem addToMarkersItem = new SimpleBottomSheetItem.Builder() + .setIcon(ic.getThemedIcon(R.drawable.ic_action_flag_dark)) + .setTitle(getString(R.string.shared_string_add_to_map_markers)) + .setLayoutId(R.layout.bottom_sheet_item_simple) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + markersHelper.addMarkersSyncGroup(syncGroup); + markersHelper.syncGroupAsync(syncGroup); + dismiss(); + MapActivity.launchMapActivityMoveToTop(getActivity()); + } + }) + .create(); + items.add(addToMarkersItem); } - View removeFromMarkersView = view.findViewById(R.id.remove_from_markers_view); + if (app.getSettings().USE_MAP_MARKERS.get() && groupSyncedWithMarkers) { - removeFromMarkersView.setVisibility(View.VISIBLE); - ((ImageView) view.findViewById(R.id.remove_from_markers_icon)) - .setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_delete_dark)); - removeFromMarkersView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - markersHelper.removeMarkersSyncGroup(syncGroup.getId(), true); - dismiss(); - MapActivity.launchMapActivityMoveToTop(getActivity()); - } - }); + BaseBottomSheetItem removeFromMarkersItem = new SimpleBottomSheetItem.Builder() + .setIcon(ic.getThemedIcon(R.drawable.ic_action_delete_dark)) + .setTitle(getString(R.string.remove_from_map_markers)) + .setLayoutId(R.layout.bottom_sheet_item_simple) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + markersHelper.removeMarkersSyncGroup(syncGroup.getId(), true); + dismiss(); + MapActivity.launchMapActivityMoveToTop(getActivity()); + } + }) + .create(); + items.add(removeFromMarkersItem); } - - View shareView = view.findViewById(R.id.share_view); if (group.points.size() > 0) { - ((ImageView) view.findViewById(R.id.share_icon)) - .setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_gshare_dark)); - shareView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - FavoritesTreeFragment fragment = getFavoritesTreeFragment(); - if (fragment != null) { - fragment.shareFavorites(group); - } - dismiss(); - } - }); - } else { - shareView.setVisibility(View.GONE); - } - if (group.points.size() == 0) { - view.findViewById(R.id.divider).setVisibility(View.GONE); + BaseBottomSheetItem shareItem = new SimpleBottomSheetItem.Builder() + .setIcon(ic.getThemedIcon(R.drawable.ic_action_gshare_dark)) + .setTitle(getString(R.string.shared_string_share)) + .setLayoutId(R.layout.bottom_sheet_item_simple) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + FavoritesTreeFragment fragment = getFavoritesTreeFragment(); + if (fragment != null) { + fragment.shareFavorites(group); + } + dismiss(); + } + }) + .create(); + items.add(shareItem); } - return view; } @Override From 7200af0c00eb798036a817a16e3b7f7d1e6f1808 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 11:21:25 +0200 Subject: [PATCH 05/29] deleted unnecessary xml file --- OsmAnd/res/layout/edit_fav_fragment.xml | 249 ------------------------ 1 file changed, 249 deletions(-) delete mode 100644 OsmAnd/res/layout/edit_fav_fragment.xml diff --git a/OsmAnd/res/layout/edit_fav_fragment.xml b/OsmAnd/res/layout/edit_fav_fragment.xml deleted file mode 100644 index b8e46dbfa6..0000000000 --- a/OsmAnd/res/layout/edit_fav_fragment.xml +++ /dev/null @@ -1,249 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From b11af88b997bde66b52caf33cc32392faacd783b Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 11:25:37 +0200 Subject: [PATCH 06/29] refactored some code --- OsmAnd/res/layout/change_fav_color.xml | 2 -- .../osmand/plus/activities/EditFavoriteGroupDialogFragment.java | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/change_fav_color.xml b/OsmAnd/res/layout/change_fav_color.xml index 99abc2ab3f..3e08ea7ed6 100644 --- a/OsmAnd/res/layout/change_fav_color.xml +++ b/OsmAnd/res/layout/change_fav_color.xml @@ -32,6 +32,4 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_action_circle" /> - - \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index 1a6f776953..340ca08f33 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -118,7 +118,6 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme items.add(byTypeItem); final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; - final View changeColorView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.change_fav_color, null); ((ImageView) changeColorView.findViewById(R.id.change_color_icon)) @@ -172,6 +171,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme getMyApplication().getFavorites() .editFavouriteGroup(group, group.name, group.color, visible); updateParentFragment(); + dismiss(); } }) .create(); From 5518b815140991fc5c0b3089aafa69f0149d8be3 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 11:31:23 +0200 Subject: [PATCH 07/29] deleted unnecessary method --- .../EditFavoriteGroupDialogFragment.java | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index 340ca08f33..860d115476 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -48,23 +48,10 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme private FavoriteGroup group; private FavouritesDbHelper helper; - @Override - public void onStart() { - super.onStart(); - - final Window window = getDialog().getWindow(); - WindowManager.LayoutParams params = window.getAttributes(); - params.height = ViewGroup.LayoutParams.WRAP_CONTENT; - params.gravity = Gravity.BOTTOM; - params.width = ViewGroup.LayoutParams.MATCH_PARENT; - window.setAttributes(params); - } - @Override public void createMenuItems(Bundle savedInstanceState) { - final Activity activity = getActivity(); - app = (OsmandApplication) activity.getApplicationContext(); + app = getMyApplication(); helper = app.getFavorites(); Bundle args = null; @@ -81,10 +68,9 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme } } items.add(new TitleItem(Algorithms.isEmpty(group.name) ? app.getString(R.string.shared_string_favorites) : group.name)); - IconsCache ic = app.getIconsCache(); BaseBottomSheetItem byTypeItem = new SimpleBottomSheetItem.Builder() - .setIcon(ic.getThemedIcon(R.drawable.ic_action_edit_dark)) + .setIcon(getContentIcon(R.drawable.ic_action_edit_dark)) .setTitle(getString(R.string.edit_name)) .setLayoutId(R.layout.bottom_sheet_item_simple) .setOnClickListener(new View.OnClickListener() { @@ -121,10 +107,11 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme final View changeColorView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.change_fav_color, null); ((ImageView) changeColorView.findViewById(R.id.change_color_icon)) - .setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_appearance)); + .setImageDrawable(getContentIcon(R.drawable.ic_action_appearance)); updateColorView(changeColorView); - BaseBottomSheetItem changeColorItem = new BaseBottomSheetItem.Builder().setCustomView(changeColorView) + BaseBottomSheetItem changeColorItem = new BaseBottomSheetItem.Builder() + .setCustomView(changeColorView) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -155,12 +142,13 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme }); popup.show(); } - }).create(); + }) + .create(); items.add(changeColorItem); BaseBottomSheetItem showOnMapItem = new BottomSheetItemWithCompoundButton.Builder() .setChecked(group.visible) - .setIcon(ic.getThemedIcon(R.drawable.ic_map)) + .setIcon(getContentIcon(R.drawable.ic_map)) .setTitle(getString(R.string.shared_string_show_on_map)) .setLayoutId(R.layout.bottom_sheet_item_with_switch) .setOnClickListener(new View.OnClickListener() { @@ -189,7 +177,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme if (app.getSettings().USE_MAP_MARKERS.get() && group.points.size() > 0 && !groupSyncedWithMarkers) { BaseBottomSheetItem addToMarkersItem = new SimpleBottomSheetItem.Builder() - .setIcon(ic.getThemedIcon(R.drawable.ic_action_flag_dark)) + .setIcon(getContentIcon(R.drawable.ic_action_flag_dark)) .setTitle(getString(R.string.shared_string_add_to_map_markers)) .setLayoutId(R.layout.bottom_sheet_item_simple) .setOnClickListener(new View.OnClickListener() { @@ -208,7 +196,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme if (app.getSettings().USE_MAP_MARKERS.get() && groupSyncedWithMarkers) { BaseBottomSheetItem removeFromMarkersItem = new SimpleBottomSheetItem.Builder() - .setIcon(ic.getThemedIcon(R.drawable.ic_action_delete_dark)) + .setIcon(getContentIcon(R.drawable.ic_action_delete_dark)) .setTitle(getString(R.string.remove_from_map_markers)) .setLayoutId(R.layout.bottom_sheet_item_simple) .setOnClickListener(new View.OnClickListener() { @@ -224,7 +212,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme } if (group.points.size() > 0) { BaseBottomSheetItem shareItem = new SimpleBottomSheetItem.Builder() - .setIcon(ic.getThemedIcon(R.drawable.ic_action_gshare_dark)) + .setIcon(getContentIcon(R.drawable.ic_action_gshare_dark)) .setTitle(getString(R.string.shared_string_share)) .setLayoutId(R.layout.bottom_sheet_item_simple) .setOnClickListener(new View.OnClickListener() { From b47009973bf70718c2eca8c13d7955a972d8a833 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 11:57:54 +0200 Subject: [PATCH 08/29] refactored some code --- OsmAnd/res/layout/change_fav_color.xml | 1 + .../EditFavoriteGroupDialogFragment.java | 47 +++++++------------ 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/OsmAnd/res/layout/change_fav_color.xml b/OsmAnd/res/layout/change_fav_color.xml index 3e08ea7ed6..26b0b107af 100644 --- a/OsmAnd/res/layout/change_fav_color.xml +++ b/OsmAnd/res/layout/change_fav_color.xml @@ -32,4 +32,5 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_action_circle" /> + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index 860d115476..7ee9c77aca 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -1,6 +1,5 @@ package net.osmand.plus.activities; -import android.app.Activity; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; @@ -14,8 +13,6 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.EditText; @@ -25,7 +22,6 @@ import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; -import net.osmand.plus.IconsCache; import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup; import net.osmand.plus.OsmandApplication; @@ -44,16 +40,12 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme public static final String TAG = "EditFavoriteGroupDialogFragment"; private static final String GROUP_NAME_KEY = "group_name_key"; - private OsmandApplication app; private FavoriteGroup group; - private FavouritesDbHelper helper; @Override public void createMenuItems(Bundle savedInstanceState) { - - app = getMyApplication(); - helper = app.getFavorites(); - + final OsmandApplication app = getMyApplication(); + FavouritesDbHelper helper = app.getFavorites(); Bundle args = null; if (savedInstanceState != null) { args = savedInstanceState; @@ -80,9 +72,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme b.setTitle(R.string.favorite_group_name); final EditText nameEditText = new EditText(getContext()); nameEditText.setText(group.name); - int leftPadding = AndroidUtils.dpToPx(getContext(), 24f); - int topPadding = AndroidUtils.dpToPx(getContext(), 4f); - b.setView(nameEditText, leftPadding, topPadding, leftPadding, topPadding); + b.setView(nameEditText); b.setNegativeButton(R.string.shared_string_cancel, null); b.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() { @Override @@ -90,7 +80,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme String name = nameEditText.getText().toString(); boolean nameChanged = !Algorithms.objectEquals(group.name, name); if (nameChanged) { - getMyApplication().getFavorites() + app.getFavorites() .editFavouriteGroup(group, name, group.color, group.visible); updateParentFragment(); } @@ -109,7 +99,6 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme ((ImageView) changeColorView.findViewById(R.id.change_color_icon)) .setImageDrawable(getContentIcon(R.drawable.ic_action_appearance)); updateColorView(changeColorView); - BaseBottomSheetItem changeColorItem = new BaseBottomSheetItem.Builder() .setCustomView(changeColorView) .setOnClickListener(new View.OnClickListener() { @@ -119,19 +108,18 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme popup.setAnchorView(changeColorView); popup.setContentWidth(AndroidUtils.dpToPx(app, 200f)); popup.setModal(true); - popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP); + popup.setDropDownGravity(Gravity.END | Gravity.TOP); popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f)); popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f)); final FavoriteColorAdapter colorAdapter = new FavoriteColorAdapter(getActivity()); popup.setAdapter(colorAdapter); popup.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override public void onItemClick(AdapterView parent, View view, int position, long id) { Integer color = colorAdapter.getItem(position); if (color != null) { if (color != group.color) { - getMyApplication().getFavorites() + app.getFavorites() .editFavouriteGroup(group, group.name, color, group.visible); updateParentFragment(); } @@ -155,8 +143,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme @Override public void onClick(View v) { boolean visible = !group.visible; -// showOnMapItem.setChecked(visible); - getMyApplication().getFavorites() + app.getFavorites() .editFavouriteGroup(group, group.name, group.color, visible); updateParentFragment(); dismiss(); @@ -169,8 +156,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme items.add(new DividerItem(getContext())); } - - final MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper(); + final MapMarkersHelper markersHelper = app.getMapMarkersHelper(); final MarkersSyncGroup syncGroup = new MarkersSyncGroup(group.name, group.name, MarkersSyncGroup.FAVORITES_TYPE, group.color); boolean groupSyncedWithMarkers = markersHelper.isGroupSynced(syncGroup.getId()); @@ -193,7 +179,6 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme items.add(addToMarkersItem); } - if (app.getSettings().USE_MAP_MARKERS.get() && groupSyncedWithMarkers) { BaseBottomSheetItem removeFromMarkersItem = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_delete_dark)) @@ -210,6 +195,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme .create(); items.add(removeFromMarkersItem); } + if (group.points.size() > 0) { BaseBottomSheetItem shareItem = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_gshare_dark)) @@ -228,7 +214,6 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme .create(); items.add(shareItem); } - } @Override @@ -255,12 +240,12 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme } private void updateColorView(View colorView) { - ImageView colorImageView = (ImageView) colorView.findViewById(R.id.colorImage); + ImageView colorImageView = colorView.findViewById(R.id.colorImage); int color = group.color == 0 ? getResources().getColor(R.color.color_favorite) : group.color; if (color == 0) { - colorImageView.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_circle)); + colorImageView.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_circle)); } else { - colorImageView.setImageDrawable(app.getIconsCache().getPaintedIcon(R.drawable.ic_action_circle, color)); + colorImageView.setImageDrawable(getMyApplication().getIconsCache().getPaintedIcon(R.drawable.ic_action_circle, color)); } } @@ -274,9 +259,9 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme public static class FavoriteColorAdapter extends ArrayAdapter { - private OsmandApplication app; + private final OsmandApplication app; - public FavoriteColorAdapter(Context context) { + FavoriteColorAdapter(Context context) { super(context, R.layout.rendering_prop_menu_item); this.app = (OsmandApplication) getContext().getApplicationContext(); init(); @@ -294,10 +279,10 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme Integer color = getItem(position); View v = convertView; if (v == null) { - v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, null); + v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, parent, false); } if (color != null) { - TextView textView = (TextView) v.findViewById(R.id.text1); + TextView textView = v.findViewById(R.id.text1); textView.setText(app.getString(ColorDialogs.paletteColors[position])); textView.setCompoundDrawablesWithIntrinsicBounds(null, null, app.getIconsCache().getPaintedIcon(R.drawable.ic_action_circle, color), null); From 545bfc91f349ec89490e7d08ff8cb90a6e01e9d1 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 12:54:36 +0200 Subject: [PATCH 09/29] refactored some code and fixed npe --- .../activities/EditFavoriteGroupDialogFragment.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index 7ee9c77aca..d6598c3474 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -47,9 +47,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme final OsmandApplication app = getMyApplication(); FavouritesDbHelper helper = app.getFavorites(); Bundle args = null; - if (savedInstanceState != null) { - args = savedInstanceState; - } else if (getArguments() != null) { + if (getArguments() != null) { args = getArguments(); } @@ -240,10 +238,10 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme } private void updateColorView(View colorView) { - ImageView colorImageView = colorView.findViewById(R.id.colorImage); + ImageView colorImageView = (ImageView) colorView.findViewById(R.id.colorImage); int color = group.color == 0 ? getResources().getColor(R.color.color_favorite) : group.color; if (color == 0) { - colorImageView.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_circle)); + colorImageView.setImageDrawable(getContentIcon(R.drawable.ic_action_circle)); } else { colorImageView.setImageDrawable(getMyApplication().getIconsCache().getPaintedIcon(R.drawable.ic_action_circle, color)); } @@ -282,7 +280,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, parent, false); } if (color != null) { - TextView textView = v.findViewById(R.id.text1); + TextView textView = (TextView) v.findViewById(R.id.text1); textView.setText(app.getString(ColorDialogs.paletteColors[position])); textView.setCompoundDrawablesWithIntrinsicBounds(null, null, app.getIconsCache().getPaintedIcon(R.drawable.ic_action_circle, color), null); From 8db675d8f59bcbb96a83d9c3c8e7164ffb3b3a8a Mon Sep 17 00:00:00 2001 From: xmd5a Date: Tue, 6 Mar 2018 14:01:16 +0300 Subject: [PATCH 10/29] Add phrase --- OsmAnd/res/values-ru/phrases.xml | 2 ++ OsmAnd/res/values/phrases.xml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/OsmAnd/res/values-ru/phrases.xml b/OsmAnd/res/values-ru/phrases.xml index b981d60f74..99ee15db48 100644 --- a/OsmAnd/res/values-ru/phrases.xml +++ b/OsmAnd/res/values-ru/phrases.xml @@ -3739,4 +3739,6 @@ Напольные покрытия Глиняная посуда + Название речного порога + diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index 4a1fd69fc6..f9d425780e 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -3759,4 +3759,6 @@ Flooring store Pottery + Name of the river rapids + From b41497611f007220192ce184e1099df762efb46a Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 13:39:17 +0200 Subject: [PATCH 11/29] refactored some code --- .../EditFavoriteGroupDialogFragment.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index d6598c3474..506b512de8 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -46,11 +46,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme public void createMenuItems(Bundle savedInstanceState) { final OsmandApplication app = getMyApplication(); FavouritesDbHelper helper = app.getFavorites(); - Bundle args = null; - if (getArguments() != null) { - args = getArguments(); - } - + Bundle args = getArguments(); if (args != null) { String groupName = args.getString(GROUP_NAME_KEY); if (groupName != null) { @@ -94,9 +90,9 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final View changeColorView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.change_fav_color, null); - ((ImageView) changeColorView.findViewById(R.id.change_color_icon)) - .setImageDrawable(getContentIcon(R.drawable.ic_action_appearance)); - updateColorView(changeColorView); + ImageView colorIcon = ((ImageView) changeColorView.findViewById(R.id.change_color_icon)); + colorIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_appearance)); + updateColorView(colorIcon); BaseBottomSheetItem changeColorItem = new BaseBottomSheetItem.Builder() .setCustomView(changeColorView) .setOnClickListener(new View.OnClickListener() { @@ -237,8 +233,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme } } - private void updateColorView(View colorView) { - ImageView colorImageView = (ImageView) colorView.findViewById(R.id.colorImage); + private void updateColorView(ImageView colorImageView) { int color = group.color == 0 ? getResources().getColor(R.color.color_favorite) : group.color; if (color == 0) { colorImageView.setImageDrawable(getContentIcon(R.drawable.ic_action_circle)); From 3f3bbc1fe802455391b5acac1dec14b5e194746a Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 6 Mar 2018 13:41:41 +0200 Subject: [PATCH 12/29] Do not show waypoints with passed markers --- OsmAnd/src/net/osmand/plus/views/GPXLayer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index 0aa24e8701..48a77d8ecf 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -364,10 +364,16 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex List fullObjects = new ArrayList<>(); @ColorInt int fileColor = getFileColor(g); + boolean synced = isSynced(g); for (WptPt o : pts) { if (o.lat >= latLonBounds.bottom && o.lat <= latLonBounds.top && o.lon >= latLonBounds.left && o.lon <= latLonBounds.right && o != contextMenuLayer.getMoveableObject()) { + if (synced) { + if (mapMarkersHelper.getMapMarker(o) == null) { + continue; + } + } cache.add(o); float x = tileBox.getPixXFromLatLon(o.lat, o.lon); float y = tileBox.getPixYFromLatLon(o.lat, o.lon); @@ -385,7 +391,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex } pointFileMap.put(o, g); } - boolean synced = isSynced(g); for (WptPt o : fullObjects) { float x = tileBox.getPixXFromLatLon(o.lat, o.lon); float y = tileBox.getPixYFromLatLon(o.lat, o.lon); From 0c19e1861ae92ff93cfe1fbbb687078cc07976ee Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 13:52:05 +0200 Subject: [PATCH 13/29] fixed ui bug(wrong imageview was sent to updateColorView) --- .../plus/activities/EditFavoriteGroupDialogFragment.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index 506b512de8..643acc287d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -90,9 +90,9 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final View changeColorView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.change_fav_color, null); - ImageView colorIcon = ((ImageView) changeColorView.findViewById(R.id.change_color_icon)); - colorIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_appearance)); - updateColorView(colorIcon); + ((ImageView) changeColorView.findViewById(R.id.change_color_icon)) + .setImageDrawable(getContentIcon(R.drawable.ic_action_appearance)); + updateColorView((ImageView) changeColorView.findViewById(R.id.colorImage)); BaseBottomSheetItem changeColorItem = new BaseBottomSheetItem.Builder() .setCustomView(changeColorView) .setOnClickListener(new View.OnClickListener() { From 304535c164299691f65acb0bc9b7695d64051131 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 14:13:53 +0200 Subject: [PATCH 14/29] changed map arrow behaviour --- .../plus/views/mapwidgets/MapMarkersWidgetsFactory.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java index 86fac1bfea..c14ab304cb 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java @@ -215,11 +215,7 @@ public class MapMarkersWidgetsFactory { return; } - boolean mapLinkedToLoc = map.getMapViewTrackingUtilities().isMapLinkedToLocation(); - Float heading = 0f; - if (mapLinkedToLoc) { - heading = map.getMapViewTrackingUtilities().getHeading(); - } + Float heading = map.getMapViewTrackingUtilities().getHeading(); MapMarker marker = markers.get(0); updateUI(loc, heading, marker, arrowImg, distText, okButton, addressText, true, customLocation != null); From 292639b9f8fb188f5fa570a42dde6f85ddb83649 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 14:18:30 +0200 Subject: [PATCH 15/29] added check for null for group --- .../plus/activities/EditFavoriteGroupDialogFragment.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index 643acc287d..7b3ae7bee3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -52,6 +52,9 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme if (groupName != null) { group = helper.getGroup(groupName); } + if (group==null){ + return; + } } items.add(new TitleItem(Algorithms.isEmpty(group.name) ? app.getString(R.string.shared_string_favorites) : group.name)); From 84852fc1d62cd2b6056693306ad46c552809555d Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 6 Mar 2018 14:35:46 +0200 Subject: [PATCH 16/29] Do not open waypoints on "add map marker" button click in destination context menu --- .../plus/mapcontextmenu/MapContextMenu.java | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 280e293b60..8ed95f5bda 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -835,27 +835,23 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL if (object != null && object instanceof MapMarker) { RenameMarkerBottomSheetDialogFragment .showInstance(mapActivity.getSupportFragmentManager(), (MapMarker) object); - } else { - if (pointDescription.isDestination()) { - mapActivity.getMapActions().editWaypoints(); - } else if (settings.USE_MAP_MARKERS.get()) { - if (pointDescription.isMapMarker()) { - hide(); - MapActivity.clearPrevActivityIntent(); - MapMarkersDialogFragment.showInstance(mapActivity); - } else { - String mapObjectName = null; - if (object instanceof Amenity) { - Amenity amenity = (Amenity) object; - mapObjectName = amenity.getName() + "_" + amenity.getType().getKeyName(); - } - mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(), - getPointDescriptionForMarker(), mapObjectName); - } + } else if (settings.USE_MAP_MARKERS.get()) { + if (pointDescription.isMapMarker()) { + hide(); + MapActivity.clearPrevActivityIntent(); + MapMarkersDialogFragment.showInstance(mapActivity); } else { - mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(), - getPointDescriptionForTarget()); + String mapObjectName = null; + if (object instanceof Amenity) { + Amenity amenity = (Amenity) object; + mapObjectName = amenity.getName() + "_" + amenity.getType().getKeyName(); + } + mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(), + getPointDescriptionForMarker(), mapObjectName); } + } else { + mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(), + getPointDescriptionForTarget()); } close(); } From cc2941b772148cce4813d6384c2777e2d0b3cc1a Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 14:46:20 +0200 Subject: [PATCH 17/29] moved check for group --- .../plus/activities/EditFavoriteGroupDialogFragment.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index 7b3ae7bee3..f1ac330a6a 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -52,9 +52,9 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme if (groupName != null) { group = helper.getGroup(groupName); } - if (group==null){ - return; - } + } + if (group==null){ + return; } items.add(new TitleItem(Algorithms.isEmpty(group.name) ? app.getString(R.string.shared_string_favorites) : group.name)); From d4458fa51eca5bf2a581364a5bd9ad604245353a Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 14:46:40 +0200 Subject: [PATCH 18/29] moved check for group --- .../osmand/plus/activities/EditFavoriteGroupDialogFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index f1ac330a6a..2b06aa5f1c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -53,7 +53,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme group = helper.getGroup(groupName); } } - if (group==null){ + if (group == null) { return; } items.add(new TitleItem(Algorithms.isEmpty(group.name) ? app.getString(R.string.shared_string_favorites) : group.name)); From 66a703e8ba87a5a61b9c4a375110f964e5cd91a8 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 15:47:24 +0200 Subject: [PATCH 19/29] changed style of xml items(now text in the same position as others bottom sheet elements) --- OsmAnd/res/layout/change_fav_color.xml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/OsmAnd/res/layout/change_fav_color.xml b/OsmAnd/res/layout/change_fav_color.xml index 26b0b107af..7768fffd40 100644 --- a/OsmAnd/res/layout/change_fav_color.xml +++ b/OsmAnd/res/layout/change_fav_color.xml @@ -12,20 +12,23 @@ + android:textAppearance="@style/TextAppearance.ListItemTitle" /> Date: Tue, 6 Mar 2018 15:54:14 +0200 Subject: [PATCH 20/29] renamed byTypeItem to editNameItem --- .../plus/activities/EditFavoriteGroupDialogFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index 2b06aa5f1c..1c4a1b4538 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -58,7 +58,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme } items.add(new TitleItem(Algorithms.isEmpty(group.name) ? app.getString(R.string.shared_string_favorites) : group.name)); - BaseBottomSheetItem byTypeItem = new SimpleBottomSheetItem.Builder() + BaseBottomSheetItem editNameItem = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_edit_dark)) .setTitle(getString(R.string.edit_name)) .setLayoutId(R.layout.bottom_sheet_item_simple) @@ -88,7 +88,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme } }) .create(); - items.add(byTypeItem); + items.add(editNameItem); final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final View changeColorView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), From d5cad82b32d37758956ccfd19cb2dd1b0e74d7fc Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 15:56:27 +0200 Subject: [PATCH 21/29] changed type of divider --- .../plus/activities/EditFavoriteGroupDialogFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index 1c4a1b4538..aa242ef972 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -30,6 +30,7 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.helpers.ColorDialogs; @@ -150,7 +151,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme items.add(showOnMapItem); if (group.points.size() > 0) { - items.add(new DividerItem(getContext())); + items.add(new DividerHalfItem(getContext())); } final MapMarkersHelper markersHelper = app.getMapMarkersHelper(); From b8aa29944be183e4aaf600ec84b4af1530625d7d Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 16:02:29 +0200 Subject: [PATCH 22/29] deleted unnecessary import --- .../osmand/plus/activities/EditFavoriteGroupDialogFragment.java | 1 - 1 file changed, 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java index aa242ef972..06a3044a81 100644 --- a/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/EditFavoriteGroupDialogFragment.java @@ -31,7 +31,6 @@ import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem; -import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.helpers.ColorDialogs; import net.osmand.util.Algorithms; From b3850d4ce79de59a8bdfa0570c0121f338a63d93 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 6 Mar 2018 16:20:28 +0200 Subject: [PATCH 23/29] Add the ability to rename map markers on amenities --- .../plus/mapcontextmenu/MapContextMenu.java | 17 +++++++++++++++-- .../plus/mapcontextmenu/MenuController.java | 4 ++++ .../controllers/AmenityMenuController.java | 4 ++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index 8ed95f5bda..a1788d050b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -832,9 +832,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } public void buttonWaypointPressed() { - if (object != null && object instanceof MapMarker) { + MapMarker marker = getMapMarker(); + if (marker != null) { RenameMarkerBottomSheetDialogFragment - .showInstance(mapActivity.getSupportFragmentManager(), (MapMarker) object); + .showInstance(mapActivity.getSupportFragmentManager(), marker); } else if (settings.USE_MAP_MARKERS.get()) { if (pointDescription.isMapMarker()) { hide(); @@ -856,6 +857,18 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL close(); } + @Nullable + private MapMarker getMapMarker() { + Object correspondingObj = menuController.getCorrespondingMapObject(); + if (correspondingObj != null && correspondingObj instanceof MapMarker) { + return (MapMarker) correspondingObj; + } + if (object != null && object instanceof MapMarker) { + return (MapMarker) object; + } + return null; + } + public void buttonFavoritePressed() { if (object != null && object instanceof FavouritePoint) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index 0c83a68727..402fce0b56 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -239,6 +239,10 @@ public abstract class MenuController extends BaseMenuController implements Colla protected abstract Object getObject(); + protected Object getCorrespondingMapObject() { + return null; + } + public boolean isActive() { return active; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index 453f2f91dc..07b29991c5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -93,8 +93,8 @@ public class AmenityMenuController extends MenuController { } @Override - public boolean isWaypointButtonEnabled() { - return marker == null; + protected Object getCorrespondingMapObject() { + return marker; } @Override From 5cce57107ea8821f1296fa113aa80a9cc65ee712 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 6 Mar 2018 16:43:58 +0200 Subject: [PATCH 24/29] Fix ConcurrentModificationException --- OsmAnd/src/net/osmand/plus/MapMarkersHelper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index c2c5e77418..ecd0bc5cfa 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -1438,7 +1438,8 @@ public class MapMarkersHelper { } public List getActiveMarkers() { - List activeMarkers = new ArrayList<>(); + List markers = new ArrayList<>(this.markers); + List activeMarkers = new ArrayList<>(markers.size()); for (MapMarker marker : markers) { if (!marker.history) { activeMarkers.add(marker); From a1a9d2a2e59f1340c48fe23a145734d29e91e0fd Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 17:42:34 +0200 Subject: [PATCH 25/29] moved checkbox to the left --- OsmAnd/res/layout/gpx_track_item.xml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/OsmAnd/res/layout/gpx_track_item.xml b/OsmAnd/res/layout/gpx_track_item.xml index 5c68c9c4f3..d3d1e9e9e0 100644 --- a/OsmAnd/res/layout/gpx_track_item.xml +++ b/OsmAnd/res/layout/gpx_track_item.xml @@ -21,6 +21,17 @@ android:paddingLeft="@dimen/dialog_content_margin" android:gravity="center_vertical"> + + - - From 9a22f22a09384616e993680a2296d00b3d181486 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 6 Mar 2018 17:45:18 +0200 Subject: [PATCH 26/29] adden visibility="gone" to checkbox --- OsmAnd/res/layout/gpx_track_item.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/layout/gpx_track_item.xml b/OsmAnd/res/layout/gpx_track_item.xml index d3d1e9e9e0..1766af34be 100644 --- a/OsmAnd/res/layout/gpx_track_item.xml +++ b/OsmAnd/res/layout/gpx_track_item.xml @@ -30,7 +30,8 @@ android:paddingRight="@dimen/dialog_content_margin" android:clickable="false" android:focusable="false" - android:focusableInTouchMode="false" /> + android:focusableInTouchMode="false" + android:visibility="gone"/> Date: Tue, 6 Mar 2018 18:27:43 +0200 Subject: [PATCH 27/29] changed checkbox --- OsmAnd/res/layout/gpx_track_item.xml | 32 +++++++++++-------- .../net/osmand/plus/helpers/GpxUiHelper.java | 3 +- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/OsmAnd/res/layout/gpx_track_item.xml b/OsmAnd/res/layout/gpx_track_item.xml index 1766af34be..a62f652a8d 100644 --- a/OsmAnd/res/layout/gpx_track_item.xml +++ b/OsmAnd/res/layout/gpx_track_item.xml @@ -21,25 +21,17 @@ android:paddingLeft="@dimen/dialog_content_margin" android:gravity="center_vertical"> - - + android:visibility="gone" + android:paddingTop="4dp" + android:paddingBottom="4dp" + android:paddingRight="@dimen/dialog_content_margin" + android:clickable="false" + android:focusableInTouchMode="false"/> + + diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index a403a43f5c..c430e64f80 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -30,6 +30,7 @@ import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.ImageView; @@ -473,7 +474,7 @@ public class GpxUiHelper { v.findViewById(R.id.check_item).setVisibility(View.GONE); } else { if (checkLayout) { - final AppCompatCheckBox ch = ((AppCompatCheckBox) v.findViewById(R.id.toggle_checkbox_item)); + final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_local_index)); ch.setVisibility(View.VISIBLE); v.findViewById(R.id.toggle_item).setVisibility(View.GONE); ch.setOnCheckedChangeListener(null); From a0773677168f1e894eeecda43ffb89e2d89bd751 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 7 Mar 2018 10:57:43 +0200 Subject: [PATCH 28/29] added visibility GONE to checkbox --- OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index c430e64f80..7c52cd7c03 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -472,6 +472,7 @@ public class GpxUiHelper { if (item.getSelected() == null) { v.findViewById(R.id.check_item).setVisibility(View.GONE); + v.findViewById(R.id.check_local_index).setVisibility(View.GONE); } else { if (checkLayout) { final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_local_index)); From 957fa9eae0621880ef951d70dd8268117b4b2fc1 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 7 Mar 2018 11:04:38 +0200 Subject: [PATCH 29/29] Add the ability to sort points door-to-door without keeping the position of the last point --- OsmAnd-java/src/net/osmand/TspAnt.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/TspAnt.java b/OsmAnd-java/src/net/osmand/TspAnt.java index 245b67ff82..815bddb7ef 100644 --- a/OsmAnd-java/src/net/osmand/TspAnt.java +++ b/OsmAnd-java/src/net/osmand/TspAnt.java @@ -1,11 +1,11 @@ package net.osmand; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Random; import net.osmand.data.LatLon; import net.osmand.util.MapUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; /* * === Implementation of ant swarm TSP solver. === * @@ -106,10 +106,13 @@ public class TspAnt { // Allocates all memory. // Adds 1 to edge lengths to ensure no zero length edges. public TspAnt readGraph(List intermediates, LatLon start, LatLon end) { + boolean keepEndPoint = end != null; List l = new ArrayList(); l.add(start); l.addAll(intermediates); - l.add(end); + if (keepEndPoint) { + l.add(end); + } n = l.size() ; // System.out.println("Cost"); graph = new double[n][n]; @@ -125,7 +128,7 @@ public class TspAnt { } maxSum = Math.rint(maxSum) + 1; for (int i = 0; i < n; i++) { - if (i == n - 1) { + if (keepEndPoint && i == n - 1) { graph[i][0] = 0.1; } else { graph[i][0] = maxSum;