/* * This file is part of the Remote Sensor Actuator Interface (ReSAI). * * Copyright(c) Andreas Kipp, Frederic Siepmann * http://opensource.cit-ec.de/projects/resai * * This file may be licensed under the terms of of the * GNU Lesser General Public License Version 3 (the ``LGPL''), * or (at your option) any later version. * * Software distributed under the License is distributed * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either * express or implied. See the LGPL for the specific language * governing rights and limitations. * * You should have received a copy of the LGPL along with this * program. If not, go to http://www.gnu.org/licenses/lgpl.html * or write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The development of this software was supported by the * Excellence Cluster EXC 277 Cognitive Interaction Technology. * The Excellence Cluster EXC 277 is a grant of the Deutsche * Forschungsgemeinschaft (DFG) in the context of the German * Excellence Initiative. * */ /** * Tab to control the speech actuator. * * @author akipp */ package de.unibi.airobots.resaidroid.tabactivities; import java.util.ArrayList; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import de.unibi.airobots.resaidroid.R; import de.unibi.airobots.resaidroid.constants.ServerConfig; import de.unibi.airobots.resaidroid.tabactivities.template.TabTemplate; public class TabSpeechActuator extends TabTemplate { private EditText txtSayText; private Button btnSay; private ListView lvSentences; private ArrayList sentences; private ArrayAdapter aa; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.speechactuator); txtSayText = (EditText) findViewById(R.id.txtSayText); btnSay = (Button) findViewById(R.id.btnSay); sentences = new ArrayList(); sentences.add("Are you Sarah Connor?"); sentences.add("My Name is Byron"); sentences.add("Have a nice day."); sentences.add("Hello."); sentences.add("Please get out of the way."); lvSentences = (ListView) findViewById(R.id.lvSentences); lvSentences.setAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1 , sentences)); btnSay.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (txtSayText.getText().length() > 0) { //TODO auslagern? addProperty("TAG", "SpeechActuatorThread"); addProperty("SpeechActuatorThread", "True"); addProperty("SPEECH", txtSayText.getText().toString()); sendMessage(ServerConfig.RECIPIENT_FULL); sentences.add(txtSayText.getText().toString()); lvSentences.invalidate(); aa.notifyDataSetChanged(); } } }); lvSentences = (ListView) findViewById(R.id.lvSentences); aa = new ArrayAdapter(this, android.R.layout.simple_list_item_1, sentences); lvSentences.setAdapter(aa); lvSentences.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView a, View v, int position, long id) { txtSayText.setText((CharSequence) lvSentences.getItemAtPosition(position)); } }); } @Override public void processProperties() { // TODO Auto-generated method stub } }