Keep screen on during voice note recording

Closes #6239
Fixes #4646
// FREEBIE
This commit is contained in:
FeuRenard 2017-02-16 21:28:06 +01:00 committed by Moxie Marlinspike
parent ed5faa4ba9
commit 0095e00bc7

View File

@ -55,6 +55,7 @@ import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener; import android.view.View.OnFocusChangeListener;
import android.view.View.OnKeyListener; import android.view.View.OnKeyListener;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
@ -1646,6 +1647,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
public void onRecorderStarted() { public void onRecorderStarted() {
Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(20); vibrator.vibrate(20);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
audioRecorder.startRecording(); audioRecorder.startRecording();
} }
@ -1654,6 +1656,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
public void onRecorderFinished() { public void onRecorderFinished() {
Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(20); vibrator.vibrate(20);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording(); ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording();
future.addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() { future.addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() {
@ -1696,6 +1699,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
public void onRecorderCanceled() { public void onRecorderCanceled() {
Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(50); vibrator.vibrate(50);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording(); ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording();
future.addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() { future.addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() {