From ffb51ef0d1ae9917c09484638ddb9a6e1ad9154c Mon Sep 17 00:00:00 2001
From: ideastudios <815106625@qq.com>
Date: Wed, 23 Oct 2019 15:57:57 +0800
Subject: [PATCH] modify the buffer interval from 20 ms to 100 ms update build
tools version gradle version
---
.idea/codeStyles/Project.xml | 116 ++++++++++++++++++
.idea/gradle.xml | 6 +-
.idea/misc.xml | 16 ++-
app/build.gradle | 21 ++--
.../oom/idealrecorderdemo/MainActivity.java | 3 +
build.gradle | 12 +-
gradle/wrapper/gradle-wrapper.properties | 4 +-
library/build.gradle | 14 +--
.../tech/oom/idealrecorder/IdealRecorder.java | 14 ++-
.../oom/idealrecorder/record/Recorder.java | 5 +-
10 files changed, 173 insertions(+), 38 deletions(-)
create mode 100644 .idea/codeStyles/Project.xml
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..681f41a
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index e449e74..d83d161 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -3,7 +3,10 @@
diff --git a/.idea/misc.xml b/.idea/misc.xml
index e0d5b93..299e423 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,7 +5,7 @@
-
+
@@ -13,23 +13,33 @@
+
+
+
+
+
-
+
+
+
+
+
+
-
+
diff --git a/app/build.gradle b/app/build.gradle
index a292c22..eda8a3b 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 26
- buildToolsVersion "26.0.0"
+ compileSdkVersion 28
+ buildToolsVersion "28.0.0"
defaultConfig {
applicationId "tech.oom.idealrecorderdemo"
minSdkVersion 16
- targetSdkVersion 26
+ targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -20,14 +20,15 @@ android {
}
dependencies {
- compile fileTree(include: ['*.jar'], dir: 'libs')
+ implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
- compile 'com.android.support:appcompat-v7:26.+'
- compile 'com.android.support.constraint:constraint-layout:1.0.2'
- testCompile 'junit:junit:4.12'
- compile 'com.yanzhenjie:permission:1.1.0'
- compile 'com.github.Jay-Goo:WaveLineView:v1.0.3'
- compile 'com.github.ideastudios:IdealRecorder:2.0.4'
+ implementation 'com.android.support:appcompat-v7:28.0.0'
+ implementation 'com.android.support.constraint:constraint-layout:1.1.3'
+ implementation 'junit:junit:4.12'
+ implementation 'com.yanzhenjie:permission:1.1.0'
+ implementation 'com.github.Jay-Goo:WaveLineView:v1.0.3'
+ implementation project(':library')
+// compile 'com.github.ideastudios:IdealRecorder:2.0.4'
}
diff --git a/app/src/main/java/tech/oom/idealrecorderdemo/MainActivity.java b/app/src/main/java/tech/oom/idealrecorderdemo/MainActivity.java
index d189940..36e4029 100644
--- a/app/src/main/java/tech/oom/idealrecorderdemo/MainActivity.java
+++ b/app/src/main/java/tech/oom/idealrecorderdemo/MainActivity.java
@@ -24,6 +24,7 @@
import jaygoo.widget.wlv.WaveLineView;
import tech.oom.idealrecorder.IdealRecorder;
import tech.oom.idealrecorder.StatusListener;
+import tech.oom.idealrecorder.utils.Log;
import tech.oom.idealrecorderdemo.widget.WaveView;
public class MainActivity extends AppCompatActivity {
@@ -71,12 +72,14 @@ public void onRecordData(short[] data, int length) {
for (int i = 0; i < length; i += 60) {
waveView.addData(data[i]);
}
+ Log.d("MainActivity", "current buffer size is " + length);
}
@Override
public void onVoiceVolume(int volume) {
double myVolume = (volume - 40) * 4;
waveLineView.setVolume((int) myVolume);
+ Log.d("MainActivity", "current volume is " + volume);
}
@Override
diff --git a/build.gradle b/build.gradle
index b964b40..895aa70 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,13 +3,10 @@
buildscript {
repositories {
jcenter()
- maven {
- url 'https://maven.google.com/'
- name 'Google'
- }
+ google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.3'
+ classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -20,10 +17,7 @@ allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
- maven {
- url 'https://maven.google.com/'
- name 'Google'
- }
+ google()
}
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 130ab37..f3ca496 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Wed Dec 06 10:56:48 CST 2017
+#Wed Oct 23 14:42:54 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
diff --git a/library/build.gradle b/library/build.gradle
index 04f855f..5a05962 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,15 +1,15 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
-group='com.github.ideastudios'
+group = 'com.github.ideastudios'
android {
- compileSdkVersion 26
- buildToolsVersion "26.0.0"
+ compileSdkVersion 28
+ buildToolsVersion "28.0.0"
defaultConfig {
minSdkVersion 15
- targetSdkVersion 26
+ targetSdkVersion 28
versionCode 1
versionName "1.0"
@@ -25,10 +25,10 @@ android {
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
- compile 'com.android.support:appcompat-v7:26.0.0'
- testCompile 'junit:junit:4.12'
+ implementation 'com.android.support:appcompat-v7:28.0.0'
+ testImplementation 'junit:junit:4.12'
}
diff --git a/library/src/main/java/tech/oom/idealrecorder/IdealRecorder.java b/library/src/main/java/tech/oom/idealrecorder/IdealRecorder.java
index 332c131..5732de7 100644
--- a/library/src/main/java/tech/oom/idealrecorder/IdealRecorder.java
+++ b/library/src/main/java/tech/oom/idealrecorder/IdealRecorder.java
@@ -5,7 +5,6 @@
import android.content.pm.PackageManager;
import android.media.AudioFormat;
import android.media.MediaRecorder;
-import android.os.Environment;
import android.os.Handler;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
@@ -56,7 +55,7 @@ public static IdealRecorder getInstance() {
* @param mContext 当前应用的application context
*/
public void init(Context mContext) {
- context = mContext;
+ context = mContext.getApplicationContext();
}
@@ -117,11 +116,16 @@ public IdealRecorder setVolumeInterval(long intervalMillis) {
*/
public IdealRecorder setRecordFilePath(String path) {
if (!TextUtils.isEmpty(path) && audioFileHelper != null) {
- if (path.startsWith(Environment.getExternalStorageDirectory().getAbsolutePath()) && !isWriteExternalStoragePermissionGranted()) {
- Log.e(TAG, "set recorder file path failed,because no WRITE_EXTERNAL_STORAGE permission was granted");
+ String externalFilePath = context.getExternalFilesDir(null).getAbsolutePath();
+ String cacheFilePath = context.getCacheDir().getAbsolutePath();
- return this;
+ if (!path.startsWith(externalFilePath) || !path.startsWith(cacheFilePath)) {
+ if (!isWriteExternalStoragePermissionGranted()) {
+ Log.e(TAG, "set recorder file path failed,because no WRITE_EXTERNAL_STORAGE permission was granted");
+ return this;
+ }
}
+
isAudioFileHelperInit = true;
audioFileHelper.setSavePath(path);
} else {
diff --git a/library/src/main/java/tech/oom/idealrecorder/record/Recorder.java b/library/src/main/java/tech/oom/idealrecorder/record/Recorder.java
index d7ff0b6..3125178 100644
--- a/library/src/main/java/tech/oom/idealrecorder/record/Recorder.java
+++ b/library/src/main/java/tech/oom/idealrecorder/record/Recorder.java
@@ -9,7 +9,10 @@
public class Recorder {
- public static final int TIMER_INTERVAL = 20;
+ /**
+ * 每次buffer语音对应的时长为100ms
+ */
+ public static final int TIMER_INTERVAL = 100;
private static final String TAG = "Recorder";
private IdealRecorder.RecordConfig recordConfig;
private AudioRecord mAudioRecorder = null;