Search in sources :

Example 16 with RotatedTileBox

use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.

the class DownloadedRegionsLayer method initLayer.

@Override
public void initLayer(final OsmandMapTileView view) {
    this.view = view;
    app = view.getApplication();
    rm = app.getResourceManager();
    osmandRegions = rm.getOsmandRegions();
    helper = new LocalIndexHelper(app);
    paintDownloaded = getPaint(view.getResources().getColor(R.color.region_uptodate));
    paintSelected = getPaint(view.getResources().getColor(R.color.region_selected));
    paintBackuped = getPaint(view.getResources().getColor(R.color.region_backuped));
    textPaint = new TextPaint();
    final WindowManager wmgr = (WindowManager) view.getApplication().getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics dm = new DisplayMetrics();
    wmgr.getDefaultDisplay().getMetrics(dm);
    textPaint.setStrokeWidth(21 * dm.scaledDensity);
    textPaint.setAntiAlias(true);
    textPaint.setTextAlign(Paint.Align.CENTER);
    pathDownloaded = new Path();
    pathSelected = new Path();
    pathBackuped = new Path();
    data = new MapLayerData<List<BinaryMapDataObject>>() {

        @Override
        public void layerOnPostExecute() {
            view.refreshMap();
        }

        public boolean queriedBoxContains(final RotatedTileBox queriedData, final RotatedTileBox newBox) {
            if (newBox.getZoom() < ZOOM_TO_SHOW_SELECTION) {
                if (queriedData != null && queriedData.getZoom() < ZOOM_TO_SHOW_SELECTION) {
                    return queriedData.containsTileBox(newBox);
                } else {
                    return false;
                }
            }
            List<BinaryMapDataObject> queriedResults = getResults();
            if (queriedData != null && queriedData.containsTileBox(newBox) && queriedData.getZoom() >= ZOOM_TO_SHOW_MAP_NAMES) {
                if (queriedResults != null && (queriedResults.isEmpty() || Math.abs(queriedData.getZoom() - newBox.getZoom()) <= 1)) {
                    return true;
                }
            }
            return false;
        }

        @Override
        protected List<BinaryMapDataObject> calculateResult(RotatedTileBox tileBox) {
            return queryData(tileBox);
        }
    };
}
Also used : Path(android.graphics.Path) RotatedTileBox(net.osmand.data.RotatedTileBox) LocalIndexHelper(net.osmand.plus.activities.LocalIndexHelper) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) DisplayMetrics(android.util.DisplayMetrics) TextPaint(android.text.TextPaint) WindowManager(android.view.WindowManager)

Example 17 with RotatedTileBox

use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.

the class MapQuickActionLayer method enterMovingMode.

private void enterMovingMode(RotatedTileBox tileBox) {
    previousMapPosition = view.getMapPosition();
    view.setMapPosition(OsmandSettings.MIDDLE_BOTTOM_CONSTANT);
    MapContextMenu menu = mapActivity.getContextMenu();
    LatLon ll = menu.isActive() && tileBox.containsLatLon(menu.getLatLon()) ? menu.getLatLon() : tileBox.getCenterLatLon();
    boolean isFollowPoint = isFolowPoint(tileBox, menu);
    menu.updateMapCenter(null);
    menu.close();
    RotatedTileBox rb = new RotatedTileBox(tileBox);
    if (!isFollowPoint && previousMapPosition != OsmandSettings.BOTTOM_CONSTANT)
        rb.setCenterLocation(0.5f, 0.3f);
    rb.setLatLonCenter(ll.getLatitude(), ll.getLongitude());
    double lat = rb.getLatFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
    double lon = rb.getLonFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
    view.setLatLon(lat, lon);
    inMovingMarkerMode = true;
    mark(View.INVISIBLE, R.id.map_ruler_layout, R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
    View collapseButton = mapActivity.findViewById(R.id.map_collapse_button);
    if (collapseButton != null && collapseButton.getVisibility() == View.VISIBLE) {
        wasCollapseButtonVisible = true;
        collapseButton.setVisibility(View.INVISIBLE);
    } else {
        wasCollapseButtonVisible = false;
    }
    view.refreshMap();
}
Also used : LatLon(net.osmand.data.LatLon) RotatedTileBox(net.osmand.data.RotatedTileBox) MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu) ImageView(android.widget.ImageView) View(android.view.View) TapTargetView(com.getkeepsafe.taptargetview.TapTargetView)

Example 18 with RotatedTileBox

use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.

the class MapContextMenuFragment method updateMapCenter.

public void updateMapCenter(LatLon mapCenter) {
    customMapCenter = true;
    menu.setMapCenter(mapCenter);
    this.mapCenter = mapCenter;
    RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
    origMarkerX = box.getCenterPixelX();
    origMarkerY = box.getCenterPixelY();
}
Also used : RotatedTileBox(net.osmand.data.RotatedTileBox)

Example 19 with RotatedTileBox

use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.

the class MapContextMenuFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    processScreenHeight(container);
    menu = getMapActivity().getContextMenu();
    markerPaddingPx = dpToPx(MARKER_PADDING_DP);
    markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
    shadowHeight = dpToPx(SHADOW_HEIGHT_TOP_DP);
    topScreenPosY = addStatusBarHeightIfNeeded(-shadowHeight);
    bottomToolbarPosY = addStatusBarHeightIfNeeded(getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar));
    minHalfY = viewHeight - (int) (viewHeight * menu.getHalfScreenMaxHeightKoef());
    zoomPaddingTop = dpToPx(ZOOM_PADDING_TOP_DP);
    view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
    if (!menu.isActive()) {
        return view;
    }
    AndroidUtils.addStatusBarPadding21v(getMapActivity(), view);
    nightMode = menu.isNightMode();
    mainView = view.findViewById(R.id.context_menu_main);
    toolbarContainer = view.findViewById(R.id.context_menu_toolbar_container);
    toolbarView = view.findViewById(R.id.context_menu_toolbar);
    toolbarBackButton = view.findViewById(R.id.context_menu_toolbar_back);
    toolbarTextView = (TextView) view.findViewById(R.id.context_menu_toolbar_text);
    updateVisibility(toolbarContainer, 0);
    toolbarBackButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            openMenuHeaderOnly();
        }
    });
    topButtonContainer = view.findViewById(R.id.context_menu_top_button_container);
    view.findViewById(R.id.context_menu_top_back).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            openMenuHeaderOnly();
        }
    });
    updateVisibility(topButtonContainer, 0);
    map = getMapActivity().getMapView();
    RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
    customMapCenter = menu.getMapCenter() != null;
    if (!customMapCenter) {
        mapCenter = box.getCenterLatLon();
        menu.setMapCenter(mapCenter);
        double markerLat = menu.getLatLon().getLatitude();
        double markerLon = menu.getLatLon().getLongitude();
        origMarkerX = (int) box.getPixXFromLatLon(markerLat, markerLon);
        origMarkerY = (int) box.getPixYFromLatLon(markerLat, markerLon);
    } else {
        mapCenter = menu.getMapCenter();
        origMarkerX = box.getCenterPixelX();
        origMarkerY = box.getCenterPixelY();
    }
    mapZoom = menu.getMapZoom();
    if (mapZoom == 0) {
        mapZoom = map.getZoom();
    }
    // Left title button
    final View leftTitleButtonView = view.findViewById(R.id.title_button_view);
    leftTitleButtonView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TitleButtonController leftTitleButtonController = menu.getLeftTitleButtonController();
            if (leftTitleButtonController != null) {
                leftTitleButtonController.buttonPressed();
            }
        }
    });
    // Right title button
    final View rightTitleButtonView = view.findViewById(R.id.title_button_right_view);
    rightTitleButtonView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TitleButtonController rightTitleButtonController = menu.getRightTitleButtonController();
            if (rightTitleButtonController != null) {
                rightTitleButtonController.buttonPressed();
            }
        }
    });
    // Left download button
    final View leftDownloadButtonView = view.findViewById(R.id.download_button_left_view);
    leftDownloadButtonView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TitleButtonController leftDownloadButtonController = menu.getLeftDownloadButtonController();
            if (leftDownloadButtonController != null) {
                leftDownloadButtonController.buttonPressed();
            }
        }
    });
    // Right download button
    final View rightDownloadButtonView = (View) view.findViewById(R.id.download_button_right_view);
    rightDownloadButtonView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
            if (rightDownloadButtonController != null) {
                rightDownloadButtonController.buttonPressed();
            }
        }
    });
    // Bottom title button
    final View bottomTitleButtonView = view.findViewById(R.id.title_button_bottom_view);
    bottomTitleButtonView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TitleButtonController bottomTitleButtonController = menu.getBottomTitleButtonController();
            if (bottomTitleButtonController != null) {
                bottomTitleButtonController.buttonPressed();
            }
        }
    });
    // Progress bar
    final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton);
    progressButton.setImageDrawable(getIcon(R.drawable.ic_action_remove_dark, R.color.ctx_menu_buttons_icon_color));
    progressButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TitleProgressController titleProgressController = menu.getTitleProgressController();
            if (titleProgressController != null) {
                titleProgressController.buttonPressed();
            }
        }
    });
    menu.updateData();
    updateButtonsAndProgress();
    if (menu.isLandscapeLayout()) {
        final TypedValue typedValueAttr = new TypedValue();
        getMapActivity().getTheme().resolveAttribute(R.attr.left_menu_view_bg, typedValueAttr, true);
        mainView.setBackgroundResource(typedValueAttr.resourceId);
        mainView.setLayoutParams(new FrameLayout.LayoutParams(menu.getLandscapeWidthPx(), ViewGroup.LayoutParams.MATCH_PARENT));
        View fabContainer = view.findViewById(R.id.context_menu_fab_container);
        fabContainer.setLayoutParams(new FrameLayout.LayoutParams(menu.getLandscapeWidthPx(), ViewGroup.LayoutParams.MATCH_PARENT));
    }
    runLayoutListener();
    final GestureDetector singleTapDetector = new GestureDetector(view.getContext(), new SingleTapConfirm());
    final GestureDetector swipeDetector = new GestureDetector(view.getContext(), new HorizontalSwipeConfirm(true));
    final View.OnTouchListener slideTouchListener = new View.OnTouchListener() {

        private float dy;

        private float dyMain;

        private float mDownY;

        private int minimumVelocity;

        private int maximumVelocity;

        private VelocityTracker velocityTracker;

        private OverScroller scroller;

        private boolean slidingUp;

        private boolean slidingDown;

        private boolean hasMoved;

        {
            scroller = new OverScroller(getContext());
            final ViewConfiguration configuration = ViewConfiguration.get(getContext());
            minimumVelocity = configuration.getScaledMinimumFlingVelocity();
            maximumVelocity = configuration.getScaledMaximumFlingVelocity();
        }

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (!hasMoved && event.getY() <= menuTopViewHeight) {
                if (singleTapDetector.onTouchEvent(event)) {
                    moving = false;
                    openMenuHalfScreen();
                    recycleVelocityTracker();
                    return true;
                }
            }
            if (menu.isLandscapeLayout()) {
                if (swipeDetector.onTouchEvent(event)) {
                    menu.close();
                    recycleVelocityTracker();
                    return true;
                }
            }
            switch(event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    hasMoved = false;
                    mDownY = event.getRawY();
                    dy = event.getY();
                    dyMain = getViewY();
                    initOrResetVelocityTracker();
                    velocityTracker.addMovement(event);
                    break;
                case MotionEvent.ACTION_MOVE:
                    if (Math.abs(event.getRawY() - mDownY) > mainView.getTouchSlop()) {
                        moving = true;
                    }
                    if (moving) {
                        hasMoved = true;
                        float y = event.getY();
                        float newY = getViewY() + (y - dy);
                        if (menu.isLandscapeLayout() && newY > topScreenPosY) {
                            newY = topScreenPosY;
                        }
                        setViewY((int) newY, false, false);
                        menuFullHeight = view.getHeight() - (int) newY + 10;
                        ViewGroup.LayoutParams lp = mainView.getLayoutParams();
                        lp.height = Math.max(menuFullHeight, menuTitleHeight);
                        mainView.setLayoutParams(lp);
                        mainView.requestLayout();
                        float newEventY = newY - (dyMain - dy);
                        MotionEvent ev = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), event.getAction(), event.getX(), newEventY, event.getMetaState());
                        initVelocityTrackerIfNotExists();
                        velocityTracker.addMovement(ev);
                        updateToolbar();
                        updateTopButton();
                    }
                    break;
                case MotionEvent.ACTION_UP:
                    if (moving) {
                        moving = false;
                        hasMoved = false;
                        int currentY = getViewY();
                        final VelocityTracker velocityTracker = this.velocityTracker;
                        velocityTracker.computeCurrentVelocity(1000, maximumVelocity);
                        int initialVelocity = (int) velocityTracker.getYVelocity();
                        if ((Math.abs(initialVelocity) > minimumVelocity)) {
                            scroller.abortAnimation();
                            scroller.fling(0, currentY, 0, initialVelocity, 0, 0, Math.min(viewHeight - menuFullHeightMax, getFullScreenTopPosY()), screenHeight, 0, 0);
                            currentY = scroller.getFinalY();
                            scroller.abortAnimation();
                            slidingUp = initialVelocity < -2000;
                            slidingDown = initialVelocity > 2000;
                        } else {
                            slidingUp = false;
                            slidingDown = false;
                        }
                        changeMenuState(currentY, slidingUp, slidingDown);
                    }
                    recycleVelocityTracker();
                    break;
                case MotionEvent.ACTION_CANCEL:
                    moving = false;
                    hasMoved = false;
                    recycleVelocityTracker();
                    break;
            }
            return true;
        }

        private void initOrResetVelocityTracker() {
            if (velocityTracker == null) {
                velocityTracker = VelocityTracker.obtain();
            } else {
                velocityTracker.clear();
            }
        }

        private void initVelocityTrackerIfNotExists() {
            if (velocityTracker == null) {
                velocityTracker = VelocityTracker.obtain();
                velocityTracker.clear();
            }
        }

        private void recycleVelocityTracker() {
            if (velocityTracker != null) {
                velocityTracker.recycle();
                velocityTracker = null;
            }
        }
    };
    View topShadowAllView = view.findViewById(R.id.context_menu_top_shadow_all);
    AndroidUtils.setBackground(getMapActivity(), topShadowAllView, nightMode, R.drawable.bg_map_context_menu_light, R.drawable.bg_map_context_menu_dark);
    ((InterceptorLinearLayout) mainView).setListener(slideTouchListener);
    mainView.setOnTouchListener(slideTouchListener);
    buildHeader();
    ((TextView) view.findViewById(R.id.context_menu_line1)).setTextColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_title_color_dark : R.color.ctx_menu_title_color_light));
    View menuLine2 = view.findViewById(R.id.context_menu_line2);
    if (menuLine2 != null) {
        ((TextView) menuLine2).setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_subtitle_color));
    }
    ((TextView) view.findViewById(R.id.distance)).setTextColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_direction_color_dark : R.color.ctx_menu_direction_color_light));
    AndroidUtils.setTextSecondaryColor(getMapActivity(), (TextView) view.findViewById(R.id.title_button_right_text), nightMode);
    AndroidUtils.setTextSecondaryColor(getMapActivity(), (TextView) view.findViewById(R.id.progressTitle), nightMode);
    // Zoom buttons
    zoomButtonsView = view.findViewById(R.id.context_menu_zoom_buttons);
    zoomInButtonView = (ImageButton) view.findViewById(R.id.context_menu_zoom_in_button);
    zoomOutButtonView = (ImageButton) view.findViewById(R.id.context_menu_zoom_out_button);
    if (menu.zoomButtonsVisible()) {
        updateImageButton(zoomInButtonView, R.drawable.map_zoom_in, R.drawable.map_zoom_in_night, R.drawable.btn_circle_trans, R.drawable.btn_circle_night, nightMode);
        updateImageButton(zoomOutButtonView, R.drawable.map_zoom_out, R.drawable.map_zoom_out_night, R.drawable.btn_circle_trans, R.drawable.btn_circle_night, nightMode);
        zoomInButtonView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                menu.zoomInPressed();
            }
        });
        zoomOutButtonView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                menu.zoomOutPressed();
            }
        });
        zoomButtonsView.setVisibility(View.VISIBLE);
    } else {
        zoomButtonsView.setVisibility(View.GONE);
    }
    GridView localTransportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid);
    GridView nearbyTransportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_nearby_routes_grid);
    TextView nearbRoutesWithinTv = (TextView) view.findViewById(R.id.nearby_routes_within_text_view);
    LinearLayout nearbyRoutesLayout = (LinearLayout) view.findViewById(R.id.nearby_routes);
    List<TransportStopRoute> localTransportStopRoutes = menu.getLocalTransportStopRoutes();
    List<TransportStopRoute> nearbyTransportStopRoutes = menu.getNearbyTransportStopRoutes();
    if (nightMode) {
        nearbRoutesWithinTv.setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_bottom_view_secondary_text_color_dark));
    } else {
        nearbRoutesWithinTv.setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_nearby_routes_text_color_dark));
    }
    if (localTransportStopRoutes != null && localTransportStopRoutes.size() > 0) {
        localTransportStopRoutesGrid.setAdapter(createTransportStopRouteAdapter(localTransportStopRoutes));
        localTransportStopRoutesGrid.setVisibility(View.VISIBLE);
    } else {
        localTransportStopRoutesGrid.setVisibility(View.GONE);
    }
    if (nearbyTransportStopRoutes != null && nearbyTransportStopRoutes.size() > 0) {
        String nearInDistance = getMyApplication().getString(R.string.transport_nearby_routes) + " " + OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_METERS, getMyApplication()).toUpperCase() + ":";
        nearbRoutesWithinTv.setText(nearInDistance);
        nearbyTransportStopRoutesGrid.setAdapter(createTransportStopRouteAdapter(nearbyTransportStopRoutes));
        nearbyTransportStopRoutesGrid.setVisibility(View.VISIBLE);
    } else {
        nearbyRoutesLayout.setVisibility(View.GONE);
    }
    View buttonsBottomBorder = view.findViewById(R.id.buttons_bottom_border);
    View buttonsTopBorder = view.findViewById(R.id.buttons_top_border);
    buttonsBottomBorder.setBackgroundColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_buttons_divider_dark : R.color.ctx_menu_buttons_divider_light));
    buttonsTopBorder.setBackgroundColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_buttons_divider_dark : R.color.ctx_menu_buttons_divider_light));
    View buttons = view.findViewById(R.id.context_menu_buttons);
    buttons.setBackgroundColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_buttons_bg_dark : R.color.ctx_menu_buttons_bg_light));
    if (!menu.buttonsVisible()) {
        buttonsTopBorder.setVisibility(View.GONE);
        buttons.setVisibility(View.GONE);
    }
    View bottomButtons = view.findViewById(R.id.context_menu_bottom_buttons);
    bottomButtons.setBackgroundColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_buttons_bg_dark : R.color.ctx_menu_buttons_bg_light));
    if (!menu.navigateButtonVisible()) {
        bottomButtons.findViewById(R.id.context_menu_directions_button).setVisibility(View.GONE);
    }
    // Action buttons
    final ImageView imageFavorite = (ImageView) view.findViewById(R.id.context_menu_fav_image_view);
    imageFavorite.setImageDrawable(getIcon(menu.getFavActionIconId(), R.color.ctx_menu_buttons_icon_color));
    imageFavorite.setContentDescription(getString(menu.getFavActionStringId()));
    ((TextView) view.findViewById(R.id.context_menu_fav_text_view)).setText(menu.getFavActionStringId());
    View favView = view.findViewById(R.id.context_menu_fav_view);
    favView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            menu.buttonFavoritePressed();
        }
    });
    final ImageView imageWaypoint = (ImageView) view.findViewById(R.id.context_menu_route_image_view);
    imageWaypoint.setImageDrawable(getIcon(menu.getWaypointActionIconId(), R.color.ctx_menu_buttons_icon_color));
    imageWaypoint.setContentDescription(getString(menu.getWaypointActionStringId()));
    View waypointView = view.findViewById(R.id.context_menu_route_view);
    if (menu.isButtonWaypointEnabled()) {
        waypointView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                menu.buttonWaypointPressed();
            }
        });
    } else {
        deactivate(waypointView);
    }
    final ImageView imageShare = (ImageView) view.findViewById(R.id.context_menu_share_image_view);
    imageShare.setImageDrawable(getIcon(R.drawable.map_action_gshare_dark, R.color.ctx_menu_buttons_icon_color));
    View shareView = view.findViewById(R.id.context_menu_share_view);
    shareView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            menu.buttonSharePressed();
        }
    });
    final ImageView imageMore = (ImageView) view.findViewById(R.id.context_menu_more_image_view);
    imageMore.setImageDrawable(getIcon(R.drawable.map_overflow_menu_white, R.color.ctx_menu_buttons_icon_color));
    View moreView = view.findViewById(R.id.context_menu_more_view);
    moreView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            menu.buttonMorePressed();
        }
    });
    // Bottom buttons
    int bottomButtonsColor = nightMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n;
    TextView detailsButton = (TextView) view.findViewById(R.id.context_menu_details_button);
    detailsButton.setTextColor(ContextCompat.getColor(getContext(), bottomButtonsColor));
    detailsButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            openMenuHalfScreen();
        }
    });
    TextView directionsButton = (TextView) view.findViewById(R.id.context_menu_directions_button);
    int iconResId = R.drawable.map_directions;
    if (menu.navigateInPedestrianMode()) {
        iconResId = R.drawable.map_action_pedestrian_dark;
    }
    Drawable drawable = getIcon(iconResId, bottomButtonsColor);
    directionsButton.setTextColor(ContextCompat.getColor(getContext(), bottomButtonsColor));
    directionsButton.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null);
    directionsButton.setCompoundDrawablePadding(dpToPx(8));
    directionsButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            menu.navigateButtonPressed();
        }
    });
    buildBottomView();
    LockableScrollView bottomScrollView = (LockableScrollView) view.findViewById(R.id.context_menu_bottom_scroll);
    bottomScrollView.setScrollingEnabled(false);
    bottomScrollView.setBackgroundColor(getResources().getColor(nightMode ? R.color.ctx_menu_bottom_view_bg_dark : R.color.ctx_menu_bottom_view_bg_light));
    view.findViewById(R.id.context_menu_bottom_view).setBackgroundColor(getResources().getColor(nightMode ? R.color.ctx_menu_bottom_view_bg_dark : R.color.ctx_menu_bottom_view_bg_light));
    // getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(false);
    containerLayoutListener = new OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            if (bottom != oldBottom) {
                processScreenHeight(view.getParent());
                runLayoutListener();
            }
        }
    };
    created = true;
    return view;
}
Also used : GestureDetector(android.view.GestureDetector) SingleTapConfirm(net.osmand.plus.views.controls.SingleTapConfirm) ViewConfiguration(android.view.ViewConfiguration) TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TypedValue(android.util.TypedValue) OverScroller(android.widget.OverScroller) RotatedTileBox(net.osmand.data.RotatedTileBox) VelocityTracker(android.view.VelocityTracker) OnLayoutChangeListener(android.view.View.OnLayoutChangeListener) ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) LockableScrollView(net.osmand.plus.LockableScrollView) TextView(android.widget.TextView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) QuadPoint(net.osmand.data.QuadPoint) LockableScrollView(net.osmand.plus.LockableScrollView) MotionEvent(android.view.MotionEvent) TitleButtonController(net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController) FrameLayout(android.widget.FrameLayout) HorizontalSwipeConfirm(net.osmand.plus.views.controls.HorizontalSwipeConfirm) GridView(android.widget.GridView) TitleProgressController(net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController) LinearLayout(android.widget.LinearLayout)

Example 20 with RotatedTileBox

use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.

the class TrackDetailsMenu method fitTrackOnMap.

private void fitTrackOnMap(LineChart chart, LatLon location, boolean forceFit) {
    QuadRect rect = getRect(chart, chart.getLowestVisibleX(), chart.getHighestVisibleX());
    if (rect != null) {
        RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy();
        int tileBoxWidthPx = 0;
        int tileBoxHeightPx = 0;
        WeakReference<TrackDetailsMenuFragment> fragmentRef = findMenuFragment();
        if (fragmentRef != null) {
            TrackDetailsMenuFragment f = fragmentRef.get();
            boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
            if (!portrait) {
                tileBoxWidthPx = tb.getPixWidth() - f.getWidth();
            } else {
                tileBoxHeightPx = tb.getPixHeight() - f.getHeight();
            }
        }
        if (forceFit) {
            mapActivity.getMapView().fitRectToMap(rect.left, rect.right, rect.top, rect.bottom, tileBoxWidthPx, tileBoxHeightPx, 0);
        } else if (location != null && !mapActivity.getMapView().getTileBox(tileBoxWidthPx, tileBoxHeightPx, 0).containsLatLon(location)) {
            boolean animating = mapActivity.getMapView().getAnimatedDraggingThread().isAnimating();
            mapActivity.getMapView().fitLocationToMap(location.getLatitude(), location.getLongitude(), mapActivity.getMapView().getZoom(), tileBoxWidthPx, tileBoxHeightPx, 0, !animating);
        } else {
            mapActivity.refreshMap();
        }
    }
}
Also used : RotatedTileBox(net.osmand.data.RotatedTileBox) QuadRect(net.osmand.data.QuadRect)

Aggregations

RotatedTileBox (net.osmand.data.RotatedTileBox)48 LatLon (net.osmand.data.LatLon)20 QuadPoint (net.osmand.data.QuadPoint)15 Paint (android.graphics.Paint)11 QuadRect (net.osmand.data.QuadRect)8 SuppressLint (android.annotation.SuppressLint)7 View (android.view.View)6 ImageView (android.widget.ImageView)5 ArrayList (java.util.ArrayList)4 Location (net.osmand.Location)4 ITileSource (net.osmand.map.ITileSource)4 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)4 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)4 PointF (android.graphics.PointF)3 TextView (android.widget.TextView)3 List (java.util.List)3 QuadPointDouble (net.osmand.data.QuadPointDouble)3 WptPt (net.osmand.plus.GPXUtilities.WptPt)3 DialogInterface (android.content.DialogInterface)2 Bitmap (android.graphics.Bitmap)2