Don't show soft keyboard in fullscreen in compact chat too.
authorDa Risk <da_risk@beem-project.com>
Fri, 06 Apr 2012 17:43:01 +0200
changeset 992 142f330bd3f6
parent 991 6ef8ae29fd7f
child 993 02aafc8b2220
Don't show soft keyboard in fullscreen in compact chat too.
res/layout/chat_compact.xml
src/com/beem/project/beem/ui/Chat.java
--- a/res/layout/chat_compact.xml	Fri Apr 06 17:24:04 2012 +0200
+++ b/res/layout/chat_compact.xml	Fri Apr 06 17:43:01 2012 +0200
@@ -18,7 +18,7 @@
 			android:layout_height="fill_parent" android:layout_weight="1"
 			android:maxLines="5"
 			android:inputType="textShortMessage|textAutoCorrect|textMultiLine|textCapSentences"
-			android:imeOptions="actionSend" android:cursorVisible="true"
+			android:imeOptions="actionSend|flagNoExtractUi" 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"
--- a/src/com/beem/project/beem/ui/Chat.java	Fri Apr 06 17:24:04 2012 +0200
+++ b/src/com/beem/project/beem/ui/Chat.java	Fri Apr 06 17:43:01 2012 +0200
@@ -52,9 +52,6 @@
 import java.util.List;
 import java.util.Map;
 
-import org.jivesoftware.smack.packet.Presence.Mode;
-import org.jivesoftware.smack.util.StringUtils;
-
 import android.app.Activity;
 import android.app.Dialog;
 import android.content.ComponentName;
@@ -82,9 +79,9 @@
 import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
+import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.view.WindowManager;
-import android.view.View.OnClickListener;
 import android.view.inputmethod.EditorInfo;
 import android.widget.BaseAdapter;
 import android.widget.Button;
@@ -111,6 +108,10 @@
 import com.beem.project.beem.utils.BeemBroadcastReceiver;
 import com.beem.project.beem.utils.Status;
 
+import org.jivesoftware.smack.packet.Presence.Mode;
+import org.jivesoftware.smack.util.StringUtils;
+
+
 /**
  * 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>
@@ -173,7 +174,7 @@
 	if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
 	    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
 	}
-	
+
 	mCompact = settings.getBoolean(BeemApplication.USE_COMPACT_CHAT_UI_KEY, false);
 	// UI
 	if (!mCompact) {
@@ -444,8 +445,165 @@
 	return result;
     }
 
-    
-    
+
+    /**
+     * {@inheritDoc}.
+     */
+    @Override
+    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+	if (v == mInputField && actionId == EditorInfo.IME_ACTION_SEND) {
+	    sendMessage();
+	    return true;
+	}
+	return false;
+    }
+
+    /**
+     * Send an XMPP message.
+     */
+    private void sendMessage() {
+	final String inputContent = mInputField.getText().toString();
+
+	if (!"".equals(inputContent)) {
+	    Message msgToSend = new Message(mContact.getJIDWithRes(), Message.MSG_TYPE_CHAT);
+	    msgToSend.setBody(inputContent);
+
+	    try {
+		if (mChat == null) {
+		    mChat = mChatManager.createChat(mContact, mMessageListener);
+		    mChat.setOpen(true);
+		}
+		mChat.sendMessage(msgToSend);
+	    } catch (RemoteException e) {
+		Log.e(TAG, e.getMessage());
+	    }
+
+	    final String self = getString(R.string.chat_self);
+	    MessageText lastMessage = null;
+	    if (mListMessages.size() != 0)
+		lastMessage = mListMessages.get(mListMessages.size() - 1);
+
+	    if (lastMessage != null && lastMessage.getName().equals(self)) {
+		lastMessage.setMessage(lastMessage.getMessage().concat("\n" + inputContent));
+		lastMessage.setTimestamp(new Date());
+	    } else
+		mListMessages.add(new MessageText(self, self, inputContent, false, new Date()));
+	    mMessagesListAdapter.notifyDataSetChanged();
+	    mInputField.setText(null);
+	}
+    }
+
+
+    /**
+     * Update the contact informations.
+     */
+    private void updateContactInformations() {
+	// Check for a contact name update
+	String name = mContact.getName();
+	String res = mContact.getSelectedRes();
+	if (!"".equals(res))
+	    name += "(" + res + ")";
+	if (!mCompact) {
+	    if (!(mContactNameTextView.getText().toString().equals(name)))
+		mContactNameTextView.setText(name);
+	    //Check for a contact status message update
+	    if (!(mContactStatusMsgTextView.getText().toString().equals(mContact.getMsgState()))) {
+		mContactStatusMsgTextView.setText(mContact.getMsgState());
+		Linkify.addLinks(mContactStatusMsgTextView, Linkify.WEB_URLS);
+	    }
+	} else {
+	    Mode m = Status.getPresenceModeFromStatus(mContact.getStatus());
+	    if (m == null)
+		setTitle(getString(R.string.chat_name) + " " + name + " ("
+			+ getString(R.string.contact_status_msg_offline) + ")");
+	    else
+		setTitle(getString(R.string.chat_name) + " " + name + " (" + m.name() + ")");
+	}
+    }
+
+    /**
+     * Update the OTR informations.
+     * @param otrState the otr state
+     */
+    private void updateOtrInformations(final String otrState) {
+	String text = null;
+	if ("ENCRYPTED".equals(otrState)) {
+	    text = Chat.this.getString(R.string.chat_otrstate_encrypted);
+	} else if ("FINISHED".equals(otrState)) {
+	    text = Chat.this.getString(R.string.chat_otrstate_finished);
+	} else if ("AUTHENTICATED".equals(otrState)) {
+	    text = Chat.this.getString(R.string.chat_otrstate_authenticated);
+	} else {
+	    text = Chat.this.getString(R.string.chat_otrstate_plaintext);
+	}
+	if (mContactOtrState != null)
+	    mContactOtrState.setText(text);
+    }
+
+    /**
+     * Update the contact status icon.
+     */
+    private void updateContactStatusIcon() {
+	if (mCompact)
+	    return;
+	String id = mContact.getAvatarId();
+	if (id == null)
+	    id = "";
+	Log.d(TAG, "update contact icon  : " + id);
+	if (!id.equals(mCurrentAvatarId)) {
+	    Drawable avatar = getAvatarDrawable(mContact.getAvatarId());
+	    mAvatarStatusDrawable.setDrawableByLayerId(R.id.avatar, avatar);
+	    mCurrentAvatarId = id;
+	}
+	mContactStatusIcon.setImageLevel(mContact.getStatus());
+    }
+
+    /**
+     * Get a Drawable containing the avatar icon.
+     * @param avatarId the avatar id to retrieve or null to get default
+     * @return a Drawable
+     */
+    private Drawable getAvatarDrawable(String avatarId) {
+	Drawable avatarDrawable = null;
+	if (avatarId != null) {
+	    Uri uri = AvatarProvider.CONTENT_URI.buildUpon().appendPath(avatarId).build();
+	    InputStream in = null;
+	    try {
+		try {
+		    in = getContentResolver().openInputStream(uri);
+		    avatarDrawable = Drawable.createFromStream(in, avatarId);
+		} finally {
+		    if (in != null)
+			in.close();
+		}
+	    } catch (IOException e) {
+		Log.w(TAG, "Error while setting the avatar", e);
+	    }
+	}
+	if (avatarDrawable == null)
+	    avatarDrawable = getResources().getDrawable(R.drawable.beem_launcher_icon_silver);
+	return avatarDrawable;
+    }
+
+    /**
+     * Prepare the status icons map.
+     */
+    private void prepareIconsStatus() {
+	mStatusIconsMap.put(Status.CONTACT_STATUS_AVAILABLE,
+		BitmapFactory.decodeResource(getResources(), android.R.drawable.presence_online));
+	mStatusIconsMap.put(Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT,
+		BitmapFactory.decodeResource(getResources(), android.R.drawable.presence_online));
+	mStatusIconsMap.put(Status.CONTACT_STATUS_AWAY,
+		BitmapFactory.decodeResource(getResources(), android.R.drawable.presence_away));
+	mStatusIconsMap.put(Status.CONTACT_STATUS_BUSY,
+		BitmapFactory.decodeResource(getResources(), android.R.drawable.presence_busy));
+	mStatusIconsMap.put(Status.CONTACT_STATUS_DISCONNECT,
+		BitmapFactory.decodeResource(getResources(), android.R.drawable.presence_offline));
+	mStatusIconsMap.put(Status.CONTACT_STATUS_UNAVAILABLE,
+		BitmapFactory.decodeResource(getResources(), R.drawable.status_requested));
+    }
+
+
     /**
      * {@inheritDoc}.
      */
@@ -632,115 +790,6 @@
     }
 
     /**
-     * Update the contact informations.
-     */
-    private void updateContactInformations() {
-	// Check for a contact name update
-	String name = mContact.getName();
-	String res = mContact.getSelectedRes();
-	if (!"".equals(res))
-	    name += "(" + res + ")";
-	if (!mCompact) {
-	    if (!(mContactNameTextView.getText().toString().equals(name)))
-		mContactNameTextView.setText(name);
-	    //Check for a contact status message update
-	    if (!(mContactStatusMsgTextView.getText().toString().equals(mContact.getMsgState()))) {
-		mContactStatusMsgTextView.setText(mContact.getMsgState());
-		Linkify.addLinks(mContactStatusMsgTextView, Linkify.WEB_URLS);
-	    }
-	} else {
-	    Mode m = Status.getPresenceModeFromStatus(mContact.getStatus());
-	    if (m == null)
-		setTitle(getString(R.string.chat_name) + " " + name + " ("
-		    + getString(R.string.contact_status_msg_offline) + ")");
-	    else
-		setTitle(getString(R.string.chat_name) + " " + name + " (" + m.name() + ")");
-	}
-    }
-
-    /**
-     * Update the OTR informations.
-     * @param otrState the otr state
-     */
-    private void updateOtrInformations(final String otrState) {
-	String text = null;
-	if ("ENCRYPTED".equals(otrState)) {
-	    text = Chat.this.getString(R.string.chat_otrstate_encrypted);
-	} else if ("FINISHED".equals(otrState)) {
-	    text = Chat.this.getString(R.string.chat_otrstate_finished);
-	} else if ("AUTHENTICATED".equals(otrState)) {
-	    text = Chat.this.getString(R.string.chat_otrstate_authenticated);
-	} else {
-	    text = Chat.this.getString(R.string.chat_otrstate_plaintext);
-	}
-	if (mContactOtrState != null)
-		mContactOtrState.setText(text);
-    }
-
-    /**
-     * Update the contact status icon.
-     */
-    private void updateContactStatusIcon() {
-	if (mCompact)
-	    return;
-	String id = mContact.getAvatarId();
-	if (id == null)
-	    id = "";
-	Log.d(TAG, "update contact icon  : " + id);
-	if (!id.equals(mCurrentAvatarId)) {
-	    Drawable avatar = getAvatarDrawable(mContact.getAvatarId());
-	    mAvatarStatusDrawable.setDrawableByLayerId(R.id.avatar, avatar);
-	    mCurrentAvatarId = id;
-	}
-	mContactStatusIcon.setImageLevel(mContact.getStatus());
-    }
-
-    /**
-     * Get a Drawable containing the avatar icon.
-     * @param avatarId the avatar id to retrieve or null to get default
-     * @return a Drawable
-     */
-    private Drawable getAvatarDrawable(String avatarId) {
-	Drawable avatarDrawable = null;
-	if (avatarId != null) {
-	    Uri uri = AvatarProvider.CONTENT_URI.buildUpon().appendPath(avatarId).build();
-	    InputStream in = null;
-	    try {
-		try {
-		    in = getContentResolver().openInputStream(uri);
-		    avatarDrawable = Drawable.createFromStream(in, avatarId);
-		} finally {
-		    if (in != null)
-			in.close();
-		}
-	    } catch (IOException e) {
-		Log.w(TAG, "Error while setting the avatar", e);
-	    }
-	}
-	if (avatarDrawable == null)
-	    avatarDrawable = getResources().getDrawable(R.drawable.beem_launcher_icon_silver);
-	return avatarDrawable;
-    }
-
-    /**
-     * Prepare the status icons map.
-     */
-    private void prepareIconsStatus() {
-	mStatusIconsMap.put(Status.CONTACT_STATUS_AVAILABLE,
-	    BitmapFactory.decodeResource(getResources(), android.R.drawable.presence_online));
-	mStatusIconsMap.put(Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT,
-	    BitmapFactory.decodeResource(getResources(), android.R.drawable.presence_online));
-	mStatusIconsMap.put(Status.CONTACT_STATUS_AWAY,
-	    BitmapFactory.decodeResource(getResources(), android.R.drawable.presence_away));
-	mStatusIconsMap.put(Status.CONTACT_STATUS_BUSY,
-	    BitmapFactory.decodeResource(getResources(), android.R.drawable.presence_busy));
-	mStatusIconsMap.put(Status.CONTACT_STATUS_DISCONNECT,
-	    BitmapFactory.decodeResource(getResources(), android.R.drawable.presence_offline));
-	mStatusIconsMap.put(Status.CONTACT_STATUS_UNAVAILABLE,
-	    BitmapFactory.decodeResource(getResources(), R.drawable.status_requested));
-    }
-
-    /**
      * {@inheritDoc}.
      */
     private class MessagesListAdapter extends BaseAdapter {
@@ -951,53 +1000,6 @@
     }
 
     /**
-     * {@inheritDoc}.
-     */
-    @Override
-    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
-	if (v == mInputField && actionId == EditorInfo.IME_ACTION_SEND) {
-	    sendMessage();
-	    return true;
-	}
-	return false;
-    }
-
-    /**
-     * Send an XMPP message.
-     */
-    private void sendMessage() {
-	final String inputContent = mInputField.getText().toString();
-
-	if (!"".equals(inputContent)) {
-	    Message msgToSend = new Message(mContact.getJIDWithRes(), Message.MSG_TYPE_CHAT);
-	    msgToSend.setBody(inputContent);
-
-	    try {
-		if (mChat == null) {
-		    mChat = mChatManager.createChat(mContact, mMessageListener);
-		    mChat.setOpen(true);
-		}
-		mChat.sendMessage(msgToSend);
-	    } catch (RemoteException e) {
-		Log.e(TAG, e.getMessage());
-	    }
-
-	    final String self = getString(R.string.chat_self);
-	    MessageText lastMessage = null;
-	    if (mListMessages.size() != 0)
-		lastMessage = mListMessages.get(mListMessages.size() - 1);
-
-	    if (lastMessage != null && lastMessage.getName().equals(self)) {
-		lastMessage.setMessage(lastMessage.getMessage().concat("\n" + inputContent));
-		lastMessage.setTimestamp(new Date());
-	    } else
-		mListMessages.add(new MessageText(self, self, inputContent, false, new Date()));
-	    mMessagesListAdapter.notifyDataSetChanged();
-	    mInputField.setText(null);
-	}
-    }
-
-    /**
      * This class is in charge of getting the new chat in the activity if someone talk to you.
      */
     private class ChatManagerListener extends IChatManagerListener.Stub {