/** * s Draw on the canvas. The canvas is split up into 5 different subsections used for drawing. * This is used for square devices * * @param canvas The canvas * @param rect The rect */ public void drawSquare(Canvas canvas, Rect rect) { mSayingPaint.setTextSize(mDeviceDensity * 45); mMinutePaint.setTextSize(mMainTextSize); String[] textToDraw = mDateFormatter.getTimeAccordingTo(); // Static background color canvas.drawColor(Color.parseColor(mBackgroundColor)); // The main canvas Rect is split into 5 Rect objects to // hold the different styles of text. Each Rect object // holds its own text. boundary.drawRectText(textToDraw[0], canvas, mSubSections[1], mHourPaint, mTextAlignment); boundary.drawRectText(textToDraw[1], canvas, mSubSections[2], mWordPaint, mTextAlignment); if (textToDraw[3] == null) boundary.drawRectText(textToDraw[2], canvas, mSubSections[3], mMinutePaint, mTextAlignment); else { adjustMinuteText(mMinutePaint, textToDraw[2] + "-" + textToDraw[3]); boundary.drawRectText( textToDraw[2] + "-" + textToDraw[3], canvas, mSubSections[3], mMinutePaint, mTextAlignment); } adjustSayingText(mSayingPaint, textToDraw[4]); boundary.drawRectText(textToDraw[4], canvas, mSubSections[4], mSayingPaint, mTextAlignment); }
/** * A separate option for round devices Draw within the bounds of a square/rectangular device * * @param canvas The canvas to dr0aw on * @param rect The width and height of the Rectangle to remain in */ public void drawRound(Canvas canvas, Rect rect) { // Reset to reg values, they are changed in their adjustSaying or adjustMinute size methods mSayingPaint.setTextSize(mDeviceDensity * 45); mMinutePaint.setTextSize(mMainTextSize); // Get text to draw. Pass in the text to drawRectText method which draws it in the // specified rectangle with respect to the specified alignment. String[] textToDraw = mDateFormatter.getTimeAccordingTo(); for (String x : textToDraw) { DebugManager.print("TAG", "Value: " + x); } // Static background color canvas.drawColor(Color.parseColor(mBackgroundColor)); // The main canvas Rect is split into 4 Rect objects to // hold the different styles of text. Each Rect object // holds its own text. boundary.drawRectText(textToDraw[0], canvas, mSubSections[1], mHourPaint, mTextAlignment); boundary.drawRectText(textToDraw[1], canvas, mSubSections[2], mWordPaint, mTextAlignment); if (textToDraw[3] == null) boundary.drawRectText(textToDraw[2], canvas, mSubSections[3], mMinutePaint, mTextAlignment); else { adjustMinuteTextRound(mMinutePaint, textToDraw[2] + "-" + textToDraw[3]); boundary.drawRectText( textToDraw[2] + "-" + textToDraw[3], canvas, mSubSections[3], mMinutePaint, mTextAlignment); } adjustSayingTextRound(mSayingPaint, textToDraw[4]); boundary.drawRectText(textToDraw[4], canvas, mSubSections[4], mSayingPaint, mTextAlignment); }
public void updateDate() { mDateFormatter.updateDate(); }