--- a/res/layout/chat.xml Sun Apr 24 01:58:35 2011 +0200
+++ b/res/layout/chat.xml Sun Apr 24 02:02:26 2011 +0200
@@ -41,15 +41,16 @@
android:focusable="true"/>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
+ android:gravity="center_vertical"
android:background="#222222" android:padding="8px">
<EditText android:id="@+id/chat_input" android:layout_width="0dip"
android:layout_height="fill_parent" android:layout_weight="1"
android:maxLines="5"
- android:inputType="textShortMessage|textAutoCorrect|textMultiLine"
+ android:inputType="textShortMessage|textAutoCorrect|textMultiLine|textCapSentences"
android:imeOptions="actionSend" android:cursorVisible="true"
android:hint="@string/chat_input_default_value" />
<Button android:id="@+id/chat_send_message"
- android:layout_width="wrap_content" android:layout_height="fill_parent"
+ android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/chat_send_message" />
</LinearLayout>
</LinearLayout>
--- a/res/layout/chat_compact.xml Sun Apr 24 01:58:35 2011 +0200
+++ b/res/layout/chat_compact.xml Sun Apr 24 02:02:26 2011 +0200
@@ -17,7 +17,7 @@
<EditText android:id="@+id/chat_input" android:layout_width="0dip"
android:layout_height="fill_parent" android:layout_weight="1"
android:maxLines="5"
- android:inputType="textShortMessage|textAutoCorrect|textMultiLine"
+ android:inputType="textShortMessage|textAutoCorrect|textMultiLine|textCapSentences"
android:imeOptions="actionSend" android:cursorVisible="true"
android:hint="@string/chat_input_default_value" />
<Button android:id="@+id/chat_send_message"
--- a/src/com/beem/project/beem/ui/Chat.java Sun Apr 24 01:58:35 2011 +0200
+++ b/src/com/beem/project/beem/ui/Chat.java Sun Apr 24 02:02:26 2011 +0200
@@ -75,6 +75,7 @@
import android.preference.PreferenceManager;
import android.text.util.Linkify;
import android.util.Log;
+import android.view.inputmethod.EditorInfo;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -83,7 +84,6 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
-import android.view.View.OnKeyListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
@@ -113,7 +113,7 @@
* This class represents an activity which allows the user to chat with his/her contacts.
* @author Jean-Manuel Da Silva <dasilvj at beem-project dot com>
*/
-public class Chat extends Activity implements OnKeyListener {
+public class Chat extends Activity implements TextView.OnEditorActionListener {
private static final String TAG = "Chat";
private static final Intent SERVICE_INTENT = new Intent();
@@ -182,7 +182,7 @@
mMessagesListView = (ListView) findViewById(R.id.chat_messages);
mMessagesListView.setAdapter(mMessagesListAdapter);
mInputField = (EditText) findViewById(R.id.chat_input);
- mInputField.setOnKeyListener(this);
+ mInputField.setOnEditorActionListener(this);
mInputField.requestFocus();
mSendButton = (Button) findViewById(R.id.chat_send_message);
mSendButton.setOnClickListener(new OnClickListener() {
@@ -780,7 +780,7 @@
* @param date the time of the message.
*/
public MessageText(final String bareJid, final String name, final String message,
- final boolean isError, Date date) {
+ final boolean isError, final Date date) {
mBareJid = bareJid;
mName = name;
mMessage = message;
@@ -868,15 +868,10 @@
* {@inheritDoc}.
*/
@Override
- public boolean onKey(View v, int keyCode, KeyEvent event) {
- if (event.getAction() == KeyEvent.ACTION_DOWN) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_ENTER:
- sendMessage();
- return true;
- default:
- return false;
- }
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+ if (v == mInputField && actionId == EditorInfo.IME_ACTION_SEND) {
+ sendMessage();
+ return true;
}
return false;
}
--- a/src/com/beem/project/beem/ui/ContactList.java Sun Apr 24 01:58:35 2011 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Sun Apr 24 02:02:26 2011 +0200
@@ -188,6 +188,7 @@
case R.id.menu_disconnect:
stopService(SERVICE_INTENT);
finish();
+ return true;
default:
return false;
}