diff --git a/README.md b/README.md index d2929ba..48fb72c 100644 --- a/README.md +++ b/README.md @@ -1,150 +1,155 @@ -[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-ArcProgressStackView-blue.svg?style=flat-square)](http://android-arsenal.com/details/1/3308) +
+

+ + Devlight + +

+
ArcProgressStackView -=================== +==================== + Present your progress bars in arc mode with information and total control. -View size, CB controls |Typeface, animation |Draw width, offset, gradient |Angle, orientation |Shadow -:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------: -![](https://lh3.googleusercontent.com/-5wahrBgdCTw/VuwHChXS3FI/AAAAAAAACNQ/eqpqhfnN5G0l3EnETDQ_I5qu4kqQYSysA/w327-h551-no/apsv_preview_size_cb.gif)|![](https://lh4.googleusercontent.com/-c6X1XyKY1go/VuwHCkNghpI/AAAAAAAACNQ/x_xtWAytFPkNrbuEDylIGKNR8mh1jW-rg/w323-h552-no/apsv_preview_typeface_animation.gif)|![](https://lh6.googleusercontent.com/-mz_x7ViHvpQ/VuwHCrwvy-I/AAAAAAAACNQ/vShu09gRxDYv1eekjOLDeSKoHMSluph3w/w325-h552-no/apsv_preview_offset.gif)|![](https://lh6.googleusercontent.com/-iuYi_G-OGrc/VuwHCgvlRNI/AAAAAAAACNQ/LNaGspht3gYsAMJfclfF9InQBzTamHj0Q/w325-h552-no/apsv_preview_angle.gif)|![](https://lh6.googleusercontent.com/-ifOq29FoVrE/VuwHCprAWrI/AAAAAAAACNQ/wLdEYiyV2kwd2rQDQf0QSMe-amHIbhogQ/w325-h552-no/apsv_preview_shadow.gif) +[![Android Arsenal](https://drive.google.com/uc?export=download&id=0BxPO_UeS7wScVWk2RmJHNGJGWUk)](http://android-arsenal.com/details/1/3308) +      +[![Android](https://drive.google.com/uc?export=download&id=0BxPO_UeS7wSccEZaclNGN0R5OWc)](https://github.com/DevLight-Mobile-Agency) +      +[![Download](https://drive.google.com/uc?export=download&id=0BxPO_UeS7wScaDl2U0QtWUx3emM)](https://bintray.com/gigamole/maven/apsv/_latestVersion) +      +[![License](https://drive.google.com/uc?export=download&id=0BxPO_UeS7wScU0tmeFpGMHVWNWs)](https://github.com/DevLight-Mobile-Agency/ArcProgressStackView/blob/master/LICENSE.txt) +      +[![Codacy](https://drive.google.com/uc?export=download&id=0BxPO_UeS7wScSHhmckZyeGJDcXc)](https://www.codacy.com/app/gigamole53/ArcProgressStackView?utm_source=github.com&utm_medium=referral&utm_content=DevLight-Mobile-Agency/ArcProgressStackView&utm_campaign=Badge_Grade) -U can check the sample app [here](https://github.com/GIGAMOLE/ArcProgressStackView/tree/master/app). +

+ +

-Download ------------- +You can check the sample app [here](https://github.com/DevLight-Mobile-Agency/ArcProgressStackView/tree/master/app). -You can download a .aar` from GitHub's [releases page](https://github.com/GIGAMOLE/ArcProgressStackView/releases). +Warn +==== +``` +This library is not more supported. +If you want to add new feature or fix a bug, grab source code and do it. +If you think your fix or feature would be useful to other developers, +I can add link of your repository to this README file. +Thank you for using our libraries. +``` -Or use Gradle jCenter: +Download +======== -```groovy -dependencies { - repositories { - mavenCentral() - maven { - url 'http://dl.bintray.com/gigamole/maven/' - } - } - compile 'com.github.gigamole.arcprogressstackview:library:+' -} -``` +You can download a `.aar` from GitHub's [releases page](https://github.com/DevLight-Mobile-Agency/ArcProgressStackView/releases). -Or Gradle Maven Central: +Or use Gradle: ```groovy -compile 'com.github.gigamole.arcprogressstackview:library:1.0.0' +compile 'devlight.io:arcprogressstackview:1.0.4' ``` -Or Maven: +Or Maven: ```xml - com.github.gigamole.arcprogressstackview - library - 1.0.0 - aar + devlight.io + arcprogressstackview + 1.0.4 + pom ``` -Android SDK Version -========= -ArcProgressStackView requires a minimum sdk version of 8, but if you want animation and shadow support it requires a minimum sdk version of 11. +Or Ivy: +```groovy + + + +``` -Sample -======== -For APSV you can set such parameters as: +Android SDK Version +=================== - - models: +`ArcProgressStackView` requires a minimum SDK version of 8, but if you want animation and shadow support it requires a minimum SDK version of 11. - allows you to set APSV models, where you set title, progress and colors. Can be set up only via code. +Sample +====== - - animation: +Parameters - allows you to animate progress with func call or with touch event. +For `APSV` you can set such parameters as: - - shadow: + - models: + allows you to set `APSV` models, where you set title, progress and colors. Can be set up only via code. - allows you to add shadow to your progress models, but remember, the shadow need LAYER_TYPE_SOFTWARE, so it decrease FPS. + - animation: + allows you to animate progress with func call or with touch event. - - round corners: + - shadow: + allows you to add shadow to your progress models, but remember, the shadow need `LAYER_TYPE_SOFTWARE`, so it decrease FPS. + - round corners: allows you to set round corners to models. - - drag/seek: - + - drag/seek: allows you to make your progress model seek like. - - typeface: - + - typeface: allows you to set custom typeface. - - text color: - + - text color: allows you to set text(title and progress indicator) color. - - shadow distance: - + - shadow distance: allows you to set shadow distance. - - shadow angle: - + - shadow angle: allows you to set shadow angle. - - shadow radius: - + - shadow radius: allows you to set shadow radius. - - shadow color: - + - shadow color: allows you to set shadow color. - - animation duration: - + - animation duration: allows you to set animation duration. - - animation listener: - + - animation listener: allows you to set animation listener. - - interpolator: - + - interpolator: allows you to set interpolator to animation. - - draw width: - + - draw width: allows you to set draw width in fraction mode(e.g. 55%) or dimension mode. - - model offset: - + - model offset: allows you to set model offset(positive or negative). - - model background: - + - model background: allows you to set model background track from start angle to sweep angle. - - start angle: - + - start angle: allows you to set start angle of models. - - sweep angle: - + - sweep angle: allows you to set sweep angle of models. - - progress indicator orientation: - + - progress indicator orientation: allows you to set progress indicator orientation. - - preview colors: - + - preview colors: allows you to set preview colors, which generate count of models equals to count of colors. - - preview background: - + - preview background: allows you to set models background preview color. -All angle variables can only be positive and be in range from 0 to 360 degrees. +Tips -The size of view automatically set up in square mode. +All angle variables can only be positive and be in range from 0 to 360 degrees. +The size of `View` automatically set up in square mode. + +Init Check out in code init: @@ -161,17 +166,17 @@ arcProgressStackView.setModels(models); Other methods check out in sample. -And XML init: +And `XML` init: ```xml - - + - + - + + + diff --git a/app/src/main/java/com/gigamole/arcprogressstackview/MainActivity.java b/app/src/main/java/devlight/io/sample/MainActivity.java similarity index 82% rename from app/src/main/java/com/gigamole/arcprogressstackview/MainActivity.java rename to app/src/main/java/devlight/io/sample/MainActivity.java index 76f366b..0fc4bd3 100644 --- a/app/src/main/java/com/gigamole/arcprogressstackview/MainActivity.java +++ b/app/src/main/java/devlight/io/sample/MainActivity.java @@ -1,9 +1,13 @@ -package com.gigamole.arcprogressstackview; +package devlight.io.sample; import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ValueAnimator; +import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; +import android.util.Log; import android.view.View; import android.view.animation.OvershootInterpolator; import android.widget.Button; @@ -14,11 +18,12 @@ import com.commonsware.cwac.colormixer.ColorMixer; import com.commonsware.cwac.colormixer.ColorMixerDialog; -import com.gigamole.library.ArcProgressStackView; import java.util.ArrayList; import java.util.Random; +import devlight.io.library.ArcProgressStackView; + public class MainActivity extends AppCompatActivity implements View.OnClickListener, CompoundButton.OnCheckedChangeListener, @@ -56,7 +61,7 @@ private void init() { mArcProgressStackView = (ArcProgressStackView) findViewById(R.id.apsv); // Get colors - final String[] startColors = getResources().getStringArray(R.array.polluted_waves); + final String[] startColors = getResources().getStringArray(R.array.devlight); final String[] endColors = getResources().getStringArray(R.array.default_preview); final String[] bgColors = getResources().getStringArray(R.array.medical_express); @@ -68,10 +73,10 @@ private void init() { // Set models final ArrayList models = new ArrayList<>(); - models.add(new ArcProgressStackView.Model("Circle", 0, Color.parseColor(bgColors[0]), mStartColors[0])); - models.add(new ArcProgressStackView.Model("Progress", 0, Color.parseColor(bgColors[1]), mStartColors[1])); - models.add(new ArcProgressStackView.Model("Stack", 0, Color.parseColor(bgColors[2]), mStartColors[2])); - models.add(new ArcProgressStackView.Model("View", 0, Color.parseColor(bgColors[3]), mStartColors[3])); + models.add(new ArcProgressStackView.Model("Strategy", 0, Color.parseColor(bgColors[0]), mStartColors[0])); + models.add(new ArcProgressStackView.Model("Design", 0, Color.parseColor(bgColors[1]), mStartColors[1])); + models.add(new ArcProgressStackView.Model("Development", 0, Color.parseColor(bgColors[2]), mStartColors[2])); + models.add(new ArcProgressStackView.Model("QA", 0, Color.parseColor(bgColors[3]), mStartColors[3])); mArcProgressStackView.setModels(models); // Get wrappers @@ -83,6 +88,7 @@ private void init() { final CheckBox cbDragging = (CheckBox) findViewById(R.id.cb_dragging); final CheckBox cbShadowing = (CheckBox) findViewById(R.id.cb_shadowing); final CheckBox cbRounding = (CheckBox) findViewById(R.id.cb_rounding); + final CheckBox cbLeveling = (CheckBox) findViewById(R.id.cb_leveling); final CheckBox cbShowModelBg = (CheckBox) findViewById(R.id.cb_show_model_bg); final CheckBox cbUseCustomTypeface = (CheckBox) findViewById(R.id.cb_use_custom_typeface); final CheckBox cbUseOvershootInterpolator = (CheckBox) findViewById(R.id.cb_use_overshoot_interpolator); @@ -95,6 +101,7 @@ private void init() { cbShadowing.setOnCheckedChangeListener(this); cbRounding.setOnCheckedChangeListener(this); cbShowModelBg.setOnCheckedChangeListener(this); + cbLeveling.setOnCheckedChangeListener(this); cbUseCustomTypeface.setOnCheckedChangeListener(this); cbUseOvershootInterpolator.setOnCheckedChangeListener(this); cbUseVerticalOrientation.setOnCheckedChangeListener(this); @@ -104,6 +111,7 @@ private void init() { onCheckedChanged(cbDragging, cbDragging.isChecked()); onCheckedChanged(cbShadowing, cbShadowing.isChecked()); onCheckedChanged(cbRounding, cbRounding.isChecked()); + onCheckedChanged(cbLeveling, cbLeveling.isChecked()); onCheckedChanged(cbShowModelBg, cbShowModelBg.isChecked()); onCheckedChanged(cbUseCustomTypeface, cbUseCustomTypeface.isChecked()); onCheckedChanged(cbUseOvershootInterpolator, cbUseOvershootInterpolator.isChecked()); @@ -114,12 +122,14 @@ private void init() { mBtnTextColor = (Button) findViewById(R.id.btn_text_color); mBtnShadowColor = (Button) findViewById(R.id.btn_shadow_color); final Button btnAnimate = (Button) findViewById(R.id.btn_animate); + final Button btnPresentation = (Button) findViewById(R.id.btn_presentation); final Button btnReset = (Button) findViewById(R.id.btn_reset); // Set buttons mBtnTextColor.setOnClickListener(this); mBtnShadowColor.setOnClickListener(this); btnAnimate.setOnClickListener(this); + btnPresentation.setOnClickListener(this); btnReset.setOnClickListener(this); // Set default colors @@ -149,26 +159,18 @@ private void init() { sbSweepAngle.setOnSeekBarChangeListener(this); // Set animator listener - mArcProgressStackView.setAnimatorListener(new Animator.AnimatorListener() { + mArcProgressStackView.setAnimatorUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override - public void onAnimationStart(final Animator animation) { - + public void onAnimationUpdate(final ValueAnimator animation) { + // Update goes here + Log.d("onAnimationUpdate: ", String.valueOf(animation.getAnimatedValue())); } - + }); + mArcProgressStackView.setAnimatorListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animation) { Toast.makeText(MainActivity.this, "ANIMATION", Toast.LENGTH_SHORT).show(); } - - @Override - public void onAnimationCancel(final Animator animation) { - - } - - @Override - public void onAnimationRepeat(final Animator animation) { - - } }); // Start apsv animation on start @@ -192,10 +194,15 @@ public void onCheckedChanged(final CompoundButton buttonView, final boolean isCh break; case R.id.cb_shadowing: mArcProgressStackView.setIsShadowed(isChecked); + mArcProgressStackView.requestLayout(); mWrapperShadow.setVisibility(isChecked ? View.VISIBLE : View.GONE); break; case R.id.cb_rounding: mArcProgressStackView.setIsRounded(isChecked); + mArcProgressStackView.postInvalidate(); + break; + case R.id.cb_leveling: + mArcProgressStackView.setIsLeveled(isChecked); break; case R.id.cb_show_model_bg: mArcProgressStackView.setModelBgEnabled(isChecked); @@ -208,8 +215,8 @@ public void onCheckedChanged(final CompoundButton buttonView, final boolean isCh break; case R.id.cb_use_vertical_orientation: mArcProgressStackView.setIndicatorOrientation(isChecked ? - ArcProgressStackView.IndicatorOrientation.VERTICAL : - ArcProgressStackView.IndicatorOrientation.HORIZONTAL + ArcProgressStackView.IndicatorOrientation.VERTICAL : + ArcProgressStackView.IndicatorOrientation.HORIZONTAL ); break; case R.id.cb_use_gradient: @@ -219,6 +226,9 @@ public void onCheckedChanged(final CompoundButton buttonView, final boolean isCh model.setColors(isChecked ? new int[]{mStartColors[i], mEndColors[i]} : null); } mArcProgressStackView.requestLayout(); + mArcProgressStackView.postInvalidate(); + break; + default: break; } } @@ -242,6 +252,11 @@ public void onClick(final View v) { finish(); startActivity(getIntent()); break; + case R.id.btn_presentation: + startActivity(new Intent(MainActivity.this, PresentationActivity.class)); + break; + default: + break; } } @@ -252,17 +267,20 @@ public void onProgressChanged(final SeekBar seekBar, final int progress, final b if (mFullSize == -1) mFullSize = mArcProgressStackView.getSize(); mArcProgressStackView.getLayoutParams().height = (int) ((mFullSize * 0.5f) + - (int) ((float) mFullSize * 0.5f * ((float) progress / 100.0f))); + (int) ((float) mFullSize * 0.5f * ((float) progress / 100.0f))); mArcProgressStackView.requestLayout(); break; case R.id.pb_shadow_distance: mArcProgressStackView.setShadowDistance(progress); + mArcProgressStackView.postInvalidate(); break; case R.id.pb_shadow_angle: mArcProgressStackView.setShadowAngle(progress); + mArcProgressStackView.postInvalidate(); break; case R.id.pb_shadow_radius: mArcProgressStackView.setShadowRadius(progress); + mArcProgressStackView.postInvalidate(); break; case R.id.pb_animation_duration: mArcProgressStackView.setAnimationDuration(progress); @@ -279,17 +297,19 @@ public void onProgressChanged(final SeekBar seekBar, final int progress, final b case R.id.pb_sweep_angle: mArcProgressStackView.setSweepAngle(progress); break; + default: + break; } } @Override public void onStartTrackingTouch(final SeekBar seekBar) { - + // Empty cause of implement } @Override public void onStopTrackingTouch(final SeekBar seekBar) { - + // Empty cause of implement } private void showColorPicker(final boolean isShadowColor) { diff --git a/app/src/main/java/devlight/io/sample/PresentationActivity.java b/app/src/main/java/devlight/io/sample/PresentationActivity.java new file mode 100644 index 0000000..3097d0e --- /dev/null +++ b/app/src/main/java/devlight/io/sample/PresentationActivity.java @@ -0,0 +1,94 @@ +package devlight.io.sample; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ValueAnimator; +import android.app.Activity; +import android.graphics.Color; +import android.os.Bundle; +import android.view.View; + +import java.util.ArrayList; + +import devlight.io.library.ArcProgressStackView; + +import static devlight.io.library.ArcProgressStackView.Model; +import static devlight.io.sample.MainActivity.MODEL_COUNT; + +/** + * Created by GIGAMOLE on 9/21/16. + */ + +public class PresentationActivity extends Activity { + + private int mCounter = 0; + + private ArcProgressStackView mArcProgressStackView; + + @Override + protected void onCreate(final Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_presentation); + + mArcProgressStackView = (ArcProgressStackView) findViewById(R.id.apsv_presentation); + mArcProgressStackView.setShadowColor(Color.argb(200, 0, 0, 0)); + mArcProgressStackView.setAnimationDuration(1000); + mArcProgressStackView.setSweepAngle(270); + + final String[] stringColors = getResources().getStringArray(R.array.devlight); + final String[] stringBgColors = getResources().getStringArray(R.array.bg); + + final int[] colors = new int[MODEL_COUNT]; + final int[] bgColors = new int[MODEL_COUNT]; + for (int i = 0; i < MODEL_COUNT; i++) { + colors[i] = Color.parseColor(stringColors[i]); + bgColors[i] = Color.parseColor(stringBgColors[i]); + } + + final ArrayList models = new ArrayList<>(); + models.add(new Model("STRATEGY", 1, bgColors[0], colors[0])); + models.add(new Model("DESIGN", 1, bgColors[1], colors[1])); + models.add(new Model("DEVELOPMENT", 1, bgColors[2], colors[2])); + models.add(new Model("QA", 1, bgColors[3], colors[3])); + mArcProgressStackView.setModels(models); + + final ValueAnimator valueAnimator = ValueAnimator.ofFloat(1.0F, 105.0F); + valueAnimator.setDuration(800); + valueAnimator.setStartDelay(200); + valueAnimator.setRepeatMode(ValueAnimator.RESTART); + valueAnimator.setRepeatCount(MODEL_COUNT - 1); + valueAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(final Animator animation) { + animation.removeListener(this); + animation.addListener(this); + mCounter = 0; + + for (final Model model : mArcProgressStackView.getModels()) model.setProgress(1); + mArcProgressStackView.animateProgress(); + } + + @Override + public void onAnimationRepeat(final Animator animation) { + mCounter++; + } + }); + valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(final ValueAnimator animation) { + mArcProgressStackView.getModels().get(Math.min(mCounter, MODEL_COUNT - 1)) + .setProgress((Float) animation.getAnimatedValue()); + mArcProgressStackView.postInvalidate(); + } + }); + + mArcProgressStackView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(final View v) { + if (valueAnimator.isRunning()) return; + if (mArcProgressStackView.getProgressAnimator().isRunning()) return; + valueAnimator.start(); + } + }); + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 668dcba..ae0bed5 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -14,12 +14,12 @@ android:layout_height="wrap_content" android:padding="15dp"> - @@ -98,6 +98,20 @@ + + + + + + + +