Merge branch 'audiorecorder-3.1.7'
This commit is contained in:
commit
8059f772ea
4 changed files with 39 additions and 17 deletions
|
|
@ -10,8 +10,8 @@ android {
|
|||
applicationId "com.github.axet.audiorecorder"
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 23 // 24+ file:// unable to open
|
||||
versionCode 235
|
||||
versionName "3.1.5"
|
||||
versionCode 238
|
||||
versionName "3.1.7"
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.github.axet.audiorecorder.activities;
|
|||
import android.Manifest;
|
||||
import android.app.ProgressDialog;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
|
|
@ -48,6 +47,7 @@ import com.github.axet.audiolibrary.encoders.Factory;
|
|||
import com.github.axet.audiolibrary.encoders.FileEncoder;
|
||||
import com.github.axet.audiolibrary.encoders.OnFlyEncoding;
|
||||
import com.github.axet.audiolibrary.widgets.PitchView;
|
||||
import com.github.axet.audiorecorder.BuildConfig;
|
||||
import com.github.axet.audiorecorder.R;
|
||||
import com.github.axet.audiorecorder.app.MainApplication;
|
||||
import com.github.axet.audiorecorder.app.Storage;
|
||||
|
|
@ -58,10 +58,6 @@ import java.io.File;
|
|||
import java.nio.ShortBuffer;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static android.media.AudioManager.SCO_AUDIO_STATE_CONNECTED;
|
||||
import static android.media.AudioManager.SCO_AUDIO_STATE_CONNECTING;
|
||||
import static android.media.AudioManager.SCO_AUDIO_STATE_DISCONNECTED;
|
||||
|
||||
public class RecordingActivity extends AppCompatActivity {
|
||||
public static final String TAG = RecordingActivity.class.getSimpleName();
|
||||
|
||||
|
|
@ -73,6 +69,7 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
|
||||
public static final String START_PAUSE = RecordingActivity.class.getCanonicalName() + ".START_PAUSE";
|
||||
public static final String PAUSE_BUTTON = RecordingActivity.class.getCanonicalName() + ".PAUSE_BUTTON";
|
||||
public static final String ACTION_FINISH_RECORDING = BuildConfig.APPLICATION_ID + ".STOP_RECORDING";
|
||||
|
||||
PhoneStateChangeListener pscl = new PhoneStateChangeListener();
|
||||
FileEncoder encoder;
|
||||
|
|
@ -105,6 +102,7 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
TextView time;
|
||||
TextView state;
|
||||
ImageButton pause;
|
||||
View done;
|
||||
PitchView pitch;
|
||||
|
||||
Storage storage;
|
||||
|
|
@ -158,6 +156,10 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
pauseButton();
|
||||
return;
|
||||
}
|
||||
if (a.equals(ACTION_FINISH_RECORDING)) {
|
||||
done.performClick();
|
||||
return;
|
||||
}
|
||||
MediaButtonReceiver.handleIntent(msc, intent);
|
||||
}
|
||||
}
|
||||
|
|
@ -222,6 +224,7 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
filter.addAction(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED);
|
||||
filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
|
||||
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
|
||||
filter.addAction(ACTION_FINISH_RECORDING);
|
||||
registerReceiver(receiver, filter);
|
||||
|
||||
edit(false, false);
|
||||
|
|
@ -292,7 +295,7 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
final View done = findViewById(R.id.recording_done);
|
||||
done = findViewById(R.id.recording_done);
|
||||
done.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
@ -375,17 +378,16 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
|
||||
void pauseButton() {
|
||||
if (thread != null) {
|
||||
receiver.pause = false;
|
||||
receiver.errors = false;
|
||||
stopRecording(getString(R.string.recording_status_pause));
|
||||
receiver.stopBluetooth();
|
||||
headset(true, false);
|
||||
} else {
|
||||
receiver.pause = true;
|
||||
receiver.errors = true;
|
||||
receiver.stopBluetooth(); // reset bluetooth
|
||||
editCut();
|
||||
if (receiver.isRecordingReady()) {
|
||||
if (receiver.isRecordingReady())
|
||||
startRecording();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
package com.github.axet.audiorecorder.app;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
|
||||
import com.github.axet.audiolibrary.encoders.FormatOGG;
|
||||
import com.github.axet.audiorecorder.R;
|
||||
|
||||
public class MainApplication extends com.github.axet.audiolibrary.app.MainApplication {
|
||||
|
|
@ -22,7 +26,19 @@ public class MainApplication extends com.github.axet.audiolibrary.app.MainApplic
|
|||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
PreferenceManager.setDefaultValues(this, R.xml.pref_general, false);
|
||||
final SharedPreferences defaultValueSp = getSharedPreferences(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, Context.MODE_PRIVATE);
|
||||
if (!defaultValueSp.getBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, false)) {
|
||||
PreferenceManager.setDefaultValues(this, R.xml.pref_general, false);
|
||||
if (!FormatOGG.supported(this)) {
|
||||
SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
SharedPreferences.Editor edit = shared.edit();
|
||||
if (Build.VERSION.SDK_INT >= 18)
|
||||
edit.putString(MainApplication.PREFERENCE_ENCODING, "m4a");
|
||||
else
|
||||
edit.putString(MainApplication.PREFERENCE_ENCODING, "flac");
|
||||
edit.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class BluetoothReceiver extends BroadcastReceiver {
|
|||
public boolean bluetoothSource = false; // are we using bluetooth source recording
|
||||
public boolean bluetoothStart = false; // did we start already?
|
||||
public boolean pausedByBluetooth = false;
|
||||
public boolean pause = false; // resumed recording by user, show error only on user actions
|
||||
public boolean errors = false; // show errors
|
||||
public boolean connecting = false;
|
||||
|
||||
public Runnable connected = new Runnable() {
|
||||
|
|
@ -43,8 +43,8 @@ public class BluetoothReceiver extends BroadcastReceiver {
|
|||
public void run() {
|
||||
handler.removeCallbacks(connected);
|
||||
onDisconnected();
|
||||
if (pause) {
|
||||
pause = false;
|
||||
if (errors) {
|
||||
errors = false;
|
||||
Toast.makeText(context, R.string.hold_by_bluetooth, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
if (connecting) {
|
||||
|
|
@ -90,12 +90,16 @@ public class BluetoothReceiver extends BroadcastReceiver {
|
|||
}
|
||||
}
|
||||
|
||||
boolean startBluetooth() {
|
||||
public void onStartBluetoothSco() {
|
||||
}
|
||||
|
||||
public boolean startBluetooth() {
|
||||
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||
if (am.isBluetoothScoAvailableOffCall()) {
|
||||
if (!bluetoothStart) {
|
||||
am.startBluetoothSco();
|
||||
bluetoothStart = true;
|
||||
onStartBluetoothSco();
|
||||
}
|
||||
if (!am.isBluetoothScoOn()) {
|
||||
pausedByBluetooth = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue