add Prefs

This commit is contained in:
Alexey Kuznetsov 2022-03-01 17:03:59 +03:00
commit d66ce336ca
4 changed files with 11 additions and 6 deletions

View file

@ -929,14 +929,14 @@ public class RecordingActivity extends AppCompatThemeActivity {
boolean startRecording() {
try {
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
String source = shared.getString(AudioApplication.PREFERENCE_SOURCE, getString(R.string.source_mic));
String source = shared.getString(AudioApplication.PREFERENCE_SOURCE, AudioApplication.PREFERENCE_SOURCE_MIC);
int user;
if (source.equals(getString(R.string.source_raw))) {
if (source.equals(AudioApplication.PREFERENCE_SOURCE_RAW)) {
if (Sound.isUnprocessedSupported(this))
user = MediaRecorder.AudioSource.UNPROCESSED;
else
user = MediaRecorder.AudioSource.VOICE_RECOGNITION;
} else if (source.equals(this.getString(R.string.source_internal))) {
} else if (source.equals(AudioApplication.PREFERENCE_SOURCE_INTERNAL)) {
user = Sound.SOURCE_INTERNAL_AUDIO;
} else {
user = MediaRecorder.AudioSource.MIC;

View file

@ -11,6 +11,7 @@ import android.util.Log;
import android.view.View;
import com.github.axet.androidlibrary.app.NotificationManagerCompat;
import com.github.axet.androidlibrary.app.Prefs;
import com.github.axet.androidlibrary.widgets.NotificationChannelCompat;
import com.github.axet.androidlibrary.widgets.RemoteNotificationCompat;
import com.github.axet.audiolibrary.encoders.FormatFLAC;
@ -26,6 +27,10 @@ public class AudioApplication extends com.github.axet.audiolibrary.app.MainAppli
public static final String PREFERENCE_TARGET = "target";
public static final String PREFERENCE_FLY = "fly";
public static final String PREFERENCE_SOURCE = "bluetooth";
public static final String PREFERENCE_SOURCE_MIC = Prefs.PrefString(R.string.source_mic);
public static final String PREFERENCE_SOURCE_BLUETOOTH = Prefs.PrefString(R.string.source_bluetooth);
public static final String PREFERENCE_SOURCE_RAW = Prefs.PrefString(R.string.source_raw);
public static final String PREFERENCE_SOURCE_INTERNAL = Prefs.PrefString(R.string.source_internal);
public static final String PREFERENCE_VERSION = "version";

View file

@ -139,7 +139,7 @@ public class BluetoothReceiver extends BroadcastReceiver {
public boolean isRecordingReady() {
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(context);
if (shared.getString(AudioApplication.PREFERENCE_SOURCE, context.getString(R.string.source_mic)).equals(context.getString(R.string.source_bluetooth))) {
if (shared.getString(AudioApplication.PREFERENCE_SOURCE, AudioApplication.PREFERENCE_SOURCE_MIC).equals(AudioApplication.PREFERENCE_SOURCE_BLUETOOTH)) {
bluetoothSource = true;
if (!startBluetooth())
return false;

View file

@ -55,8 +55,8 @@ public class RecordingSourcePreferenceCompat extends ListPreference {
CharSequence[] values = getEntryValues();
ArrayList<CharSequence> tt = new ArrayList<>();
ArrayList<CharSequence> vv = new ArrayList<>();
String raw = getContext().getString(R.string.source_raw);
String internal = getContext().getString(R.string.source_internal);
String raw = AudioApplication.PREFERENCE_SOURCE_RAW;
String internal = AudioApplication.PREFERENCE_SOURCE_INTERNAL;
for (int i = 0; i < values.length; i++) {
String v = values[i].toString();
String t = text[i].toString();