/ItemID/src/com/ideal/itemid/VoiceRecorderActivity.java
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 17package com.ideal.itemid; 18 19import android.app.Activity; 20import android.content.Context; 21import android.os.Bundle; 22import android.os.Vibrator; 23import android.speech.tts.TextToSpeech; 24import android.speech.tts.TextToSpeech.OnInitListener; 25 26/** 27 * Main Activity for IDEAL Item ID Label Maker. Enables users to record 28 * a message and then generate a QR code that can be printed out. 29 * Scanning this QR code later will cause the recorded message to be 30 * played back to the user. 31 */ 32public class VoiceRecorderActivity extends Activity { 33 final public long FILE_TIMESTAMP = System.currentTimeMillis(); 34 35 private VoiceRecorderRecordingView mRecordingView; 36 37 private VoiceRecorderConfirmationView mConfirmationView; 38 39 public TextToSpeech mTts; 40 41 public Vibrator mVibe; 42 43 /** Called when the activity is first created. */ 44 @Override 45 public void onCreate(Bundle savedInstanceState) { 46 super.onCreate(savedInstanceState); 47 mVibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); 48 mTts = new TextToSpeech(this, new OnInitListener() { 49 @Override 50 public void onInit(int status) { 51 mTts.addEarcon("[tock]", "com.ideal.itemid", R.raw.tock_snd); 52 showRecordingView(); 53 } 54 }); 55 } 56 57 @Override 58 public void onDestroy() { 59 super.onDestroy(); 60 if (mTts != null) { 61 mTts.shutdown(); 62 } 63 } 64 65 public void showConfirmationView() { 66 mConfirmationView = new VoiceRecorderConfirmationView(this); 67 this.setContentView(mConfirmationView); 68 } 69 70 public void showRecordingView() { 71 mRecordingView = new VoiceRecorderRecordingView(this); 72 this.setContentView(mRecordingView); 73 } 74}