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(); } }
@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; }
@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); }
public void setContentText(CharSequence text) { textDrawer.setContentText(text); }
public void setContentTitle(CharSequence title) { textDrawer.setContentTitle(title); }