Merge branch 'audiorecorder-3.5.5'
This commit is contained in:
commit
793c3ea11e
6 changed files with 44 additions and 61 deletions
|
|
@ -9,8 +9,8 @@ android {
|
|||
applicationId "com.github.axet.audiorecorder"
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 30
|
||||
versionCode 360
|
||||
versionName "3.5.4"
|
||||
versionCode 361
|
||||
versionName "3.5.5"
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
|
|
@ -53,7 +53,7 @@ android {
|
|||
|
||||
dependencies {
|
||||
testImplementation 'junit:junit:4.12'
|
||||
implementation ('com.github.axet:android-audio-library:1.1.6') // implementation project(':android-audio-library')
|
||||
implementation ('com.github.axet:android-audio-library:1.1.7') // implementation project(':android-audio-library')
|
||||
implementation ('com.github.axet:wget:1.7.0') { exclude group: 'org.json', module: 'json' }
|
||||
assets('com.google.android.exoplayer:exoplayer:2.7.3') { exclude group: 'com.android.support' }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -928,19 +928,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
|
|||
|
||||
boolean startRecording() {
|
||||
try {
|
||||
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
String source = shared.getString(AudioApplication.PREFERENCE_SOURCE, AudioApplication.PREFERENCE_SOURCE_MIC);
|
||||
int user;
|
||||
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(AudioApplication.PREFERENCE_SOURCE_INTERNAL)) {
|
||||
user = Sound.SOURCE_INTERNAL_AUDIO;
|
||||
} else {
|
||||
user = MediaRecorder.AudioSource.MIC;
|
||||
}
|
||||
int user = AudioApplication.from(this).getSource();
|
||||
if (user == Sound.SOURCE_INTERNAL_AUDIO && !recording.sound.permitted()) {
|
||||
Sound.showInternalAudio(this, RESULT_INTERNAL);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -152,13 +152,6 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
|
|||
if (Build.VERSION.SDK_INT >= 21)
|
||||
s.setStorageAccessFramework(this, RESULT_STORAGE);
|
||||
|
||||
AudioManager am = (AudioManager) context.getSystemService(AUDIO_SERVICE);
|
||||
Preference bluetooth = pm.findPreference(AudioApplication.PREFERENCE_SOURCE);
|
||||
if (!am.isBluetoothScoAvailableOffCall()) {
|
||||
bluetooth.setVisible(false);
|
||||
}
|
||||
bindPreferenceSummaryToValue(bluetooth);
|
||||
|
||||
Preference p = pm.findPreference(AudioApplication.PREFERENCE_CALL);
|
||||
p.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.app.PendingIntent;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.MediaRecorder;
|
||||
import android.os.Build;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
|
@ -14,6 +15,7 @@ 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.app.Sound;
|
||||
import com.github.axet.audiolibrary.encoders.FormatFLAC;
|
||||
import com.github.axet.audiolibrary.encoders.FormatM4A;
|
||||
import com.github.axet.audiolibrary.encoders.FormatOGG;
|
||||
|
|
@ -145,4 +147,21 @@ public class AudioApplication extends com.github.axet.audiolibrary.app.MainAppli
|
|||
edit.putInt(PREFERENCE_VERSION, 4);
|
||||
edit.commit();
|
||||
}
|
||||
|
||||
public int getSource() {
|
||||
final SharedPreferences shared = android.preference.PreferenceManager.getDefaultSharedPreferences(this);
|
||||
String source = shared.getString(AudioApplication.PREFERENCE_SOURCE, AudioApplication.PREFERENCE_SOURCE_MIC);
|
||||
int user;
|
||||
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(AudioApplication.PREFERENCE_SOURCE_INTERNAL)) {
|
||||
user = Sound.SOURCE_INTERNAL_AUDIO;
|
||||
} else {
|
||||
user = MediaRecorder.AudioSource.MIC;
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ public class EncodingStorage extends HashMap<File, EncodingStorage.Info> {
|
|||
|
||||
public void load() {
|
||||
clear();
|
||||
load(storage.getTempEncoding().getParentFile());
|
||||
Context context = storage.getContext();
|
||||
load(context.getCacheDir());
|
||||
load(context.getExternalCacheDir());
|
||||
|
|
@ -111,7 +110,7 @@ public class EncodingStorage extends HashMap<File, EncodingStorage.Info> {
|
|||
try {
|
||||
put(f, new Info(new JSONObject(FileUtils.readFileToString(j, Charset.defaultCharset()))));
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "unable to read json", e);
|
||||
Log.d(TAG, "unable to read json " + j, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ package com.github.axet.audiorecorder.widgets;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
import android.support.v7.preference.ListPreferenceDialogFragmentCompat;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
|
|
@ -17,8 +19,9 @@ import com.github.axet.audiorecorder.app.Storage;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class RecordingSourcePreferenceCompat extends ListPreference {
|
||||
public class RecordingSourcePreferenceCompat extends com.github.axet.audiolibrary.widgets.RecordingSourcePreferenceCompat {
|
||||
public RecordingSourcePreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
|
@ -35,45 +38,26 @@ public class RecordingSourcePreferenceCompat extends ListPreference {
|
|||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callChangeListener(Object newValue) {
|
||||
update(newValue);
|
||||
return super.callChangeListener(newValue);
|
||||
public boolean isSourceSupported(String s) {
|
||||
if (s.equals(AudioApplication.PREFERENCE_SOURCE_RAW) && !Sound.isUnprocessedSupported(getContext()))
|
||||
return false;
|
||||
if (s.equals(AudioApplication.PREFERENCE_SOURCE_INTERNAL) && Build.VERSION.SDK_INT < 29)
|
||||
return false;
|
||||
AudioManager am = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
|
||||
if (s.equals(AudioApplication.PREFERENCE_SOURCE_BLUETOOTH) && !am.isBluetoothScoAvailableOffCall())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object onGetDefaultValue(TypedArray a, int index) {
|
||||
Object def = super.onGetDefaultValue(a, index);
|
||||
update(def);
|
||||
return def;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
|
||||
super.onSetInitialValue(restoreValue, defaultValue);
|
||||
CharSequence[] text = getEntries();
|
||||
CharSequence[] values = getEntryValues();
|
||||
ArrayList<CharSequence> tt = new ArrayList<>();
|
||||
ArrayList<CharSequence> vv = new ArrayList<>();
|
||||
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();
|
||||
if (v.equals(raw) && !Sound.isUnprocessedSupported(getContext()))
|
||||
public LinkedHashMap<String, String> filter(LinkedHashMap<String, String> mm) {
|
||||
LinkedHashMap<String, String> map = new LinkedHashMap<>();
|
||||
for (String v : mm.keySet()) {
|
||||
String t = mm.get(v);
|
||||
if (!isSourceSupported(v))
|
||||
continue;
|
||||
if (v.equals(internal) && Build.VERSION.SDK_INT < 29)
|
||||
continue;
|
||||
vv.add(v);
|
||||
tt.add(t);
|
||||
map.put(v, t);
|
||||
}
|
||||
setEntryValues(vv.toArray(new CharSequence[0]));
|
||||
setEntries(tt.toArray(new CharSequence[0]));
|
||||
update(getValue()); // defaultValue null after defaults set
|
||||
}
|
||||
|
||||
public void update(Object value) {
|
||||
String v = (String) value;
|
||||
setSummary(v);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue