classe dialog pour integrer des smiley dans un message a terminer, un fichier color a nourrir et utiliser des modif un peu partout
--- 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 @@
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
<uses-permission android:name="com.beem.project.beem.BEEM_SERVICE"></uses-permission>
+<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>
</manifest>
--- 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 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" id="text1"
- android:textStyle="bold"
+ android:textSize="2mm"
+ android:textColor="@color/black"
android:singleLine="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
\ No newline at end of file
--- 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 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <ListView android:id="@+id/listMessages"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:scrollbars="horizontal"
- />
- <EditText android:id="@+id/sendText"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textSize="16sp"
- android:autoText="false"
- android:capitalize="none"
- android:scrollHorizontally="true"/>
- <Button android:id="@+id/send"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Send">
- </Button>
-</LinearLayout>
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@color/blue_sky">
+
+ <ListView android:id="@android:id/list"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:transcriptMode="alwaysScroll"/>
+
+ <EditText android:id="@+id/userText"
+ android:layout_width="fill_parent"
+ android:cursorVisible="false"
+ android:hint="@string/SendIMHint"
+ android:layout_height="wrap_content" />
+
+</LinearLayout>
\ No newline at end of file
--- /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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"/>
\ No newline at end of file
--- /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 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:title="Insert a smiley" android:id="@+id/sendim_smiley"/>
+</menu>
--- /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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="blue_sky">#A0C8FF</color>
+ <color name="black">#000000</color>
+</resources>
\ No newline at end of file
--- 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 @@
<resources>
<string name="app_name">Beem</string>
- <!-- Class Beem -->
+ <!-- Beem class -->
<string name="BeemCreateAccount">Creer un compte</string>
<string name="BeemJabberID">Jabber ID</string>
- <!-- Class BeemService -->
+ <!-- BeemService class -->
<string name="BeemServiceDescription">Use the Beem Service</string>
<string name="BeemServiceCreated">BeemService Created</string>
<string name="BeemServiceDestroyed">BeemService destroyed</string>
- <!-- Preferences information -->
+ <!-- Preferences informations -->
<string name="PreferenceFileName">Beem</string>
<string name="PreferenceLoginKey">login</string>
<string name="PreferenceHostKey">host</string>
<string name="PreferencePasswordKey">password</string>
<string name="PreferencePortKey">port</string>
+
+ <!-- SendIM class -->
+ <string name="SendIMSays">says :\n</string>
+ <string name="SendIMHint">Tip text here</string>
+ <string name="SendIMState">Is : </string>
+ <string name="SendIMFrom">and is speaking from : </string>
+ <string name="SendIMSmiley">Insert a smiley</string>
</resources>
--- 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<String> mMessages = new ArrayList<String>();
-
- @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<String> mMessages = new ArrayList<String>();
+ private ArrayAdapter<String> 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<String>(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<String> adapter = new ArrayAdapter<String>(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;
+ }
+ }
}
--- /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");
+ }
+}