Merge branch 'audiorecorder-3.1.22'

This commit is contained in:
Alexey Kuznetsov 2018-03-08 17:09:33 +03:00
commit 10e2075848
3 changed files with 23 additions and 7 deletions

View file

@ -10,8 +10,8 @@ android {
applicationId "com.github.axet.audiorecorder"
minSdkVersion 9
targetSdkVersion 23 // 24+ file:// unable to open
versionCode 252
versionName "3.1.21"
versionCode 253
versionName "3.1.22"
}
signingConfigs {
release {

View file

@ -63,7 +63,8 @@ public class MainActivity extends AppCompatThemeActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
showLocked(getWindow());
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
setContentView(R.layout.activity_main);
@ -81,6 +82,7 @@ public class MainActivity extends AppCompatThemeActivity {
@Override
public void onClick(View view) {
recordings.select(-1);
finish();
RecordingActivity.startActivity(MainActivity.this, false);
}
});
@ -100,7 +102,6 @@ public class MainActivity extends AppCompatThemeActivity {
RecordingService.startIfPending(this);
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
receiver = new ScreenReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@ -116,6 +117,7 @@ public class MainActivity extends AppCompatThemeActivity {
void checkPending() {
if (storage.recordingPending()) {
finish();
RecordingActivity.startActivity(MainActivity.this, true);
return;
}
@ -192,6 +194,13 @@ public class MainActivity extends AppCompatThemeActivity {
super.onResume();
Log.d(TAG, "onResume");
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
if (shared.getBoolean(MainApplication.PREFERENCE_CONTROLS, false))
showLocked(getWindow());
else
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
invalidateOptionsMenu(); // update storage folder intent
try {
@ -200,7 +209,6 @@ public class MainActivity extends AppCompatThemeActivity {
Error(e);
}
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
final String last = shared.getString(MainApplication.PREFERENCE_LAST, "");
Runnable done = new Runnable() {
@Override

View file

@ -110,6 +110,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
Storage storage;
Sound sound;
RecordingReceiver receiver;
ScreenReceiver screen;
Handler handler = new Handler();
ShortBuffer dbBuffer = null;
@ -201,8 +202,7 @@ public class RecordingActivity extends AppCompatThemeActivity {
super.onCreate(savedInstanceState);
showLocked(getWindow());
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
setContentView(R.layout.activity_recording);
@ -220,6 +220,9 @@ public class RecordingActivity extends AppCompatThemeActivity {
samplesUpdate = (int) (pitch.getPitchTime() * sampleRate / 1000.0);
samplesUpdateStereo = samplesUpdate * Sound.getChannels(this);
screen = new ScreenReceiver();
screen.registerReceiver(this);
receiver = new RecordingReceiver();
receiver.filter.addAction(PAUSE_BUTTON);
receiver.filter.addAction(ACTION_FINISH_RECORDING);
@ -668,6 +671,11 @@ public class RecordingActivity extends AppCompatThemeActivity {
receiver.stopBluetooth();
headset(false, false);
if (screen != null) {
screen.close();
screen = null;
}
if (receiver != null) {
receiver.close();
receiver = null;