Esempio n. 1
0
 @Override
 public void onDraw(Canvas canvas, RectF latlonBounds, RectF tilesRect, DrawSettings nightMode) {
   boolean bold = routeLayer.getHelper().isFollowingMode();
   int color = !nightMode.isNightMode() ? Color.BLACK : Color.BLACK;
   if (paintText.getColor() != color) {
     paintText.setColor(color);
     paintSubText.setColor(color);
     paintSmallText.setColor(color);
     paintSmallSubText.setColor(color);
   }
   if (paintText.isFakeBoldText() != bold) {
     paintText.setFakeBoldText(bold);
     paintSubText.setFakeBoldText(bold);
     paintSmallText.setFakeBoldText(bold);
     paintSmallSubText.setFakeBoldText(bold);
   }
   // update data on draw
   rightStack.updateInfo();
   leftStack.updateInfo();
   if (view.getRotate() != cachedRotate) {
     cachedRotate = view.getRotate();
     compassView.invalidate();
   }
   lanesControl.updateInfo();
   //		topText.setTextColor(color);
   //		String text = "Пр.Независимости";
   //		float ts = topText.getPaint().measureText(text);
   //		int wth = topText.getRight() /*- compassView.getRight()*/;
   //		while(ts > wth && topText.getTextSize() - 1 > 5) {
   //			topText.setTextSize(topText.getTextSize() - 1);
   //			ts = topText.getPaint().measureText(text);
   //		}
   //		topText.setText(text);
 }
Esempio n. 2
0
  public void createTopBarElements() {
    // 1. Create view groups and controls
    statusBar = createStatusBar();
    statusBar.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_top));

    lanesControl = createLanesControl();
    lanesControl.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_free));

    rightStack = new MapStackControl(view.getContext());
    rightStack.addStackView(createAltitudeControl());
    rightStack.addStackView(createDistanceControl());
    rightStack.addCollapsedView(createSpeedControl());
    rightStack.addCollapsedView(createTimeControl());

    leftStack = new MapStackControl(view.getContext());
    leftStack.addStackView(createNextInfoControl());
    leftStack.addStackView(createMiniMapControl());
    leftStack.addStackView(createNextNextInfoControl());
    //		leftStack.addStackView(createAlarmInfoControl());

    // 2. Preparations
    Rect topRectPadding = new Rect();
    view.getResources().getDrawable(R.drawable.box_top).getPadding(topRectPadding);

    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.FILL_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.FILL_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.FILL_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.FILL_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);

    parent.addView(rightStack);
    parent.addView(leftStack);
    parent.addView(statusBar);
    parent.addView(lanesControl);
  }