Create additional line in context menu
This commit is contained in:
parent
d033e8fe6e
commit
0c5634a2b6
5 changed files with 78 additions and 2 deletions
|
@ -97,6 +97,15 @@
|
|||
android:layout_height="@dimen/context_menu_sub_info_height"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
|
||||
tools:text="Museum"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/context_menu_line3"
|
||||
style="@style/TextAppearance.ContextMenuSubtitle"/>
|
||||
|
||||
<TextView
|
||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.os.Bundle;
|
|||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -1117,6 +1118,18 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
line2.setText(line2Str.toString());
|
||||
}
|
||||
|
||||
TextView line3 = (TextView) view.findViewById(R.id.context_menu_line3);
|
||||
String additionalTypeStr = menu.getAdditionalTypeStr();
|
||||
if (TextUtils.isEmpty(additionalTypeStr)) {
|
||||
line3.setVisibility(View.GONE);
|
||||
} else {
|
||||
line3.setVisibility(View.VISIBLE);
|
||||
line3.setText(additionalTypeStr);
|
||||
Drawable icon = menu.getAdditionalLineTypeIcon();
|
||||
line3.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
||||
line3.setCompoundDrawablePadding(dpToPx(5f));
|
||||
}
|
||||
|
||||
TextView openingHoursTextView = (TextView) view.findViewById(R.id.opening_hours_text_view);
|
||||
OpeningHoursInfo openingHoursInfo = menu.getOpeningHoursInfo();
|
||||
if (openingHoursInfo != null && openingHoursInfo.containsInfo()) {
|
||||
|
|
|
@ -378,6 +378,10 @@ public abstract class MenuController extends BaseMenuController {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean needAdditionalTypeStr() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean displayStreetNameInTitle() {
|
||||
return false;
|
||||
}
|
||||
|
@ -398,6 +402,10 @@ public abstract class MenuController extends BaseMenuController {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Drawable getAdditionalLineTypeIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getFavActionIconId() {
|
||||
return R.drawable.map_action_fav_dark;
|
||||
}
|
||||
|
@ -424,6 +432,10 @@ public abstract class MenuController extends BaseMenuController {
|
|||
return "";
|
||||
}
|
||||
|
||||
public String getAdditionalTypeStr() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public OpeningHoursInfo getOpeningHoursInfo() {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,10 @@ public abstract class MenuTitleController {
|
|||
protected Drawable leftIcon;
|
||||
protected String nameStr = "";
|
||||
protected String typeStr = "";
|
||||
protected String additionalTypeStr = "";
|
||||
protected String commonTypeStr = "";
|
||||
protected Drawable secondLineTypeIcon;
|
||||
protected Drawable additionalLineTypeIcon;
|
||||
protected String streetStr = "";
|
||||
protected OpeningHoursInfo openingHoursInfo;
|
||||
|
||||
|
@ -78,6 +80,10 @@ public abstract class MenuTitleController {
|
|||
return secondLineTypeIcon;
|
||||
}
|
||||
|
||||
public Drawable getAdditionalLineTypeIcon() {
|
||||
return additionalLineTypeIcon;
|
||||
}
|
||||
|
||||
public String getTypeStr() {
|
||||
MenuController menuController = getMenuController();
|
||||
if (menuController != null && menuController.needTypeStr()) {
|
||||
|
@ -87,6 +93,15 @@ public abstract class MenuTitleController {
|
|||
}
|
||||
}
|
||||
|
||||
public String getAdditionalTypeStr() {
|
||||
MenuController menuController = getMenuController();
|
||||
if (menuController != null && menuController.needAdditionalTypeStr()) {
|
||||
return additionalTypeStr;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getStreetStr() {
|
||||
if (needStreetName()) {
|
||||
if (searchingAddress()) {
|
||||
|
@ -135,11 +150,13 @@ public abstract class MenuTitleController {
|
|||
leftIconId = 0;
|
||||
leftIcon = null;
|
||||
secondLineTypeIcon = null;
|
||||
additionalLineTypeIcon = null;
|
||||
|
||||
if (menuController != null) {
|
||||
leftIconId = menuController.getLeftIconId();
|
||||
leftIcon = menuController.getLeftIcon();
|
||||
secondLineTypeIcon = menuController.getSecondLineTypeIcon();
|
||||
additionalLineTypeIcon = menuController.getAdditionalLineTypeIcon();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,6 +170,7 @@ public abstract class MenuTitleController {
|
|||
if (menuController != null) {
|
||||
nameStr = menuController.getNameStr();
|
||||
typeStr = menuController.getTypeStr();
|
||||
additionalTypeStr = menuController.getAdditionalTypeStr();
|
||||
commonTypeStr = menuController.getCommonTypeStr();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ import android.support.v4.content.ContextCompat;
|
|||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -14,6 +16,8 @@ import net.osmand.plus.mapcontextmenu.MenuController;
|
|||
import net.osmand.plus.mapcontextmenu.builders.WptPtMenuBuilder;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class WptPtMenuController extends MenuController {
|
||||
|
||||
private WptPt wpt;
|
||||
|
@ -74,8 +78,8 @@ public class WptPtMenuController extends MenuController {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Drawable getSecondLineTypeIcon() {
|
||||
if (Algorithms.isEmpty(getTypeStr())) {
|
||||
public Drawable getAdditionalLineTypeIcon() {
|
||||
if (Algorithms.isEmpty(getAdditionalTypeStr())) {
|
||||
return null;
|
||||
} else {
|
||||
return getIcon(R.drawable.ic_action_group_name_16);
|
||||
|
@ -87,8 +91,28 @@ public class WptPtMenuController extends MenuController {
|
|||
return getMapActivity().getMyApplication().getMapMarkersHelper().getMapMarker(wpt) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needAdditionalTypeStr() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
GpxSelectionHelper helper = getMapActivity().getMyApplication().getSelectedGpxHelper();
|
||||
SelectedGpxFile selectedGpxFile = helper.getSelectedGPXFile(wpt);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getMapActivity().getString(R.string.gpx_wpt));
|
||||
sb.append(", ");
|
||||
if (selectedGpxFile != null) {
|
||||
File file = new File(selectedGpxFile.getGpxFile().path);
|
||||
String gpxName = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " ");
|
||||
sb.append(gpxName);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAdditionalTypeStr() {
|
||||
return wpt.category != null ? wpt.category : "";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue