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 /src/main/java/de/pixart | |
parent | acc88b085cd3acd532af2c88475562bb03059308 (diff) |
prevent accidental close of voice recorder
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/RecordingActivity.java | 17 |
1 files changed, 12 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; |