# HG changeset patch # User Philippe Lago # Date 1238173963 -3600 # Node ID 4e7c6918b0928ebad59f598a36b78b59a1f38f80 # Parent a0baf41c24a146d75aba55e9918e7a84c7bb4649 classe dialog pour integrer des smiley dans un message a terminer, un fichier color a nourrir et utiliser des modif un peu partout diff -r a0baf41c24a1 -r 4e7c6918b092 AndroidManifest.xml --- a/AndroidManifest.xml Thu Mar 26 20:29:35 2009 +0100 +++ b/AndroidManifest.xml Fri Mar 27 18:12:43 2009 +0100 @@ -24,4 +24,5 @@ + diff -r a0baf41c24a1 -r 4e7c6918b092 res/layout/messagelist.xml --- a/res/layout/messagelist.xml Thu Mar 26 20:29:35 2009 +0100 +++ b/res/layout/messagelist.xml Fri Mar 27 18:12:43 2009 +0100 @@ -1,6 +1,7 @@ \ No newline at end of file diff -r a0baf41c24a1 -r 4e7c6918b092 res/layout/sendim.xml --- a/res/layout/sendim.xml Thu Mar 26 20:29:35 2009 +0100 +++ b/res/layout/sendim.xml Fri Mar 27 18:12:43 2009 +0100 @@ -1,26 +1,20 @@ - - - - + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="@color/blue_sky"> + + + + + + \ No newline at end of file diff -r a0baf41c24a1 -r 4e7c6918b092 res/layout/sendimdialogsmiley.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/res/layout/sendimdialogsmiley.xml Fri Mar 27 18:12:43 2009 +0100 @@ -0,0 +1,5 @@ + + \ No newline at end of file diff -r a0baf41c24a1 -r 4e7c6918b092 res/menu/sendimmenu.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/res/menu/sendimmenu.xml Fri Mar 27 18:12:43 2009 +0100 @@ -0,0 +1,3 @@ + + + diff -r a0baf41c24a1 -r 4e7c6918b092 res/values/colors.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/res/values/colors.xml Fri Mar 27 18:12:43 2009 +0100 @@ -0,0 +1,5 @@ + + + #A0C8FF + #000000 + \ No newline at end of file diff -r a0baf41c24a1 -r 4e7c6918b092 res/values/strings.xml --- a/res/values/strings.xml Thu Mar 26 20:29:35 2009 +0100 +++ b/res/values/strings.xml Fri Mar 27 18:12:43 2009 +0100 @@ -2,19 +2,26 @@ Beem - + Creer un compte Jabber ID - + Use the Beem Service BeemService Created BeemService destroyed - + Beem login host password port + + + says :\n + Tip text here + Is : + and is speaking from : + Insert a smiley diff -r a0baf41c24a1 -r 4e7c6918b092 src/com/beem/project/beem/ui/SendIM.java --- a/src/com/beem/project/beem/ui/SendIM.java Thu Mar 26 20:29:35 2009 +0100 +++ b/src/com/beem/project/beem/ui/SendIM.java Fri Mar 27 18:12:43 2009 +0100 @@ -2,51 +2,121 @@ import java.util.ArrayList; -import org.jivesoftware.smack.packet.Message; - -import android.app.Activity; +import android.app.ListActivity; +import android.content.SharedPreferences; import android.os.Bundle; +import android.view.KeyEvent; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; +import android.view.View.OnClickListener; +import android.view.View.OnKeyListener; import android.widget.ArrayAdapter; -import android.widget.Button; import android.widget.EditText; -import android.widget.ListView; import com.beem.project.beem.R; -public class SendIM extends Activity { - private EditText mToSend; - private ListView mList; - private ArrayList mMessages = new ArrayList(); - - @Override +/** + * @author barbu + * This activity class provide the view for instant messaging + * after selecting a correspondant. + */ + +public class SendIM extends ListActivity implements OnClickListener, OnKeyListener { + private EditText mToSend; + private ArrayList mMessages = new ArrayList(); + private ArrayAdapter mAdapter; + private SendIMDialogSmiley mSmyDialog; + private SharedPreferences mSet; + + /** + * Constructor. + */ + public SendIM() { + super(); + } + + /** + * Overload of onCreate() Activity inherited function + */ + @Override public void onCreate(Bundle saveBundle) { - super.onCreate(saveBundle); - setContentView(R.layout.sendim); - mToSend = (EditText) findViewById(R.id.sendText); - mList = (ListView) findViewById(R.id.listMessages); - - Button send = (Button) this.findViewById(R.id.send); - send.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - String text = mToSend.getText().toString(); - if (text != "") - { - /* - * Prepare the message to send - * */ - Message msg = new Message("barbu", Message.Type.chat); - msg.setBody(text); - mMessages.add("Barbu says:\n" + text); - mToSend.setText(""); - setListAdapter(); - } - } - }); + super.onCreate(saveBundle); + setContentView(R.layout.sendim); + mToSend = (EditText) findViewById(R.id.userText); + mSet = getSharedPreferences("lol", MODE_PRIVATE); + mSmyDialog = new SendIMDialogSmiley(this, mSet); + + mAdapter = new ArrayAdapter(this, R.layout.messagelist, mMessages); + setListAdapter(mAdapter); + + mToSend.setOnClickListener(this); + mToSend.setOnKeyListener(this); + } + + /** + * Abstract method inherited from OnClickListener + */ + public void onClick(View view) { + sendText(); + } + + /** + * This method send a message to the server over the XMPP + * connection and display it on activity view + * TODO : Exception si la connexion se coupe pendant la conversation + */ + private void sendText() { + String text = mToSend.getText().toString(); + if (!text.equals("")) { + /* + * Prepare the message to be send + * */ + /*Message msg = new Message("barbu", Message.Type.chat);*/ + /*msg.setBody(text);*/ + mAdapter.add("Barbu " + getString(R.string.SendIMSays) + text); + mToSend.setText(null); } - - private void setListAdapter() { - ArrayAdapter adapter = new ArrayAdapter(this, R.layout.messagelist, mMessages); - mList.setAdapter(adapter); + } + + /** + * Abstract method inherited from OnKeyListener + */ + public boolean onKey(View v, int keyCode, KeyEvent event) { + if (event.getAction() == KeyEvent.ACTION_DOWN) { + switch (keyCode) { + case KeyEvent.KEYCODE_DPAD_CENTER: + case KeyEvent.KEYCODE_ENTER: + sendText(); + return true; + } } + return false; + } + + /** + * Callback for menu creation. + * @param menu + * the menu created + * @return true on success, false otherwise + */ + @Override + public final boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.sendimmenu, menu); + return true; + } + + @Override + public final boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.sendim_smiley: + mSmyDialog.show(); + return true; + default: + return false; + } + } } diff -r a0baf41c24a1 -r 4e7c6918b092 src/com/beem/project/beem/ui/SendIMDialogSmiley.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/ui/SendIMDialogSmiley.java Fri Mar 27 18:12:43 2009 +0100 @@ -0,0 +1,25 @@ +package com.beem.project.beem.ui; + +import com.beem.project.beem.R; + +import android.app.Dialog; +import android.content.SharedPreferences; +import android.widget.Button; + +public class SendIMDialogSmiley extends Dialog { + private SendIM mSendIM; + private SharedPreferences mSet; + + public SendIMDialogSmiley(SendIM sendim, SharedPreferences settings) { + super(sendim); + this.mSendIM = sendim; + this.mSet = settings; + } + + @Override + protected void onStart() { + super.onStart(); + setContentView(R.layout.sendimdialogsmiley); + setTitle("Select a smiley"); + } +}