diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-11-12 18:08:31 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-11-12 18:08:31 +0100 |
commit | ef7bcb1b07e3edf36b463aae4cc953ab29d498b0 (patch) | |
tree | 8d010887fceec30b3093fa1717f4ff88d2377738 | |
parent | acc88b085cd3acd532af2c88475562bb03059308 (diff) |
prevent accidental close of voice recorder
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/RecordingActivity.java | 17 | ||||
-rw-r--r-- | src/main/res/values-de/strings.xml | 1 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 1 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/RecordingActivity.java b/src/main/java/de/pixart/messenger/ui/RecordingActivity.java index a9ebccb8c..ed753022b 100644 --- a/src/main/java/de/pixart/messenger/ui/RecordingActivity.java +++ b/src/main/java/de/pixart/messenger/ui/RecordingActivity.java @@ -13,9 +13,9 @@ import android.view.View; import android.view.WindowManager; import android.widget.Button; import android.widget.TextView; +import android.widget.Toast; import java.io.File; -import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; @@ -55,6 +55,7 @@ public class RecordingActivity extends Activity implements View.OnClickListener this.mCancelButton.setOnClickListener(this); this.mStopButton = (Button) this.findViewById(R.id.share_button); this.mStopButton.setOnClickListener(this); + this.setFinishOnTouchOutside(false); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } @@ -62,7 +63,11 @@ public class RecordingActivity extends Activity implements View.OnClickListener protected void onStart() { super.onStart(); Log.d(Config.LOGTAG, "output: " + getOutputFile()); - startRecording(); + if (!startRecording()) { + mStopButton.setEnabled(false); + mStopButton.setTextColor(0x8a000000); + Toast.makeText(this,R.string.unable_to_start_recording,Toast.LENGTH_SHORT).show(); + } } @Override @@ -73,7 +78,7 @@ public class RecordingActivity extends Activity implements View.OnClickListener } } - private void startRecording() { + private boolean startRecording() { mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); @@ -95,12 +100,14 @@ public class RecordingActivity extends Activity implements View.OnClickListener mStartTime = SystemClock.elapsedRealtime(); mHandler.postDelayed(mTickExecutor, 100); Log.d(Config.LOGTAG,"started recording to "+mOutputFile.getAbsolutePath()); - } catch (IOException e) { + return true; + } catch (Exception e) { Log.e(Config.LOGTAG, "prepare() failed "+e.getMessage()); + return false; } } - protected void stopRecording(boolean saveFile) { + protected void stopRecording(boolean saveFile) { mRecorder.stop(); mRecorder.release(); mRecorder = null; diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml index 60a2a72cc..93fe79e05 100644 --- a/src/main/res/values-de/strings.xml +++ b/src/main/res/values-de/strings.xml @@ -678,5 +678,6 @@ <string name="data_saver_enabled_explained">Dein Betriebssystem verbietet Pix-Art Messenger im Hintergrund den Zugang zum Internet. Um Benachrichtigungen erhalten zu können, solltest du Pix-Art Messenger den Zugang erlauben, wenn der Datensparmodus aktiv ist. Pix-Art Messenger wird dennoch versuchen, so viel Daten wie möglich einzusparen.</string> <string name="navigate">Zum Standort navigieren</string> <string name="received_contact">Kontakt empfangen</string> + <string name="unable_to_start_recording">Aufnahme kann nicht gestartet werden</string> </resources> diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index c11d05ef4..4b3cd95b6 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -729,4 +729,5 @@ <string name="add_to_contact_list">Add to contact list</string> <string name="received_contact">Received contact</string> <string name="contact">Contact</string> + <string name="unable_to_start_recording">Unable to start recording</string> </resources> |