first commit
This commit is contained in:
commit
60718b503c
34 changed files with 1315 additions and 0 deletions
48
.gitignore
vendored
Normal file
48
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# Built application files
|
||||
*.apk
|
||||
*.ap_
|
||||
|
||||
# Files for the ART/Dalvik VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
out/
|
||||
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
# Log Files
|
||||
*.log
|
||||
|
||||
# Android Studio Navigation editor temp files
|
||||
.navigation/
|
||||
|
||||
# Android Studio captures folder
|
||||
captures/
|
||||
|
||||
# Intellij
|
||||
*.iml
|
||||
.idea/workspace.xml
|
||||
.idea/modules.xml
|
||||
.idea/misc.xml
|
||||
.idea/libraries
|
||||
.idea/vcs.xml
|
||||
.idea/codeStyleSettings.xml
|
||||
|
||||
# Keystore files
|
||||
*.jks
|
||||
|
||||
# External native build folder generated in Android Studio 2.2 and later
|
||||
.externalNativeBuild
|
||||
22
.idea/compiler.xml
generated
Normal file
22
.idea/compiler.xml
generated
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
3
.idea/copyright/profiles_settings.xml
generated
Normal file
3
.idea/copyright/profiles_settings.xml
generated
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
||||
6
.idea/encodings.xml
generated
Normal file
6
.idea/encodings.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
19
.idea/gradle.xml
generated
Normal file
19
.idea/gradle.xml
generated
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/../dixitmobile-common/library" />
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/vxt-audio-recorder" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
12
.idea/runConfigurations.xml
generated
Normal file
12
.idea/runConfigurations.xml
generated
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
23
build.gradle
Normal file
23
build.gradle
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.3.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
17
gradle.properties
Normal file
17
gradle.properties
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#Thu Mar 16 12:26:18 CET 2017
|
||||
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
|
||||
160
gradlew
vendored
Executable file
160
gradlew
vendored
Executable file
|
|
@ -0,0 +1,160 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
90
gradlew.bat
vendored
Normal file
90
gradlew.bat
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
3
settings.gradle
Normal file
3
settings.gradle
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
include ':vxt-audio-recorder'
|
||||
include ':library'
|
||||
project(':library').projectDir = new File('../dixitmobile-common/library')
|
||||
1
vxt-audio-recorder/.gitignore
vendored
Normal file
1
vxt-audio-recorder/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
40
vxt-audio-recorder/build.gradle
Normal file
40
vxt-audio-recorder/build.gradle
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion "25.0.2"
|
||||
|
||||
signingConfigs {
|
||||
demo {
|
||||
storeFile file("../../.keystore/tellnext.jks")
|
||||
storePassword "tellnext"
|
||||
keyAlias "tellnext_demo"
|
||||
keyPassword "tellnext"
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.voixtreme.audiorecorder"
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 25
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
signingConfig signingConfigs.demo
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 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 project (':library')
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
17
vxt-audio-recorder/proguard-rules.pro
vendored
Normal file
17
vxt-audio-recorder/proguard-rules.pro
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /AndroidSDK/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.voixtreme.audiorecorder;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumentation test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() throws Exception {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.tellnext.recordaudio", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
30
vxt-audio-recorder/src/main/AndroidManifest.xml
Normal file
30
vxt-audio-recorder/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.voixtreme.audiorecorder">
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
|
||||
<activity
|
||||
android:name="com.voixtreme.audiorecorder.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait" >
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,593 @@
|
|||
package com.voixtreme.audiorecorder;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Locale;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
import android.media.AudioFormat;
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioRecord;
|
||||
import android.media.MediaPlayer;
|
||||
import android.media.MediaRecorder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.view.menu.ExpandedMenuView;
|
||||
import android.text.format.Time;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
|
||||
import com.dixitmobile.common.VerifyPermissions;
|
||||
|
||||
/**
|
||||
* jima (2017-05-23)
|
||||
*
|
||||
* Example project showing how to pair/unpair/list BT devices... changed to record audio through "startBluetoothSco()"
|
||||
* Would need a cleanup someday...
|
||||
*/
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
public static final int SAMPLE_RATE = 16000;
|
||||
public static final boolean isStereo = false;
|
||||
|
||||
private static final String SOUND_PATH = "voixtreme/sound_test";
|
||||
|
||||
private Button mBTSettingsBtn;
|
||||
private Button mBTToggle;
|
||||
private Button mRecordAudioBtn;
|
||||
private Button mStopRecordAudioBtn;
|
||||
private Button mPlayRecording;
|
||||
private float iGain = 1.0f;
|
||||
private TextView mLog;
|
||||
|
||||
protected int bitsPerSamples = 16;
|
||||
|
||||
private AudioManager mAudioManager;
|
||||
private short[] mBuffer;
|
||||
|
||||
private AudioRecord mRecorder;
|
||||
private int mFileCounter = 1;
|
||||
|
||||
private boolean mIsRecording = false;
|
||||
|
||||
private VerifyPermissions mVerifyPermissions;
|
||||
private BluetoothAdapter mBluetoothAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mVerifyPermissions = new VerifyPermissions(this);
|
||||
mVerifyPermissions.addPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
mVerifyPermissions.addPermission(Manifest.permission.RECORD_AUDIO);
|
||||
if(mVerifyPermissions.checkPermissions()) {
|
||||
initialize();
|
||||
}
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
mLog = (TextView) findViewById(R.id.log);
|
||||
mLog.setMovementMethod(new ScrollingMovementMethod());
|
||||
mLog.setText("");
|
||||
|
||||
mBTSettingsBtn = (Button) findViewById(R.id.btn_bt_settings);
|
||||
mBTToggle = (Button) findViewById(R.id.btn_bt_toggle);
|
||||
mRecordAudioBtn = (Button) findViewById(R.id.btn_record_audio);
|
||||
mPlayRecording = (Button) findViewById(R.id.btn_play);
|
||||
mStopRecordAudioBtn = (Button) findViewById(R.id.btn_stop_record_audio);
|
||||
mRecordAudioBtn.setOnClickListener(mRecordAudioClickListener);
|
||||
mStopRecordAudioBtn.setOnClickListener(mStopRecordAudioClickListener);
|
||||
|
||||
File dir = new File(System.getenv("EXTERNAL_STORAGE") + "/" + SOUND_PATH);
|
||||
if (dir.exists()) {
|
||||
log("save dir: " + dir.getAbsolutePath());
|
||||
} else {
|
||||
if (dir.mkdirs()) {
|
||||
log("created directory: " + dir.getAbsolutePath());
|
||||
} else {
|
||||
log("could NOT create directory: " + dir.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (mBluetoothAdapter.isEnabled()) {
|
||||
showBTEnabled();
|
||||
} else {
|
||||
showBTDisabled();
|
||||
}
|
||||
|
||||
mBTSettingsBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
Intent intentOpenBluetoothSettings = new Intent();
|
||||
intentOpenBluetoothSettings.setAction(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
|
||||
startActivity(intentOpenBluetoothSettings);
|
||||
}
|
||||
});
|
||||
|
||||
mBTToggle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (mBluetoothAdapter.isEnabled()) {
|
||||
mBluetoothAdapter.disable();
|
||||
} else {
|
||||
mBluetoothAdapter.enable();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mPlayRecording.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
File file = new File(System.getenv("EXTERNAL_STORAGE") + "/" + SOUND_PATH + "/sound"
|
||||
+ String.format(Locale.UK, "%03d", mFileCounter) + ".wav");
|
||||
|
||||
if (file.exists()) {
|
||||
try {
|
||||
MediaPlayer mp = new MediaPlayer();
|
||||
mp.setDataSource(file.getAbsolutePath());
|
||||
mp.prepare();
|
||||
mp.start();
|
||||
} catch (Exception e) {
|
||||
log("Cannot play wav file: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(MainActivity.this, "No file to play", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
|
||||
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
filter.addAction(BluetoothDevice.ACTION_FOUND);
|
||||
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
|
||||
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
|
||||
|
||||
registerReceiver(mScoReceiver, new IntentFilter(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED));
|
||||
registerReceiver(mReceiver, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
unregisterReceiver(mScoReceiver);
|
||||
unregisterReceiver(mReceiver);
|
||||
mAudioManager.setBluetoothScoOn(false);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void showBTEnabled() {
|
||||
|
||||
stopRecording();
|
||||
mRecordAudioBtn.setText(R.string.record_start_bt);
|
||||
mBTToggle.setText(R.string.text_disable);
|
||||
|
||||
log("bluetooth enabled...");
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
log("isVolumeFixed?: " + mAudioManager.isVolumeFixed());
|
||||
}
|
||||
}
|
||||
|
||||
private void showBTDisabled() {
|
||||
|
||||
stopRecording();
|
||||
mRecordAudioBtn.setText(R.string.record_start_mic);
|
||||
mBTToggle.setText(R.string.text_enable);
|
||||
|
||||
log("bluetooth disabled...");
|
||||
}
|
||||
|
||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
|
||||
if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
|
||||
final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
|
||||
|
||||
if (state == BluetoothAdapter.STATE_ON) {
|
||||
showBTEnabled();
|
||||
} else if (state == BluetoothAdapter.STATE_OFF) {
|
||||
showBTDisabled();
|
||||
}
|
||||
} else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
|
||||
|
||||
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
|
||||
|
||||
} else if (BluetoothDevice.ACTION_FOUND.equals(action)) {
|
||||
|
||||
} else {
|
||||
log("Unknown broadcast: " + action);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
View.OnClickListener mRecordAudioClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
mRecordAudioBtn.setEnabled(false);
|
||||
mStopRecordAudioBtn.setEnabled(true);
|
||||
|
||||
if (mRecordAudioBtn.getText().equals(getString(R.string.record_start_bt))) {
|
||||
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
|
||||
|
||||
if (mAudioManager.isBluetoothScoAvailableOffCall()) {
|
||||
if (!mAudioManager.isBluetoothScoOn()) {
|
||||
mAudioManager.setBluetoothScoOn(true);
|
||||
}
|
||||
|
||||
mAudioManager.startBluetoothSco();
|
||||
} else {
|
||||
log("bluetoothSCO NOT AVAILABLE");
|
||||
}
|
||||
} else {
|
||||
mAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
startRecording();
|
||||
}
|
||||
}
|
||||
};
|
||||
View.OnClickListener mStopRecordAudioClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
mRecordAudioBtn.setEnabled(true);
|
||||
mStopRecordAudioBtn.setEnabled(false);
|
||||
|
||||
log("-- stop recording");
|
||||
|
||||
mIsRecording = false;
|
||||
mAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
mAudioManager.stopBluetoothSco();
|
||||
|
||||
mRecorder.stop();
|
||||
mAudioManager.stopBluetoothSco();
|
||||
mIsRecording = false;
|
||||
|
||||
File inFile = new File(System.getenv("EXTERNAL_STORAGE") + "/" + SOUND_PATH + "/sound"
|
||||
+ String.format(Locale.UK, "%03d", mFileCounter) + ".raw");
|
||||
File outFile = new File(System.getenv("EXTERNAL_STORAGE") + "/" + SOUND_PATH + "/sound"
|
||||
+ String.format(Locale.UK, "%03d", mFileCounter) + ".wav");
|
||||
if (outFile.exists()) {
|
||||
outFile.delete();
|
||||
}
|
||||
|
||||
log("raw file: " + inFile.getAbsoluteFile());
|
||||
log("wav file: " + outFile.getAbsoluteFile());
|
||||
|
||||
try {
|
||||
rawToWave(inFile, outFile);
|
||||
} catch (Exception e) {
|
||||
log("ERROR converting to wav...");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
BroadcastReceiver mScoReceiver = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
if (!intent.getAction().equals(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -1);
|
||||
// int prevState = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_PREVIOUS_STATE, -1);
|
||||
|
||||
if (state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) {
|
||||
|
||||
log("disconnected...");
|
||||
stopRecording();
|
||||
}
|
||||
else if (state == AudioManager.SCO_AUDIO_STATE_CONNECTING) {
|
||||
|
||||
log("connecting...");
|
||||
}
|
||||
else if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
|
||||
|
||||
log("connected...");
|
||||
startRecording();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void startRecording() {
|
||||
|
||||
if (mIsRecording) {
|
||||
return;
|
||||
}
|
||||
|
||||
int bufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE
|
||||
, (isStereo ? AudioFormat.CHANNEL_IN_STEREO
|
||||
: AudioFormat.CHANNEL_IN_MONO)
|
||||
, AudioFormat.ENCODING_PCM_16BIT);
|
||||
mBuffer = new short[bufferSize];
|
||||
mRecorder = new AudioRecord(MediaRecorder.AudioSource.VOICE_RECOGNITION
|
||||
, SAMPLE_RATE
|
||||
, (isStereo ? AudioFormat.CHANNEL_IN_STEREO
|
||||
: AudioFormat.CHANNEL_IN_MONO)
|
||||
, AudioFormat.ENCODING_PCM_16BIT
|
||||
, bufferSize);
|
||||
|
||||
try {
|
||||
mRecorder.startRecording();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log("recording error: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
mIsRecording = true;
|
||||
if (mRecordAudioBtn.getText().equals(getString(R.string.record_start_bt))) {
|
||||
log("-- recording BT...");
|
||||
} else {
|
||||
log("-- recording MIC...");
|
||||
}
|
||||
|
||||
File file = new File(System.getenv("EXTERNAL_STORAGE") + "/" + SOUND_PATH + "/sound"
|
||||
+ String.format(Locale.UK, "%03d", mFileCounter) + ".raw");
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
startBufferedWrite(file);
|
||||
}
|
||||
|
||||
private void stopRecording() {
|
||||
|
||||
if (mIsRecording) {
|
||||
mStopRecordAudioBtn.callOnClick();
|
||||
} else {
|
||||
mStopRecordAudioBtn.setEnabled(false);
|
||||
mRecordAudioBtn.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void startBufferedWrite(final File file) {
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
DataOutputStream output = null;
|
||||
int logSize = 1024*50;
|
||||
int curSize = 0;
|
||||
int total = 0;
|
||||
|
||||
try {
|
||||
output = new DataOutputStream(new BufferedOutputStream(
|
||||
new FileOutputStream(file)));
|
||||
|
||||
while (mIsRecording) {
|
||||
double sum = 0;
|
||||
|
||||
int readSize = mRecorder.read(mBuffer, 0,
|
||||
mBuffer.length);
|
||||
|
||||
curSize += readSize;
|
||||
if (curSize > logSize) {
|
||||
total += curSize;
|
||||
curSize = 0;
|
||||
final int totalKb = (total/1024);
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// log("written...: " + totalKb + "Kb");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final int bytesPerSample = bitsPerSamples / 8;
|
||||
final int emptySpace = 64 - bitsPerSamples;
|
||||
int byteIndex = 0;
|
||||
int byteIndex2 = 0;
|
||||
int temp = 0;
|
||||
int mLeftTemp = 0;
|
||||
int mRightTemp = 0;
|
||||
int a = 0;
|
||||
int x = 0;
|
||||
|
||||
for (int frameIndex = 0; frameIndex < readSize; frameIndex++) {
|
||||
for (int c = 0; c < 1; c++) {
|
||||
if (iGain != 1) {
|
||||
long accumulator = 0;
|
||||
for (int b = 0; b < bytesPerSample; b++) {
|
||||
|
||||
accumulator += ((long) (mBuffer[byteIndex++] & 0xFF)) << (b * 8 + emptySpace);
|
||||
}
|
||||
|
||||
double sample = ((double) accumulator / (double) Long.MAX_VALUE);
|
||||
sample *= iGain;
|
||||
int intValue = (int) ((double) sample * (double) Integer.MAX_VALUE);
|
||||
for (int i = 0; i < bytesPerSample; i++) {
|
||||
mBuffer[i + byteIndex2] = (byte) (intValue >>> ((i + 2) * 8) & 0xff);
|
||||
}
|
||||
|
||||
byteIndex2 += bytesPerSample;
|
||||
}
|
||||
}// end for(channel)
|
||||
|
||||
// mBuffer[frameIndex] *=iGain;
|
||||
if (mBuffer[frameIndex] > 32765) {
|
||||
mBuffer[frameIndex] = 32767;
|
||||
} else if (mBuffer[frameIndex] < -32767) {
|
||||
mBuffer[frameIndex] = -32767;
|
||||
}
|
||||
|
||||
output.writeShort(mBuffer[frameIndex]);
|
||||
sum += mBuffer[frameIndex] * mBuffer[frameIndex];
|
||||
}
|
||||
|
||||
if (readSize > 0) {
|
||||
final double amplitude = sum / readSize;
|
||||
// mProgressBar.setProgress((int) Math.sqrt(amplitude));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Toast.makeText(MainActivity.this, e.getMessage(),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} finally {
|
||||
// mProgressBar.setProgress(0);
|
||||
if (output != null) {
|
||||
try {
|
||||
output.flush();
|
||||
} catch (IOException e) {
|
||||
Toast.makeText(MainActivity.this, e.getMessage(),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} finally {
|
||||
try {
|
||||
output.close();
|
||||
} catch (IOException e) {
|
||||
Toast.makeText(MainActivity.this, e.getMessage(),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
private void rawToWave(final File rawFile, final File waveFile)
|
||||
throws IOException {
|
||||
|
||||
byte[] rawData = new byte[(int) rawFile.length()];
|
||||
DataInputStream input = null;
|
||||
try {
|
||||
|
||||
input = new DataInputStream(new FileInputStream(rawFile));
|
||||
input.read(rawData);
|
||||
} finally {
|
||||
if (input != null) {
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
|
||||
DataOutputStream output = null;
|
||||
try {
|
||||
output = new DataOutputStream(new FileOutputStream(waveFile));
|
||||
// WAVE header
|
||||
// see http://ccrma.stanford.edu/courses/422/projects/WaveFormat/
|
||||
writeString(output, "RIFF"); // chunk id
|
||||
writeInt(output, 36 + rawData.length); // chunk size
|
||||
writeString(output, "WAVE"); // format
|
||||
writeString(output, "fmt "); // subchunk 1 id
|
||||
writeInt(output, 16); // subchunk 1 size
|
||||
writeShort(output, (short) 1); // audio format (1 = PCM)
|
||||
writeShort(output, (short) (isStereo ? 2 : 1)); // number of channels
|
||||
writeInt(output, SAMPLE_RATE); // sample rate
|
||||
writeInt(output, SAMPLE_RATE * 2); // byte rate
|
||||
writeShort(output, (short) 2); // block align
|
||||
writeShort(output, (short) 16); // bits per sample
|
||||
writeString(output, "data"); // subchunk 2 id
|
||||
writeInt(output, rawData.length); // subchunk 2 size
|
||||
// Audio data (conversion big endian -> little endian)
|
||||
short[] shorts = new short[rawData.length / 2];
|
||||
ByteBuffer.wrap(rawData).order(ByteOrder.LITTLE_ENDIAN)
|
||||
.asShortBuffer().get(shorts);
|
||||
ByteBuffer bytes = ByteBuffer.allocate(shorts.length * 2);
|
||||
|
||||
for (short s : shorts) {
|
||||
|
||||
// Apply Gain
|
||||
/*
|
||||
* s *= iGain; if(s>32767) { s=32767; } else if(s<-32768) {
|
||||
* s=-32768; }
|
||||
*/
|
||||
bytes.putShort(s);
|
||||
}
|
||||
output.write(bytes.array());
|
||||
} finally {
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private File getFile(final String suffix) {
|
||||
|
||||
Time time = new Time();
|
||||
time.setToNow();
|
||||
return new File(Environment.getExternalStorageDirectory(),
|
||||
time.format("%Y%m%d%H%M%S") + "." + suffix);
|
||||
}
|
||||
|
||||
private void writeInt(final DataOutputStream output, final int value)
|
||||
throws IOException {
|
||||
output.write(value >> 0);
|
||||
output.write(value >> 8);
|
||||
output.write(value >> 16);
|
||||
output.write(value >> 24);
|
||||
}
|
||||
|
||||
private void writeShort(final DataOutputStream output, final short value)
|
||||
throws IOException {
|
||||
output.write(value >> 0);
|
||||
output.write(value >> 8);
|
||||
}
|
||||
|
||||
private void writeString(final DataOutputStream output, final String value)
|
||||
throws IOException {
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
output.write(value.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
private void log(String txt) {
|
||||
|
||||
Log.d(TAG, txt.trim());
|
||||
mLog.append(txt + "\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
|
||||
if (requestCode == VerifyPermissions.REQUEST_CODE_PERMISSIONS) {
|
||||
if (mVerifyPermissions.onRequestPermissionResult(requestCode, permissions, grantResults)) {
|
||||
initialize();
|
||||
} else {
|
||||
mVerifyPermissions.showErrorDialog(R.string.error_no_permission, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 148 KiB |
66
vxt-audio-recorder/src/main/res/layout/activity_main.xml
Normal file
66
vxt-audio-recorder/src/main/res/layout/activity_main.xml
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/activity_vertical_margin">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:paddingTop="3dp"
|
||||
android:src="@drawable/logo_voixtreme" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_bt_settings"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||
android:layout_weight="0.5"
|
||||
android:enabled="true"
|
||||
android:text="@string/text_bt_settings" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_bt_toggle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||
android:layout_weight="0.5"
|
||||
android:enabled="true"
|
||||
android:text="@string/text_enable" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_record_audio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||
android:enabled="false"
|
||||
android:text="@string/record_start_bt" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_play"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||
android:text="@string/play_wav" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_stop_record_audio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||
android:enabled="false"
|
||||
android:text="@string/record_stop" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/log"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="bottom"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/activity_vertical_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textSize="17sp"
|
||||
android:text="@string/text_list_devices" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/lv_paired"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||
android:cacheColorHint="#00000000" />
|
||||
|
||||
</LinearLayout>
|
||||
37
vxt-audio-recorder/src/main/res/layout/list_item_device.xml
Normal file
37
vxt-audio-recorder/src/main/res/layout/list_item_device.xml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_pair"
|
||||
android:layout_width="125dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="@string/text_pair" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@+id/btn_pair"
|
||||
android:layout_alignTop="@+id/btn_pair"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:textSize="16sp"
|
||||
android:textColor="#000000"
|
||||
android:text="Galaxy Nexus" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_address"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@+id/btn_pair"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignBottom="@+id/btn_pair"
|
||||
android:text="000000000" />
|
||||
|
||||
</RelativeLayout>
|
||||
BIN
vxt-audio-recorder/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
vxt-audio-recorder/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
BIN
vxt-audio-recorder/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
vxt-audio-recorder/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
BIN
vxt-audio-recorder/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
vxt-audio-recorder/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.9 KiB |
BIN
vxt-audio-recorder/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
vxt-audio-recorder/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
vxt-audio-recorder/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
BIN
vxt-audio-recorder/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
6
vxt-audio-recorder/src/main/res/values-w820dp/dimens.xml
Normal file
6
vxt-audio-recorder/src/main/res/values-w820dp/dimens.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
||||
6
vxt-audio-recorder/src/main/res/values/colors.xml
Normal file
6
vxt-audio-recorder/src/main/res/values/colors.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
</resources>
|
||||
5
vxt-audio-recorder/src/main/res/values/dimens.xml
Normal file
5
vxt-audio-recorder/src/main/res/values/dimens.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">5dp</dimen>
|
||||
</resources>
|
||||
28
vxt-audio-recorder/src/main/res/values/strings.xml
Normal file
28
vxt-audio-recorder/src/main/res/values/strings.xml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<resources>
|
||||
<string name="app_name">VoiXtreme Audio Recorder</string>
|
||||
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
|
||||
<string name="text_bluetooth_off">BT is Off</string>
|
||||
<string name="text_bluetooth_on">BT is On</string>
|
||||
|
||||
<string name="text_enable">Enable BT</string>
|
||||
<string name="text_disable">Disable BT</string>
|
||||
|
||||
<string name="play_wav">Play Last Recording</string>
|
||||
<string name="record_start_bt">Record BT Headset</string>
|
||||
<string name="record_start_mic">Record Device Mic</string>
|
||||
<string name="record_stop">Stop Recording</string>
|
||||
|
||||
<string name="text_view_paired">Paired Devices</string>
|
||||
<string name="text_scan_devices">Scan Devices</string>
|
||||
<string name="text_connect_sco">Connect SCO</string>
|
||||
<string name="text_bt_settings">BT Settings</string>
|
||||
<string name="text_stop_scan">Scan Devices</string>
|
||||
|
||||
<string name="text_list_paired_devices">Paired Devices</string>
|
||||
<string name="text_list_devices">List of Devices</string>
|
||||
|
||||
<string name="text_pair">Pair</string>
|
||||
</resources>
|
||||
11
vxt-audio-recorder/src/main/res/values/styles.xml
Normal file
11
vxt-audio-recorder/src/main/res/values/styles.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.voixtreme.audiorecorder;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() throws Exception {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue