private void registerWidget(MapActivity activity) {
   MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
   final OsmandMapTileView mv = activity.getMapView();
   if (mapInfoLayer != null && mapInfoLayer.getSideWidget(FPSTextInfoWidget.class) == null) {
     FPSTextInfoWidget fps = new FPSTextInfoWidget(mv, activity);
     mapInfoLayer.registerSideWidget(
         fps, R.drawable.widget_no_icon, R.string.map_widget_fps_info, "fps", false, 30);
     mapInfoLayer.recreateControls();
   }
 }
 @Override
 public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
   if (isActive()) {
     registerWidget(activity);
   } else {
     MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
     if (mapInfoLayer != null && mapInfoLayer.getSideWidget(FPSTextInfoWidget.class) != null) {
       mapInfoLayer.removeSideWidget(mapInfoLayer.getSideWidget(FPSTextInfoWidget.class));
       mapInfoLayer.recreateControls();
     }
   }
 }
示例#3
0
  private void registerWidget(MapActivity activity) {
    MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
    monitoringControl = createMonitoringControl(activity);

    layer.registerSideWidget(
        monitoringControl,
        R.drawable.ic_action_play_dark,
        R.string.map_widget_monitoring,
        "monitoring",
        false,
        18);
    layer.recreateControls();
  }
示例#4
0
 @Override
 public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
   if (isActive()) {
     if (monitoringControl == null) {
       registerWidget(activity);
     }
   } else {
     if (monitoringControl != null) {
       MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
       layer.removeSideWidget(monitoringControl);
       layer.recreateControls();
       monitoringControl = null;
     }
   }
 }
示例#5
0
 private void registerWidget(MapActivity activity) {
   MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
   if (mapInfoLayer != null) {
     routeStepsControl =
         createRouteStepsInfoControl(
             activity, mapInfoLayer.getPaintSubText(), mapInfoLayer.getPaintSubText());
     mapInfoLayer
         .getMapInfoControls()
         .registerSideWidget(
             routeStepsControl,
             R.drawable.widget_target,
             R.string.map_widget_route_points,
             "route_steps",
             false,
             8);
     mapInfoLayer.recreateControls();
   }
 }
示例#6
0
  public void createControls() {
    // 1. Create view groups and controls
    statusBar.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_top));
    rightStack = new StackWidgetView(view.getContext());
    leftStack = new StackWidgetView(view.getContext());

    // 2. Preparations
    Rect topRectPadding = new Rect();
    view.getResources().getDrawable(R.drawable.box_top).getPadding(topRectPadding);
    // for measurement
    statusBar.addView(backToLocation);
    STATUS_BAR_MARGIN_X = (int) (STATUS_BAR_MARGIN_X * scaleCoefficient);
    statusBar.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    Rect statusBarPadding = new Rect();
    statusBar.getBackground().getPadding(statusBarPadding);
    // 3. put into frame parent layout controls
    FrameLayout parent = (FrameLayout) view.getParent();
    // status bar hides own top part
    int topMargin = statusBar.getMeasuredHeight() - statusBarPadding.top - statusBarPadding.bottom;
    // we want that status bar lays over map stack controls
    topMargin -= topRectPadding.top;

    FrameLayout.LayoutParams flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.RIGHT);
    flp.rightMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = topMargin;
    rightStack.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.CENTER_HORIZONTAL | Gravity.TOP);
    flp.topMargin = (int) (topMargin + scaleCoefficient * 8);
    lanesControl.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.LEFT);
    flp.leftMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = topMargin;
    leftStack.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.TOP);
    flp.leftMargin = STATUS_BAR_MARGIN_X;
    flp.rightMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = -topRectPadding.top;
    statusBar.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            (int) (78 * scaleCoefficient),
            (int) (78 * scaleCoefficient),
            Gravity.RIGHT | Gravity.BOTTOM);
    flp.rightMargin = (int) (10 * scaleCoefficient);
    flp.bottomMargin = (int) (85 * scaleCoefficient);
    alarmControl.setLayoutParams(flp);

    parent.addView(rightStack);
    parent.addView(leftStack);
    parent.addView(statusBar);
    parent.addView(lanesControl);
    parent.addView(alarmControl);
    alarmControl.setVisibility(View.GONE);
    lanesControl.setVisibility(View.GONE);

    // update and create controls
    recreateControls();
  }