* Authors: Nathaniel McCallum <npmccallum@redhat.com>
*
* Copyright (C) 2013 Nathaniel McCallum, Red Hat
- * see file 'COPYING' for use and warranty information
*
- * This program is free software you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.fedorahosted.freeotp;
super(context);
setup();
}
-
+
private void setup() {
paint = new Paint();
rectf = new RectF();
rect = new Rect();
-
- paint.setColor(0x33333300);
- paint.setAlpha(0x99);
+
+ paint.setARGB(0x99, 0x33, 0x33, 0x33);
paint.setAntiAlias(true);
paint.setStyle(Style.FILL_AND_STROKE);
}
+ @Override
+ public synchronized void setProgress(int progress) {
+ super.setProgress(progress);
+ if (paint != null) {
+ int percent = progress * 100 / getMax();
+ if (percent > 25 || progress == 0)
+ paint.setARGB(0x99, 0x33, 0x33, 0x33);
+ else
+ paint.setARGB(0x99, 0xff, 0xe0 * percent / 25, 0x00);
+ }
+ }
+
@Override
protected synchronized void onDraw(Canvas canvas) {
getDrawingRect(rect);
rect.top += getPaddingTop() + 2;
rect.right -= getPaddingRight() + 2;
rect.bottom -= getPaddingBottom() + 2;
-
+
rectf.set(rect);
canvas.drawArc(rectf, -90, getProgress() * 360 / getMax(), true, paint);
}