diff --git a/android/test-app/build.gradle b/android/test-app/build.gradle index cecf5f3d0..ce69fd329 100644 --- a/android/test-app/build.gradle +++ b/android/test-app/build.gradle @@ -53,6 +53,7 @@ android.applicationVariants.all { variant -> dependencies { // implementation project(':app') implementation 'com.arthenica:mobile-ffmpeg-full:4.3.1' + implementation 'com.arthenica:smart-exception-java:0.1.0' implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' } diff --git a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/MainActivity.java b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/MainActivity.java index 736d9ab3c..4e87841eb 100644 --- a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/MainActivity.java +++ b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/MainActivity.java @@ -36,6 +36,7 @@ import com.arthenica.mobileffmpeg.Config; import com.arthenica.mobileffmpeg.util.AsyncSingleFFmpegExecuteTask; import com.arthenica.mobileffmpeg.util.ResourcesUtil; import com.arthenica.mobileffmpeg.util.SingleExecuteCallback; +import com.arthenica.smartexception.java.Exceptions; import java.io.File; import java.io.IOException; @@ -56,6 +57,10 @@ public class MainActivity extends AppCompatActivity { Manifest.permission.CAMERA }; + static { + Exceptions.registerRootPackage("com.arthenica"); + } + protected static final Queue actionQueue = new ConcurrentLinkedQueue<>(); protected static final Handler handler = new Handler(); @@ -72,7 +77,7 @@ public class MainActivity extends AppCompatActivity { try { callable.call(); } catch (final Exception e) { - android.util.Log.e(MainActivity.TAG, "Running UI action received error.", e); + android.util.Log.e(TAG, String.format("Running UI action received error.%s", Exceptions.getStackTraceString(e))); } } } while (callable != null); @@ -123,7 +128,7 @@ public class MainActivity extends AppCompatActivity { registerAppFont(); Log.d(TAG, "Application fonts registered."); } catch (final IOException e) { - Log.e(TAG, "Font registration failed.", e); + Log.e(TAG, String.format("Font registration failed.%s", Exceptions.getStackTraceString(e))); } Log.d(TAG, "Listing supported camera ids."); diff --git a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/PipeTabFragment.java b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/PipeTabFragment.java index 1c9e72ec1..6cc7b8459 100644 --- a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/PipeTabFragment.java +++ b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/PipeTabFragment.java @@ -43,6 +43,7 @@ import com.arthenica.mobileffmpeg.util.AsyncCatImageTask; import com.arthenica.mobileffmpeg.util.DialogUtil; import com.arthenica.mobileffmpeg.util.ResourcesUtil; import com.arthenica.mobileffmpeg.util.SingleExecuteCallback; +import com.arthenica.smartexception.java.Exceptions; import java.io.File; import java.io.IOException; @@ -188,7 +189,7 @@ public class PipeTabFragment extends Fragment { startAsyncCatImageProcess(image3File.getAbsolutePath(), pipe3); } catch (IOException e) { - Log.e(TAG, "Create video failed", e); + Log.e(TAG, String.format("Create video failed %s", Exceptions.getStackTraceString(e))); Popup.show(requireContext(), "Create video failed"); } } diff --git a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/SubtitleTabFragment.java b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/SubtitleTabFragment.java index f31a9a6a1..79ecc41ec 100644 --- a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/SubtitleTabFragment.java +++ b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/SubtitleTabFragment.java @@ -42,6 +42,7 @@ import com.arthenica.mobileffmpeg.StatisticsCallback; import com.arthenica.mobileffmpeg.util.DialogUtil; import com.arthenica.mobileffmpeg.util.ResourcesUtil; import com.arthenica.mobileffmpeg.util.SingleExecuteCallback; +import com.arthenica.smartexception.java.Exceptions; import java.io.File; import java.io.IOException; @@ -103,7 +104,7 @@ public class SubtitleTabFragment extends Fragment { @Override public void apply(LogMessage message) { - android.util.Log.d(MainActivity.TAG, message.getText()); + Log.d(MainActivity.TAG, message.getText()); } }); } @@ -229,7 +230,7 @@ public class SubtitleTabFragment extends Fragment { }, ffmpegCommand); } catch (IOException e) { - Log.e(TAG, "Burn subtitles failed", e); + Log.e(TAG, String.format("Burn subtitles failed %s", Exceptions.getStackTraceString(e))); Popup.show(requireContext(), "Burn subtitles failed"); } } diff --git a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/VidStabTabFragment.java b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/VidStabTabFragment.java index ffa30b25f..30357ac4b 100644 --- a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/VidStabTabFragment.java +++ b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/VidStabTabFragment.java @@ -38,6 +38,7 @@ import com.arthenica.mobileffmpeg.LogMessage; import com.arthenica.mobileffmpeg.util.DialogUtil; import com.arthenica.mobileffmpeg.util.ResourcesUtil; import com.arthenica.mobileffmpeg.util.SingleExecuteCallback; +import com.arthenica.smartexception.java.Exceptions; import java.io.File; import java.io.IOException; @@ -92,7 +93,7 @@ public class VidStabTabFragment extends Fragment { @Override public void apply(LogMessage message) { - android.util.Log.d(MainActivity.TAG, message.getText()); + Log.d(MainActivity.TAG, message.getText()); } }); } @@ -121,7 +122,7 @@ public class VidStabTabFragment extends Fragment { stabilizedVideoFile.delete(); } - android.util.Log.d(TAG, "Testing VID.STAB"); + Log.d(TAG, "Testing VID.STAB"); showCreateProgressDialog(); @@ -131,13 +132,13 @@ public class VidStabTabFragment extends Fragment { final String ffmpegCommand = Video.generateShakingVideoScript(image1File.getAbsolutePath(), image2File.getAbsolutePath(), image3File.getAbsolutePath(), videoFile.getAbsolutePath()); - android.util.Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", ffmpegCommand)); + Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", ffmpegCommand)); MainActivity.executeAsync(new SingleExecuteCallback() { @Override public void apply(final int returnCode, final String commandOutput) { - android.util.Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode)); + Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode)); hideCreateProgressDialog(); @@ -147,30 +148,30 @@ public class VidStabTabFragment extends Fragment { public Object call() { if (returnCode == RETURN_CODE_SUCCESS) { - android.util.Log.d(TAG, "Create completed successfully; stabilizing video."); + Log.d(TAG, "Create completed successfully; stabilizing video."); final String analyzeVideoCommand = String.format("-y -i %s -vf vidstabdetect=shakiness=10:accuracy=15:result=%s -f null -", videoFile.getAbsolutePath(), shakeResultsFile.getAbsolutePath()); showStabilizeProgressDialog(); - android.util.Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", analyzeVideoCommand)); + Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", analyzeVideoCommand)); MainActivity.executeAsync(new SingleExecuteCallback() { @Override public void apply(final int returnCode, final String commandOutput) { - android.util.Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode)); + Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode)); if (returnCode == RETURN_CODE_SUCCESS) { final String stabilizeVideoCommand = String.format("-y -i %s -vf vidstabtransform=smoothing=30:input=%s -c:v mpeg4 %s", videoFile.getAbsolutePath(), shakeResultsFile.getAbsolutePath(), stabilizedVideoFile.getAbsolutePath()); - android.util.Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", stabilizeVideoCommand)); + Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", stabilizeVideoCommand)); MainActivity.executeAsync(new SingleExecuteCallback() { @Override public void apply(final int returnCode, final String commandOutput) { - android.util.Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode)); + Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode)); hideStabilizeProgressDialog(); @@ -179,12 +180,12 @@ public class VidStabTabFragment extends Fragment { @Override public Object call() { if (returnCode == RETURN_CODE_SUCCESS) { - android.util.Log.d(TAG, "Stabilize video completed successfully; playing videos."); + Log.d(TAG, "Stabilize video completed successfully; playing videos."); playVideo(); playStabilizedVideo(); } else { Popup.show(requireContext(), "Stabilize video failed. Please check log for the details."); - android.util.Log.d(TAG, String.format("Stabilize video failed with rc=%d", returnCode)); + Log.d(TAG, String.format("Stabilize video failed with rc=%d", returnCode)); } return null; @@ -196,14 +197,14 @@ public class VidStabTabFragment extends Fragment { } else { hideStabilizeProgressDialog(); Popup.show(requireContext(), "Stabilize video failed. Please check log for the details."); - android.util.Log.d(TAG, String.format("Stabilize video failed with rc=%d", returnCode)); + Log.d(TAG, String.format("Stabilize video failed with rc=%d", returnCode)); } } }, analyzeVideoCommand); } else { Popup.show(requireContext(), "Create video failed. Please check log for the details."); - android.util.Log.d(TAG, String.format("Create failed with rc=%d", returnCode)); + Log.d(TAG, String.format("Create failed with rc=%d", returnCode)); } return null; @@ -213,7 +214,7 @@ public class VidStabTabFragment extends Fragment { }, ffmpegCommand); } catch (IOException e) { - android.util.Log.e(TAG, "Stabilize video failed", e); + Log.e(TAG, String.format("Stabilize video failed %s", Exceptions.getStackTraceString(e))); Popup.show(requireContext(), "Stabilize video failed"); } } diff --git a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/VideoTabFragment.java b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/VideoTabFragment.java index 60112566b..bafe863d1 100644 --- a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/VideoTabFragment.java +++ b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/VideoTabFragment.java @@ -46,6 +46,7 @@ import com.arthenica.mobileffmpeg.StatisticsCallback; import com.arthenica.mobileffmpeg.util.DialogUtil; import com.arthenica.mobileffmpeg.util.ResourcesUtil; import com.arthenica.mobileffmpeg.util.SingleExecuteCallback; +import com.arthenica.smartexception.java.Exceptions; import java.io.File; import java.io.IOException; @@ -206,7 +207,7 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele }, ffmpegCommand); } catch (IOException e) { - Log.e(TAG, "Encode video failed", e); + Log.e(TAG, String.format("Encode video failed %s", Exceptions.getStackTraceString(e))); Popup.show(requireContext(), "Encode video failed"); } } @@ -228,7 +229,7 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode)); } catch (IOException e) { - Log.e(TAG, "Encode webp failed", e); + Log.e(TAG, String.format("Encode webp failed %s", Exceptions.getStackTraceString(e))); Popup.show(requireContext(), "Encode webp failed"); } } diff --git a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/util/AsyncCatImageTask.java b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/util/AsyncCatImageTask.java index f4872367f..7c8b5d351 100644 --- a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/util/AsyncCatImageTask.java +++ b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/util/AsyncCatImageTask.java @@ -22,6 +22,8 @@ package com.arthenica.mobileffmpeg.util; import android.os.AsyncTask; import android.util.Log; +import com.arthenica.smartexception.java.Exceptions; + import java.io.IOException; import static com.arthenica.mobileffmpeg.test.MainActivity.TAG; @@ -41,7 +43,7 @@ public class AsyncCatImageTask extends AsyncTask { return rc; } catch (final IOException | InterruptedException e) { - Log.e(TAG, String.format("Async cat image command failed for %s.", inputs[0]), e); + Log.e(TAG, String.format("Async cat image command failed for %s.%s", inputs[0], Exceptions.getStackTraceString(e))); return -1; } } diff --git a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/util/ResourcesUtil.java b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/util/ResourcesUtil.java index 69174de69..bbbe66830 100644 --- a/android/test-app/src/main/java/com/arthenica/mobileffmpeg/util/ResourcesUtil.java +++ b/android/test-app/src/main/java/com/arthenica/mobileffmpeg/util/ResourcesUtil.java @@ -25,12 +25,15 @@ import android.graphics.BitmapFactory; import android.util.Log; import com.arthenica.mobileffmpeg.test.MainActivity; +import com.arthenica.smartexception.java.Exceptions; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import static com.arthenica.mobileffmpeg.test.MainActivity.TAG; + public class ResourcesUtil { public static void resourceToFile(Resources resources, final int resourceId, final File file) throws IOException { Bitmap bitmap = BitmapFactory.decodeResource(resources, resourceId); @@ -60,7 +63,7 @@ public class ResourcesUtil { outputStream.write(buffer, 0, readSize); } } catch (final IOException e) { - Log.e(MainActivity.TAG, "Saving raw resource failed.", e); + Log.e(TAG, String.format("Saving raw resource failed.%s", Exceptions.getStackTraceString(e))); } finally { inputStream.close(); outputStream.flush();