Merge branch 'audiorecorder-1.6.0'
This commit is contained in:
commit
ed7136b401
10 changed files with 162 additions and 17 deletions
|
|
@ -8,8 +8,8 @@ android {
|
|||
applicationId "com.github.axet.audiorecorder"
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 23
|
||||
versionCode 147
|
||||
versionName "1.5.17"
|
||||
versionCode 148
|
||||
versionName "1.6.0"
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
|
|
@ -43,5 +43,5 @@ android {
|
|||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.github.axet:android-audio-library:0.0.48' // compile project(':android-audio-library')
|
||||
compile 'com.github.axet:android-audio-library:0.0.51' // compile project(':android-audio-library')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.github.axet.audiorecorder.activities;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
|
|
@ -95,7 +97,11 @@ public class MainActivity extends AppCompatActivity {
|
|||
list.setEmptyView(findViewById(R.id.empty_list));
|
||||
|
||||
if (Storage.permitted(MainActivity.this, PERMISSIONS, 1)) {
|
||||
storage.migrateLocalStorage();
|
||||
try {
|
||||
storage.migrateLocalStorage();
|
||||
} catch (RuntimeException e) {
|
||||
Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,12 +112,25 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
Intent showIntent() {
|
||||
Uri selectedUri = Uri.fromFile(storage.getStoragePath());
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(selectedUri, "resource/folder");
|
||||
return intent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
|
||||
MenuItem item = menu.findItem(R.id.action_show_folder);
|
||||
Intent intent = showIntent();
|
||||
if (intent.resolveActivityInfo(getPackageManager(), 0) == null) {
|
||||
item.setVisible(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -129,9 +148,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
if (id == R.id.action_show_folder) {
|
||||
Uri selectedUri = Uri.fromFile(storage.getStoragePath());
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(selectedUri, "resource/folder");
|
||||
Intent intent = showIntent();
|
||||
if (intent.resolveActivityInfo(getPackageManager(), 0) != null) {
|
||||
startActivity(intent);
|
||||
} else {
|
||||
|
|
@ -207,7 +224,11 @@ public class MainActivity extends AppCompatActivity {
|
|||
switch (requestCode) {
|
||||
case 1:
|
||||
if (Storage.permitted(MainActivity.this, permissions)) {
|
||||
storage.migrateLocalStorage();
|
||||
try {
|
||||
storage.migrateLocalStorage();
|
||||
} catch (RuntimeException e) {
|
||||
Error(e);
|
||||
}
|
||||
recordings.load(null);
|
||||
checkPending();
|
||||
} else {
|
||||
|
|
@ -246,4 +267,33 @@ public class MainActivity extends AppCompatActivity {
|
|||
TextView text = (TextView) findViewById(R.id.space_left);
|
||||
text.setText(((MainApplication) getApplication()).formatFree(free, sec));
|
||||
}
|
||||
|
||||
|
||||
public void Error(Throwable e) {
|
||||
String msg = e.getMessage();
|
||||
if (msg == null || msg.isEmpty()) {
|
||||
Throwable t = e;
|
||||
while (t.getCause() != null)
|
||||
t = t.getCause();
|
||||
msg = t.getClass().getSimpleName();
|
||||
}
|
||||
Error(msg);
|
||||
}
|
||||
|
||||
public void Error(String msg) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Error");
|
||||
builder.setMessage(msg);
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import com.github.axet.androidlibrary.animations.MarginBottomAnimation;
|
|||
import com.github.axet.androidlibrary.sound.AudioTrack;
|
||||
import com.github.axet.audiolibrary.app.RawSamples;
|
||||
import com.github.axet.audiolibrary.app.Sound;
|
||||
import com.github.axet.audiolibrary.app.Storage;
|
||||
import com.github.axet.audiolibrary.encoders.Encoder;
|
||||
import com.github.axet.audiolibrary.encoders.EncoderInfo;
|
||||
import com.github.axet.audiolibrary.encoders.Factory;
|
||||
|
|
@ -45,6 +44,7 @@ import com.github.axet.audiolibrary.encoders.FileEncoder;
|
|||
import com.github.axet.audiolibrary.widgets.PitchView;
|
||||
import com.github.axet.audiorecorder.R;
|
||||
import com.github.axet.audiorecorder.app.MainApplication;
|
||||
import com.github.axet.audiorecorder.app.Storage;
|
||||
import com.github.axet.audiorecorder.services.RecordingService;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -180,7 +180,7 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
sampleRate = Integer.parseInt(shared.getString(MainApplication.PREFERENCE_RATE, ""));
|
||||
sampleRate = Sound.getValidRecordRate(MainApplication.getMode(this), sampleRate);
|
||||
sampleRate = Sound.getValidRecordRate(MainApplication.getInMode(this), sampleRate);
|
||||
samplesUpdate = (int) (pitch.getPitchTime() * sampleRate / 1000.0);
|
||||
|
||||
updateBufferSize(false);
|
||||
|
|
@ -443,7 +443,7 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
int playUpdate = PitchView.UPDATE_SPEED * sampleRate / 1000;
|
||||
|
||||
RawSamples rs = new RawSamples(storage.getTempRecording());
|
||||
int len = (int) (rs.getSamples() - editSample);
|
||||
int len = (int) (rs.getSamples() - editSample); // in samples
|
||||
|
||||
final AudioTrack.OnPlaybackPositionUpdateListener listener = new AudioTrack.OnPlaybackPositionUpdateListener() {
|
||||
@Override
|
||||
|
|
@ -461,10 +461,12 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
}
|
||||
};
|
||||
|
||||
short[] buf = new short[len];
|
||||
rs.open(editSample, buf.length);
|
||||
int r = rs.read(buf);
|
||||
play = sound.generateTrack(sampleRate, buf, r);
|
||||
AudioTrack.AudioBuffer buffer = new AudioTrack.AudioBuffer(sampleRate, MainApplication.getOutMode(this), Sound.AUDIO_FORMAT, len);
|
||||
rs.open(editSample, len); // len in samples
|
||||
int r = rs.read(buffer.buffer); // r in samples
|
||||
if (r != buffer.len)
|
||||
throw new RuntimeException("unable to read data");
|
||||
play = sound.generateTrack(buffer);
|
||||
play.setPositionNotificationPeriod(playUpdate);
|
||||
play.setPlaybackPositionUpdateListener(listener, handler);
|
||||
play.play();
|
||||
|
|
@ -589,12 +591,12 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
|
||||
rs.open(samplesTime);
|
||||
|
||||
int min = AudioRecord.getMinBufferSize(sampleRate, MainApplication.getMode(RecordingActivity.this), Sound.AUDIO_FORMAT);
|
||||
int min = AudioRecord.getMinBufferSize(sampleRate, MainApplication.getInMode(RecordingActivity.this), Sound.AUDIO_FORMAT);
|
||||
if (min <= 0) {
|
||||
throw new RuntimeException("Unable to initialize AudioRecord: Bad audio values");
|
||||
}
|
||||
|
||||
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate, MainApplication.getMode(RecordingActivity.this), Sound.AUDIO_FORMAT, min * 2);
|
||||
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate, MainApplication.getInMode(RecordingActivity.this), Sound.AUDIO_FORMAT, min * 2);
|
||||
if (recorder.getState() != AudioRecord.STATE_INITIALIZED) {
|
||||
throw new RuntimeException("Unable to initialize AudioRecord");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
|
|||
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_RATE));
|
||||
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_THEME));
|
||||
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_CHANNELS));
|
||||
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_FORMAT));
|
||||
}
|
||||
|
||||
public static int getAppTheme(Context context) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
package com.github.axet.audiorecorder.app;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class Storage extends com.github.axet.audiolibrary.app.Storage {
|
||||
|
||||
public Storage(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getNewFile() {
|
||||
|
||||
SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String ext = shared.getString(MainApplication.PREFERENCE_ENCODING, "");
|
||||
|
||||
String format = "%s";
|
||||
|
||||
format = shared.getString(MainApplication.PREFERENCE_FORMAT, format);
|
||||
|
||||
format = format.replaceAll("%s", SIMPLE.format(new Date()));
|
||||
format = format.replaceAll("%I", ISO8601.format(new Date()));
|
||||
format = format.replaceAll("%T", "" + System.currentTimeMillis() / 1000);
|
||||
|
||||
File parent = getStoragePath();
|
||||
if (!parent.exists()) {
|
||||
if (!parent.mkdirs())
|
||||
throw new RuntimeException("Unable to create: " + parent);
|
||||
}
|
||||
|
||||
return getNextFile(parent, format, ext);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -41,6 +41,18 @@
|
|||
<item>2</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="format_text" translatable="false">
|
||||
<item>2017-02-01 09.08.01.wav</item>
|
||||
<item>1487926249.wav</item>
|
||||
<item>20170528T043902.wav</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="format_values" formatted="false" translatable="false">
|
||||
<item>%s</item>
|
||||
<item>%T</item>
|
||||
<item>%I</item>
|
||||
</string-array>
|
||||
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="not_permitted">Not permitted</string>
|
||||
<string name="no_folder_app">No folder view application installed</string>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,16 @@
|
|||
android:summary="Aufnahmekanäle"
|
||||
android:title="Mono/Stereo" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="%s"
|
||||
android:entries="@array/format_text"
|
||||
android:entryValues="@array/format_values"
|
||||
android:key="format"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:summary="2015-11"
|
||||
android:title="Name Format" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="call"
|
||||
|
|
|
|||
|
|
@ -36,6 +36,16 @@
|
|||
android:summary="録音チャンネル"
|
||||
android:title="モード" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="%s"
|
||||
android:entries="@array/format_text"
|
||||
android:entryValues="@array/format_values"
|
||||
android:key="format"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:summary="2015-11"
|
||||
android:title="Name Format" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="call"
|
||||
|
|
|
|||
|
|
@ -36,6 +36,16 @@
|
|||
android:summary="Режим записи"
|
||||
android:title="Режим" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="%s"
|
||||
android:entries="@array/format_text"
|
||||
android:entryValues="@array/format_values"
|
||||
android:key="format"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:summary="2015-12-31 22:11:34"
|
||||
android:title="Имя Нового Файла" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="call"
|
||||
|
|
|
|||
|
|
@ -36,6 +36,16 @@
|
|||
android:summary="Recording channels"
|
||||
android:title="Mode" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="%s"
|
||||
android:entries="@array/format_text"
|
||||
android:entryValues="@array/format_values"
|
||||
android:key="format"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:summary="2015-12-31 22:11:34"
|
||||
android:title="Name Format" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="call"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue