4 * Authors: Nathaniel McCallum <npmccallum@redhat.com>
6 * Copyright (C) 2013 Nathaniel McCallum, Red Hat
7 * see file 'COPYING' for use and warranty information
9 * This program is free software you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 package org.fedorahosted.freeotp;
25 import android.content.Context;
26 import android.graphics.Canvas;
27 import android.graphics.Paint;
28 import android.graphics.Paint.Style;
29 import android.graphics.Rect;
30 import android.graphics.RectF;
31 import android.util.AttributeSet;
32 import android.widget.ProgressBar;
34 public class CircleProgressBar extends ProgressBar {
39 public CircleProgressBar(Context context, AttributeSet attrs, int defStyle) {
40 super(context, attrs, defStyle);
44 public CircleProgressBar(Context context, AttributeSet attrs) {
45 super(context, attrs);
49 public CircleProgressBar(Context context) {
54 private void setup() {
59 paint.setColor(0x33333300);
61 paint.setAntiAlias(true);
62 paint.setStyle(Style.FILL_AND_STROKE);
66 protected synchronized void onDraw(Canvas canvas) {
68 rect.left += getPaddingLeft() + 2;
69 rect.top += getPaddingTop() + 2;
70 rect.right -= getPaddingRight() + 2;
71 rect.bottom -= getPaddingBottom() + 2;
74 canvas.drawArc(rectf, -90, getProgress() * 360 / getMax(), true, paint);