import android.content.AsyncQueryHandler;
import android.content.ContentResolver;
import android.content.ContentUris;
-import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.os.RemoteException;
+import android.provider.Browser;
import android.provider.Im;
import android.text.Editable;
import android.text.TextUtils;
public void onClick(DialogInterface dialog, int which) {
Uri uri = Uri.parse(linkUrls.get(which));
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- intent.addCategory(Intent.CATEGORY_BROWSABLE);
+ intent.putExtra(Browser.EXTRA_APPLICATION_ID, mScreen.getPackageName());
mScreen.startActivity(intent);
}
});
case KeyEvent.KEYCODE_ENTER:
if (event.isAltPressed()) {
mEdtInput.append("\n");
- } else {
- handleEnterKey();
+ return true;
}
- return true;
}
}
return false;
}
});
+
+ mEdtInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+ if (event != null) {
+ if (event.isAltPressed()) {
+ return false;
+ }
+ }
+
+ sendMessage();
+ return true;
+ }
+ });
+
// TODO: this is a hack to implement BUG #1611278, when dispatchKeyEvent() works with
// the soft keyboard, we should remove this hack.
mEdtInput.addTextChangedListener(new TextWatcher() {
unregisterChatSessionListener();
}
- private void handleEnterKey() {
- Configuration config = getResources().getConfiguration();
- if (config.orientation == config.ORIENTATION_LANDSCAPE) {
- // in the landscape mode, we'll send the message if the user is using a physical
- // keyboard. However, on the soft keyboard, we'll close the keyboard and put the
- // focus on the Send button, in order to prevent accidental sending the message.
- if (config.hardKeyboardHidden == config.HARDKEYBOARDHIDDEN_NO) {
- sendMessage();
- } else {
- closeSoftKeyboard();
- mSendButton.requestFocus();
- }
- } else {
- // in the portrait mode, the user would always be using the soft keyboard, so pressing
- // the Enter key would close the keyboard and puts the focus on the Send button.
- closeSoftKeyboard();
- mSendButton.requestFocus();
- }
- }
-
private void closeSoftKeyboard() {
InputMethodManager inputMethodManager =
(InputMethodManager)mApp.getSystemService(Context.INPUT_METHOD_SERVICE);
mQueryHandler.cancelOperation(QUERY_TOKEN);
}
- Uri uri;
- if (Im.Contacts.TYPE_GROUP == mType) {
- uri = ContentUris.withAppendedId(Im.GroupMessages.CONTENT_URI_GROUP_MESSAGES_BY, mChatId);
- } else {
- uri = Im.Messages.getContentUriByContact(mProviderId, mAccountId, mUserName);
- }
+ Uri uri = Im.Messages.getContentUriByThreadId(mChatId);
if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)){
log("queryCursor: uri=" + uri);
new AlertDialog.Builder(mContext)
.setTitle(R.string.confirm)
.setMessage(r.getString(R.string.confirm_block_contact, mNickName))
- .setPositiveButton(R.string.no, null) // default button
- .setNegativeButton(R.string.yes, confirmListener)
+ .setPositiveButton(R.string.yes, confirmListener) // default button
+ .setNegativeButton(R.string.no, null)
.setCancelable(false)
.show();
}
for (int i = 0 ; i < len ; i++) {
mColumnNames[i] = columnNames[i];
- if (mColumnNames[i].equals(Im.BaseMessageColumns.DATE)) {
+ if (mColumnNames[i].equals(Im.Messages.DATE)) {
mDateColumn = i;
}
}
private int mScrollState;
private boolean mNeedRequeryCursor;
- private int mContactColumn;
+ private int mNicknameColumn;
private int mBodyColumn;
private int mDateColumn;
private int mTypeColumn;
}
private void resolveColumnIndex(Cursor c) {
- mContactColumn = c.getColumnIndexOrThrow(Im.BaseMessageColumns.CONTACT);
- mBodyColumn = c.getColumnIndexOrThrow(Im.BaseMessageColumns.BODY);
- mDateColumn = c.getColumnIndexOrThrow(Im.BaseMessageColumns.DATE);
- mTypeColumn = c.getColumnIndexOrThrow(Im.BaseMessageColumns.TYPE);
- mErrCodeColumn = c.getColumnIndexOrThrow(Im.BaseMessageColumns.ERROR_CODE);
+ mNicknameColumn = c.getColumnIndexOrThrow(Im.Messages.NICKNAME);
+ mBodyColumn = c.getColumnIndexOrThrow(Im.Messages.BODY);
+ mDateColumn = c.getColumnIndexOrThrow(Im.Messages.DATE);
+ mTypeColumn = c.getColumnIndexOrThrow(Im.Messages.TYPE);
+ mErrCodeColumn = c.getColumnIndexOrThrow(Im.Messages.ERROR_CODE);
mDeltaColumn = c.getColumnIndexOrThrow(DeltaCursor.DELTA_COLUMN_NAME);
}
MessageView chatMsgView = (MessageView) view;
int type = cursor.getInt(mTypeColumn);
- String contact = isGroupChat() ? cursor.getString(mContactColumn) : mNickName;
+ String contact = isGroupChat() ? cursor.getString(mNicknameColumn) : mNickName;
String body = cursor.getString(mBodyColumn);
long delta = cursor.getLong(mDeltaColumn);
boolean showTimeStamp = (delta > SHOW_TIME_STAMP_INTERVAL);