Merge branch 'audiorecorder-1.4.18'

This commit is contained in:
Alexey Kuznetsov 2017-04-07 21:48:48 +03:00
commit 8548972b28
9 changed files with 72 additions and 230 deletions

View file

@ -8,8 +8,8 @@ android {
applicationId "com.github.axet.audiorecorder"
minSdkVersion 9
targetSdkVersion 23
versionCode 119
versionName "1.4.17"
versionCode 120
versionName "1.4.18"
}
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.20' // compile project(':android-audio-library')
compile 'com.github.axet:android-audio-library:0.0.21' // compile project(':android-audio-library')
}

View file

@ -14,7 +14,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppThemeLight">
android:theme="@style/RecThemeLight">
<service android:name=".services.RecordingService" />
<activity
@ -25,7 +25,7 @@
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:theme="@style/AppThemeLight.NoActionBar">
android:theme="@style/RecThemeLight.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View file

@ -13,14 +13,16 @@ import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.preference.RingtonePreference;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.preference.PreferenceScreen;
import android.view.MenuItem;
import android.widget.Toast;
@ -45,7 +47,7 @@ import java.util.List;
* href="http://developer.android.com/guide/topics/ui/settings.html">Settings
* API Guide</a> for more information on developing a Settings UI.
*/
public class SettingsActivity extends AppCompatPreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
public class SettingsActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
public static <T> T[] removeElement(Class<T> c, T[] aa, int i) {
List<T> ll = Arrays.asList(aa);
@ -76,21 +78,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity implements Sha
? listPreference.getEntries()[index]
: null);
} else if (preference instanceof RingtonePreference) {
// For ringtone preferences, look up the correct display value
// using RingtoneManager.
Ringtone ringtone = RingtoneManager.getRingtone(
preference.getContext(), Uri.parse(stringValue));
if (ringtone == null) {
// Clear the summary if there was a lookup error.
preference.setSummary(null);
} else {
// Set the summary to reflect the new ringtone display
// name.
String name = ringtone.getTitle(preference.getContext());
preference.setSummary(name);
}
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
@ -130,6 +117,33 @@ public class SettingsActivity extends AppCompatPreferenceActivity implements Sha
.getString(preference.getKey(), ""));
}
static void initPrefs(PreferenceManager pm, PreferenceScreen screen) {
Context context = screen.getContext();
ListPreference enc = (ListPreference) pm.findPreference(MainApplication.PREFERENCE_ENCODING);
String v = enc.getValue();
CharSequence[] ee = Factory.getEncodingTexts(context);
CharSequence[] vv = Factory.getEncodingValues(context);
if (ee.length > 1) {
enc.setEntries(ee);
enc.setEntryValues(vv);
int i = enc.findIndexOfValue(v);
if (i == -1) {
enc.setValueIndex(0);
} else {
enc.setValueIndex(i);
}
bindPreferenceSummaryToValue(enc);
} else {
screen.removePreference(enc);
}
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_RATE));
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_THEME));
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_CHANNELS));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -139,35 +153,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity implements Sha
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
shared.registerOnSharedPreferenceChangeListener(this);
if (Build.VERSION.SDK_INT < 11) {
addPreferencesFromResource(R.xml.pref_general);
ListPreference enc = (ListPreference) findPreference(MainApplication.PREFERENCE_ENCODING);
String v = enc.getValue();
CharSequence[] ee = Factory.getEncodingTexts(this);
CharSequence[] vv = Factory.getEncodingValues(this);
if (ee.length > 1) {
enc.setEntries(ee);
enc.setEntryValues(vv);
int i = enc.findIndexOfValue(v);
if (i == -1) {
enc.setValueIndex(0);
} else {
enc.setValueIndex(i);
}
bindPreferenceSummaryToValue(enc);
} else {
getPreferenceScreen().removePreference(enc);
}
bindPreferenceSummaryToValue(findPreference(MainApplication.PREFERENCE_RATE));
bindPreferenceSummaryToValue(findPreference(MainApplication.PREFERENCE_THEME));
bindPreferenceSummaryToValue(findPreference(MainApplication.PREFERENCE_CHANNELS));
} else {
getFragmentManager().beginTransaction().replace(android.R.id.content, new GeneralPreferenceFragment()).commit();
}
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new GeneralPreferenceFragment()).commit();
}
/**
@ -182,23 +168,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity implements Sha
}
}
/**
* {@inheritDoc}
*/
@Override
public boolean onIsMultiPane() {
return isXLargeTablet(this);
}
/**
* {@inheritDoc}
*/
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onBuildHeaders(List<Header> target) {
// loadHeadersFromResource(R.xml.pref_headers, target);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
@ -213,6 +182,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity implements Sha
* This method stops fragment injection in malicious applications.
* Make sure to deny any unknown fragments here.
*/
@TargetApi(11)
protected boolean isValidFragment(String fragmentName) {
return PreferenceFragment.class.getName().equals(fragmentName)
|| GeneralPreferenceFragment.class.getName().equals(fragmentName);
@ -258,40 +228,15 @@ public class SettingsActivity extends AppCompatPreferenceActivity implements Sha
* This fragment shows general preferences only. It is used when the
* activity is showing a two-pane settings UI.
*/
@TargetApi(11)
public static class GeneralPreferenceFragment extends PreferenceFragment {
public static class GeneralPreferenceFragment extends PreferenceFragmentCompat {
public GeneralPreferenceFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_general);
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setHasOptionsMenu(true);
ListPreference enc = (ListPreference) findPreference(MainApplication.PREFERENCE_ENCODING);
String v = enc.getValue();
CharSequence[] ee = Factory.getEncodingTexts(getActivity());
CharSequence[] vv = Factory.getEncodingValues(getActivity());
if (ee.length > 1) {
enc.setEntries(ee);
enc.setEntryValues(vv);
int i = enc.findIndexOfValue(v);
if (i == -1) {
enc.setValueIndex(0);
} else {
enc.setValueIndex(i);
}
bindPreferenceSummaryToValue(enc);
} else {
getPreferenceScreen().removePreference(enc);
}
bindPreferenceSummaryToValue(findPreference(MainApplication.PREFERENCE_RATE));
bindPreferenceSummaryToValue(findPreference(MainApplication.PREFERENCE_THEME));
bindPreferenceSummaryToValue(findPreference(MainApplication.PREFERENCE_CHANNELS));
addPreferencesFromResource(R.xml.pref_general);
initPrefs(getPreferenceManager(), getPreferenceScreen());
}
@Override

View file

@ -1,2 +1,21 @@
<resources>
<style name="RecThemeLight" parent="AppThemeLight">
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
</style>
<style name="RecThemeDark" parent="AppThemeDark">
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
</style>
<style name="RecThemeLight.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="RecThemeDark.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>

View file

@ -1,61 +0,0 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.github.axet.androidlibrary.widgets.StoragePathPreference
android:defaultValue="Audio Recorder"
android:key="storage_path"
android:summary="/sdcard/some/"
android:title="Папка для хранения" />
<ListPreference
android:defaultValue="16000"
android:entries="@array/sample_rate_text"
android:entryValues="@array/sample_rate_values"
android:key="sample_rate"
android:negativeButtonText="@null"
android:positiveButtonText="@null"
android:summary="44100"
android:title="Частота записи" />
<ListPreference
android:defaultValue="ogg"
android:entries="@array/encodings_text"
android:entryValues="@array/encodings_values"
android:key="encoding"
android:negativeButtonText="@null"
android:positiveButtonText="@null"
android:summary="Формат выходного файла (.wav, .m4a, ...)"
android:title="Кодировка" />
<ListPreference
android:defaultValue="1"
android:entries="@array/channels_text"
android:entryValues="@array/channels_values"
android:key="channels"
android:negativeButtonText="@null"
android:positiveButtonText="@null"
android:summary="Режим записи"
android:title="Режим" />
<SwitchPreference
android:defaultValue="true"
android:key="call"
android:summary="Останавливать запись на время разговора по телефону"
android:title="Пауза на время разговора" />
<SwitchPreference
android:defaultValue="true"
android:key="silence"
android:summary="Включать беззвучный режим на время записи"
android:title="Режим тишины" />
<ListPreference
android:defaultValue="Theme_White"
android:entries="@array/themes_text"
android:entryValues="@array/themes_values"
android:key="theme"
android:negativeButtonText="@null"
android:positiveButtonText="@null"
android:summary="Установить тему приложения (темная / светлая)"
android:title="Тема приложения" />
</PreferenceScreen>

View file

@ -1,6 +1,6 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.github.axet.androidlibrary.widgets.StoragePathPreference
<com.github.axet.androidlibrary.widgets.StoragePathPreferenceCompat
android:defaultValue="Audio Recorder"
android:key="storage_path"
android:summary="/sdcard/some/"
@ -36,13 +36,13 @@
android:summary="Режим записи"
android:title="Режим" />
<CheckBoxPreference
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="call"
android:summary="Останавливать запись на время разговора по телефону"
android:title="Пауза на время разговора" />
<CheckBoxPreference
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="silence"
android:summary="Включать беззвучный режим на время записи"

View file

@ -1,61 +0,0 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.github.axet.androidlibrary.widgets.StoragePathPreference
android:defaultValue="Audio Recorder"
android:key="storage_path"
android:summary="/sdcard/some/"
android:title="Storage Path" />
<ListPreference
android:defaultValue="16000"
android:entries="@array/sample_rate_text"
android:entryValues="@array/sample_rate_values"
android:key="sample_rate"
android:negativeButtonText="@null"
android:positiveButtonText="@null"
android:summary="44100"
android:title="Sample Rate" />
<ListPreference
android:defaultValue="ogg"
android:entries="@array/encodings_text"
android:entryValues="@array/encodings_values"
android:key="encoding"
android:negativeButtonText="@null"
android:positiveButtonText="@null"
android:summary="Output file formats (.wav, .m4a, ...)"
android:title="Encoding" />
<ListPreference
android:defaultValue="1"
android:entries="@array/channels_text"
android:entryValues="@array/channels_values"
android:key="channels"
android:negativeButtonText="@null"
android:positiveButtonText="@null"
android:summary="Recording channels"
android:title="Mode" />
<SwitchPreference
android:defaultValue="true"
android:key="call"
android:summary="Stop recording on answering and continue on hangup"
android:title="Pause recording during calls" />
<SwitchPreference
android:defaultValue="true"
android:key="silence"
android:summary="Put phone in 'silence mode' during recording"
android:title="Silence mode" />
<ListPreference
android:defaultValue="Theme_White"
android:entries="@array/themes_text"
android:entryValues="@array/themes_values"
android:key="theme"
android:negativeButtonText="@null"
android:positiveButtonText="@null"
android:summary="Set application theme (dark / light)"
android:title="Application Theme" />
</PreferenceScreen>

View file

@ -1,6 +1,6 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.github.axet.androidlibrary.widgets.StoragePathPreference
<com.github.axet.androidlibrary.widgets.StoragePathPreferenceCompat
android:defaultValue="Audio Recorder"
android:key="storage_path"
android:summary="/sdcard/some/"
@ -36,13 +36,13 @@
android:summary="Recording channels"
android:title="Mode" />
<CheckBoxPreference
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="call"
android:summary="Stop recording on answering and continue on hangup"
android:title="Pause recording during calls" />
android:title="Pause during calls" />
<CheckBoxPreference
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="silence"
android:summary="Put phone in 'silence mode' during recording"

View file

@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files