diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..fb7f4a8
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
new file mode 100644
index 0000000..a25576a
--- /dev/null
+++ b/.idea/deploymentTargetDropDown.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 7bfef59..6d48cc1 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,16 @@
-
+
+
+
+
+
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 7f68460..0000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index c914382..251bb09 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -3,13 +3,13 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
- compileSdkVersion 30
- buildToolsVersion "29.0.3"
+ compileSdkVersion 31
+ buildToolsVersion "30.0.3"
// 0123456789
defaultConfig {
applicationId "com.ahmedbadereldin.videotrimmerapplication"
- minSdkVersion 19
- targetSdkVersion 30
+ minSdkVersion 21
+ targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -24,10 +24,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
- debuggable true
- minifyEnabled true
- shrinkResources true
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+// debuggable true
+// minifyEnabled true
+// shrinkResources true
+// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
@@ -40,12 +40,12 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
- implementation 'androidx.core:core-ktx:1.3.1'
- implementation 'androidx.appcompat:appcompat:1.2.0'
- implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
- testImplementation 'junit:junit:4.13'
- androidTestImplementation 'androidx.test.ext:junit:1.1.1'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+ implementation 'androidx.core:core-ktx:1.6.0'
+ implementation 'androidx.appcompat:appcompat:1.3.1'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
@@ -56,9 +56,18 @@ dependencies {
implementation 'io.reactivex:rxjava:1.3.5'
implementation 'io.reactivex:rxandroid:1.2.1'
- implementation('com.github.bumptech.glide:glide:4.11.0') {
+ implementation('com.github.bumptech.glide:glide:4.12.0') {
exclude group: "com.android.support"
}
+
+ //CameraX Dependencies
+ implementation "androidx.camera:camera-core:1.1.0-alpha09"
+ implementation "androidx.camera:camera-camera2:1.1.0-alpha09"
+ implementation "androidx.camera:camera-lifecycle:1.1.0-alpha09"
+ implementation "androidx.camera:camera-view:1.0.0-alpha29"
+ implementation "androidx.camera:camera-extensions:1.0.0-alpha29"
+ implementation 'com.sangcomz:FishBun:1.0.0-alpha05'
+
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation project(':videotrimmer')
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 7db003a..59d1ddc 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,9 +4,22 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -30,6 +43,7 @@
android:name=".NewPostActivity"
android:configChanges="orientation|screenSize"
android:launchMode="singleTask"
+ android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
@@ -47,6 +61,7 @@
android:configChanges="orientation|screenSize"
android:launchMode="singleTask"
android:screenOrientation="portrait"
+ android:exported="true"
android:theme="@style/AppTheme.SlidrActivityTheme"
android:windowSoftInputMode="adjustPan" />
@@ -55,9 +70,20 @@
android:configChanges="orientation|screenSize"
android:launchMode="singleTask"
android:screenOrientation="portrait"
+ android:exported="true"
android:theme="@style/AppTheme.SlidrActivityTheme"
android:windowSoftInputMode="adjustPan" />
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/ahmedbadereldin/videotrimmerapplication/NewPostActivity.java b/app/src/main/java/com/ahmedbadereldin/videotrimmerapplication/NewPostActivity.java
index 280618c..83ab9ad 100644
--- a/app/src/main/java/com/ahmedbadereldin/videotrimmerapplication/NewPostActivity.java
+++ b/app/src/main/java/com/ahmedbadereldin/videotrimmerapplication/NewPostActivity.java
@@ -147,6 +147,8 @@ private void loadImage(Uri filepath) {
if (fileExt.equalsIgnoreCase("MP4")) {
File file = new File(path);
+ Log.d(TAG, "loadImageloadImageloadImageloadImage: " + path);
+ Log.d(TAG, "loadImageloadImageloadImageloadImage: " + file.length());
if (file.exists()) {
startActivityForResult(new Intent(NewPostActivity.this, VideoTrimmerActivity.class).putExtra("EXTRA_PATH", path), VIDEO_TRIM);
overridePendingTransition(0, 0);
diff --git a/app/src/main/java/com/ahmedbadereldin/videotrimmerapplication/VideoTrimmerActivity.java b/app/src/main/java/com/ahmedbadereldin/videotrimmerapplication/VideoTrimmerActivity.java
index 8e2db63..8a8d903 100644
--- a/app/src/main/java/com/ahmedbadereldin/videotrimmerapplication/VideoTrimmerActivity.java
+++ b/app/src/main/java/com/ahmedbadereldin/videotrimmerapplication/VideoTrimmerActivity.java
@@ -1,13 +1,17 @@
package com.ahmedbadereldin.videotrimmerapplication;
import android.app.ProgressDialog;
+import android.content.Context;
import android.content.Intent;
+import android.database.Cursor;
+import android.graphics.Color;
import android.media.MediaMetadataRetriever;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
+import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
@@ -20,6 +24,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
import com.ahmedbadereldin.videotrimmer.Utility;
import com.ahmedbadereldin.videotrimmer.customVideoViews.BackgroundTask;
@@ -28,8 +33,12 @@
import com.ahmedbadereldin.videotrimmer.customVideoViews.OnRangeSeekBarChangeListener;
import com.ahmedbadereldin.videotrimmer.customVideoViews.OnVideoTrimListener;
import com.ahmedbadereldin.videotrimmer.customVideoViews.TileView;
+import com.sangcomz.fishbun.FishBun;
+import com.sangcomz.fishbun.adapter.image.impl.GlideAdapter;
import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
import java.util.Locale;
import java.util.Objects;
@@ -117,9 +126,14 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
if (getIntent().getExtras() != null) {
srcFile = getIntent().getExtras().getString("EXTRA_PATH");
+
}
dstFile = Environment.getExternalStorageDirectory() + "/" + getString(R.string.app_name) + new Date().getTime()
+ Utility.VIDEO_FORMAT;
+// dstFile = Environment.getExternalStorageDirectory() + "/" + getString(R.string.app_name) + new Date().getTime()
+// + Utility.VIDEO_FORMAT;
+
+ Log.d("srcFile", "loadImageloadImageloadImageloadImage: " + dstFile);
tileView.post(() -> {
setBitmap(Uri.parse(srcFile));
@@ -205,7 +219,10 @@ public void onClick(View view) {
mediaMetadataRetriever = new MediaMetadataRetriever();
mediaMetadataRetriever.setDataSource(VideoTrimmerActivity.this, Uri.parse(srcFile));
final File file = new File(srcFile);
-
+ Log.d(
+ "executeAAAA",
+ "execute: " + "Aaaa" + file.length() + " " + dstFile + " " + mStartPosition + " " + mEndPosition + " " + mOnVideoTrimListener
+ );
//notify that video trimming started
if (mOnVideoTrimListener != null)
mOnVideoTrimListener.onTrimStarted();
@@ -214,7 +231,11 @@ public void onClick(View view) {
@Override
public void execute() {
try {
- Utility.startTrim(file, dstFile, mStartPosition * 1000, mEndPosition * 1000, mOnVideoTrimListener);
+ Log.d(
+ "executeAAAA",
+ "execute: " + "Aaaa" + file.length() + " " + dstFile + " " + mStartPosition + " " + mEndPosition + " " + mOnVideoTrimListener
+ );
+ Utility.startTrim(VideoTrimmerActivity.this,file, dstFile, mStartPosition * 1000, mEndPosition * 1000, mOnVideoTrimListener);
} catch (final Throwable e) {
Objects.requireNonNull(Thread.getDefaultUncaughtExceptionHandler()).uncaughtException(Thread.currentThread(), e);
}
@@ -421,4 +442,6 @@ public String milliSecondsToTimer(long milliseconds) {
// return timer string
return finalTimerString;
}
+
+
}
diff --git a/app/src/main/java/com/ahmedbadereldin/videotrimmerapplication/kotlinCode/VideoTrimmerKotlinActivity.kt b/app/src/main/java/com/ahmedbadereldin/videotrimmerapplication/kotlinCode/VideoTrimmerKotlinActivity.kt
index e68255a..5fb2a0e 100644
--- a/app/src/main/java/com/ahmedbadereldin/videotrimmerapplication/kotlinCode/VideoTrimmerKotlinActivity.kt
+++ b/app/src/main/java/com/ahmedbadereldin/videotrimmerapplication/kotlinCode/VideoTrimmerKotlinActivity.kt
@@ -187,7 +187,7 @@ class VideoTrimmerKotlinActivity : AppCompatActivity(),
"executeAAAA",
"execute: " + "Aaaa" + file.length() + " " + dstFile + " " + mStartPosition + " " + mEndPosition + " " + mOnVideoTrimListener
)
- Utility.startTrim(
+ Utility.startTrim(this@VideoTrimmerKotlinActivity,
file,
dstFile!!,
mStartPosition * 1000.toLong(),
diff --git a/app/src/main/res/xml/provider_paths.xml b/app/src/main/res/xml/provider_paths.xml
new file mode 100644
index 0000000..2edfa17
--- /dev/null
+++ b/app/src/main/res/xml/provider_paths.xml
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/build.gradle b/build.gradle
index 2342847..1972c40 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,12 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = "1.3.72"
+ ext.kotlin_version = "1.5.31"
repositories {
google()
jcenter()
}
dependencies {
- classpath "com.android.tools.build:gradle:4.0.1"
+ classpath 'com.android.tools.build:gradle:7.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 1ab4bdb..f7811fc 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
diff --git a/videotrimmer/build.gradle b/videotrimmer/build.gradle
index a4fe4cd..762597c 100644
--- a/videotrimmer/build.gradle
+++ b/videotrimmer/build.gradle
@@ -8,8 +8,6 @@ android {
defaultConfig {
minSdkVersion 19
targetSdkVersion 30
- versionCode 1
- versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
diff --git a/videotrimmer/src/main/java/com/ahmedbadereldin/videotrimmer/Utility.java b/videotrimmer/src/main/java/com/ahmedbadereldin/videotrimmer/Utility.java
index 68f630a..71310bc 100644
--- a/videotrimmer/src/main/java/com/ahmedbadereldin/videotrimmer/Utility.java
+++ b/videotrimmer/src/main/java/com/ahmedbadereldin/videotrimmer/Utility.java
@@ -1,9 +1,13 @@
package com.ahmedbadereldin.videotrimmer;
+import android.app.Activity;
import android.net.Uri;
+import android.os.Environment;
import android.util.Log;
+import android.widget.Toast;
import androidx.annotation.NonNull;
+import androidx.core.content.ContextCompat;
import com.ahmedbadereldin.videotrimmer.customVideoViews.OnVideoTrimListener;
import com.coremedia.iso.boxes.Container;
@@ -29,15 +33,11 @@ public class Utility {
public static final String VIDEO_FORMAT = ".mp4";
private static final String TAG = Utility.class.getSimpleName();
- public static void startTrim(@NonNull File src, @NonNull String dst, long startMs, long endMs,
+ public static void startTrim(Activity activity, @NonNull File src, @NonNull String dst, long startMs, long endMs,
@NonNull OnVideoTrimListener callback) throws IOException {
- final String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date());
- File file = new File(dst);
- file.getParentFile().mkdirs();
- Log.d(TAG, "Generated file path " + dst);
- generateVideo(src, file, startMs, endMs, callback);
-
-
+ File file1 = create(activity, dst);
+ if (file1 != null)
+ generateVideo(src, file1, startMs, endMs, callback);
}
private static void generateVideo(@NonNull File src, @NonNull File dst, long startMs,
@@ -103,16 +103,39 @@ private static void generateVideo(@NonNull File src, @NonNull File dst, long sta
Container out = new DefaultMp4Builder().build(movie);
- FileOutputStream fos = new FileOutputStream(dst);
- FileChannel fc = fos.getChannel();
- out.writeContainer(fc);
-
- fc.close();
- fos.close();
- if (callback != null)
- callback.getResult(Uri.parse(dst.toString()));
+ try {
+ FileOutputStream fos = new FileOutputStream(dst);
+ FileChannel fc = fos.getChannel();
+ out.writeContainer(fc);
+ fc.close();
+ fos.close();
+ if (callback != null)
+ callback.getResult(Uri.parse(dst.toString()));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
}
+ private static File create(Activity activity, String dst) {
+ File file = new File(dst);
+ file.getParentFile().mkdirs();
+// File storageDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
+ File storageDir = activity.getExternalFilesDir(file.getParentFile().getAbsolutePath());
+ Log.d(TAG, "Generated file path " + file.getParentFile().getAbsolutePath() + " ----< 123123 file1 " + storageDir.exists());
+ Log.d(TAG, "Generated file path " + Environment.DIRECTORY_PICTURES + " ----< 123123 file1 " + storageDir.exists());
+
+ try {
+ return File.createTempFile(
+ activity.getResources().getString(R.string.app_name) + new Date().getTime(), /* prefix */
+ ".mp4", /* suffix */
+ storageDir /* directory */
+ );
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
}