diff --git a/app/src/main/java/com/github/axet/audiorecorder/activities/RecordingActivity.java b/app/src/main/java/com/github/axet/audiorecorder/activities/RecordingActivity.java index f0a244d..84438fd 100644 --- a/app/src/main/java/com/github/axet/audiorecorder/activities/RecordingActivity.java +++ b/app/src/main/java/com/github/axet/audiorecorder/activities/RecordingActivity.java @@ -375,17 +375,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(); - } } } diff --git a/app/src/main/java/com/github/axet/audiorecorder/app/MainApplication.java b/app/src/main/java/com/github/axet/audiorecorder/app/MainApplication.java index 631ce33..ba3eb32 100644 --- a/app/src/main/java/com/github/axet/audiorecorder/app/MainApplication.java +++ b/app/src/main/java/com/github/axet/audiorecorder/app/MainApplication.java @@ -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(); + } + } } } diff --git a/app/src/main/java/com/github/axet/audiorecorder/services/BluetoothReceiver.java b/app/src/main/java/com/github/axet/audiorecorder/services/BluetoothReceiver.java index bd64c8f..fef2355 100644 --- a/app/src/main/java/com/github/axet/audiorecorder/services/BluetoothReceiver.java +++ b/app/src/main/java/com/github/axet/audiorecorder/services/BluetoothReceiver.java @@ -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;