Merge pull request #4669 from osmandapp/add_marker_buttons
Change the button in the context menu of the marker
This commit is contained in:
commit
aaa9753785
9 changed files with 169 additions and 35 deletions
11
OsmAnd/res/drawable/passed_icon_dark.xml
Normal file
11
OsmAnd/res/drawable/passed_icon_dark.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/osmand_orange"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item android:drawable="@drawable/ic_action_marker_passed"/>
|
||||
</layer-list>
|
11
OsmAnd/res/drawable/passed_icon_light.xml
Normal file
11
OsmAnd/res/drawable/passed_icon_light.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/map_widget_blue"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item android:drawable="@drawable/ic_action_marker_passed"/>
|
||||
</layer-list>
|
|
@ -166,20 +166,69 @@
|
|||
|
||||
<LinearLayout
|
||||
android:id="@+id/title_button_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/context_menu_action_buttons_h"
|
||||
android:layout_marginTop="@dimen/context_menu_buttons_top_margin"
|
||||
android:clickable="true"
|
||||
android:orientation="horizontal"
|
||||
android:minHeight="@dimen/context_menu_action_buttons_h"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/context_menu_buttons_padding_bottom"
|
||||
android:paddingLeft="62dp"
|
||||
android:paddingRight="2dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/title_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="left|center_vertical"
|
||||
android:paddingLeft="@dimen/context_menu_button_padding_x"
|
||||
android:paddingRight="@dimen/context_menu_button_padding_x"
|
||||
android:text="@string/recording_context_menu_play"
|
||||
android:textColor="?attr/contextMenuButtonColor"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_button_right_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="-4dp"
|
||||
android:clickable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:text="— 00:26"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/title_button_right"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="@dimen/context_menu_button_padding_x"
|
||||
android:paddingRight="@dimen/context_menu_button_padding_x"
|
||||
android:text="@string/shared_string_delete"
|
||||
android:textColor="?attr/contextMenuButtonColor"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/title_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:background="?attr/dashboard_divider"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/title_button"
|
||||
android:id="@+id/subtitle_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
|
@ -190,29 +239,6 @@
|
|||
android:textColor="?attr/contextMenuButtonColor"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_button_right_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="-4dp"
|
||||
android:clickable="true"
|
||||
android:gravity="center_vertical"
|
||||
tools:text="— 00:26"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/title_button_right"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="@dimen/context_menu_button_padding_x"
|
||||
android:paddingRight="@dimen/context_menu_button_padding_x"
|
||||
android:text="@string/shared_string_delete"
|
||||
android:textColor="?attr/contextMenuButtonColor"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="show_on_top_bar">Show on Top Bar</string>
|
||||
<string name="mark_passed">Mark passed</string>
|
||||
<string name="import_gpx_file_description">can be imported as Favorites points, or as track file.</string>
|
||||
<string name="import_as_gpx">Import as GPX file</string>
|
||||
<string name="import_as_favorites">Import as Favorites</string>
|
||||
|
|
|
@ -795,6 +795,16 @@ public class MapMarkersHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void moveMarkerToTop(MapMarker marker) {
|
||||
int i = mapMarkers.indexOf(marker);
|
||||
if (i != -1 && mapMarkers.size() > 1) {
|
||||
mapMarkers.remove(i);
|
||||
mapMarkers.add(0, marker);
|
||||
reorderActiveMarkersIfNeeded();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public void moveMapMarker(MapMarker marker, LatLon latLon) {
|
||||
if (marker != null) {
|
||||
LatLon point = new LatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
|
|
|
@ -1035,6 +1035,14 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
}
|
||||
}
|
||||
|
||||
public TitleButtonController getLeftSubtitleButtonController() {
|
||||
if (menuController != null) {
|
||||
return menuController.getLeftSubtitleButtonController();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public TitleButtonController getLeftDownloadButtonController() {
|
||||
if (menuController != null) {
|
||||
return menuController.getLeftDownloadButtonController();
|
||||
|
|
|
@ -175,6 +175,18 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
}
|
||||
});
|
||||
|
||||
// Left subtitle button
|
||||
final Button leftSubtitleButton = (Button) view.findViewById(R.id.subtitle_button);
|
||||
leftSubtitleButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TitleButtonController leftSubtitleButtonController = menu.getLeftSubtitleButtonController();
|
||||
if (leftSubtitleButtonController != null) {
|
||||
leftSubtitleButtonController.buttonPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Left download button
|
||||
final Button leftDownloadButton = (Button) view.findViewById(R.id.download_button_left);
|
||||
leftDownloadButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -686,14 +698,17 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
TitleButtonController leftTitleButtonController = menu.getLeftTitleButtonController();
|
||||
TitleButtonController rightTitleButtonController = menu.getRightTitleButtonController();
|
||||
TitleButtonController topRightTitleButtonController = menu.getTopRightTitleButtonController();
|
||||
TitleButtonController leftSubtitleButtonController = menu.getLeftSubtitleButtonController();
|
||||
TitleButtonController leftDownloadButtonController = menu.getLeftDownloadButtonController();
|
||||
TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
|
||||
TitleProgressController titleProgressController = menu.getTitleProgressController();
|
||||
|
||||
// Title buttons
|
||||
boolean showTitleButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null);
|
||||
boolean showTitleDivider = leftSubtitleButtonController != null;
|
||||
final View titleButtonsContainer = view.findViewById(R.id.title_button_container);
|
||||
titleButtonsContainer.setVisibility(showTitleButtonsContainer ? View.VISIBLE : View.GONE);
|
||||
view.findViewById(R.id.title_divider).setVisibility(showTitleDivider ? View.VISIBLE : View.GONE);
|
||||
|
||||
// Left title button
|
||||
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
|
||||
|
@ -705,7 +720,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
Drawable leftIcon = leftTitleButtonController.getLeftIcon();
|
||||
if (leftIcon != null) {
|
||||
leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
leftTitleButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||
leftTitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||
}
|
||||
|
||||
if (leftTitleButtonController.needRightText) {
|
||||
|
@ -727,7 +742,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
|
||||
Drawable leftIcon = rightTitleButtonController.getLeftIcon();
|
||||
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
rightTitleButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||
rightTitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||
} else {
|
||||
rightTitleButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -740,11 +755,26 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
|
||||
Drawable leftIcon = topRightTitleButtonController.getLeftIcon();
|
||||
topRightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
topRightTitleButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||
topRightTitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||
} else {
|
||||
topRightTitleButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Left subtitle button
|
||||
final Button leftSubtitleButton = (Button) view.findViewById(R.id.subtitle_button);
|
||||
if (leftSubtitleButtonController != null) {
|
||||
leftSubtitleButton.setText(leftSubtitleButtonController.caption);
|
||||
leftSubtitleButton.setVisibility(leftSubtitleButtonController.visible ? View.VISIBLE : View.GONE);
|
||||
|
||||
Drawable leftIcon = leftSubtitleButtonController.getLeftIcon();
|
||||
if (leftIcon != null) {
|
||||
leftSubtitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
leftSubtitleButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||
}
|
||||
} else {
|
||||
leftSubtitleButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Download buttons
|
||||
boolean showDownloadButtonsContainer =
|
||||
((leftDownloadButtonController != null && leftDownloadButtonController.visible)
|
||||
|
@ -772,7 +802,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
Drawable leftIcon = leftDownloadButtonController.getLeftIcon();
|
||||
if (leftIcon != null) {
|
||||
leftDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
leftDownloadButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||
leftDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||
}
|
||||
} else {
|
||||
leftDownloadButton.setVisibility(View.GONE);
|
||||
|
@ -786,7 +816,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
|
||||
Drawable leftIcon = rightDownloadButtonController.getLeftIcon();
|
||||
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
|
||||
rightDownloadButton.setCompoundDrawablePadding(dpToPx(4f));
|
||||
rightDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
|
||||
} else {
|
||||
rightDownloadButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -98,6 +99,7 @@ public abstract class MenuController extends BaseMenuController {
|
|||
protected TitleButtonController leftTitleButtonController;
|
||||
protected TitleButtonController rightTitleButtonController;
|
||||
protected TitleButtonController topRightTitleButtonController;
|
||||
protected TitleButtonController leftSubtitleButtonController;
|
||||
|
||||
protected TitleButtonController leftDownloadButtonController;
|
||||
protected TitleButtonController rightDownloadButtonController;
|
||||
|
@ -321,6 +323,10 @@ public abstract class MenuController extends BaseMenuController {
|
|||
return topRightTitleButtonController;
|
||||
}
|
||||
|
||||
public TitleButtonController getLeftSubtitleButtonController() {
|
||||
return leftSubtitleButtonController;
|
||||
}
|
||||
|
||||
public TitleButtonController getLeftDownloadButtonController() {
|
||||
return leftDownloadButtonController;
|
||||
}
|
||||
|
@ -495,10 +501,18 @@ public abstract class MenuController extends BaseMenuController {
|
|||
public boolean needRightText = false;
|
||||
public String rightTextCaption = "";
|
||||
public boolean visible = true;
|
||||
public boolean needColorizeIcon = true;
|
||||
public Drawable leftIcon;
|
||||
|
||||
public Drawable getLeftIcon() {
|
||||
if (leftIcon != null) {
|
||||
return leftIcon;
|
||||
}
|
||||
if (leftIconId != 0) {
|
||||
return getIcon(leftIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange);
|
||||
if (needColorizeIcon) {
|
||||
return getIcon(leftIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange);
|
||||
}
|
||||
return ContextCompat.getDrawable(getMapActivity(), leftIconId);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package net.osmand.plus.mapcontextmenu.controllers;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -21,6 +23,7 @@ public class MapMarkerMenuController extends MenuController {
|
|||
this.mapMarker = mapMarker;
|
||||
builder.setShowNearestWiki(true);
|
||||
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||
|
||||
leftTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
|
@ -28,8 +31,27 @@ public class MapMarkerMenuController extends MenuController {
|
|||
getMapActivity().getContextMenu().close();
|
||||
}
|
||||
};
|
||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_remove);
|
||||
leftTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark;
|
||||
leftTitleButtonController.needColorizeIcon = false;
|
||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.mark_passed);
|
||||
leftTitleButtonController.leftIconId = isLight() ? R.drawable.passed_icon_light : R.drawable.passed_icon_dark;
|
||||
|
||||
leftSubtitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
markersHelper.moveMarkerToTop(getMapMarker());
|
||||
getMapActivity().getContextMenu().close();
|
||||
}
|
||||
};
|
||||
leftSubtitleButtonController.caption = getMapActivity().getString(R.string.show_on_top_bar);
|
||||
leftSubtitleButtonController.leftIcon = createShowOnTopbarIcon();
|
||||
}
|
||||
|
||||
private Drawable createShowOnTopbarIcon() {
|
||||
IconsCache ic = getMapActivity().getMyApplication().getIconsCache();
|
||||
Drawable background = ic.getIcon(R.drawable.ic_action_device_top,
|
||||
isLight() ? R.color.on_map_icon_color : R.color.ctx_menu_info_text_dark);
|
||||
Drawable topbar = ic.getIcon(R.drawable.ic_action_device_topbar, R.color.dashboard_blue);
|
||||
return new LayerDrawable(new Drawable[]{background, topbar});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue