Context menu fixes (PointDescription)

This commit is contained in:
Alexey Kulish 2015-11-05 12:39:36 +03:00
parent 5b031c603d
commit afa9542a70
23 changed files with 330 additions and 155 deletions

View file

@ -4,7 +4,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
android:background="@android:color/transparent"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:id="@+id/context_menu_main"
@ -110,10 +111,10 @@
android:id="@+id/title_button_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="44dp"
android:layout_marginRight="2dp"
android:paddingLeft="44dp"
android:paddingRight="2dp"
android:layout_marginTop="-16dp"
android:layout_marginBottom="4dp"
android:paddingBottom="4dp"
android:clickable="true"
android:orientation="horizontal">
@ -131,11 +132,11 @@
<TextView
android:id="@+id/title_button_right_text"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:clickable="true"
android:layout_marginLeft="-4dp"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
android:text="— 00:26"/>
@ -155,6 +156,78 @@
</LinearLayout>
<LinearLayout
android:id="@+id/title_progress_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="54dp"
android:paddingRight="2dp"
android:layout_marginTop="-16dp"
android:paddingBottom="4dp"
android:clickable="true"
android:orientation="horizontal"
tools:visibility="visible"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:layout_marginRight="12dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/progressTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:visibility="visible"
tools:text="@string/shared_string_downloading"/>
<TextView
android:id="@+id/progressPercent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="12dp"
android:visibility="visible"
tools:text="12%"/>
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"/>
</LinearLayout>
<ImageView
android:id="@+id/progressButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_gravity="center_vertical"
android:background="?android:selectableItemBackground"
android:scaleType="center"
tools:src="@drawable/ic_action_remove_dark"/>
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/buttons_top_border"
android:layout_width="match_parent"

View file

@ -9,6 +9,9 @@
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="rec_photo_description">Photo %1$s</string>
<string name="rec_audio_description">Audio %1$s</string>
<string name="rec_video_description">Video %1$s</string>
<string name="shared_string_upload">Upload</string>
<string name="osm_edit_created_poi">Created OSM POI</string>
<string name="osm_edit_created_bug">Created OSM bug</string>

View file

@ -226,11 +226,14 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
if (desc != null) {
return desc;
} else if (this.isAudio()) {
return ctx.getResources().getString(R.string.shared_string_audio);
String time = AndroidUtils.formatDateTime(ctx, file.lastModified());
return ctx.getString(R.string.rec_audio_description, time).trim();
} else if (this.isVideo()) {
return ctx.getResources().getString(R.string.shared_string_video);
String time = AndroidUtils.formatDateTime(ctx, file.lastModified());
return ctx.getString(R.string.rec_video_description, time).trim();
} else if (this.isPhoto()) {
return ctx.getResources().getString(R.string.shared_string_photo);
String time = AndroidUtils.formatDateTime(ctx, file.lastModified());
return ctx.getString(R.string.rec_photo_description, time).trim();
}
return "";
}

View file

@ -29,6 +29,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import java.util.ArrayList;
@ -89,7 +90,15 @@ public class WaypointDialogHelper {
} else {
textDist.setText("");
}
String descr = PointDescription.getSimpleName(point, app);
String descr;
PointDescription pd = point.getPointDescription(app);
if (Algorithms.isEmpty(pd.getName())) {
descr = pd.getTypeName();
} else {
descr = pd.getName();
}
if(textShadow != null) {
textShadow.setText(descr);
}

View file

@ -11,6 +11,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuController.MenuType;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.OsmandMapLayer;
@ -382,6 +383,14 @@ public class MapContextMenu extends MenuTitleController {
}
}
public TitleProgressController getTitleProgressController() {
if (menuController != null) {
return menuController.getTitleProgressController();
} else {
return null;
}
}
public boolean fabVisible() {
return menuController == null || menuController.fabVisible();
}

View file

@ -26,6 +26,7 @@ import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import net.osmand.data.LatLon;
@ -36,7 +37,9 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
@ -45,7 +48,7 @@ import static net.osmand.plus.mapcontextmenu.MenuBuilder.SHADOW_HEIGHT_BOTTOM_DP
import static net.osmand.plus.mapcontextmenu.MenuBuilder.SHADOW_HEIGHT_TOP_DP;
public class MapContextMenuFragment extends Fragment {
public class MapContextMenuFragment extends Fragment implements DownloadEvents {
public static final String TAG = "MapContextMenuFragment";
@ -61,6 +64,7 @@ public class MapContextMenuFragment extends Fragment {
private TitleButtonController leftTitleButtonController;
private TitleButtonController rightTitleButtonController;
private TitleButtonController topRightTitleButtonController;
private TitleProgressController titleProgressController;
private int menuTopViewHeight;
private int menuTopShadowHeight;
@ -128,6 +132,7 @@ public class MapContextMenuFragment extends Fragment {
leftTitleButtonController = menu.getLeftTitleButtonController();
rightTitleButtonController = menu.getRightTitleButtonController();
topRightTitleButtonController = menu.getTopRightTitleButtonController();
titleProgressController = menu.getTitleProgressController();
map = getMapActivity().getMapView();
RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
@ -145,19 +150,24 @@ public class MapContextMenuFragment extends Fragment {
origMarkerY = box.getCenterPixelY();
}
IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent();
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
mainView = view.findViewById(R.id.context_menu_main);
// Title buttons
boolean showButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null)
&& (titleProgressController == null || !titleProgressController.visible);
final View titleButtonsContainer = view.findViewById(R.id.title_button_container);
titleButtonsContainer.setVisibility(
leftTitleButtonController != null || rightTitleButtonController != null ? View.VISIBLE : View.GONE);
titleButtonsContainer.setVisibility(showButtonsContainer ? View.VISIBLE : View.GONE);
// Left title button
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
final TextView titleButtonRightText = (TextView) view.findViewById(R.id.title_button_right_text);
if (leftTitleButtonController != null) {
leftTitleButton.setText(leftTitleButtonController.getCaption());
leftTitleButton.setText(leftTitleButtonController.caption);
leftTitleButton.setVisibility(leftTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
Drawable leftIcon = leftTitleButtonController.getLeftIcon();
if (leftIcon != null) {
@ -171,8 +181,8 @@ public class MapContextMenuFragment extends Fragment {
}
});
if (leftTitleButtonController.isNeedRightText()) {
titleButtonRightText.setText(leftTitleButtonController.getRightTextCaption());
if (leftTitleButtonController.needRightText) {
titleButtonRightText.setText(leftTitleButtonController.rightTextCaption);
} else {
titleButtonRightText.setVisibility(View.GONE);
}
@ -184,7 +194,8 @@ public class MapContextMenuFragment extends Fragment {
// Right title button
final Button rightTitleButton = (Button) view.findViewById(R.id.title_button_right);
if (rightTitleButtonController != null) {
rightTitleButton.setText(rightTitleButtonController.getCaption());
rightTitleButton.setText(rightTitleButtonController.caption);
rightTitleButton.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
Drawable leftIcon = rightTitleButtonController.getLeftIcon();
if (leftIcon != null) {
@ -204,7 +215,8 @@ public class MapContextMenuFragment extends Fragment {
// Top Right title button
final Button topRightTitleButton = (Button) view.findViewById(R.id.title_button_top_right);
if (topRightTitleButtonController != null) {
topRightTitleButton.setText(topRightTitleButtonController.getCaption());
topRightTitleButton.setText(topRightTitleButtonController.caption);
topRightTitleButton.setVisibility(topRightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
Drawable leftIcon = topRightTitleButtonController.getLeftIcon();
if (leftIcon != null) {
@ -221,6 +233,25 @@ public class MapContextMenuFragment extends Fragment {
topRightTitleButton.setVisibility(View.GONE);
}
// Progress bar
final View titleProgressContainer = view.findViewById(R.id.title_progress_container);
if (titleProgressController != null) {
updateProgress();
final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton);
progressButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark,
light ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
progressButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
titleProgressController.buttonPressed();
}
});
} else {
titleProgressContainer.setVisibility(View.GONE);
}
if (menu.isLandscapeLayout()) {
mainView.setLayoutParams(new FrameLayout.LayoutParams(dpToPx(menu.getLandscapeWidthDp()),
ViewGroup.LayoutParams.MATCH_PARENT));
@ -387,9 +418,6 @@ public class MapContextMenuFragment extends Fragment {
buildHeader();
IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent();
// FAB
fabView = (ImageView)view.findViewById(R.id.context_menu_fab_view);
if (menu.fabVisible()) {
@ -462,6 +490,27 @@ public class MapContextMenuFragment extends Fragment {
menuFullHeightMax = menuTitleHeight + (menuBottomViewHeight > 0 ? menuBottomViewHeight : -dpToPx(SHADOW_HEIGHT_BOTTOM_DP));
}
private void updateProgress() {
final View titleProgressContainer = view.findViewById(R.id.title_progress_container);
titleProgressContainer.setVisibility(titleProgressController.visible ? View.VISIBLE : View.GONE);
final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
final TextView progressTitle = (TextView) view.findViewById(R.id.progressTitle);
final TextView progressPercent = (TextView) view.findViewById(R.id.progressPercent);
progressTitle.setText(titleProgressController.caption);
if (titleProgressController.indeterminate) {
progressPercent.setVisibility(View.GONE);
} else {
progressPercent.setVisibility(View.VISIBLE);
progressPercent.setText(titleProgressController.progress + "%");
}
progressBar.setIndeterminate(titleProgressController.indeterminate);
progressBar.setProgress(titleProgressController.progress);
final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton);
progressButton.setVisibility(titleProgressController.buttonVisible ? View.VISIBLE : View.GONE);
}
private void buildHeader() {
IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent();
@ -772,6 +821,22 @@ public class MapContextMenuFragment extends Fragment {
.addToBackStack(TAG).commit();
}
//DownloadEvents
@Override
public void newDownloadIndexes() {
}
@Override
public void downloadInProgress() {
}
@Override
public void downloadHasFinished() {
}
private MapActivity getMapActivity() {
return (MapActivity)getActivity();
}

View file

@ -47,43 +47,17 @@ public abstract class MenuController extends BaseMenuController {
private MenuBuilder builder;
private int currentMenuState;
private MenuType menuType = MenuType.STANDARD;
private PointDescription pointDescription;
protected TitleButtonController leftTitleButtonController;
protected TitleButtonController rightTitleButtonController;
protected TitleButtonController topRightTitleButtonController;
public abstract class TitleButtonController {
protected TitleProgressController titleProgressController;
public String caption = "";
public int leftIconId = 0;
public boolean needRightText = false;
public String rightTextCaption = "";
public String getCaption() {
return caption;
}
public boolean isNeedRightText() {
return needRightText;
}
public String getRightTextCaption() {
return rightTextCaption;
}
public Drawable getLeftIcon() {
if (leftIconId != 0) {
return getIcon(leftIconId, getResIdFromAttribute(R.attr.contextMenuButtonColor));
} else {
return null;
}
}
public abstract void buttonPressed();
}
public MenuController(MenuBuilder builder, MapActivity mapActivity) {
public MenuController(MenuBuilder builder, PointDescription pointDescription, MapActivity mapActivity) {
super(mapActivity);
this.pointDescription = pointDescription;
this.builder = builder;
this.currentMenuState = getInitialMenuState();
}
@ -98,23 +72,23 @@ public abstract class MenuController extends BaseMenuController {
MenuController menuController = null;
if (object != null) {
if (object instanceof Amenity) {
menuController = new AmenityMenuController(app, mapActivity, (Amenity) object);
menuController = new AmenityMenuController(app, mapActivity, pointDescription, (Amenity) object);
} else if (object instanceof FavouritePoint) {
menuController = new FavouritePointMenuController(app, mapActivity, (FavouritePoint) object);
menuController = new FavouritePointMenuController(app, mapActivity, pointDescription, (FavouritePoint) object);
} else if (object instanceof SearchHistoryHelper.HistoryEntry) {
menuController = new HistoryMenuController(app, mapActivity, (SearchHistoryHelper.HistoryEntry) object);
menuController = new HistoryMenuController(app, mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object);
} else if (object instanceof TargetPoint) {
menuController = new TargetPointMenuController(app, mapActivity, (TargetPoint) object);
menuController = new TargetPointMenuController(app, mapActivity, pointDescription, (TargetPoint) object);
} else if (object instanceof OsMoDevice) {
menuController = new OsMoMenuController(app, mapActivity, (OsMoDevice) object);
menuController = new OsMoMenuController(app, mapActivity, pointDescription, (OsMoDevice) object);
} else if (object instanceof Recording) {
menuController = new AudioVideoNoteMenuController(app, mapActivity, (Recording) object);
menuController = new AudioVideoNoteMenuController(app, mapActivity, pointDescription, (Recording) object);
} else if (object instanceof OsmPoint) {
menuController = new EditPOIMenuController(app, mapActivity, pointDescription, (OsmPoint) object);
} else if (object instanceof WptPt) {
menuController = new WptPtMenuController(app, mapActivity, (WptPt) object);
menuController = new WptPtMenuController(app, mapActivity, pointDescription, (WptPt) object);
} else if (object instanceof BinaryMapDataObject) {
menuController = new MapDataMenuController(app, mapActivity, (BinaryMapDataObject) object);
menuController = new MapDataMenuController(app, mapActivity, pointDescription, (BinaryMapDataObject) object);
} else if (object instanceof LatLon) {
if (pointDescription.isParking()) {
menuController = new ParkingPositionMenuController(app, mapActivity, pointDescription);
@ -146,6 +120,10 @@ public abstract class MenuController extends BaseMenuController {
}
}
public PointDescription getPointDescription() {
return pointDescription;
}
public int getInitialMenuState() {
if (isLandscapeLayout()) {
return MenuState.FULL_SCREEN;
@ -218,6 +196,10 @@ public abstract class MenuController extends BaseMenuController {
return topRightTitleButtonController;
}
public TitleProgressController getTitleProgressController() {
return titleProgressController;
}
public boolean fabVisible() {
return true;
}
@ -257,4 +239,45 @@ public abstract class MenuController extends BaseMenuController {
public void share(LatLon latLon, String title) {
ShareMenu.show(latLon, title, getMapActivity());
}
public abstract class TitleButtonController {
public String caption = "";
public int leftIconId = 0;
public boolean needRightText = false;
public String rightTextCaption = "";
public boolean visible = true;
public Drawable getLeftIcon() {
if (leftIconId != 0) {
return getIcon(leftIconId, getResIdFromAttribute(R.attr.contextMenuButtonColor));
} else {
return null;
}
}
public abstract void buttonPressed();
}
public abstract class TitleProgressController {
public String caption = "";
public int progress;
public boolean indeterminate;
public boolean visible;
public boolean buttonVisible;
public void setIndexesDownloadMode() {
progress = 0;
caption = getMapActivity().getString(R.string.downloading_list_indexes);
indeterminate = true;
buttonVisible = false;
}
public void setMapDownloadMode() {
indeterminate = false;
buttonVisible = true;
}
public abstract void buttonPressed();
}
}

View file

@ -151,6 +151,7 @@ public abstract class MenuTitleController {
nameStr = streetStr;
addressUnknown = false;
streetStr = "";
getPointDescription().setName(nameStr);
}
getMapActivity().runOnUiThread(new Runnable() {
public void run() {

View file

@ -17,8 +17,8 @@ public class AmenityMenuController extends MenuController {
private final Amenity amenity;
public AmenityMenuController(OsmandApplication app, MapActivity mapActivity, final Amenity amenity) {
super(new AmenityMenuBuilder(app, amenity), mapActivity);
public AmenityMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final Amenity amenity) {
super(new AmenityMenuBuilder(app, amenity), pointDescription, mapActivity);
this.amenity = amenity;
}
@ -78,6 +78,6 @@ public class AmenityMenuController extends MenuController {
@Override
public String getNameStr() {
return amenity.getName(getMapActivity().getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get());
return getPointDescription().getName();
}
}

View file

@ -7,6 +7,7 @@ import android.net.Uri;
import net.osmand.access.AccessibleAlertBuilder;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
@ -16,23 +17,15 @@ import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.builders.AudioVideoNoteMenuBuilder;
import java.io.File;
import java.text.DateFormat;
import java.util.Date;
public class AudioVideoNoteMenuController extends MenuController {
private Recording recording;
private DateFormat dateFormat;
private DateFormat timeFormat;
private AudioVideoNotesPlugin plugin;
public AudioVideoNoteMenuController(OsmandApplication app, MapActivity mapActivity, final Recording recording) {
super(new AudioVideoNoteMenuBuilder(app, recording), mapActivity);
public AudioVideoNoteMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final Recording recording) {
super(new AudioVideoNoteMenuBuilder(app, recording), pointDescription, mapActivity);
this.recording = recording;
plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
dateFormat = android.text.format.DateFormat.getMediumDateFormat(mapActivity);
timeFormat = android.text.format.DateFormat.getTimeFormat(mapActivity);
leftTitleButtonController = new TitleButtonController() {
@Override
@ -94,15 +87,7 @@ public class AudioVideoNoteMenuController extends MenuController {
@Override
public String getNameStr() {
File file = recording.getFile();
String recType = recording.getType(getMapActivity());
String recName = recording.getName(getMapActivity());
if (file != null && recType.equals(recName)) {
Date date = new Date(recording.getFile().lastModified());
return dateFormat.format(date) + " " + timeFormat.format(date);
} else {
return recording.getName(getMapActivity());
}
return getPointDescription().getName();
}
@Override

View file

@ -30,14 +30,12 @@ import java.util.Map;
public class EditPOIMenuController extends MenuController {
private PointDescription pointDescription;
private OsmEditingPlugin plugin;
private String pointTypeStr;
private ProgressDialogPoiUploader poiUploader;
public EditPOIMenuController(OsmandApplication app, final MapActivity mapActivity, final PointDescription pointDescription, final OsmPoint osmPoint) {
super(new EditPOIMenuBuilder(app, osmPoint), mapActivity);
this.pointDescription = pointDescription;
public EditPOIMenuController(OsmandApplication app, final MapActivity mapActivity, PointDescription pointDescription, final OsmPoint osmPoint) {
super(new EditPOIMenuBuilder(app, osmPoint), pointDescription, mapActivity);
plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
poiUploader = new ProgressDialogPoiUploader() {
@ -138,7 +136,7 @@ public class EditPOIMenuController extends MenuController {
@Override
public String getNameStr() {
return pointDescription.getSimpleName(getMapActivity(), false);
return getPointDescription().getName();
}
@Override

View file

@ -4,6 +4,7 @@ import android.graphics.drawable.Drawable;
import android.support.v4.app.Fragment;
import net.osmand.data.FavouritePoint;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -17,8 +18,8 @@ public class FavouritePointMenuController extends MenuController {
private FavouritePoint fav;
public FavouritePointMenuController(OsmandApplication app, MapActivity mapActivity, final FavouritePoint fav) {
super(new FavouritePointMenuBuilder(app, fav), mapActivity);
public FavouritePointMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
super(new FavouritePointMenuBuilder(app, fav), pointDescription, mapActivity);
this.fav = fav;
}
@ -70,6 +71,6 @@ public class FavouritePointMenuController extends MenuController {
@Override
public String getNameStr() {
return fav.getName();
return getPointDescription().getName();
}
}

View file

@ -2,6 +2,7 @@ package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -14,8 +15,8 @@ public class HistoryMenuController extends MenuController {
private HistoryEntry entry;
public HistoryMenuController(OsmandApplication app, MapActivity mapActivity, final HistoryEntry entry) {
super(new MenuBuilder(app), mapActivity);
public HistoryMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final HistoryEntry entry) {
super(new MenuBuilder(app), pointDescription, mapActivity);
this.entry = entry;
}
@ -46,7 +47,7 @@ public class HistoryMenuController extends MenuController {
@Override
public String getNameStr() {
return entry.getName().getSimpleName(getMapActivity(), false);
return getPointDescription().getName();
}
@Override

View file

@ -12,6 +12,8 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController;
@ -19,8 +21,8 @@ public class MapDataMenuController extends MenuController {
private WorldRegion region;
private String regionName;
public MapDataMenuController(OsmandApplication app, MapActivity mapActivity, final BinaryMapDataObject dataObject) {
super(new MenuBuilder(app), mapActivity);
public MapDataMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final BinaryMapDataObject dataObject) {
super(new MenuBuilder(app), pointDescription, mapActivity);
OsmandRegions osmandRegions = app.getRegions();
String fullName = osmandRegions.getFullName(dataObject);
final WorldRegion region = osmandRegions.getRegionData(fullName);
@ -31,6 +33,9 @@ public class MapDataMenuController extends MenuController {
regionName = dataObject.getName();
}
boolean hasIndexes = app.getDownloadThread().getIndexes().isDownloadedFromInternet;
boolean isDownloading = false; //todo
leftTitleButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {
@ -62,8 +67,26 @@ public class MapDataMenuController extends MenuController {
// todo other maps
}
};
topRightTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_others);
topRightTitleButtonController.caption = getMapActivity().getString(R.string.download_select_map_types);
topRightTitleButtonController.visible = hasIndexes && !isDownloading;
titleProgressController = new TitleProgressController() {
@Override
public void buttonPressed() {
// todo cancel download
}
};
if (!hasIndexes) {
titleProgressController.setIndexesDownloadMode();
titleProgressController.visible = true;
getMapActivity().getMyApplication().getDownloadThread().runReloadIndexFiles();
} else if (isDownloading) {
titleProgressController.setMapDownloadMode();
titleProgressController.caption = "Downloading..."; // todo
titleProgressController.visible = true;
} else {
titleProgressController.visible = false;
}
}
@Override

View file

@ -11,11 +11,8 @@ import net.osmand.plus.mapcontextmenu.MenuController;
public class MyLocationMenuController extends MenuController {
private PointDescription pointDescription;
public MyLocationMenuController(OsmandApplication app, MapActivity mapActivity, final PointDescription pointDescription) {
super(new MenuBuilder(app), mapActivity);
this.pointDescription = pointDescription;
public MyLocationMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription) {
super(new MenuBuilder(app), pointDescription, mapActivity);
}
@Override
@ -31,6 +28,6 @@ public class MyLocationMenuController extends MenuController {
@Override
public String getNameStr() {
return pointDescription.getTypeName();
return getPointDescription().getName();
}
}

View file

@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
import net.osmand.Location;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
@ -15,8 +16,8 @@ public class OsMoMenuController extends MenuController {
private OsMoDevice device;
public OsMoMenuController(OsmandApplication app, MapActivity mapActivity, final OsMoDevice device) {
super(new MenuBuilder(app), mapActivity);
public OsMoMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final OsMoDevice device) {
super(new MenuBuilder(app), pointDescription, mapActivity);
this.device = device;
}
@ -41,7 +42,7 @@ public class OsMoMenuController extends MenuController {
@Override
public String getNameStr() {
return device.getVisibleName();
return getPointDescription().getName();
}
@Override

View file

@ -14,13 +14,11 @@ import net.osmand.util.Algorithms;
public class ParkingPositionMenuController extends MenuController {
private PointDescription pointDescription;
private ParkingPositionPlugin plugin;
private String parkingDescription = "";
public ParkingPositionMenuController(OsmandApplication app, MapActivity mapActivity, final PointDescription pointDescription) {
super(new MenuBuilder(app), mapActivity);
this.pointDescription = pointDescription;
super(new MenuBuilder(app), pointDescription, mapActivity);
plugin = OsmandPlugin.getPlugin(ParkingPositionPlugin.class);
if (plugin != null) {
StringBuilder sb = new StringBuilder();
@ -60,7 +58,7 @@ public class ParkingPositionMenuController extends MenuController {
@Override
public String getNameStr() {
return pointDescription.getTypeName();
return getPointDescription().getName();
}
@Override

View file

@ -13,11 +13,8 @@ import net.osmand.util.Algorithms;
public class PointDescriptionMenuController extends MenuController {
private PointDescription pointDescription;
public PointDescriptionMenuController(OsmandApplication app, MapActivity mapActivity, final PointDescription pointDescription) {
super(new MenuBuilder(app), mapActivity);
this.pointDescription = pointDescription;
super(new MenuBuilder(app), pointDescription, mapActivity);
}
@Override
@ -27,7 +24,7 @@ public class PointDescriptionMenuController extends MenuController {
@Override
public boolean needTypeStr() {
String typeName = pointDescription.getTypeName();
String typeName = getPointDescription().getTypeName();
return (typeName != null && !Algorithms.isEmpty(typeName));
}
@ -38,7 +35,7 @@ public class PointDescriptionMenuController extends MenuController {
@Override
public Drawable getLeftIcon() {
return getIcon(SearchHistoryFragment.getItemIcon(pointDescription));
return getIcon(SearchHistoryFragment.getItemIcon(getPointDescription()));
}
@Override
@ -52,13 +49,13 @@ public class PointDescriptionMenuController extends MenuController {
@Override
public String getNameStr() {
return pointDescription.getSimpleName(getMapActivity(), false);
return getPointDescription().getName();
}
@Override
public String getTypeStr() {
if (needTypeStr()) {
return pointDescription.getTypeName();
return getPointDescription().getTypeName();
} else {
return "";
}
@ -66,6 +63,6 @@ public class PointDescriptionMenuController extends MenuController {
@Override
public boolean needStreetName() {
return !pointDescription.isAddress();
return !getPointDescription().isAddress();
}
}

View file

@ -1,7 +1,9 @@
package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
import android.util.Log;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
@ -15,8 +17,8 @@ public class TargetPointMenuController extends MenuController {
private TargetPoint targetPoint;
public TargetPointMenuController(OsmandApplication app, MapActivity mapActivity, final TargetPoint targetPoint) {
super(new MenuBuilder(app), mapActivity);
public TargetPointMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final TargetPoint targetPoint) {
super(new MenuBuilder(app), pointDescription, mapActivity);
this.targetPoint = targetPoint;
leftTitleButtonController = new TitleButtonController() {
@Override
@ -41,7 +43,7 @@ public class TargetPointMenuController extends MenuController {
@Override
public boolean needTypeStr() {
return true;
return !Algorithms.isEmpty(getNameStr());
}
@Override
@ -63,14 +65,7 @@ public class TargetPointMenuController extends MenuController {
@Override
public String getNameStr() {
String name = "";
if (targetPoint.getOriginalPointDescription() != null) {
name = targetPoint.getOriginalPointDescription().getSimpleName(getMapActivity(), false);
}
if (Algorithms.isEmpty(name)) {
name = getTypeStr();
}
return name;
return getPointDescription().getName();
}
@Override
@ -78,13 +73,8 @@ public class TargetPointMenuController extends MenuController {
return targetPoint.getPointDescription(getMapActivity()).getTypeName();
}
@Override
public boolean displayStreetNameinTitle() {
return true;
}
@Override
public boolean needStreetName() {
return Algorithms.isEmpty(targetPoint.getOnlyName());
return !needTypeStr();
}
}

View file

@ -2,22 +2,21 @@ package net.osmand.plus.mapcontextmenu.controllers;
import android.graphics.drawable.Drawable;
import net.osmand.data.PointDescription;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.builders.FavouritePointMenuBuilder;
import net.osmand.plus.mapcontextmenu.builders.WptPtMenuBuilder;
import net.osmand.util.Algorithms;
public class WptPtMenuController extends MenuController {
private WptPt wpt;
public WptPtMenuController(OsmandApplication app, MapActivity mapActivity, final WptPt wpt) {
super(new WptPtMenuBuilder(app, wpt), mapActivity);
public WptPtMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final WptPt wpt) {
super(new WptPtMenuBuilder(app, wpt), pointDescription, mapActivity);
this.wpt = wpt;
}
@ -45,7 +44,7 @@ public class WptPtMenuController extends MenuController {
@Override
public boolean needTypeStr() {
return true;
return wpt.category != null;
}
@Override
@ -55,16 +54,13 @@ public class WptPtMenuController extends MenuController {
@Override
public Drawable getSecondLineIcon() {
return getIcon(R.drawable.ic_small_group);
if (wpt.category != null) {
return getIcon(R.drawable.ic_small_group);
} else {
return null;
}
}
/*
@Override
public int getFavActionIconId() {
return R.drawable.ic_action_edit_dark;
}
*/
@Override
public String getTypeStr() {
return wpt.category != null ? wpt.category : getMapActivity().getString(R.string.shared_string_none);
@ -72,6 +68,6 @@ public class WptPtMenuController extends MenuController {
@Override
public String getNameStr() {
return wpt.name != null ? wpt.name : getMapActivity().getString(R.string.gpx_wpt);
return getPointDescription().getName();
}
}

View file

@ -241,11 +241,13 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye
@Override
public PointDescription getObjectName(Object o) {
// if(o instanceof OsMoDevice) {
// return map.getString(R.string.osmo_user_name) + " " + ((OsMoDevice) o).getVisibleName();
// }
String desc = getObjectDescription(o);
return desc == null ? null : new PointDescription(PointDescription.POINT_TYPE_MARKER, desc);
if(o instanceof OsMoDevice) {
return new PointDescription(PointDescription.POINT_TYPE_MARKER, map.getString(R.string.osmo_user_name) + " " + ((OsMoDevice) o).getVisibleName());
} else {
return null;
}
//String desc = getObjectDescription(o);
//return desc == null ? null : new PointDescription(PointDescription.POINT_TYPE_MARKER, desc);
}
public void refresh() {

View file

@ -139,7 +139,7 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
@Override
public PointDescription getObjectName(Object o) {
return new PointDescription(PointDescription.POINT_TYPE_PARKING_MARKER,
view.getContext().getString(R.string.osmand_parking_position_name), "");
view.getContext().getString(R.string.osmand_parking_position_name));
}
public void refresh() {

View file

@ -334,7 +334,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
private boolean mIgnoreEvent = false;
private Calendar cal = Calendar.getInstance();
@Override
public void onTimeChanged(TimePicker timePicker, int hourOfDay, int minute) {
if (mIgnoreEvent) {