task note voice appends, task title voice replaces

pull/14/head
Tim Su 15 years ago
parent 785598a263
commit 08a9aa6bde

@ -28,15 +28,15 @@ import java.util.List;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.TabActivity;
import android.app.DatePickerDialog.OnDateSetListener;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.DialogInterface.OnCancelListener;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
@ -49,7 +49,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
@ -65,6 +64,7 @@ import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import android.widget.ToggleButton;
import android.widget.AdapterView.OnItemSelectedListener;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.Property.StringProperty;
@ -253,6 +253,7 @@ public final class TaskEditActivity extends TabActivity {
int prompt = R.string.voice_edit_note_prompt;
voiceNoteAssistant = new VoiceInputAssistant(this, voiceAddNoteButton,
notesEditText);
voiceNoteAssistant.setAppend(true);
voiceNoteAssistant.setLanguageModel(RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
voiceNoteAssistant.configureMicrophoneButton(prompt);
}

@ -44,6 +44,7 @@ public class VoiceInputAssistant {
private final Activity activity;
private final ImageButton voiceButton;
private final EditText textField;
private boolean append = false;
private String languageModel = RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH;
@ -61,6 +62,11 @@ public class VoiceInputAssistant {
return languageModel;
}
/** Sets whether voice input will append into field */
public void setAppend(boolean append) {
this.append = append;
}
/**
* Creates a new VoiceInputAssistant-instance simply for checking the availability of the
* RecognizerService. This is used for Preferences-Screens that dont want to provide
@ -156,10 +162,12 @@ public class VoiceInputAssistant {
// make sure we only do this if there is SomeThing (tm) returned
if (match != null && match.size() > 0 && match.get(0).length() > 0) {
String recognizedSpeech = match.get(0);
if(recognizedSpeech.length() > 0)
recognizedSpeech = recognizedSpeech.substring(0, 1).toUpperCase() +
recognizedSpeech.substring(1).toLowerCase();
if(append)
textField.setText((textField.getText() + " " + recognizedSpeech).trim());
else
textField.setText(recognizedSpeech);
}
}

Loading…
Cancel
Save