4 * Authors: Nathaniel McCallum <npmccallum@redhat.com>
6 * Copyright (C) 2013 Nathaniel McCallum, Red Hat
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 package org.fedorahosted.freeotp;
23 import android.content.Context;
24 import android.graphics.Canvas;
25 import android.graphics.Paint;
26 import android.graphics.Paint.Style;
27 import android.graphics.Rect;
28 import android.graphics.RectF;
29 import android.util.AttributeSet;
30 import android.widget.ProgressBar;
32 public class CircleProgressBar extends ProgressBar {
37 public CircleProgressBar(Context context, AttributeSet attrs, int defStyle) {
38 super(context, attrs, defStyle);
42 public CircleProgressBar(Context context, AttributeSet attrs) {
43 super(context, attrs);
47 public CircleProgressBar(Context context) {
52 private void setup() {
57 paint.setColor(0x33333300);
59 paint.setAntiAlias(true);
60 paint.setStyle(Style.FILL_AND_STROKE);
64 protected synchronized void onDraw(Canvas canvas) {
66 rect.left += getPaddingLeft() + 2;
67 rect.top += getPaddingTop() + 2;
68 rect.right -= getPaddingRight() + 2;
69 rect.bottom -= getPaddingBottom() + 2;
72 canvas.drawArc(rectf, -90, getProgress() * 360 / getMax(), true, paint);