diff --git a/README.md b/README.md index 10d35ee..1fbeee6 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,18 @@ you can customize WaveformSeekBar, all of this attributes can change via xml or |wave_progress_color|Color|`waveProgressColor`|Reached Waves color, default color is `Color.WHITE`| | - |IntArray|`sample`|Sample data for drawing waves, default is `null`| +# Reduce size +Add ``` android:extractNativeLibs="false" ``` to application in the Manifest.xml + +``` xml + + + +``` + # License ``` Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d2373ab..cd8e447 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,7 +11,8 @@ android:label="@string/app_name" android:supportsRtl="false" android:theme="@style/AppTheme" - android:extractNativeLibs="false"> + android:extractNativeLibs="false" + android:requestLegacyExternalStorage="true"> diff --git a/app/src/main/java/com/masoudss/activity/MainActivity.kt b/app/src/main/java/com/masoudss/activity/MainActivity.kt index 9c8e392..c75d3e7 100644 --- a/app/src/main/java/com/masoudss/activity/MainActivity.kt +++ b/app/src/main/java/com/masoudss/activity/MainActivity.kt @@ -146,7 +146,9 @@ class MainActivity : AppCompatActivity() { var waves: IntArray = intArrayOf() - WaveformOptions.getSampleFrom(path) { + WaveformOptions.init(this@MainActivity) + + WaveformOptions.getSampleFrom(path!!) { waves = it } diff --git a/lib/build.gradle b/lib/build.gradle index c02580b..54b2b96 100755 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -28,7 +28,7 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "androidx.appcompat:appcompat:1.2.0" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.github.lincollincol:Amplituda:1.3' + implementation 'com.github.lincollincol:Amplituda:1.4' } repositories { mavenCentral() diff --git a/lib/src/main/java/com/masoudss/lib/WaveformOptions.kt b/lib/src/main/java/com/masoudss/lib/WaveformOptions.kt index 804542a..e0361c8 100644 --- a/lib/src/main/java/com/masoudss/lib/WaveformOptions.kt +++ b/lib/src/main/java/com/masoudss/lib/WaveformOptions.kt @@ -1,15 +1,23 @@ package com.masoudss.lib +import android.content.Context import linc.com.amplituda.Amplituda import java.io.File object WaveformOptions { - private val amplituda by lazy { Amplituda() } + private var amplituda: Amplituda? = null + + @JvmStatic + fun init(context: Context) { + if(amplituda == null) { + amplituda = Amplituda(context) + } + } @JvmStatic fun getSampleFrom(file: File, onSuccess:(samples: IntArray) -> Unit) { - amplituda.fromFile(file) + amplituda!!.fromFile(file) .amplitudesAsList { onSuccess(it.toIntArray()) } @@ -17,7 +25,7 @@ object WaveformOptions { @JvmStatic fun getSampleFrom(path: String, onSuccess: (IntArray) -> Unit) { - amplituda.fromPath(path) + amplituda!!.fromPath(path) .amplitudesAsList { onSuccess(it.toIntArray()) }