/ItemID/src/com/ideal/itemid/VoiceRecorderActivity.java

http://eyes-free.googlecode.com/ · Java · 74 lines · 41 code · 11 blank · 22 comment · 2 complexity · 267d41a834b3c0f95cff2ed7306f981a MD5 · raw file

  1. /*
  2. * Copyright (C) 2010 The IDEAL Group
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.ideal.itemid;
  17. import android.app.Activity;
  18. import android.content.Context;
  19. import android.os.Bundle;
  20. import android.os.Vibrator;
  21. import android.speech.tts.TextToSpeech;
  22. import android.speech.tts.TextToSpeech.OnInitListener;
  23. /**
  24. * Main Activity for IDEAL Item ID Label Maker. Enables users to record
  25. * a message and then generate a QR code that can be printed out.
  26. * Scanning this QR code later will cause the recorded message to be
  27. * played back to the user.
  28. */
  29. public class VoiceRecorderActivity extends Activity {
  30. final public long FILE_TIMESTAMP = System.currentTimeMillis();
  31. private VoiceRecorderRecordingView mRecordingView;
  32. private VoiceRecorderConfirmationView mConfirmationView;
  33. public TextToSpeech mTts;
  34. public Vibrator mVibe;
  35. /** Called when the activity is first created. */
  36. @Override
  37. public void onCreate(Bundle savedInstanceState) {
  38. super.onCreate(savedInstanceState);
  39. mVibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
  40. mTts = new TextToSpeech(this, new OnInitListener() {
  41. @Override
  42. public void onInit(int status) {
  43. mTts.addEarcon("[tock]", "com.ideal.itemid", R.raw.tock_snd);
  44. showRecordingView();
  45. }
  46. });
  47. }
  48. @Override
  49. public void onDestroy() {
  50. super.onDestroy();
  51. if (mTts != null) {
  52. mTts.shutdown();
  53. }
  54. }
  55. public void showConfirmationView() {
  56. mConfirmationView = new VoiceRecorderConfirmationView(this);
  57. this.setContentView(mConfirmationView);
  58. }
  59. public void showRecordingView() {
  60. mRecordingView = new VoiceRecorderRecordingView(this);
  61. this.setContentView(mRecordingView);
  62. }
  63. }