Exemple #1
0
  public void recreateControls() {
    rightStack.clearAllViews();
    mapInfoControls.populateStackControl(rightStack, view, false);

    leftStack.clearAllViews();
    mapInfoControls.populateStackControl(leftStack, view, true);
    leftStack.requestLayout();
    rightStack.requestLayout();

    statusBar.removeAllViews();
    mapInfoControls.populateStatusBar(statusBar);
    updateColorShadowsOfText(null);
  }
Exemple #2
0
 @Override
 public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
   updateColorShadowsOfText(drawSettings);
   // update data on draw
   rightStack.updateInfo(drawSettings);
   leftStack.updateInfo(drawSettings);
   lanesControl.updateInfo(drawSettings);
   alarmControl.updateInfo(drawSettings);
   for (int i = 0; i < statusBar.getChildCount(); i++) {
     View v = statusBar.getChildAt(i);
     if (v instanceof UpdateableWidget) {
       ((UpdateableWidget) v).updateInfo(drawSettings);
     }
   }
 }
Exemple #3
0
  public void updateColorShadowsOfText(DrawSettings drawSettings) {
    boolean transparent = view.getSettings().TRANSPARENT_MAP_THEME.get();
    boolean nightMode = drawSettings == null ? false : drawSettings.isNightMode();
    boolean following = routeLayer.getHelper().isFollowingMode();
    int calcThemeId = (transparent ? 4 : 0) | (nightMode ? 2 : 0) | (following ? 1 : 0);
    if (themeId != calcThemeId) {
      themeId = calcThemeId;
      boolean textBold = following;
      int textColor = nightMode ? 0xffC8C8C8 : Color.BLACK;
      int textShadowColor = transparent && !nightMode ? Color.WHITE : Color.TRANSPARENT;
      int boxTop;
      int boxTopStack;
      int boxTopR;
      int boxTopL;
      int expand;
      Drawable boxFree = view.getResources().getDrawable(R.drawable.box_free_simple);

      if (transparent) {
        boxTop = R.drawable.box_top_t;
        boxTopStack = R.drawable.box_top_t_stack;
        boxTopR = R.drawable.box_top_rt;
        boxTopL = R.drawable.box_top_lt;
        expand = R.drawable.box_expand_t;
        if (nightMode) {
          boxFree = view.getResources().getDrawable(R.drawable.box_night_free_simple);
        }
      } else if (nightMode) {
        boxTop = R.drawable.box_top_n;
        boxTopStack = R.drawable.box_top_n_stack;
        boxTopR = R.drawable.box_top_rn;
        boxTopL = R.drawable.box_top_ln;
        expand = R.drawable.box_expand_t;
        boxFree = view.getResources().getDrawable(R.drawable.box_night_free_simple);
      } else {
        boxTop = R.drawable.box_top;
        boxTopStack = R.drawable.box_top_stack;
        boxTopR = R.drawable.box_top_r;
        boxTopL = R.drawable.box_top_l;
        expand = R.drawable.box_expand;
      }
      lanesControl.setBackgroundDrawable(boxFree);
      rightStack.setTopDrawable(view.getResources().getDrawable(boxTopR));
      rightStack.setStackDrawable(boxTopStack);

      leftStack.setTopDrawable(view.getResources().getDrawable(boxTopL));
      leftStack.setStackDrawable(boxTopStack);

      leftStack.setExpandImageDrawable(view.getResources().getDrawable(expand));
      rightStack.setExpandImageDrawable(view.getResources().getDrawable(expand));
      statusBar.setBackgroundDrawable(view.getResources().getDrawable(boxTop));

      paintText.setColor(textColor);
      paintSubText.setColor(textColor);
      paintSmallText.setColor(textColor);
      paintSmallSubText.setColor(textColor);

      topText.setShadowColor(textShadowColor);
      leftStack.setShadowColor(textShadowColor);
      rightStack.setShadowColor(textShadowColor);

      paintText.setFakeBoldText(textBold);
      paintSubText.setFakeBoldText(textBold);
      paintSmallText.setFakeBoldText(textBold);
      paintSmallSubText.setFakeBoldText(textBold);

      rightStack.invalidate();
      leftStack.invalidate();
      statusBar.invalidate();
    }
  }
Exemple #4
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();
  }