make recording activity not crash if microphone was in use. fixes #3160

This commit is contained in:
Daniel Gultsch 2018-08-31 11:04:18 +02:00
parent 2febbe1b8d
commit b565c20d91
4 changed files with 17 additions and 5 deletions

View File

@ -67,7 +67,8 @@ public class RecordingActivity extends Activity implements View.OnClickListener
super.onStart(); super.onStart();
if (!startRecording()) { if (!startRecording()) {
this.binding.shareButton.setEnabled(false); 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) { protected void stopRecording(boolean saveFile) {
mShouldFinishAfterWrite = saveFile; mShouldFinishAfterWrite = saveFile;
try {
mRecorder.stop(); mRecorder.stop();
mRecorder.release(); mRecorder.release();
} catch (Exception e) {
if (saveFile) {
Toast.makeText(this,R.string.unable_to_save_recording, Toast.LENGTH_SHORT).show();
}
} finally {
mRecorder = null; mRecorder = null;
mStartTime = 0; mStartTime = 0;
}
if (!saveFile && mOutputFile != null) { if (!saveFile && mOutputFile != null) {
if (mOutputFile.delete()) { if (mOutputFile.delete()) {
Log.d(Config.LOGTAG,"deleted canceled recording"); Log.d(Config.LOGTAG,"deleted canceled recording");

View File

@ -42,6 +42,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_margin="8dp"
android:textAppearance="@style/TextAppearance.Conversations.Display2.Monospace"/> android:textAppearance="@style/TextAppearance.Conversations.Display2.Monospace"/>
</RelativeLayout> </RelativeLayout>
</layout> </layout>

View File

@ -127,6 +127,7 @@
<string name="openpgp_error">OpenKeychain reported an error</string> <string name="openpgp_error">OpenKeychain reported an error</string>
<string name="accept">Accept</string> <string name="accept">Accept</string>
<string name="error">An error has occurred</string> <string name="error">An error has occurred</string>
<string name="recording_error">Error</string>
<string name="your_account">Your account</string> <string name="your_account">Your account</string>
<string name="send_presence_updates">Send presence updates</string> <string name="send_presence_updates">Send presence updates</string>
<string name="receive_presence_updates">Receive presence updates</string> <string name="receive_presence_updates">Receive presence updates</string>
@ -725,4 +726,5 @@
<string name="create_dialog_group_chat_name">Group chat name</string> <string name="create_dialog_group_chat_name">Group chat name</string>
<string name="conference_destroyed">This group chat has been destroyed</string> <string name="conference_destroyed">This group chat has been destroyed</string>
<string name="phone_book">Address book</string> <string name="phone_book">Address book</string>
<string name="unable_to_save_recording">Unable to save recording</string>
</resources> </resources>

View File

@ -264,6 +264,7 @@
<item name="colorAccent">@color/blue_a200</item> <item name="colorAccent">@color/blue_a200</item>
<item name="color_background_primary">@color/grey50</item> <item name="color_background_primary">@color/grey50</item>
<item name="divider">@color/black12</item> <item name="divider">@color/black12</item>
<item name="TextSizeTitle">18sp</item>
<item name="TextSizeBody2">14sp</item> <item name="TextSizeBody2">14sp</item>
<item name="TextSizeDisplay2">45sp</item> <item name="TextSizeDisplay2">45sp</item>
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>