Skip to content

Commit

Permalink
Adds record time and travis conf
Browse files Browse the repository at this point in the history
  • Loading branch information
netodevel committed Jan 31, 2018
1 parent 96f7304 commit 6d555b1
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 6 deletions.
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: android
jdk: oraclejdk8
sudo: false
addons:
apt:
packages:
- lynx
android:
components:
- platform-tools
- tools
- build-tools-27.0.2
- android-27
- extra-android-m2repository

#before_install: chmod +x gradle/publish.sh
#script: publish.sh
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {
}
dependencies {
compile 'br.com.netodevel:circle-video-record:2.0'
compile 'br.com.netodevel:circle-video-record:2.4'
}
```
Expand All @@ -37,6 +37,7 @@ dependencies {
android:layout_centerInParent="true"
app:circle_width="280dp"
app:circle_height="280dp"
app:record_time="10000"
app:play_button_image="@drawable/ic_play_circle"
app:close_button_image="@drawable/ic_stop"
app:max_time_message="Max time!!">
Expand All @@ -61,6 +62,7 @@ override fun onCreate(savedInstanceState: Bundle?) {
* Setup Circle Video Record
*/
circle_video_record.setup(root_layout, cameraView)
//circle_video_record.setRecordTime(2000)

button_record.setOnClickListener {
mStatus = !mStatus!!;
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/br/com/netodevel/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class MainActivity : AppCompatActivity() {
*/
circle_video_record.setup(root_layout, cameraView)

//circle_video_record.setRecordTime(2000)

button_record.setOnClickListener {
mStatus = !mStatus!!;

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
app:play_button_image="@drawable/ic_play_circle"
app:close_button_image="@drawable/ic_stop"
app:max_time_message="Max time!!"
app:record_time="10000"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</br.com.netodevel.circle_video_record.CircleVideoRecord>
Expand Down
6 changes: 3 additions & 3 deletions circle-video-record/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'

version = '2.3'
version = '2.4'
group = 'br.com.netodevel'

android {
Expand All @@ -12,7 +12,7 @@ android {
minSdkVersion 15
targetSdkVersion 26
versionCode 2
versionName "2.3"
versionName "2.4"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down Expand Up @@ -65,7 +65,7 @@ install {
packaging 'aar'
groupId 'br.com.netodevel'
artifactId 'circle-video-record'
version '2.3'
version '2.4'

licenses {
license {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class CircleVideoRecord extends RelativeLayout {
private Drawable drawablePlayButton;
private Drawable drawableCloseButton;
private String maxTimeMessage = "";
private Integer recordTime;

private RelativeLayout mRootLayout;

public CircleVideoRecord(Context context) {
Expand Down Expand Up @@ -86,6 +88,7 @@ public void setup(RelativeLayout view, CameraView cameraView) {
progressFrameLayout.setId(ID_PROGRESS_FRAME_LAYOUT);
progressFrameLayout.setVisibility(INVISIBLE);
progressFrameLayout.setBackground(ContextCompat.getDrawable(mContext, R.drawable.shape_circle));
progressFrameLayout.setRecordTime(recordTime != 0 ? recordTime : 10000);

LayoutParams layoutParams = new LayoutParams(circleWidth != 0 ? circleWidth : 290, circleHeight != 0 ? circleHeight : 290);
layoutParams.addRule(CENTER_IN_PARENT, TRUE);
Expand Down Expand Up @@ -148,6 +151,7 @@ public void callback(CameraKitVideo cameraKitVideo) {
});

recording = true;

progressFrameLayout.start();
progressFrameLayout.requestLayout();
}
Expand Down Expand Up @@ -211,6 +215,11 @@ public void hide() {
this.mCloseButton.setVisibility(INVISIBLE);
}

public void setRecordTime(Integer milliSeconds) {
recordTime = milliSeconds;
progressFrameLayout.setRecordTime(recordTime);
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void cropViews() {
ViewOutlineProvider vop = new ViewOutlineProvider() {
Expand Down Expand Up @@ -294,6 +303,7 @@ public void init(final Context context, AttributeSet attrs, int defStyleAttr, in
circleHeight = (int) typedArray.getDimension(R.styleable.CircleVideoRecord_circle_height, ViewGroup.LayoutParams.WRAP_CONTENT);

maxTimeMessage = (String) typedArray.getString(R.styleable.CircleVideoRecord_max_time_message);
recordTime = (int) typedArray.getInt(R.styleable.CircleVideoRecord_record_time, 0);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class CircularAnimatedDrawable extends Drawable implements Animatable {

private ValueAnimator mValueAnimatorSweep;
private static final Interpolator SWEEP_INTERPOLATOR = new DecelerateInterpolator();
private static final int SWEEP_ANIMATOR_DURATION = 10000;
private static final Float MIN_SWEEP_ANGLE = 30f;

private final RectF fBounds = new RectF();
Expand All @@ -36,6 +35,7 @@ public class CircularAnimatedDrawable extends Drawable implements Animatable {
private boolean mRunning;

private ProgressListener progressListener;
private int sweepAnimatorDuration;

public CircularAnimatedDrawable(View view, float borderWidth, int arcColor) {
mAnimatedView = view;
Expand All @@ -51,6 +51,12 @@ public CircularAnimatedDrawable(View view, float borderWidth, int arcColor) {
setupAnimations();
}

public void setSweepAnimatorDuration(int milliSeconds){
this.sweepAnimatorDuration = milliSeconds;

mValueAnimatorSweep.setDuration(sweepAnimatorDuration != 0 ? sweepAnimatorDuration : 10000);
}

public void setOnProgressListener(ProgressListener progressListener) {
this.progressListener = progressListener;
}
Expand Down Expand Up @@ -145,7 +151,7 @@ public void setCurrentSweepAngle(float currentSweepAngle) {
private void setupAnimations() {
mValueAnimatorSweep = ValueAnimator.ofFloat(mCurrentSweepAngle, 360f);
mValueAnimatorSweep.setInterpolator(SWEEP_INTERPOLATOR);
mValueAnimatorSweep.setDuration(SWEEP_ANIMATOR_DURATION);
mValueAnimatorSweep.setDuration(sweepAnimatorDuration != 0 ? sweepAnimatorDuration : 10000);

mValueAnimatorSweep.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.support.annotation.RequiresApi;
import android.support.annotation.StyleRes;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.FrameLayout;

/**
Expand All @@ -20,6 +21,7 @@ public class ProgressFrameLayout extends FrameLayout {
private CircularAnimatedDrawable mAnimatedDrawable;
private State mState;
private FinishVideoListener finishVideoListener;
private int recordTime;

public ProgressFrameLayout(@NonNull Context context) {
super(context);
Expand Down Expand Up @@ -62,13 +64,18 @@ public void stop() {
this.mState = State.STOP;
}

public void setRecordTime(Integer milliSeconds) {
this.recordTime = milliSeconds;
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mState == State.PROGRESS) {
if (mAnimatedDrawable == null || !mAnimatedDrawable.isRunning()) {
mAnimatedDrawable = new CircularAnimatedDrawable(this, 5, Color.WHITE);
mAnimatedDrawable.setSweepAnimatorDuration(recordTime);

mAnimatedDrawable.setOnProgressListener(new ProgressListener() {
@Override
Expand Down
2 changes: 2 additions & 0 deletions circle-video-record/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

<attr name="max_time_message" format="string"/>

<attr name="record_time" format="integer"/>

</declare-styleable>

<declare-styleable name="CameraTouchButton">
Expand Down
Empty file added publish.sh
Empty file.

0 comments on commit 6d555b1

Please sign in to comment.