From b565c20d9108e7a1ef8ca3f79431744bdb767f09 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 31 Aug 2018 11:04:18 +0200 Subject: [PATCH] make recording activity not crash if microphone was in use. fixes #3160 --- .../conversations/ui/RecordingActivity.java | 18 +++++++++++++----- src/main/res/layout/activity_recording.xml | 1 + src/main/res/values/strings.xml | 2 ++ src/main/res/values/themes.xml | 1 + 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/RecordingActivity.java b/src/main/java/eu/siacs/conversations/ui/RecordingActivity.java index 88c40da9a..710969334 100644 --- a/src/main/java/eu/siacs/conversations/ui/RecordingActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RecordingActivity.java @@ -67,7 +67,8 @@ public class RecordingActivity extends Activity implements View.OnClickListener super.onStart(); if (!startRecording()) { this.binding.shareButton.setEnabled(false); - Toast.makeText(this, R.string.unable_to_start_recording, Toast.LENGTH_SHORT).show(); + this.binding.timer.setTextAppearance(this, R.style.TextAppearance_Conversations_Title); + this.binding.timer.setText(R.string.unable_to_start_recording); } } @@ -108,10 +109,17 @@ public class RecordingActivity extends Activity implements View.OnClickListener protected void stopRecording(boolean saveFile) { mShouldFinishAfterWrite = saveFile; - mRecorder.stop(); - mRecorder.release(); - mRecorder = null; - mStartTime = 0; + try { + mRecorder.stop(); + mRecorder.release(); + } catch (Exception e) { + if (saveFile) { + Toast.makeText(this,R.string.unable_to_save_recording, Toast.LENGTH_SHORT).show(); + } + } finally { + mRecorder = null; + mStartTime = 0; + } if (!saveFile && mOutputFile != null) { if (mOutputFile.delete()) { Log.d(Config.LOGTAG,"deleted canceled recording"); diff --git a/src/main/res/layout/activity_recording.xml b/src/main/res/layout/activity_recording.xml index b4e4b1660..db0775b9d 100644 --- a/src/main/res/layout/activity_recording.xml +++ b/src/main/res/layout/activity_recording.xml @@ -42,6 +42,7 @@ android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" + android:layout_margin="8dp" android:textAppearance="@style/TextAppearance.Conversations.Display2.Monospace"/> \ No newline at end of file diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 21baf7ce0..2f4ecbafc 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -127,6 +127,7 @@ OpenKeychain reported an error Accept An error has occurred + Error Your account Send presence updates Receive presence updates @@ -725,4 +726,5 @@ Group chat name This group chat has been destroyed Address book + Unable to save recording diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index 532214c81..545bd8b74 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -264,6 +264,7 @@ @color/blue_a200 @color/grey50 @color/black12 + 18sp 14sp 45sp true