Example #1
0
  private void updateStyle(TypedArray styled, boolean invalidate) {
    int backgroundColor =
        styled.getColor(R.styleable.ShowcaseView_sv_backgroundColor, Color.argb(128, 80, 80, 80));
    int showcaseColor = styled.getColor(R.styleable.ShowcaseView_sv_showcaseColor, HOLO_BLUE);
    String buttonText = styled.getString(R.styleable.ShowcaseView_sv_buttonText);
    if (TextUtils.isEmpty(buttonText)) {
      buttonText = getResources().getString(android.R.string.ok);
    }
    boolean tintButton = styled.getBoolean(R.styleable.ShowcaseView_sv_tintButtonColor, true);

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

    styled.recycle();

    showcaseDrawer.setShowcaseColour(showcaseColor);
    showcaseDrawer.setBackgroundColour(backgroundColor);
    tintButton(showcaseColor, tintButton);
    mEndButton.setText(buttonText);
    textDrawer.setTitleStyling(titleTextAppearance);
    textDrawer.setDetailStyling(detailTextAppearance);
    hasAlteredText = true;

    if (invalidate) {
      invalidate();
    }
  }
Example #2
0
 @Override
 public boolean onPreDraw() {
   boolean recalculatedCling =
       showcaseAreaCalculator.calculateShowcaseRect(showcaseX, showcaseY, showcaseDrawer);
   boolean recalculateText = recalculatedCling || hasAlteredText;
   if (recalculateText) {
     textDrawer.calculateTextPosition(
         getMeasuredWidth(), getMeasuredHeight(), this, shouldCentreText);
   }
   hasAlteredText = false;
   return true;
 }
Example #3
0
  @Override
  protected void dispatchDraw(Canvas canvas) {
    if (showcaseX < 0 || showcaseY < 0 || shotStateStore.hasShot()) {
      super.dispatchDraw(canvas);
      return;
    }

    // Draw background color
    showcaseDrawer.erase(bitmapBuffer);

    // Draw the showcase drawable
    if (!hasNoTarget) {
      showcaseDrawer.drawShowcase(bitmapBuffer, showcaseX, showcaseY, scaleMultiplier);
      showcaseDrawer.drawToCanvas(canvas, bitmapBuffer);
    }

    // Draw the text on the screen, recalculating its position if necessary
    textDrawer.draw(canvas);

    super.dispatchDraw(canvas);
  }
Example #4
0
 public void setContentText(CharSequence text) {
   textDrawer.setContentText(text);
 }
Example #5
0
 public void setContentTitle(CharSequence title) {
   textDrawer.setContentTitle(title);
 }