Skip to content

Commit

Permalink
trim time issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowtham committed Sep 4, 2020
1 parent 6b06afe commit 38f9a95
Show file tree
Hide file tree
Showing 26 changed files with 379 additions and 261 deletions.
18 changes: 18 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

sourceSets {
main {
assets.srcDirs = ['src/main/assets', 'src/main/assets/']
res.srcDirs = ['src/main/res', 'src/main/res/drawable']
}
}

dexOptions {
javaMaxHeapSize "4g"
}

configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
all*.exclude group: 'xpp3', module: 'xpp3'
}

packagingOptions {
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}

buildTypes {
release {
minifyEnabled true
Expand Down
6 changes: 5 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-dontwarn com.gowtham.library**
-keep class com.gowtham.library** { *; }
-keep interface com.gowtham.library** { *; }
Binary file added app/release/app-release.aab
Binary file not shown.
Binary file added app/release/app-release.apk
Binary file not shown.
20 changes: 20 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 1,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.gowtham.videotrimmer",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 1,
"versionName": "1.0",
"enabled": true,
"outputFile": "app-release.apk"
}
]
}

This file was deleted.

92 changes: 49 additions & 43 deletions app/src/main/java/com/gowtham/videotrimmer/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package com.gowtham.videotrimmer;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
Expand All @@ -15,14 +9,23 @@
import android.view.View;
import android.widget.EditText;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import com.cocosw.bottomsheet.BottomSheet;
import com.gowtham.library.ui.ActVideoTrimmer;
import com.gowtham.library.utils.TrimmerConstants;
import com.gowtham.library.utils.LogMessage;
import com.gowtham.library.utils.TrimmerUtils;
import com.gowtham.library.utils.TrimmerConstants;

import java.io.File;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

Expand All @@ -32,7 +35,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe

private MediaController mediaController;

private EditText edtFixedGap,edtMinGap, edtMinFrom, edtMAxTo;
private EditText edtFixedGap, edtMinGap, edtMinFrom, edtMAxTo;

private int trimType;

Expand All @@ -43,10 +46,10 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = findViewById(R.id.video_view);
edtFixedGap=findViewById(R.id.edt_fixed_gap);
edtMinGap=findViewById(R.id.edt_min_gap);
edtMinFrom =findViewById(R.id.edt_min_from);
edtMAxTo =findViewById(R.id.edt_max_to);
edtFixedGap = findViewById(R.id.edt_fixed_gap);
edtMinGap = findViewById(R.id.edt_min_gap);
edtMinFrom = findViewById(R.id.edt_min_from);
edtMAxTo = findViewById(R.id.edt_max_to);
mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);

Expand All @@ -62,22 +65,26 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
try {
if (requestCode == TrimmerConstants.REQ_CODE_VIDEO_TRIMMER && data != null) {
Uri uri = Uri.parse(data.getStringExtra(TrimmerConstants.TRIMMED_VIDEO_PATH));
Log.d(TAG,"Trimmed path:: "+uri);
Log.d(TAG, "Trimmed path:: " + uri);
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
}else if (requestCode == REQUEST_TAKE_VIDEO && resultCode == RESULT_OK) {
String filepath = String.valueOf(uri);
File file = new File(filepath);
long length = file.length();
Log.d(TAG, "Video size:: " + (length / 1024));
} else if (requestCode == REQUEST_TAKE_VIDEO && resultCode == RESULT_OK) {
/* //check video duration if needed
if (TrimmerUtils.getVideoDuration(this,data.getData())<=30){
Toast.makeText(this,"Video should be larger than 30 sec",Toast.LENGTH_SHORT).show();
return;
}*/
if (data.getData()!=null){
LogMessage.v("Video path:: "+data.getData());
if (data.getData() != null) {
LogMessage.v("Video path:: " + data.getData());
openTrimActivity(String.valueOf(data.getData()));
}else{
Toast.makeText(this,"video uri is null",Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "video uri is null", Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e) {
Expand All @@ -86,30 +93,29 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
}

private void openTrimActivity(String data) {
if (trimType==0){
Intent intent=new Intent(this,ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI,data);
intent.putExtra(TrimmerConstants.HIDE_PLAYER_SEEKBAR,true);
intent.putExtra(TrimmerConstants.DESTINATION,"/storage/emulated/0/DCIM/TESTFOLDER");
if (trimType == 0) {
Intent intent = new Intent(this, ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI, data);
intent.putExtra(TrimmerConstants.DESTINATION, "/storage/emulated/0/DCIM/TESTFOLDER");
startActivityForResult(intent, TrimmerConstants.REQ_CODE_VIDEO_TRIMMER);
}else if (trimType==1){
Intent intent=new Intent(this,ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI,data);
intent.putExtra(TrimmerConstants.TRIM_TYPE,1);
intent.putExtra(TrimmerConstants.FIXED_GAP_DURATION,getEdtValueLong(edtFixedGap));
} else if (trimType == 1) {
Intent intent = new Intent(this, ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI, data);
intent.putExtra(TrimmerConstants.TRIM_TYPE, 1);
intent.putExtra(TrimmerConstants.FIXED_GAP_DURATION, getEdtValueLong(edtFixedGap));
startActivityForResult(intent, TrimmerConstants.REQ_CODE_VIDEO_TRIMMER);
}else if (trimType==2){
Intent intent=new Intent(this,ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI,data);
intent.putExtra(TrimmerConstants.TRIM_TYPE,2);
intent.putExtra(TrimmerConstants.MIN_GAP_DURATION,getEdtValueLong(edtMinGap));
} else if (trimType == 2) {
Intent intent = new Intent(this, ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI, data);
intent.putExtra(TrimmerConstants.TRIM_TYPE, 2);
intent.putExtra(TrimmerConstants.MIN_GAP_DURATION, getEdtValueLong(edtMinGap));
startActivityForResult(intent, TrimmerConstants.REQ_CODE_VIDEO_TRIMMER);
}else{
Intent intent=new Intent(this,ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI,data);
intent.putExtra(TrimmerConstants.TRIM_TYPE,3);
intent.putExtra(TrimmerConstants.MIN_FROM_DURATION,getEdtValueLong(edtMinFrom));
intent.putExtra(TrimmerConstants.MAX_TO_DURATION,getEdtValueLong(edtMAxTo));
} else {
Intent intent = new Intent(this, ActVideoTrimmer.class);
intent.putExtra(TrimmerConstants.TRIM_VIDEO_URI, data);
intent.putExtra(TrimmerConstants.TRIM_TYPE, 3);
intent.putExtra(TrimmerConstants.MIN_FROM_DURATION, getEdtValueLong(edtMinFrom));
intent.putExtra(TrimmerConstants.MAX_TO_DURATION, getEdtValueLong(edtMAxTo));
startActivityForResult(intent, TrimmerConstants.REQ_CODE_VIDEO_TRIMMER);
}
}
Expand Down Expand Up @@ -214,17 +220,17 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
showVideoOptions();
}

private boolean isEdtTxtEmpty(EditText editText){
private boolean isEdtTxtEmpty(EditText editText) {
return editText.getText().toString().trim().isEmpty();
}

private long getEdtValueLong(EditText editText){
private long getEdtValueLong(EditText editText) {
return Long.parseLong(editText.getText().toString().trim());
}

private boolean checkCamStoragePer() {
return checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.CAMERA);
Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA);
}

private boolean checkPermission(String... permissions) {
Expand Down
32 changes: 32 additions & 0 deletions app/src/main/java/com/gowtham/videotrimmer/SquareVideoView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.gowtham.videotrimmer;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.VideoView;

import androidx.appcompat.widget.AppCompatImageView;

public class SquareVideoView extends VideoView {

public SquareVideoView(Context context) {
super(context);
}

public SquareVideoView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public SquareVideoView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}


@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);

int width = getMeasuredWidth();
setMeasuredDimension(width, width);
}

}
Loading

0 comments on commit 38f9a95

Please sign in to comment.