Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-11-08 17:45:55 +01:00
commit 664870bc10
12 changed files with 189 additions and 47 deletions

View file

@ -33,13 +33,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:layout_marginBottom="16dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/context_menu_icon_layout"
android:layout_width="42dp"
android:layout_height="match_parent"
android:orientation="horizontal">
android:layout_height="match_parent">
<ImageView
android:id="@+id/context_menu_icon_view"
@ -54,54 +54,88 @@
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/context_menu_line1"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/search_address_building"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size_large"/>
android:orientation="horizontal">
<TextView
android:id="@+id/context_menu_line2"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_weight="1">
<TextView
android:id="@+id/context_menu_line1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/search_address_building"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size_large"/>
</LinearLayout>
<LinearLayout
android:id="@+id/context_menu_close_btn_layout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="66dp"
android:orientation="horizontal">
<Button
android:id="@+id/title_button_top_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/shared_string_others"
android:textColor="?attr/contextMenuButtonColor"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="4dp"
android:text="@string/other_location"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
android:layout_marginTop="4dp">
</LinearLayout>
<ImageView
android:id="@+id/direction"
android:layout_width="@dimen/dashFavDirectionSize"
android:layout_height="@dimen/dashFavDirectionSize"
android:layout_gravity="center_vertical" />
<LinearLayout
android:id="@+id/context_menu_close_btn_layout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="66dp"
android:orientation="horizontal">
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="4dp"
android:layout_gravity="center_vertical"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="100500 km" />
<Button
android:id="@+id/title_button_top_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/shared_string_others"
android:textColor="?attr/contextMenuButtonColor"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:id="@+id/context_menu_line2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/other_location"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
</LinearLayout>
@ -116,7 +150,9 @@
android:layout_marginTop="-16dp"
android:paddingBottom="4dp"
android:clickable="true"
android:orientation="horizontal">
android:orientation="horizontal"
tools:visibility="visible"
android:visibility="gone">
<Button
android:id="@+id/title_button"
@ -133,7 +169,7 @@
<TextView
android:id="@+id/title_button_right_text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:clickable="true"
android:layout_marginLeft="-4dp"

View file

@ -61,6 +61,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_gravity="center_vertical"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
tools:text="100500 km" />

View file

@ -399,6 +399,10 @@ public class MapContextMenu extends MenuTitleController {
return menuController == null || menuController.buttonsVisible();
}
public boolean displayDistanceDirection() {
return menuController != null && menuController.displayDistanceDirection();
}
public void updateData() {
if (menuController != null) {
menuController.updateData();

View file

@ -29,26 +29,31 @@ import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
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.dashboard.DashLocationFragment;
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;
import net.osmand.util.MapUtils;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
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 implements DownloadEvents {
public class MapContextMenuFragment extends Fragment implements DownloadEvents, OsmAndLocationListener, OsmAndCompassListener {
public static final String TAG = "MapContextMenuFragment";
@ -84,6 +89,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
private int origMarkerY;
private boolean customMapCenter;
private LatLon location;
private Float heading;
private int screenOrientation;
private class SingleTapConfirm implements OnGestureListener {
@Override
@ -550,6 +559,26 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
}
}
@Override
public void onResume() {
super.onResume();
screenOrientation = DashLocationFragment.getScreenOrientation(getActivity());
if (menu.displayDistanceDirection()) {
if (location == null) {
location = getMyApplication().getSettings().getLastKnownMapLocation();
}
getMyApplication().getLocationProvider().addLocationListener(this);
getMyApplication().getLocationProvider().addCompassListener(this);
}
}
@Override
public void onPause() {
getMyApplication().getLocationProvider().removeLocationListener(this);
getMyApplication().getLocationProvider().removeCompassListener(this);
super.onPause();
}
@Override
public void onDestroyView() {
super.onDestroyView();
@ -641,6 +670,15 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
line1.setText(menu.getTitleStr());
// Text line 2
TextView distanceText = (TextView) view.findViewById(R.id.distance);
ImageView direction = (ImageView) view.findViewById(R.id.direction);
if (menu.displayDistanceDirection()) {
updateDistanceDirection();
} else {
direction.setVisibility(View.GONE);
distanceText.setVisibility(View.GONE);
}
TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2);
line2.setText(menu.getLocationStr());
Drawable icon = menu.getSecondLineIcon();
@ -650,6 +688,14 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
}
}
private void updateDistanceDirection() {
TextView distanceText = (TextView) view.findViewById(R.id.distance);
ImageView direction = (ImageView) view.findViewById(R.id.direction);
boolean mapLinked = getMapActivity().getMapViewTrackingUtilities().isMapLinkedToLocation() && location != null;
DashLocationFragment.updateLocationView(!mapLinked, location, heading, direction, distanceText,
menu.getLatLon().getLatitude(), menu.getLatLon().getLongitude(), screenOrientation, getMyApplication(), getActivity());
}
private int getPosY() {
return getPosY(false);
}
@ -870,5 +916,26 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
return dm.heightPixels;
}
@Override
public void updateLocation(Location location) {
if (location != null) {
this.location = new LatLon(location.getLatitude(), location.getLongitude());
updateDistanceDirection();
}
; }
@Override
public void updateCompassValue(float value) {
// 99 in next line used to one-time initalize arrows (with reference vs. fixed-north direction) on non-compass
// devices
float lastHeading = heading != null ? heading : 99;
heading = value;
if (Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
updateDistanceDirection();
} else {
heading = lastHeading;
}
}
}

View file

@ -220,7 +220,11 @@ public abstract class MenuController extends BaseMenuController {
return menuType != MenuType.STANDARD;
}
public boolean displayStreetNameinTitle() {
public boolean displayStreetNameInTitle() {
return false;
}
public boolean displayDistanceDirection() {
return false;
}

View file

@ -59,8 +59,8 @@ public abstract class MenuTitleController {
return typeStr;
} else {
if (Algorithms.isEmpty(streetStr)) {
return PointDescription.getLocationName(getMapActivity(),
getLatLon().getLatitude(), getLatLon().getLongitude(), true).replaceAll("\n", "");
return "";//PointDescription.getLocationName(getMapActivity(),
//getLatLon().getLatitude(), getLatLon().getLongitude(), true).replaceAll("\n", "");
} else {
return streetStr;
}
@ -147,7 +147,7 @@ public abstract class MenuTitleController {
if (!Algorithms.isEmpty(streetStr)) {
MenuController menuController = getMenuController();
if (menuController == null || menuController.displayStreetNameinTitle()) {
if (menuController == null || menuController.displayStreetNameInTitle()) {
nameStr = streetStr;
addressUnknown = false;
streetStr = "";

View file

@ -48,6 +48,11 @@ public class FavouritePointMenuController extends MenuController {
return true;
}
@Override
public boolean displayDistanceDirection() {
return true;
}
@Override
public Drawable getLeftIcon() {
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), fav.getColor(), true);

View file

@ -31,6 +31,11 @@ public class HistoryMenuController extends MenuController {
return (typeName != null && !typeName.isEmpty());
}
@Override
public boolean displayDistanceDirection() {
return true;
}
@Override
public Drawable getLeftIcon() {
return getIcon(SearchHistoryFragment.getItemIcon(entry.getName()));

View file

@ -51,6 +51,11 @@ public class ParkingPositionMenuController extends MenuController {
return !Algorithms.isEmpty(parkingDescription);
}
@Override
public boolean displayDistanceDirection() {
return true;
}
@Override
public Drawable getLeftIcon() {
return getIcon(R.drawable.ic_action_parking_dark, R.color.map_widget_blue, R.color.osmand_orange);

View file

@ -29,7 +29,12 @@ public class PointDescriptionMenuController extends MenuController {
}
@Override
public boolean displayStreetNameinTitle() {
public boolean displayStreetNameInTitle() {
return true;
}
@Override
public boolean displayDistanceDirection() {
return true;
}

View file

@ -46,6 +46,11 @@ public class TargetPointMenuController extends MenuController {
return !Algorithms.isEmpty(getNameStr());
}
@Override
public boolean displayDistanceDirection() {
return true;
}
@Override
public Drawable getLeftIcon() {
if (!targetPoint.intermediate) {

View file

@ -47,6 +47,11 @@ public class WptPtMenuController extends MenuController {
return wpt.category != null;
}
@Override
public boolean displayDistanceDirection() {
return true;
}
@Override
public Drawable getLeftIcon() {
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), wpt.getColor(), true);