diff --git a/README.md b/README.md index db817ea..ae382f5 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,8 @@ Usage vumeter:speed="10" vumeter:blockNumber="5" vumeter:blockSpacing="20dp" - vumeter:backgroundColor="#33b5e5"/> + vumeter:backgroundColor="#33b5e5" + vumeter:startOff="false"/> ``` See [DemoApp](https://github.com/HugoGresse/AndroidVuMeter/blob/master/app/src/main/java/io/gresse/hugo/vumeter/MainActivity.java) for complete usage example. @@ -40,7 +41,7 @@ Download Using Gradle: ``` -compile 'io.gresse.hugo.vumeterlibrary:vumeterlibrary:1.0.9' +compile 'io.gresse.hugo.vumeterlibrary:vumeterlibrary:1.0.10' ``` *Hosted on jCenter only.* diff --git a/app/app.iml b/app/app.iml index 628a14f..d157232 100644 --- a/app/app.iml +++ b/app/app.iml @@ -36,13 +36,13 @@ - + - + @@ -71,8 +71,8 @@ - - + + @@ -86,12 +86,13 @@ + - + - - - + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index eb0adf3..147b140 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,15 +1,16 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 22 - buildToolsVersion "23.0.0 rc3" + compileSdkVersion 23 + buildToolsVersion "23.0.0" defaultConfig { applicationId "io.gresse.hugo.vumeter" minSdkVersion 9 - targetSdkVersion 22 - versionCode 1 - versionName "1.0" + targetSdkVersion 23 + versionCode 2 + versionName "1.0.10" + archivesBaseName = "VuMeterLibrary-demo-" + versionName } buildTypes { release { @@ -21,6 +22,6 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:22.2.1' + compile 'com.android.support:appcompat-v7:23.0.0' compile project(':vumeterlibrary') } \ No newline at end of file diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 8650c6b..6136a19 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -7,17 +7,18 @@ android:id="@+id/action_stop" android:orderInCategory="100" android:title="@string/action_stop" - app:showAsAction="ifRoom"/> + app:showAsAction="always" + tools:ignore="AlwaysShowAction"/> + app:showAsAction="always"/> + app:showAsAction="always"/> diff --git a/build.gradle b/build.gradle index d9448d9..e3686c4 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' diff --git a/vumeterlibrary/build.gradle b/vumeterlibrary/build.gradle index 2c7a50a..8e24a60 100644 --- a/vumeterlibrary/build.gradle +++ b/vumeterlibrary/build.gradle @@ -5,14 +5,14 @@ apply plugin: 'com.jfrog.bintray' apply plugin: 'com.github.dcendents.android-maven' android { - compileSdkVersion 22 - buildToolsVersion "23.0.0 rc3" + compileSdkVersion 23 + buildToolsVersion "23.0.0" defaultConfig { minSdkVersion 9 - targetSdkVersion 22 - versionCode 10 - versionName "1.0.9" + targetSdkVersion 23 + versionCode 11 + versionName "1.0.10" } buildTypes { release { @@ -24,7 +24,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:22.2.1' + compile 'com.android.support:appcompat-v7:23.0.0' } /////////////////////////////////////////// diff --git a/vumeterlibrary/src/main/java/io/gresse/hugo/vumeterlibrary/Dynamics.java b/vumeterlibrary/src/main/java/io/gresse/hugo/vumeterlibrary/Dynamics.java index 84cb87f..dbe661a 100644 --- a/vumeterlibrary/src/main/java/io/gresse/hugo/vumeterlibrary/Dynamics.java +++ b/vumeterlibrary/src/main/java/io/gresse/hugo/vumeterlibrary/Dynamics.java @@ -68,6 +68,10 @@ public boolean isAtRest() { return mIsToTarget; } + public void setAtRest(boolean atRest){ + mIsToTarget = atRest; + } + public float getPosition() { return mPosition; } diff --git a/vumeterlibrary/src/main/java/io/gresse/hugo/vumeterlibrary/VuMeterView.java b/vumeterlibrary/src/main/java/io/gresse/hugo/vumeterlibrary/VuMeterView.java index ccc562d..74ca3c1 100644 --- a/vumeterlibrary/src/main/java/io/gresse/hugo/vumeterlibrary/VuMeterView.java +++ b/vumeterlibrary/src/main/java/io/gresse/hugo/vumeterlibrary/VuMeterView.java @@ -1,12 +1,12 @@ package io.gresse.hugo.vumeterlibrary; +import android.annotation.SuppressLint; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.util.AttributeSet; -import android.util.Log; import android.view.View; import java.util.Random; @@ -26,6 +26,7 @@ public class VuMeterView extends View { public static final int DEFAULT_BLOCK_SPACING = 20; public static final int DEFAULT_SPEED = 10; public static final int DEFAULT_STOP_SIZE = 30; + public static final boolean DEFAULT_START_OFF = false; public static final int FPS = 60; public static final int STATE_PAUSE = 0; @@ -82,18 +83,25 @@ private void init(AttributeSet attrs, int defStyle) { mBlockSpacing = a.getDimension(R.styleable.VuMeterView_blockSpacing, DEFAULT_BLOCK_SPACING); mSpeed = a.getInt(R.styleable.VuMeterView_speed, DEFAULT_SPEED); mStopSize = a.getDimension(R.styleable.VuMeterView_stopSize, DEFAULT_STOP_SIZE); + boolean startOff = a.getBoolean(R.styleable.VuMeterView_startOff, DEFAULT_START_OFF); a.recycle(); // Init initialiseCollections(); mPaint.setColor(mColor); - mState = STATE_PLAYING; + + if(startOff){ + mState = STATE_PAUSE; + } else { + mState = STATE_PLAYING; + } mDrawPass = mBlockPass = mContentHeight = mContentWidth = mPaddingLeft = mPaddingTop = mLeft = mTop = mPaddingRight = mPaddingBottom = mRight = 0; } + @SuppressLint("DrawAllocation") @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); @@ -107,6 +115,15 @@ protected void onDraw(Canvas canvas) { if (mBlockWidth == 0) { mBlockWidth = (int) ((mContentWidth - (mBlockNumber - 1) * mBlockSpacing) / mBlockNumber); + + // called if startOff is true + if(mState == STATE_PAUSE){ + int stopSize = (int) (mContentHeight - mStopSize); + for (int i = 0; i < mBlockNumber; i++) { + mDestinationValues[i] = new Dynamics(mSpeed, stopSize); + mDestinationValues[i].setAtRest(true); + } + } } @@ -296,7 +313,6 @@ public void pause(){ public void stop(boolean withAnimation){ mState = STATE_STOP; int collapseSize = (int) (mContentHeight - mStopSize); - Log.d(LOG_TAG, "collapseSize: " + collapseSize); for(int i = 0; i < mBlockNumber; i++){ if(withAnimation){ mDestinationValues[i].setTargetPosition(collapseSize); diff --git a/vumeterlibrary/src/main/res/values/attrs_vu_meter_view.xml b/vumeterlibrary/src/main/res/values/attrs_vu_meter_view.xml index 2920d4d..57f6a81 100644 --- a/vumeterlibrary/src/main/res/values/attrs_vu_meter_view.xml +++ b/vumeterlibrary/src/main/res/values/attrs_vu_meter_view.xml @@ -5,5 +5,6 @@ + diff --git a/vumeterlibrary/vumeterlibrary.iml b/vumeterlibrary/vumeterlibrary.iml index 198ab57..9e8ca6a 100644 --- a/vumeterlibrary/vumeterlibrary.iml +++ b/vumeterlibrary/vumeterlibrary.iml @@ -1,5 +1,5 @@ - + @@ -37,13 +37,13 @@ - + - + @@ -65,7 +65,6 @@ - @@ -85,15 +84,13 @@ - - - + - - - + + + \ No newline at end of file