├── demo ├── .gitignore ├── images │ └── showcase.png ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ ├── drawable │ │ │ ├── circle2_bg.xml │ │ │ ├── circle_bg.xml │ │ │ └── circle3_bg.xml │ │ └── layout │ │ │ └── demo_layout.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── github │ │ └── kratorius │ │ └── circleprogress │ │ └── demo │ │ └── DemoActivity.java └── build.gradle ├── library ├── .gitignore ├── src │ └── main │ │ ├── res │ │ └── values │ │ │ ├── strings.xml │ │ │ └── attrs.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── github │ │ └── kratorius │ │ └── circleprogress │ │ └── CircleProgressView.java └── build.gradle ├── settings.gradle ├── .gitignore ├── gradle.properties ├── README.md └── LICENSE /demo/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':library', 'demo' -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | local.properties 3 | 4 | bin/ 5 | gen/ 6 | out/ 7 | 8 | .gradle 9 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | VERSION_NAME=1.0 2 | VERSION_CODE=1 3 | GROUP=com.github.kratorius.circleprogress -------------------------------------------------------------------------------- /demo/images/showcase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivgiuliani/android-circleprogress/HEAD/demo/images/showcase.png -------------------------------------------------------------------------------- /demo/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Circle Progress Demo 3 | 4 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Circle Progress 3 | 4 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivgiuliani/android-circleprogress/HEAD/demo/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivgiuliani/android-circleprogress/HEAD/demo/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivgiuliani/android-circleprogress/HEAD/demo/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable/circle2_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/circle_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/circle3_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:0.13.2' 7 | } 8 | } 9 | apply plugin: 'com.android.library' 10 | 11 | repositories { 12 | jcenter() 13 | } 14 | 15 | android { 16 | compileSdkVersion 19 17 | buildToolsVersion "19.1.0" 18 | 19 | defaultConfig { 20 | minSdkVersion 9 21 | targetSdkVersion 21 22 | versionCode Integer.parseInt(project.VERSION_CODE) 23 | versionName project.VERSION_NAME 24 | } 25 | } 26 | 27 | dependencies { 28 | } 29 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:0.12.+' 7 | } 8 | } 9 | apply plugin: 'android' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | android { 16 | compileSdkVersion 19 17 | buildToolsVersion "19.1.0" 18 | 19 | defaultConfig { 20 | minSdkVersion 9 21 | targetSdkVersion 19 22 | versionCode Integer.parseInt(project.VERSION_CODE) 23 | versionName project.VERSION_NAME 24 | } 25 | } 26 | 27 | dependencies { 28 | compile project(':library') 29 | } 30 | -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /demo/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /library/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-circleprogress 2 | 3 | A simple progress indicator on a circle. 4 | 5 | ![Screen](https://github.com/kratorius/android-circleprogress/raw/master/demo/images/showcase.png) 6 | 7 | 8 | ## Requirements 9 | 10 | * API 9+ 11 | 12 | 13 | ## Getting started 14 | 15 | Just add the library to your project and add a view like this: 16 | 17 | ``` xml 18 | 25 | ``` 26 | 27 | For more examples, check the [demo project](https://github.com/kratorius/android-circleprogress/tree/master/demo). 28 | 29 | 30 | ## Available view properties 31 | 32 | * `circleProgressThickness`: controls the thickness of the circle 33 | * `circleProgressColor`: the color of the circle 34 | * `circleProgressValue`: the "progress" (in the 0-100 range) 35 | * `circleProgressStartAngle`: starting angle 36 | * `circleProgressText`: optional text inside the circle 37 | * `circleProgressTextColor`: above text's color 38 | * `circleProgressTextSize`: above text's size 39 | * `circleProgressStartAnimation`: one of `none`, `roll`, `fadeIn`, `incremental`, `thicknessExpand`. 40 | 41 | -------------------------------------------------------------------------------- /demo/src/main/java/com/github/kratorius/circleprogress/demo/DemoActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.kratorius.circleprogress.demo; 2 | 3 | import android.app.Activity; 4 | import android.graphics.drawable.ScaleDrawable; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.Button; 8 | 9 | import com.github.kratorius.circleprogress.CircleProgressView; 10 | 11 | public class DemoActivity extends Activity { 12 | private Button btnFadeInReload; 13 | private Button btnRollReload; 14 | private Button btnRollIncremental; 15 | 16 | private CircleProgressView crcBackgroundLine; 17 | 18 | private int[] mCirclesId = new int[] { 19 | R.id.crc_standard, 20 | R.id.crc_large_thickness, 21 | R.id.crc_animated_fadeIn, 22 | R.id.crc_animated_roll, 23 | R.id.crc_animated_incremental, 24 | R.id.crc_ovalized, 25 | R.id.crc_diff_start_angle, 26 | R.id.crc_bg1, 27 | R.id.crc_bg2, 28 | R.id.crc_bg3, 29 | }; 30 | 31 | private int[] mIncButtonsId = new int[] { 32 | R.id.btn_inc_standard, 33 | R.id.btn_inc_large_thickness, 34 | R.id.btn_inc_animated_fadeIn, 35 | R.id.btn_inc_animated_roll, 36 | R.id.btn_inc_animated_incremental, 37 | R.id.btn_inc_ovalized, 38 | R.id.btn_inc_diff_start_angle, 39 | R.id.btn_inc_bg1, 40 | R.id.btn_inc_bg2, 41 | R.id.btn_inc_bg3, 42 | }; 43 | 44 | private int[] mDecButtonsId = new int[] { 45 | R.id.btn_dec_standard, 46 | R.id.btn_dec_large_thickness, 47 | R.id.btn_dec_animated_fadeIn, 48 | R.id.btn_dec_animated_roll, 49 | R.id.btn_dec_animated_incremental, 50 | R.id.btn_dec_ovalized, 51 | R.id.btn_dec_diff_start_angle, 52 | R.id.btn_dec_bg1, 53 | R.id.btn_dec_bg2, 54 | R.id.btn_dec_bg3, 55 | }; 56 | 57 | @Override 58 | protected void onCreate(Bundle savedInstanceState) { 59 | super.onCreate(savedInstanceState); 60 | setContentView(R.layout.demo_layout); 61 | 62 | btnFadeInReload = (Button) findViewById(R.id.btn_reload_fade_in); 63 | btnRollReload = (Button) findViewById(R.id.btn_reload_roll); 64 | btnRollIncremental = (Button) findViewById(R.id.btn_reload_incremental); 65 | crcBackgroundLine = (CircleProgressView) findViewById(R.id.crc_bg2); 66 | 67 | Reloader reloader = new Reloader(); 68 | 69 | btnFadeInReload.setOnClickListener(reloader); 70 | btnRollReload.setOnClickListener(reloader); 71 | btnRollIncremental.setOnClickListener(reloader); 72 | 73 | for (int i = 0; i < mCirclesId.length; i++) { 74 | CircleProgressView tmp = (CircleProgressView) findViewById(mCirclesId[i]); 75 | Button inc = (Button) findViewById(mIncButtonsId[i]); 76 | Button dec = (Button) findViewById(mDecButtonsId[i]); 77 | inc.setOnClickListener(new Incrementer(tmp)); 78 | dec.setOnClickListener(new Decrementer(tmp)); 79 | } 80 | } 81 | 82 | private class Reloader implements View.OnClickListener { 83 | @Override 84 | public void onClick(View view) { 85 | finish(); 86 | startActivity(getIntent()); 87 | } 88 | } 89 | 90 | private static class Incrementer implements View.OnClickListener { 91 | private CircleProgressView mRef; 92 | public Incrementer(CircleProgressView ref) { 93 | mRef = ref; 94 | } 95 | @Override 96 | public void onClick(View view) { 97 | int val = mRef.getValue(); 98 | val++; 99 | val = Math.min(Math.max(val, 0), 100); 100 | mRef.setValue(val); 101 | } 102 | } 103 | 104 | private static class Decrementer implements View.OnClickListener { 105 | private CircleProgressView mRef; 106 | public Decrementer(CircleProgressView ref) { 107 | mRef = ref; 108 | } 109 | @Override 110 | public void onClick(View view) { 111 | int val = mRef.getValue(); 112 | val--; 113 | val = Math.min(Math.max(val, 0), 100); 114 | mRef.setValue(val); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /library/src/main/java/com/github/kratorius/circleprogress/CircleProgressView.java: -------------------------------------------------------------------------------- 1 | package com.github.kratorius.circleprogress; 2 | 3 | import android.animation.ObjectAnimator; 4 | import android.annotation.TargetApi; 5 | import android.content.Context; 6 | import android.content.res.TypedArray; 7 | import android.graphics.Canvas; 8 | import android.graphics.Color; 9 | import android.graphics.Paint; 10 | import android.graphics.Path; 11 | import android.graphics.RectF; 12 | import android.os.Build; 13 | import android.util.AttributeSet; 14 | import android.view.View; 15 | import android.view.animation.DecelerateInterpolator; 16 | 17 | /** 18 | * Simple progress bar shown as a circle. 19 | */ 20 | public class CircleProgressView extends View { 21 | private final static int DEFAULT_THICKNESS = 20; 22 | private final static int DEFAULT_VALUE = 0; 23 | private final static int DEFAULT_START_ANGLE = -90; 24 | private final static int DEFAULT_COLOR = Color.DKGRAY; 25 | private final static int DEFAULT_TEXT_SIZE = 45; 26 | private final static int DEFAULT_START_ANIMATION_DURATION = 500; 27 | 28 | // keep in sync with values in attrs.xml 29 | private final static int ANIM_NONE = 0; 30 | private final static int ANIM_ROLL = 1; 31 | private final static int ANIM_FADE_IN = 2; 32 | private final static int ANIM_INCREMENTAL = 3; 33 | private final static int ANIM_THICKNESS_EXPAND = 4; 34 | 35 | private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 36 | private final Paint mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 37 | 38 | private final Path mPath = new Path(); 39 | private final RectF mDrawRect = new RectF(); 40 | 41 | private int mThickness; 42 | private int mColor; 43 | private int mValue; 44 | private int mStartAngle; 45 | 46 | private String mText; 47 | private int mTextColor; 48 | private int mTextSize; 49 | 50 | private int mStartAnimation; 51 | private int mStartAnimationDuration; 52 | 53 | public CircleProgressView(Context context) { 54 | this(context, null, 0); 55 | } 56 | 57 | public CircleProgressView(Context context, AttributeSet attrs) { 58 | this(context, attrs, 0); 59 | } 60 | 61 | public CircleProgressView(Context context, AttributeSet attrs, int defStyle) { 62 | super(context, attrs, defStyle); 63 | 64 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressView); 65 | try { 66 | assert a != null; 67 | mThickness = a.getDimensionPixelSize(R.styleable.CircleProgressView_circleProgressThickness, DEFAULT_THICKNESS); 68 | mColor = a.getColor(R.styleable.CircleProgressView_circleProgressColor, DEFAULT_COLOR); 69 | mTextColor = a.getColor(R.styleable.CircleProgressView_circleProgressTextColor, mColor); 70 | mValue = a.getInteger(R.styleable.CircleProgressView_circleProgressValue, DEFAULT_VALUE); 71 | mStartAngle = a.getInteger(R.styleable.CircleProgressView_circleProgressStartAngle, DEFAULT_START_ANGLE); 72 | mTextSize = a.getDimensionPixelSize(R.styleable.CircleProgressView_circleProgressTextSize, DEFAULT_TEXT_SIZE); 73 | mText = a.getString(R.styleable.CircleProgressView_circleProgressText); 74 | mStartAnimation = a.getInteger(R.styleable.CircleProgressView_circleProgressStartAnimation, ANIM_NONE); 75 | mStartAnimationDuration = a.getInteger(R.styleable.CircleProgressView_circleProgressStartAnimationDuration, DEFAULT_START_ANIMATION_DURATION); 76 | } finally { 77 | a.recycle(); 78 | } 79 | 80 | setValue(mValue); 81 | 82 | mPaint.setStyle(Paint.Style.STROKE); 83 | mPaint.setColor(mColor); 84 | mPaint.setStrokeWidth(mThickness); 85 | 86 | mTextPaint.setColor(mTextColor); 87 | mTextPaint.setTextSize(mTextSize); 88 | mTextPaint.setTextAlign(Paint.Align.CENTER); 89 | } 90 | 91 | @Override 92 | protected void onDraw(Canvas canvas) { 93 | super.onDraw(canvas); 94 | 95 | // rescale [0-100] in [0-360] 96 | final int degrees = (int) ((mValue / 100.) * 360); 97 | final int width = getWidth() - getPaddingRight(); 98 | final int height = getHeight() - getPaddingBottom(); 99 | final String text = getText(); 100 | 101 | mPath.reset(); 102 | 103 | mDrawRect.top = getPaddingTop() + mThickness; 104 | mDrawRect.left = getPaddingLeft() + mThickness; 105 | mDrawRect.bottom = height - mThickness; 106 | mDrawRect.right = width - mThickness; 107 | 108 | mPath.addArc(mDrawRect, mStartAngle, degrees); 109 | canvas.drawPath(mPath, mPaint); 110 | 111 | int textX = getWidth() / 2; 112 | int textY = (int) ((getHeight() / 2) - ((mTextPaint.descent() + mTextPaint.ascent()) / 2.)); 113 | 114 | canvas.drawText(text, textX, textY, mTextPaint); 115 | } 116 | 117 | @TargetApi(Build.VERSION_CODES.HONEYCOMB) 118 | @Override 119 | protected void onAttachedToWindow() { 120 | super.onAttachedToWindow(); 121 | // currently animations are ignored on devices that don't support 122 | // them natively 123 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { 124 | return; 125 | } 126 | 127 | ObjectAnimator animator; 128 | switch (mStartAnimation) { 129 | case ANIM_ROLL: 130 | animator = ObjectAnimator.ofInt(this, "startAngle", mStartAngle - 180, mStartAngle); 131 | animator.setInterpolator(new DecelerateInterpolator()); 132 | break; 133 | case ANIM_FADE_IN: 134 | animator = ObjectAnimator.ofFloat(this, "alpha", 0, 1); 135 | break; 136 | case ANIM_INCREMENTAL: 137 | animator = ObjectAnimator.ofInt(this, "value", 0, mValue); 138 | animator.setInterpolator(new DecelerateInterpolator()); 139 | break; 140 | case ANIM_THICKNESS_EXPAND: 141 | animator = ObjectAnimator.ofInt(this, "thickness", 0, mThickness); 142 | animator.setInterpolator(new DecelerateInterpolator()); 143 | break; 144 | default: 145 | animator = null; 146 | } 147 | 148 | if (animator != null) { 149 | animator.setDuration(mStartAnimationDuration); 150 | animator.start(); 151 | } 152 | } 153 | 154 | /** 155 | * Sets the value of the progress circle. 156 | * @param value value in percentage of the progress bar. This must be 157 | * in the 0-100 range (both included). 158 | */ 159 | public void setValue(int value) { 160 | if (value < 0 || value > 100) { 161 | throw new IllegalArgumentException( 162 | String.format("Value was %d but must be in the 0-100 range", value) 163 | ); 164 | } 165 | mValue = value; 166 | invalidate(); 167 | } 168 | 169 | /** 170 | * Returns the current value of the progress circle. 171 | * @return current progress circle's value 172 | */ 173 | public int getValue() { 174 | return mValue; 175 | } 176 | 177 | /** 178 | * Sets the thickness of the of the circle progress bar. 179 | * @param thickness thickness of the of the circle progress bar 180 | */ 181 | public void setThickness(int thickness) { 182 | if (thickness < 0) { 183 | throw new IllegalArgumentException( 184 | String.format("Thickness was %d but must be positive", thickness) 185 | ); 186 | } 187 | mThickness = thickness; 188 | mPaint.setStrokeWidth(thickness); 189 | invalidate(); 190 | } 191 | 192 | /** 193 | * Returns the current thickness of the circle progress bar. 194 | * @return thickness of the circle progress bar 195 | */ 196 | public int getThickness() { 197 | return mThickness; 198 | } 199 | 200 | /** 201 | * Sets the color of the circle progress bar. 202 | * @param color color of the circle progress bar. 203 | */ 204 | public void setColor(int color) { 205 | mColor = color; 206 | mPaint.setColor(mColor); 207 | invalidate(); 208 | } 209 | 210 | /** 211 | * Returns the current color of the circle progress bar. 212 | * @return color of the circle progress bar 213 | */ 214 | public int getColor() { 215 | return mColor; 216 | } 217 | 218 | /** 219 | * Sets the text inside the circle progress bar.
220 | * If the text is {@code null}, the view will show the current value 221 | * inside the circle. 222 | * @param text input text or null to show the current value 223 | */ 224 | public void setText(String text) { 225 | mText = text; 226 | invalidate(); 227 | } 228 | 229 | /** 230 | * Returns the current text inside the circle progress bar. 231 | * @return text inside the circle progress bar or null if there's no 232 | * text set 233 | */ 234 | public String getText() { 235 | if (mText == null) { 236 | return Integer.toString(mValue); 237 | } 238 | return mText; 239 | } 240 | 241 | /** 242 | * Sets the color of the text inside circle progress bar. 243 | * @param color text color 244 | */ 245 | public void setTextColor(int color) { 246 | mTextColor = color; 247 | mTextPaint.setColor(mTextColor); 248 | invalidate(); 249 | } 250 | 251 | /** 252 | * Returns the color of the text inside the circle progress bar. 253 | * @return color of the circle progress bar 254 | */ 255 | public int getTextColor() { 256 | return mTextColor; 257 | } 258 | 259 | /** 260 | * Sets the size of the text inside the circle progress bar. 261 | * @param size text size 262 | */ 263 | public void setTextSize(int size) { 264 | mTextSize = size; 265 | mTextPaint.setTextSize(size); 266 | invalidate(); 267 | } 268 | 269 | /** 270 | * Returns the size of the text inside the circle progress bar. 271 | * @return text size 272 | */ 273 | public int getTextSize() { 274 | return mTextSize; 275 | } 276 | 277 | /** 278 | * Sets the start angle of the progress circle. This corresponds to the point 279 | * in the circle where the drawing starts.
280 | * The angle {@code 0} corresponds to the rightmost point on the circle (if you 281 | * take a clock as reference, it'd be the 15 mins point).
282 | * If the start angle is negative or >= 360, the start angle is treated as start 283 | * angle modulo 360. 284 | * @param angle angle in degrees 285 | */ 286 | public void setStartAngle(int angle) { 287 | mStartAngle = angle; 288 | invalidate(); 289 | } 290 | 291 | /** 292 | * Returns the current start angle. 293 | * @return start angle 294 | */ 295 | public int getStartAngle() { 296 | return mStartAngle; 297 | } 298 | } 299 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2013 Vito Giuliani 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/demo_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 15 | 16 | 20 | 24 | 25 | 31 | 32 |