Exemple #1
0
  @Override
  protected void dispatchDraw(Canvas canvas) {
    if (mShowcaseX < 0 || mShowcaseY < 0 || mIsRedundant) {
      super.dispatchDraw(canvas);
      return;
    }

    boolean recalculatedCling = mShowcaseDrawer.calculateShowcaseRect(mShowcaseX, mShowcaseY);
    boolean recalculateText = recalculatedCling || mAlteredText;
    mAlteredText = false;

    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB && !mHasNoTarget) {
      Path path = new Path();
      path.addCircle(mShowcaseX, mShowcaseY, mShowcaseRadius, Path.Direction.CW);
      canvas.clipPath(path, Op.DIFFERENCE);
    }

    // Draw background color
    canvas.drawColor(mBackgroundColor);

    // Draw the showcase drawable
    if (!mHasNoTarget) {
      mShowcaseDrawer.drawShowcase(
          canvas, mShowcaseX, mShowcaseY, mScaleMultiplier, mShowcaseRadius);
    }

    // Draw the text on the screen, recalculating its position if necessary
    if (recalculateText) {
      mTextDrawer.calculateTextPosition(canvas.getWidth(), canvas.getHeight(), this);
    }
    mTextDrawer.draw(canvas, recalculateText);

    super.dispatchDraw(canvas);
  }
Exemple #2
0
  protected ShowcaseView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Get the attributes for the ShowcaseView
    final TypedArray styled =
        context
            .getTheme()
            .obtainStyledAttributes(
                attrs, R.styleable.ShowcaseView, R.attr.showcaseViewStyle, R.style.ShowcaseView);
    mBackgroundColor =
        styled.getInt(R.styleable.ShowcaseView_sv_backgroundColor, Color.argb(128, 80, 80, 80));
    int showcaseColor =
        styled.getColor(R.styleable.ShowcaseView_sv_showcaseColor, Color.parseColor("#33B5E5"));

    int titleTextAppearance =
        styled.getResourceId(
            R.styleable.ShowcaseView_sv_titleTextAppearance,
            R.style.TextAppearance_ShowcaseView_Title);
    int detailTextAppearance =
        styled.getResourceId(
            R.styleable.ShowcaseView_sv_detailTextAppearance,
            R.style.TextAppearance_ShowcaseView_Detail);

    mButtonText = styled.getString(R.styleable.ShowcaseView_sv_buttonText);
    styled.recycle();

    mMetricScale = getContext().getResources().getDisplayMetrics().density;
    mEndButton = (Button) LayoutInflater.from(context).inflate(R.layout.showcase_button, null);

    mShowcaseDrawer = new ClingDrawerImpl(getResources(), showcaseColor);

    // TODO: This isn't ideal, ClingDrawer and Calculator interfaces should be separate
    mTextDrawer = new TextDrawerImpl(mMetricScale, mShowcaseDrawer);
    mTextDrawer.setTitleStyling(context, titleTextAppearance);
    mTextDrawer.setDetailStyling(context, detailTextAppearance);

    ConfigOptions options = new ConfigOptions();
    options.showcaseId = getId();
    setConfigOptions(options);

    init();
  }
Exemple #3
0
 public void setText(String titleText, String subText) {
   mTextDrawer.setTitle(titleText);
   mTextDrawer.setDetails(subText);
   mAlteredText = true;
   invalidate();
 }