This commit is contained in:
GaidamakUA 2015-10-23 15:58:49 +03:00
commit 7e8ddaee17
40 changed files with 493 additions and 355 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -81,6 +81,19 @@
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
<Button
android:id="@+id/title_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:gravity="left|center_vertical"
android:text="@string/osmand_parking_delete"
android:background="?android:selectableItemBackground"
android:textColor="?attr/contextMenuButtonColor"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>

View file

@ -2193,4 +2193,5 @@
<string name="simulate_initial_startup">Simuler første opstart</string>
<string name="share_menu_location">Del placering</string>
<string name="shared_string_send">Send</string>
</resources>
<string name="hello_blank_fragment">Hej tomme fragment</string>
</resources>

View file

@ -2214,4 +2214,6 @@ Afghanistan, Albanie, Algérie, Allemagne, Andorre, Angola, Anguilla, Antigua-et
<string name="share_geo">geo :</string>
<string name="share_qr_code">QR-Code</string>
<string name="share_menu_title">Partager ce lieu</string>
<string name="share_menu_location">Partager ce lieu</string>
<string name="shared_string_send">Envoyer</string>
</resources>

View file

@ -2225,7 +2225,7 @@ Si consiglia di aggiungere uno o più punti intermedi per migliorarne le prestaz
<string name="favorite_category_name">Nome della categoria</string>
<string name="favorite_category_add_new_title">Aggiungi una nuova categoria</string>
<string name="confirm_download_roadmaps">Sei sicuro di volere scaricare mappe solo stradali anche se disponi di mappe complete?</string>
<string name="value_downloaded_from_max">%1$.1f da %2$.1f MB</string>
<string name="value_downloaded_from_max">%1$.1f di %2$.1f MB</string>
<string name="file_size_in_mb">%.1f MB</string>
<string name="update_all">Aggiorna tutto (%1$s MB)</string>
<string name="free_downloads_used">Download gratuiti utilizzati</string>
@ -2235,4 +2235,5 @@ Si consiglia di aggiungere uno o più punti intermedi per migliorarne le prestaz
<string name="simulate_initial_startup_descr">"Resetta l\'indicatore del primo avvio, non modificare tutte le altre impostazioni"</string>
<string name="simulate_initial_startup">Simula il primo avvio</string>
<string name="share_menu_location">Condivisi la posizione</string>
</resources>
<string name="hello_blank_fragment">Pulisci il segmento</string>
</resources>

View file

@ -2216,4 +2216,25 @@
<string name="poi_tomb_crypt">Тип: крипта</string>
<string name="poi_tomb_pyramid">Тип: пирамида</string>
<string name="poi_historic_civilization_ancient_roman">Цивилизация: древнеримская</string>
<string name="poi_historic_civilization_nuragic">Цивилизация: нурагическая</string>
<string name="poi_historic_civilization_etruscan">Цивилизация: этрусская</string>
<string name="poi_historic_civilization_prehistoric">Цивилизация: доисторическая</string>
<string name="poi_historic_civilization_ancient_greek">Цивилизация: древнегреческая</string>
<string name="poi_historic_civilization_roman">Цивилизация: римская</string>
<string name="poi_historic_civilization_byzantine">Цивилизация: византийская</string>
<string name="poi_historic_civilization_imperial_chinese">Цивилизация: китайская</string>
<string name="poi_historic_civilization_ancient_egyptian">Цивилизация: древнеегипетская</string>
<string name="poi_historic_civilization_celtic">Цивилизация: кельтская</string>
<string name="poi_historic_civilization_western_roman">Цивилизация: западная римская</string>
<string name="poi_historic_civilization_mycenaean">Цивилизация: микенская</string>
<string name="poi_historic_civilization_dacian">Цивилизация: гето-дакская</string>
<string name="poi_historic_civilization_hernici">Цивилизация: герники</string>
<string name="poi_historic_civilization_greek_egyptian">Цивилизация: греко-египетская</string>
<string name="poi_historic_civilization_roman_and_byzantine_egyptian">Цивилизация: римская и византийско-египетская</string>
<string name="poi_historic_civilization_helladic">Цивилизация: элладская</string>
<string name="poi_historic_civilization_cycladic">Цивилизация: кикладская</string>
<string name="poi_historic_civilization_minoan">Цивилизация: минойская</string>
<string name="poi_historic_civilization_tiahuanacota">Цивилизация: тиуанако</string>
</resources>

View file

@ -979,7 +979,7 @@
<string name="osmand_parking_warning_text">Напоминание об ограниченном времени стоянки автомобиля уже добавлено в календарь. Вам будет необходимо удалить его вручную.</string>
<string name="osmand_parking_time_limit_title">Задайте максимальное время стоянки</string>
<string name="osmand_parking_delete_confirm">Хотите удалить расположение запаркованного автомобиля?</string>
<string name="osmand_parking_delete">Удалить метку места стоянки</string>
<string name="osmand_parking_delete">Удалить точку парковки</string>
<string name="osmand_parking_choose_type">Выберите тип стоянки</string>
<string name="osmand_parking_lim_text">С ограничением по времени</string>
<string name="osmand_parking_no_lim_text">Без ограничения времени</string>
@ -1005,7 +1005,7 @@
<string name="osmand_parking_hours">Часов</string>
<string name="osmand_parking_minutes">Минут</string>
<string name="osmand_parking_position_description_add_time">Автомобиль был припаркован в:</string>
<string name="osmand_parking_position_description_add_time">Припаркован в:</string>
<string name="use_compass_navigation_descr">Использовать навигацию по компасу, если направление не определено</string>
<string name="use_compass_navigation">Использовать компас</string>
<string name="route_updated_loc_found">Маршрут будет пересчитан после определения местоположения</string>

View file

@ -2170,4 +2170,5 @@
<string name="share_geo">地理:</string>
<string name="share_menu_location">分享位置</string>
<string name="shared_string_send">發送</string>
</resources>
<string name="hello_blank_fragment">哈囉,成空的片段</string>
</resources>

View file

@ -2220,4 +2220,25 @@
<string name="poi_tomb_crypt">Type: crypt</string>
<string name="poi_tomb_pyramid">Type: pyramid</string>
<string name="poi_historic_civilization_ancient_roman">Civilization: ancient roman</string>
<string name="poi_historic_civilization_nuragic">Civilization: nuragic</string>
<string name="poi_historic_civilization_etruscan">Civilization: etruscan</string>
<string name="poi_historic_civilization_prehistoric">Civilization: prehistoric</string>
<string name="poi_historic_civilization_ancient_greek">Civilization: ancient greek</string>
<string name="poi_historic_civilization_roman">Civilization: roman</string>
<string name="poi_historic_civilization_byzantine">Civilization: byzantine</string>
<string name="poi_historic_civilization_imperial_chinese">Civilization: imperial chinese</string>
<string name="poi_historic_civilization_ancient_egyptian">Civilization: ancient egyptian</string>
<string name="poi_historic_civilization_celtic">Civilization: celtic</string>
<string name="poi_historic_civilization_western_roman">Civilization: western roman</string>
<string name="poi_historic_civilization_mycenaean">Civilization: mycenaean</string>
<string name="poi_historic_civilization_dacian">Civilization: dacian</string>
<string name="poi_historic_civilization_hernici">Civilization: hernici</string>
<string name="poi_historic_civilization_greek_egyptian">Civilization: greek egyptian</string>
<string name="poi_historic_civilization_roman_and_byzantine_egyptian">Civilization: roman and byzantine egyptian</string>
<string name="poi_historic_civilization_helladic">Civilization: helladic</string>
<string name="poi_historic_civilization_cycladic">Civilization: cycladic</string>
<string name="poi_historic_civilization_minoan">Civilization: minoan</string>
<string name="poi_historic_civilization_tiahuanacota">Civilization: tiahuanacota</string>
</resources>

View file

@ -32,6 +32,7 @@ public class PointDescription implements Serializable {
public static final String POINT_TYPE_ADDRESS = "address";
public static final String POINT_TYPE_OSM_NOTE= "osm_note";
public static final String POINT_TYPE_MARKER = "marker";
public static final String POINT_TYPE_PARKING_MARKER = "parking_marker";
public static final String POINT_TYPE_AUDIO_NOTE = "audionote";
public static final String POINT_TYPE_VIDEO_NOTE = "videonote";
public static final String POINT_TYPE_PHOTO_NOTE = "photonote";
@ -183,6 +184,10 @@ public class PointDescription implements Serializable {
return POINT_TYPE_TARGET.equals(type);
}
public boolean isParking() {
return POINT_TYPE_PARKING_MARKER.equals(type);
}
@Override
public int hashCode() {
final int prime = 31;

View file

@ -138,7 +138,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
if (mapInfoLayer != null ) {
distanceControl = createDistanceControl(activity);
mapInfoLayer.registerSideWidget(distanceControl,
R.drawable.ic_action_ruler_dark, R.string.map_widget_distancemeasurement, "distance.measurement", false, 21);
R.drawable.ic_action_ruler, R.string.map_widget_distancemeasurement, "distance.measurement", false, 21);
mapInfoLayer.recreateControls();
updateText();
}

View file

@ -21,7 +21,7 @@ import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.mapcontextmenu.details.AmenityMenuController;
import net.osmand.plus.mapcontextmenu.details.FavouritePointMenuController;
import net.osmand.plus.mapcontextmenu.details.HistoryMenuController;
import net.osmand.plus.mapcontextmenu.details.MenuController;
import net.osmand.plus.mapcontextmenu.details.ParkingPositionController;
import net.osmand.plus.mapcontextmenu.details.PointDescriptionMenuController;
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
import net.osmand.plus.routing.RoutingHelper;
@ -220,6 +220,10 @@ public class MapContextMenu {
menuController = new FavouritePointMenuController(app, mapActivity, (FavouritePoint) object);
} else if (object instanceof HistoryEntry) {
menuController = new HistoryMenuController(app, mapActivity, (HistoryEntry) object);
} else if (object instanceof LatLon) {
if (pointDescription.isParking()) {
menuController = new ParkingPositionController(app, mapActivity, pointDescription, (LatLon) object);
}
}
} else {
menuController = new PointDescriptionMenuController(app, mapActivity, pointDescription, latLon);
@ -370,10 +374,6 @@ public class MapContextMenu {
});
}
public int getFabIconId() {
return mapActivity.getMapActions().getRouteMode(latLon).getSmallIconDark();
}
public void fabPressed() {
mapActivity.getMapActions().directionTo(latLon.getLatitude(), latLon.getLongitude());
hide();
@ -527,4 +527,21 @@ public class MapContextMenu {
}
}
public boolean hasTitleButton() {
return menuController != null && menuController.hasTitleButton();
}
public String getTitleButtonCaption() {
if (menuController != null) {
return menuController.getTitleButtonCaption();
} else {
return "";
}
}
public void titleButtonPressed() {
if (menuController != null) {
menuController.titleButtonPressed();
}
}
}

View file

@ -21,6 +21,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.DecelerateInterpolator;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
@ -35,13 +36,12 @@ 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.mapcontextmenu.details.MenuController;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import static net.osmand.plus.mapcontextmenu.details.MenuBuilder.SHADOW_HEIGHT_BOTTOM_DP;
import static net.osmand.plus.mapcontextmenu.details.MenuBuilder.SHADOW_HEIGHT_TOP_DP;
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 {
@ -150,6 +150,18 @@ public class MapContextMenuFragment extends Fragment {
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
mainView = view.findViewById(R.id.context_menu_main);
Button titleButton = (Button) view.findViewById(R.id.title_button);
titleButton.setVisibility(menu.hasTitleButton() ? View.VISIBLE : View.GONE);
if (menu.hasTitleButton()) {
titleButton.setText(menu.getTitleButtonCaption());
titleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
menu.titleButtonPressed();
}
});
}
if (menu.isLandscapeLayout()) {
mainView.setLayoutParams(new FrameLayout.LayoutParams(dpToPx(menu.getLandscapeWidthDp()),
ViewGroup.LayoutParams.MATCH_PARENT));

View file

@ -0,0 +1,161 @@
package net.osmand.plus.mapcontextmenu;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.text.util.Linkify;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.render.RenderingIcons;
import java.util.LinkedList;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
public abstract class MenuBuilder {
public static final float SHADOW_HEIGHT_TOP_DP = 16f;
public static final float SHADOW_HEIGHT_BOTTOM_DP = 6f;
protected OsmandApplication app;
protected LinkedList<PlainMenuItem> plainMenuItems;
private boolean firstRow;
private boolean light;
public class PlainMenuItem {
private int iconId;
private String text;
public PlainMenuItem(int iconId, String text) {
this.iconId = iconId;
this.text = text;
}
public int getIconId() {
return iconId;
}
public String getText() {
return text;
}
}
public MenuBuilder(OsmandApplication app) {
this.app = app;
plainMenuItems = new LinkedList<>();
light = app.getSettings().isLightContent();
}
public void build(View view) {
firstRow = true;
}
protected boolean isFirstRow() {
return firstRow;
}
protected void rowBuilt() {
firstRow = false;
}
protected void buildRow(final View view, Drawable icon, String text, int textColor) {
LinearLayout ll = new LinearLayout(view.getContext());
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llParams);
// Icon
LinearLayout llIcon = new LinearLayout(view.getContext());
llIcon.setOrientation(LinearLayout.HORIZONTAL);
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), isFirstRow() ? dpToPx(48f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(48f)));
llIcon.setGravity(Gravity.CENTER_VERTICAL);
ll.addView(llIcon);
ImageView iconView = new ImageView(view.getContext());
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
llIconParams.setMargins(dpToPx(16f), isFirstRow() ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP / 2f) : dpToPx(12f), dpToPx(32f), dpToPx(12f));
llIconParams.gravity = Gravity.CENTER_VERTICAL;
iconView.setLayoutParams(llIconParams);
iconView.setScaleType(ImageView.ScaleType.CENTER);
iconView.setImageDrawable(icon);
llIcon.addView(iconView);
// Text
LinearLayout llText = new LinearLayout(view.getContext());
llText.setOrientation(LinearLayout.VERTICAL);
ll.addView(llText);
TextView textView = new TextView(view.getContext());
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llTextParams.setMargins(0, isFirstRow() ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(8f), 0, dpToPx(8f));
textView.setLayoutParams(llTextParams);
textView.setTextSize(16);
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
textView.setAutoLinkMask(Linkify.ALL);
textView.setLinksClickable(true);
textView.setText(text);
if (textColor > 0) {
textView.setTextColor(view.getResources().getColor(textColor));
}
LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
llText.setLayoutParams(llTextViewParams);
llText.addView(textView);
((LinearLayout) view).addView(ll);
View horizontalLine = new View(view.getContext());
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
llHorLineParams.gravity = Gravity.BOTTOM;
horizontalLine.setLayoutParams(llHorLineParams);
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
((LinearLayout) view).addView(horizontalLine);
rowBuilt();
}
public void addPlainMenuItem(int iconId, String text) {
plainMenuItems.add(new PlainMenuItem(iconId, text));
}
public Drawable getRowIcon(int iconId) {
IconsCache iconsCache = app.getIconsCache();
boolean light = app.getSettings().isLightContent();
return iconsCache.getIcon(iconId,
light ? R.color.icon_color : R.color.icon_color_light);
}
public Drawable getRowIcon(Context ctx, String fileName) {
Bitmap iconBitmap = RenderingIcons.getIcon(ctx, fileName, false);
if (iconBitmap != null) {
return new BitmapDrawable(ctx.getResources(), iconBitmap);
} else {
return null;
}
}
public int dpToPx(float dp) {
Resources r = app.getResources();
return (int) TypedValue.applyDimension(
COMPLEX_UNIT_DIP,
dp,
r.getDisplayMetrics()
);
}
}

View file

@ -1,4 +1,4 @@
package net.osmand.plus.mapcontextmenu.details;
package net.osmand.plus.mapcontextmenu;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@ -25,12 +25,14 @@ public abstract class MenuController {
private int currentMenuState;
private boolean portraitMode;
private boolean largeDevice;
private boolean light;
public MenuController(MenuBuilder builder, MapActivity mapActivity) {
this.builder = builder;
this.mapActivity = mapActivity;
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
light = mapActivity.getMyApplication().getSettings().isLightContent();
this.currentMenuState = getInitialMenuState();
}
@ -134,10 +136,24 @@ public abstract class MenuController {
}
protected Drawable getIcon(int iconId) {
return getIcon(iconId, R.color.icon_color, R.color.icon_color_light);
}
protected Drawable getIcon(int iconId, int colorLightId, int colorDarkId) {
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
boolean light = mapActivity.getMyApplication().getSettings().isLightContent();
return iconsCache.getIcon(iconId,
light ? R.color.icon_color : R.color.icon_color_light);
light ? colorLightId : colorDarkId);
}
public boolean hasTitleButton() {
return false;
}
public String getTitleButtonCaption() {
return "";
}
public void titleButtonPressed() {
}
public boolean shouldShowButtons() {

View file

@ -1,11 +1,9 @@
package net.osmand.plus.mapcontextmenu.details;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.text.Html;
import android.text.TextUtils;
import android.text.util.Linkify;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
@ -19,6 +17,7 @@ import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.views.POIMapLayer;
import net.osmand.util.Algorithms;
import net.osmand.util.OpeningHoursParser;
@ -26,8 +25,6 @@ import net.osmand.util.OpeningHoursParser;
import java.util.Calendar;
import java.util.Map;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
public class AmenityMenuBuilder extends MenuBuilder {
private final Amenity amenity;
@ -41,7 +38,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
buildRow(view, getRowIcon(iconId), text, textColor, isWiki);
}
private void buildRow(final View view, Drawable icon, String text, int textColor, final boolean isWiki) {
protected void buildRow(final View view, Drawable icon, String text, int textColor, final boolean isWiki) {
boolean light = app.getSettings().isLightContent();
LinearLayout ll = new LinearLayout(view.getContext());

View file

@ -9,6 +9,7 @@ import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.util.Algorithms;

View file

@ -1,17 +1,11 @@
package net.osmand.plus.mapcontextmenu.details;
import android.graphics.drawable.Drawable;
import android.text.util.Linkify;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.data.FavouritePoint;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.util.Algorithms;
public class FavouritePointMenuBuilder extends MenuBuilder {
@ -27,69 +21,6 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
buildRow(view, getRowIcon(iconId), text, textColor);
}
private void buildRow(final View view, Drawable icon, String text, int textColor) {
boolean light = app.getSettings().isLightContent();
LinearLayout ll = new LinearLayout(view.getContext());
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llParams);
// Icon
LinearLayout llIcon = new LinearLayout(view.getContext());
llIcon.setOrientation(LinearLayout.HORIZONTAL);
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), isFirstRow() ? dpToPx(48f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(48f)));
llIcon.setGravity(Gravity.CENTER_VERTICAL);
ll.addView(llIcon);
ImageView iconView = new ImageView(view.getContext());
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
llIconParams.setMargins(dpToPx(16f), isFirstRow() ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP / 2f) : dpToPx(12f), dpToPx(32f), dpToPx(12f));
llIconParams.gravity = Gravity.CENTER_VERTICAL;
iconView.setLayoutParams(llIconParams);
iconView.setScaleType(ImageView.ScaleType.CENTER);
iconView.setImageDrawable(icon);
llIcon.addView(iconView);
// Text
LinearLayout llText = new LinearLayout(view.getContext());
llText.setOrientation(LinearLayout.VERTICAL);
ll.addView(llText);
TextView textView = new TextView(view.getContext());
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llTextParams.setMargins(0, isFirstRow() ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(8f), 0, dpToPx(8f));
textView.setLayoutParams(llTextParams);
textView.setTextSize(16);
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
textView.setAutoLinkMask(Linkify.ALL);
textView.setLinksClickable(true);
textView.setText(text);
if (textColor > 0) {
textView.setTextColor(view.getResources().getColor(textColor));
}
LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
llText.setLayoutParams(llTextViewParams);
llText.addView(textView);
((LinearLayout) view).addView(ll);
View horizontalLine = new View(view.getContext());
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
llHorLineParams.gravity = Gravity.BOTTOM;
horizontalLine.setLayoutParams(llHorLineParams);
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
((LinearLayout) view).addView(horizontalLine);
rowBuilt();
}
@Override
public void build(View view) {
super.build(view);

View file

@ -10,6 +10,7 @@ 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.editors.FavoritePointEditor;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;

View file

@ -1,17 +1,10 @@
package net.osmand.plus.mapcontextmenu.details;
import android.graphics.drawable.Drawable;
import android.text.util.Linkify;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
public class HistoryMenuBuilder extends MenuBuilder {
private final HistoryEntry entry;
@ -25,69 +18,6 @@ public class HistoryMenuBuilder extends MenuBuilder {
buildRow(view, getRowIcon(iconId), text, textColor);
}
private void buildRow(final View view, Drawable icon, String text, int textColor) {
boolean light = app.getSettings().isLightContent();
LinearLayout ll = new LinearLayout(view.getContext());
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llParams);
// Icon
LinearLayout llIcon = new LinearLayout(view.getContext());
llIcon.setOrientation(LinearLayout.HORIZONTAL);
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), isFirstRow() ? dpToPx(48f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(48f)));
llIcon.setGravity(Gravity.CENTER_VERTICAL);
ll.addView(llIcon);
ImageView iconView = new ImageView(view.getContext());
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
llIconParams.setMargins(dpToPx(16f), isFirstRow() ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP / 2f) : dpToPx(12f), dpToPx(32f), dpToPx(12f));
llIconParams.gravity = Gravity.CENTER_VERTICAL;
iconView.setLayoutParams(llIconParams);
iconView.setScaleType(ImageView.ScaleType.CENTER);
iconView.setImageDrawable(icon);
llIcon.addView(iconView);
// Text
LinearLayout llText = new LinearLayout(view.getContext());
llText.setOrientation(LinearLayout.VERTICAL);
ll.addView(llText);
TextView textView = new TextView(view.getContext());
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llTextParams.setMargins(0, isFirstRow() ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(8f), 0, dpToPx(8f));
textView.setLayoutParams(llTextParams);
textView.setTextSize(16);
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
textView.setAutoLinkMask(Linkify.ALL);
textView.setLinksClickable(true);
textView.setText(text);
if (textColor > 0) {
textView.setTextColor(view.getResources().getColor(textColor));
}
LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
llText.setLayoutParams(llTextViewParams);
llText.addView(textView);
((LinearLayout) view).addView(ll);
View horizontalLine = new View(view.getContext());
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
llHorLineParams.gravity = Gravity.BOTTOM;
horizontalLine.setLayoutParams(llHorLineParams);
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
((LinearLayout) view).addView(horizontalLine);
rowBuilt();
}
@Override
public void build(View view) {
super.build(view);

View file

@ -9,6 +9,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchHistoryFragment;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.mapcontextmenu.MenuController;
public class HistoryMenuController extends MenuController {

View file

@ -1,92 +0,0 @@
package net.osmand.plus.mapcontextmenu.details;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;
import android.view.View;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.render.RenderingIcons;
import java.util.LinkedList;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
public abstract class MenuBuilder {
public class PlainMenuItem {
private int iconId;
private String text;
public PlainMenuItem(int iconId, String text) {
this.iconId = iconId;
this.text = text;
}
public int getIconId() {
return iconId;
}
public String getText() {
return text;
}
}
public static final float SHADOW_HEIGHT_TOP_DP = 16f;
public static final float SHADOW_HEIGHT_BOTTOM_DP = 6f;
protected OsmandApplication app;
protected LinkedList<PlainMenuItem> plainMenuItems;
private boolean firstRow;
public MenuBuilder(OsmandApplication app) {
this.app = app;
plainMenuItems = new LinkedList<>();
}
public void build(View view) {
firstRow = true;
}
protected boolean isFirstRow() {
return firstRow;
}
protected void rowBuilt() {
firstRow = false;
}
public void addPlainMenuItem(int iconId, String text) {
plainMenuItems.add(new PlainMenuItem(iconId, text));
}
public Drawable getRowIcon(int iconId) {
IconsCache iconsCache = app.getIconsCache();
boolean light = app.getSettings().isLightContent();
return iconsCache.getIcon(iconId,
light ? R.color.icon_color : R.color.icon_color_light);
}
public Drawable getRowIcon(Context ctx, String fileName) {
Bitmap iconBitmap = RenderingIcons.getIcon(ctx, fileName, false);
if (iconBitmap != null) {
return new BitmapDrawable(ctx.getResources(), iconBitmap);
} else {
return null;
}
}
public int dpToPx(float dp) {
Resources r = app.getResources();
return (int) TypedValue.applyDimension(
COMPLEX_UNIT_DIP,
dp,
r.getDisplayMetrics()
);
}
}

View file

@ -0,0 +1,26 @@
package net.osmand.plus.mapcontextmenu.details;
import android.view.View;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
public class ParkingPositionBuilder extends MenuBuilder {
public ParkingPositionBuilder(OsmandApplication app) {
super(app);
}
private void buildRow(View view, int iconId, String text, int textColor) {
buildRow(view, getRowIcon(iconId), text, textColor);
}
@Override
public void build(View view) {
super.build(view);
for (PlainMenuItem item : plainMenuItems) {
buildRow(view, item.getIconId(), item.getText(), 0);
}
}
}

View file

@ -0,0 +1,106 @@
package net.osmand.plus.mapcontextmenu.details;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchHistoryFragment;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
import net.osmand.util.Algorithms;
public class ParkingPositionController extends MenuController {
private PointDescription pointDescription;
private LatLon latLon;
ParkingPositionPlugin plugin;
String parkingDescription = "";
public ParkingPositionController(OsmandApplication app, MapActivity mapActivity, final PointDescription pointDescription, LatLon latLon) {
super(new ParkingPositionBuilder(app), mapActivity);
this.pointDescription = pointDescription;
this.latLon = latLon;
plugin = OsmandPlugin.getPlugin(ParkingPositionPlugin.class);
if (plugin != null) {
StringBuilder sb = new StringBuilder();
sb.append(plugin.getParkingStartDesc(mapActivity));
String leftDesc = plugin.getParkingLeftDesc(mapActivity);
if (!Algorithms.isEmpty(leftDesc)) {
sb.append("\n").append(leftDesc);
}
parkingDescription = sb.toString();
}
}
@Override
protected int getInitialMenuStatePortrait() {
return MenuState.HEADER_ONLY;
}
@Override
protected int getSupportedMenuStatesPortrait() {
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
}
@Override
public boolean needTypeStr() {
return !Algorithms.isEmpty(parkingDescription);
}
@Override
public Drawable getLeftIcon() {
return getIcon(R.drawable.ic_action_parking_dark, R.color.map_widget_blue, R.color.osmand_orange);
}
@Override
public String getNameStr() {
return pointDescription.getTypeName();
}
@Override
public String getTypeStr() {
return parkingDescription;
}
@Override
public boolean hasTitleButton() {
return true;
}
@Override
public String getTitleButtonCaption() {
return getMapActivity().getText(R.string.osmand_parking_delete).toString();
}
@Override
public void titleButtonPressed() {
if (plugin != null) {
plugin.showDeleteDialog(getMapActivity());
}
}
@Override
public boolean needStreetName() {
return false;
}
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription) {
if (pointDescription != null) {
addPlainMenuItem(R.drawable.map_my_location, PointDescription.getLocationName(getMapActivity(),
latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", ""));
}
}
@Override
public void saveEntityState(Bundle bundle, String key) {
bundle.putSerializable(key, latLon);
}
}

View file

@ -1,17 +1,10 @@
package net.osmand.plus.mapcontextmenu.details;
import android.graphics.drawable.Drawable;
import android.text.util.Linkify;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
public class PointDescriptionMenuBuilder extends MenuBuilder {
private final PointDescription pointDescription;
@ -25,69 +18,6 @@ public class PointDescriptionMenuBuilder extends MenuBuilder {
buildRow(view, getRowIcon(iconId), text, textColor);
}
private void buildRow(final View view, Drawable icon, String text, int textColor) {
boolean light = app.getSettings().isLightContent();
LinearLayout ll = new LinearLayout(view.getContext());
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llParams);
// Icon
LinearLayout llIcon = new LinearLayout(view.getContext());
llIcon.setOrientation(LinearLayout.HORIZONTAL);
llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), isFirstRow() ? dpToPx(48f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(48f)));
llIcon.setGravity(Gravity.CENTER_VERTICAL);
ll.addView(llIcon);
ImageView iconView = new ImageView(view.getContext());
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
llIconParams.setMargins(dpToPx(16f), isFirstRow() ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP / 2f) : dpToPx(12f), dpToPx(32f), dpToPx(12f));
llIconParams.gravity = Gravity.CENTER_VERTICAL;
iconView.setLayoutParams(llIconParams);
iconView.setScaleType(ImageView.ScaleType.CENTER);
iconView.setImageDrawable(icon);
llIcon.addView(iconView);
// Text
LinearLayout llText = new LinearLayout(view.getContext());
llText.setOrientation(LinearLayout.VERTICAL);
ll.addView(llText);
TextView textView = new TextView(view.getContext());
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llTextParams.setMargins(0, isFirstRow() ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(8f), 0, dpToPx(8f));
textView.setLayoutParams(llTextParams);
textView.setTextSize(16);
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
textView.setAutoLinkMask(Linkify.ALL);
textView.setLinksClickable(true);
textView.setText(text);
if (textColor > 0) {
textView.setTextColor(view.getResources().getColor(textColor));
}
LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
llText.setLayoutParams(llTextViewParams);
llText.addView(textView);
((LinearLayout) view).addView(ll);
View horizontalLine = new View(view.getContext());
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
llHorLineParams.gravity = Gravity.BOTTOM;
horizontalLine.setLayoutParams(llHorLineParams);
horizontalLine.setBackgroundColor(app.getResources().getColor(light ? R.color.ctx_menu_info_divider_light : R.color.ctx_menu_info_divider_dark));
((LinearLayout) view).addView(horizontalLine);
rowBuilt();
}
@Override
public void build(View view) {
super.build(view);

View file

@ -9,6 +9,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchHistoryFragment;
import net.osmand.plus.mapcontextmenu.MenuController;
public class PointDescriptionMenuController extends MenuController {

View file

@ -28,10 +28,10 @@ public class ShareMenu {
private static final String KEY_SHARE_MENU_POINT_TITLE = "key_share_menu_point_title";
public enum ShareItem {
MESSAGE(R.drawable.ic_action_export, R.string.shared_string_send),
CLIPBOARD(R.drawable.ic_action_export, R.string.shared_string_copy),
GEO(R.drawable.ic_action_export, R.string.share_geo),
QR_CODE(R.drawable.ic_action_export, R.string.share_qr_code);
MESSAGE(R.drawable.ic_action_message, R.string.shared_string_send),
CLIPBOARD(R.drawable.ic_action_copy, R.string.shared_string_copy),
GEO(R.drawable.ic_world_globe_dark, R.string.share_geo),
QR_CODE(R.drawable.ic_action_qrcode, R.string.share_qr_code);
final int iconResourceId;
final int titleResourceId;

View file

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

View file

@ -29,6 +29,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
@ -124,8 +125,8 @@ public class ParkingPositionPlugin extends OsmandPlugin {
}
public boolean setParkingPosition(double latitude, double longitude) {
parkingLat.set((float)latitude);
parkingLon.set((float)longitude);
parkingLat.set((float) latitude);
parkingLon.set((float) longitude);
parkingPosition = constructParkingPosition();
return true;
}
@ -210,21 +211,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
public void registerMapContextMenuActions(final MapActivity mapActivity,
final double latitude, final double longitude,
ContextMenuAdapter adapter, Object selectedObj) {
if (selectedObj == parkingPosition && parkingPosition != null) {
OnContextMenuClick removeListener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId,
int pos, boolean isChecked) {
if ((resId == R.string.context_menu_item_delete_parking_point)) {
showDeleteDialog(mapActivity);
}
return true;
}
};
adapter.item(R.string.context_menu_item_delete_parking_point)
.iconColor( R.drawable.ic_action_remove_dark).listen(removeListener).position(0).reg();
}
OnContextMenuClick addListener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId,
@ -295,12 +282,12 @@ public class ParkingPositionPlugin extends OsmandPlugin {
@Override
public void onClick(DialogInterface dialog, int which) {
showDeleteEventWarning(activity);
if(parkingLayer != null) {
if (parkingLayer != null) {
parkingLayer.refresh();
}
clearParkingPosition();
if (activity instanceof MapActivity){
((MapActivity)activity).getMapView().refreshMap();
if (activity instanceof MapActivity) {
((MapActivity) activity).getContextMenu().close();
}
}
});
@ -365,8 +352,8 @@ public class ParkingPositionPlugin extends OsmandPlugin {
Calendar cal = Calendar.getInstance();
//int hour = cal.get(Calendar.HOUR_OF_DAY );
//int minute = cal.get(Calendar.MINUTE);
cal.add(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour());
cal.add(Calendar.MINUTE, timePicker.getCurrentMinute());
cal.add(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour());
cal.add(Calendar.MINUTE, timePicker.getCurrentMinute());
setParkingTime(cal.getTimeInMillis());
CheckBox addCalendarEvent = (CheckBox) setTimeParking.findViewById(R.id.check_event_in_calendar);
if (addCalendarEvent.isChecked()) {
@ -391,7 +378,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
intent.putExtra("calendar_id", 1); //$NON-NLS-1$
intent.putExtra("title", view.getContext().getString(R.string.osmand_parking_event)); //$NON-NLS-1$
intent.putExtra("beginTime", getParkingTime()); //$NON-NLS-1$
intent.putExtra("endTime", getParkingTime()+60*60*1000); //$NON-NLS-1$
intent.putExtra("endTime", getParkingTime() + 60 * 60 * 1000); //$NON-NLS-1$
view.getContext().startActivity(intent);
}
@ -426,6 +413,10 @@ public class ParkingPositionPlugin extends OsmandPlugin {
setParkingType(isLimited);
setParkingStartTime(Calendar.getInstance().getTimeInMillis());
if (parkingLayer != null) {
MapContextMenu menu = mapActivity.getContextMenu();
if (menu.isVisible()) {
menu.show(new LatLon(latitude, longitude), parkingLayer.getObjectName(parkingPosition), parkingPosition);
}
parkingLayer.refresh();
}
}
@ -539,6 +530,50 @@ public class ParkingPositionPlugin extends OsmandPlugin {
return timeStringBuilder.toString();
}
String getFormattedTimeInterval(long timeInMillis, Activity ctx) {
if (timeInMillis < 0) {
timeInMillis *= -1;
}
StringBuilder timeStringBuilder = new StringBuilder();
int hours = (int) timeInMillis / (1000 * 60 * 60);
int minMills = (int) timeInMillis % (1000 * 60 * 60);
int minutes = minMills / (1000 * 60);
if (hours > 0) {
timeStringBuilder.append(hours);
timeStringBuilder.append(" ");
timeStringBuilder.append(ctx.getString(R.string.osmand_parking_hour));
}
timeStringBuilder.append(" ");
timeStringBuilder.append(minutes);
timeStringBuilder.append(" ");
timeStringBuilder.append(ctx.getString(R.string.osmand_parking_minute));
return timeStringBuilder.toString();
}
public String getParkingStartDesc(Activity ctx) {
return ctx.getString(R.string.osmand_parking_position_description_add_time)
+ " " + getFormattedTime(getStartParkingTime(), ctx);
}
public String getParkingLeftDesc(Activity ctx) {
StringBuilder descr = new StringBuilder();
if (getParkingType()) {
long endtime = getParkingTime();
long currTime = Calendar.getInstance().getTimeInMillis();
long timeDiff = endtime - currTime;
descr.append(getFormattedTimeInterval(timeDiff, ctx)).append(" ");
if (timeDiff < 0) {
descr.append(ctx.getString(R.string.osmand_parking_overdue));
} else {
descr.append(ctx.getString(R.string.osmand_parking_time_left));
}
}
return descr.toString();
}
public String getParkingDescription(Activity ctx) {
StringBuilder timeLimitDesc = new StringBuilder();
timeLimitDesc.append(ctx.getString(R.string.osmand_parking_position_description_add_time) + " ");