diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-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; |