mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-25 00:48:52 -05:00
contact picture generation centralized + basic registry stuff
This commit is contained in:
parent
eadebeb77c
commit
a80e3131be
@ -209,8 +209,7 @@ public class OtrEngine implements OtrEngineHost {
|
||||
|
||||
@Override
|
||||
public void unreadableMessageReceived(SessionID arg0) throws OtrException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
throw new OtrException(new Exception("unreadable message received"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,6 +29,7 @@ public class Account extends AbstractEntity{
|
||||
|
||||
public static final int OPTION_USETLS = 0;
|
||||
public static final int OPTION_DISABLED = 1;
|
||||
public static final int OPTION_REGISTER = 2;
|
||||
|
||||
public static final int STATUS_CONNECTING = 0;
|
||||
public static final int STATUS_DISABLED = -2;
|
||||
|
@ -396,7 +396,7 @@ public class XmppConnectionService extends Service {
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
//Log.d(LOGTAG,"calling start service. caller was:"+intent.getAction());
|
||||
Log.d(LOGTAG,"calling start service. caller was:"+intent.getAction());
|
||||
ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
@ -441,6 +441,7 @@ public class XmppConnectionService extends Service {
|
||||
Log.d(LOGTAG,account.getJid()+": time out during connect reconnecting");
|
||||
reconnectAccount(account,true);
|
||||
} else {
|
||||
Log.d(LOGTAG,"seconds since last connect:"+((SystemClock.elapsedRealtime() - account.getXmppConnection().lastConnect) / 1000));
|
||||
Log.d(LOGTAG,account.getJid()+": status="+account.getStatus());
|
||||
// TODO notify user of ssl cert problem or auth problem or what ever
|
||||
}
|
||||
@ -836,6 +837,7 @@ public class XmppConnectionService extends Service {
|
||||
} else {
|
||||
conversation.setMode(Conversation.MODE_SINGLE);
|
||||
}
|
||||
conversation.setMessages(databaseBackend.getMessages(conversation, 50));
|
||||
this.databaseBackend.updateConversation(conversation);
|
||||
conversation.setContact(findContact(account,
|
||||
conversation.getContactJid()));
|
||||
@ -887,7 +889,7 @@ public class XmppConnectionService extends Service {
|
||||
public void createAccount(Account account) {
|
||||
databaseBackend.createAccount(account);
|
||||
this.accounts.add(account);
|
||||
account.setXmppConnection(this.createConnection(account));
|
||||
this.reconnectAccount(account, false);
|
||||
if (accountChangedListener != null)
|
||||
accountChangedListener.onAccountListChangedListener();
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ public class ConversationActivity extends XmppActivity {
|
||||
xmppConnectionService.createContact(contact);
|
||||
}
|
||||
};
|
||||
protected ConversationActivity activity = this;
|
||||
|
||||
public List<Conversation> getConversationList() {
|
||||
return this.conversationList;
|
||||
@ -177,17 +178,8 @@ public class ConversationActivity extends XmppActivity {
|
||||
((TextView) view.findViewById(R.id.conversation_lastupdate))
|
||||
.setText(UIHelper.readableTimeDifference(conv.getLatestMessage().getTimeSent()));
|
||||
|
||||
Uri profilePhoto = conv.getProfilePhotoUri();
|
||||
ImageView imageView = (ImageView) view.findViewById(R.id.conversation_image);
|
||||
if (profilePhoto!=null) {
|
||||
imageView.setImageURI(profilePhoto);
|
||||
} else {
|
||||
imageView.setImageBitmap(UIHelper.getUnknownContactPicture(getItem(position).getName(),200));
|
||||
}
|
||||
|
||||
|
||||
((ImageView) view.findViewById(R.id.conversation_image))
|
||||
.setImageURI(conv.getProfilePhotoUri());
|
||||
imageView.setImageBitmap(UIHelper.getContactPicture(getItem(position).getContact(), 200, activity.getApplicationContext()));
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import eu.siacs.conversations.utils.PhoneHelper;
|
||||
import eu.siacs.conversations.utils.UIHelper;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
@ -64,7 +65,7 @@ public class ConversationFragment extends Fragment {
|
||||
private EditText chatMsg;
|
||||
|
||||
protected Bitmap selfBitmap;
|
||||
|
||||
|
||||
private IntentSender askForPassphraseIntent = null;
|
||||
|
||||
private OnClickListener sendMsgListener = new OnClickListener() {
|
||||
@ -85,34 +86,37 @@ public class ConversationFragment extends Fragment {
|
||||
}
|
||||
};
|
||||
protected OnClickListener clickToDecryptListener = new OnClickListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.d("gultsch","clicked to decrypt");
|
||||
if (askForPassphraseIntent!=null) {
|
||||
Log.d("gultsch", "clicked to decrypt");
|
||||
if (askForPassphraseIntent != null) {
|
||||
try {
|
||||
getActivity().startIntentSenderForResult(askForPassphraseIntent, ConversationActivity.REQUEST_DECRYPT_PGP, null, 0, 0, 0);
|
||||
getActivity().startIntentSenderForResult(
|
||||
askForPassphraseIntent,
|
||||
ConversationActivity.REQUEST_DECRYPT_PGP, null, 0,
|
||||
0, 0);
|
||||
} catch (SendIntentException e) {
|
||||
Log.d("gultsch","couldnt fire intent");
|
||||
Log.d("gultsch", "couldnt fire intent");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private LinearLayout pgpInfo;
|
||||
private LinearLayout mucError;
|
||||
private TextView mucErrorText;
|
||||
private OnClickListener clickToMuc = new OnClickListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(),MucDetailsActivity.class);
|
||||
Intent intent = new Intent(getActivity(), MucDetailsActivity.class);
|
||||
intent.setAction(MucDetailsActivity.ACTION_VIEW_MUC);
|
||||
intent.putExtra("uuid", conversation.getUuid());
|
||||
startActivity(intent);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public void hidePgpPassphraseBox() {
|
||||
pgpInfo.setVisibility(View.GONE);
|
||||
}
|
||||
@ -152,13 +156,13 @@ public class ConversationFragment extends Fragment {
|
||||
ImageButton sendButton = (ImageButton) view
|
||||
.findViewById(R.id.textSendButton);
|
||||
sendButton.setOnClickListener(this.sendMsgListener);
|
||||
|
||||
|
||||
pgpInfo = (LinearLayout) view.findViewById(R.id.pgp_keyentry);
|
||||
pgpInfo.setOnClickListener(clickToDecryptListener);
|
||||
mucError = (LinearLayout) view.findViewById(R.id.muc_error);
|
||||
mucError.setOnClickListener(clickToMuc );
|
||||
mucError.setOnClickListener(clickToMuc);
|
||||
mucErrorText = (TextView) view.findViewById(R.id.muc_error_msg);
|
||||
|
||||
|
||||
messagesView = (ListView) view.findViewById(R.id.messages_view);
|
||||
|
||||
messageListAdapter = new ArrayAdapter<Message>(this.getActivity()
|
||||
@ -206,19 +210,13 @@ public class ConversationFragment extends Fragment {
|
||||
viewHolder.imageView = (ImageView) view
|
||||
.findViewById(R.id.message_photo);
|
||||
if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
|
||||
Uri uri = item.getConversation()
|
||||
.getProfilePhotoUri();
|
||||
if (uri != null) {
|
||||
viewHolder.imageView
|
||||
.setImageBitmap(mBitmapCache.get(item
|
||||
.getConversation().getName(),
|
||||
uri));
|
||||
} else {
|
||||
viewHolder.imageView
|
||||
.setImageBitmap(mBitmapCache.get(item
|
||||
.getConversation().getName(),
|
||||
null));
|
||||
}
|
||||
|
||||
viewHolder.imageView.setImageBitmap(mBitmapCache
|
||||
.get(item.getConversation().getName(), item
|
||||
.getConversation().getContact(),
|
||||
getActivity()
|
||||
.getApplicationContext()));
|
||||
|
||||
}
|
||||
break;
|
||||
case ERROR:
|
||||
@ -245,24 +243,30 @@ public class ConversationFragment extends Fragment {
|
||||
if (item.getConversation().getMode() == Conversation.MODE_MULTI) {
|
||||
if (item.getCounterpart() != null) {
|
||||
viewHolder.imageView.setImageBitmap(mBitmapCache
|
||||
.get(item.getCounterpart(), null));
|
||||
.get(item.getCounterpart(), null,
|
||||
getActivity()
|
||||
.getApplicationContext()));
|
||||
} else {
|
||||
viewHolder.imageView
|
||||
.setImageBitmap(mBitmapCache.get(item
|
||||
.getConversation().getName(), null));
|
||||
viewHolder.imageView.setImageBitmap(mBitmapCache
|
||||
.get(item.getConversation().getName(),
|
||||
null, getActivity()
|
||||
.getApplicationContext()));
|
||||
}
|
||||
}
|
||||
}
|
||||
String body = item.getBody();
|
||||
if (body != null) {
|
||||
if (item.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||
viewHolder.messageBody.setText(getString(R.string.encrypted_message));
|
||||
viewHolder.messageBody
|
||||
.setText(getString(R.string.encrypted_message));
|
||||
viewHolder.messageBody.setTextColor(0xff33B5E5);
|
||||
viewHolder.messageBody.setTypeface(null,Typeface.ITALIC);
|
||||
viewHolder.messageBody.setTypeface(null,
|
||||
Typeface.ITALIC);
|
||||
} else {
|
||||
viewHolder.messageBody.setText(body.trim());
|
||||
viewHolder.messageBody.setTextColor(0xff000000);
|
||||
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
|
||||
viewHolder.messageBody.setTypeface(null,
|
||||
Typeface.NORMAL);
|
||||
}
|
||||
}
|
||||
if (item.getStatus() == Message.STATUS_UNSEND) {
|
||||
@ -296,26 +300,8 @@ public class ConversationFragment extends Fragment {
|
||||
boolean showPhoneSelfContactPicture = sharedPref.getBoolean(
|
||||
"show_phone_selfcontact_picture", true);
|
||||
|
||||
Bitmap self = null;
|
||||
|
||||
if (showPhoneSelfContactPicture) {
|
||||
Uri selfiUri = PhoneHelper.getSefliUri(getActivity());
|
||||
if (selfiUri != null) {
|
||||
try {
|
||||
self = BitmapFactory.decodeStream(getActivity()
|
||||
.getContentResolver().openInputStream(selfiUri));
|
||||
} catch (FileNotFoundException e) {
|
||||
self = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (self == null) {
|
||||
self = UIHelper.getUnknownContactPicture(conversation.getAccount()
|
||||
.getJid(), 200);
|
||||
}
|
||||
|
||||
final Bitmap selfBitmap = self;
|
||||
return selfBitmap;
|
||||
return UIHelper.getSelfContactPicture(conversation.getAccount(), 200,
|
||||
showPhoneSelfContactPicture, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -332,7 +318,7 @@ public class ConversationFragment extends Fragment {
|
||||
final ConversationActivity activity = (ConversationActivity) getActivity();
|
||||
activity.registerListener();
|
||||
this.conversation = activity.getSelectedConversation();
|
||||
if (this.conversation==null) {
|
||||
if (this.conversation == null) {
|
||||
return;
|
||||
}
|
||||
this.selfBitmap = findSelfPicture();
|
||||
@ -344,7 +330,7 @@ public class ConversationFragment extends Fragment {
|
||||
activity.getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
activity.getActionBar().setTitle(conversation.getName());
|
||||
activity.invalidateOptionsMenu();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (queuedPqpMessage != null) {
|
||||
@ -354,30 +340,36 @@ public class ConversationFragment extends Fragment {
|
||||
sendPgpMessage(message);
|
||||
}
|
||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||
activity.xmppConnectionService.setOnRenameListener(new OnRenameListener() {
|
||||
|
||||
@Override
|
||||
public void onRename(final boolean success) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
|
||||
activity.xmppConnectionService
|
||||
.setOnRenameListener(new OnRenameListener() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (success) {
|
||||
Toast.makeText(getActivity(), "Your nickname has been changed",Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), "Nichname is already in use",Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
public void onRename(final boolean success) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (success) {
|
||||
Toast.makeText(
|
||||
getActivity(),
|
||||
"Your nickname has been changed",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(getActivity(),
|
||||
"Nichname is already in use",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMessages() {
|
||||
ConversationActivity activity = (ConversationActivity) getActivity();
|
||||
List<Message> encryptedMessages = new LinkedList<Message>();
|
||||
for(Message message : this.conversation.getMessages()) {
|
||||
for (Message message : this.conversation.getMessages()) {
|
||||
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||
encryptedMessages.add(message);
|
||||
}
|
||||
@ -394,7 +386,7 @@ public class ConversationFragment extends Fragment {
|
||||
if (messageList.size() >= 1) {
|
||||
int latestEncryption = this.conversation.getLatestMessage()
|
||||
.getEncryption();
|
||||
if (latestEncryption== Message.ENCRYPTION_DECRYPTED) {
|
||||
if (latestEncryption == Message.ENCRYPTION_DECRYPTED) {
|
||||
conversation.nextMessageEncryption = Message.ENCRYPTION_PGP;
|
||||
} else {
|
||||
conversation.nextMessageEncryption = latestEncryption;
|
||||
@ -418,8 +410,9 @@ public class ConversationFragment extends Fragment {
|
||||
messagesView.setSelection(size - 1);
|
||||
if (!activity.shouldPaneBeOpen()) {
|
||||
conversation.markRead();
|
||||
//TODO update notifications
|
||||
UIHelper.updateNotification(getActivity(), activity.getConversationList(), null, false);
|
||||
// TODO update notifications
|
||||
UIHelper.updateNotification(getActivity(),
|
||||
activity.getConversationList(), null, false);
|
||||
activity.updateConversationList();
|
||||
}
|
||||
}
|
||||
@ -472,16 +465,18 @@ public class ConversationFragment extends Fragment {
|
||||
xmppService.sendMessage(message, null);
|
||||
chatMsg.setText("");
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||
getActivity());
|
||||
builder.setTitle("No openPGP key found");
|
||||
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||
builder.setMessage("There is no openPGP key assoziated with this contact");
|
||||
builder.setNegativeButton("Cancel", null);
|
||||
builder.setPositiveButton("Send plain text",
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
conversation.nextMessageEncryption = Message.ENCRYPTION_NONE;
|
||||
message.setEncryption(Message.ENCRYPTION_NONE);
|
||||
xmppService.sendMessage(message, null);
|
||||
@ -492,7 +487,7 @@ public class ConversationFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void sendOtrMessage(final Message message) {
|
||||
ConversationActivity activity = (ConversationActivity) getActivity();
|
||||
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
||||
@ -564,20 +559,15 @@ public class ConversationFragment extends Fragment {
|
||||
private HashMap<String, Bitmap> bitmaps = new HashMap<String, Bitmap>();
|
||||
private Bitmap error = null;
|
||||
|
||||
public Bitmap get(String name, Uri uri) {
|
||||
public Bitmap get(String name, Contact contact, Context context) {
|
||||
if (bitmaps.containsKey(name)) {
|
||||
return bitmaps.get(name);
|
||||
} else {
|
||||
Bitmap bm;
|
||||
if (uri != null) {
|
||||
try {
|
||||
bm = BitmapFactory.decodeStream(getActivity()
|
||||
.getContentResolver().openInputStream(uri));
|
||||
} catch (FileNotFoundException e) {
|
||||
bm = UIHelper.getUnknownContactPicture(name, 200);
|
||||
}
|
||||
if (contact == null) {
|
||||
bm = UIHelper.getContactPictureByName(name, 200);
|
||||
} else {
|
||||
bm = UIHelper.getUnknownContactPicture(name, 200);
|
||||
bm = UIHelper.getContactPicture(contact, 200, context);
|
||||
}
|
||||
bitmaps.put(name, bm);
|
||||
return bm;
|
||||
@ -591,47 +581,49 @@ public class ConversationFragment extends Fragment {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DecryptMessage extends AsyncTask<Message, Void, Boolean> {
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Message... params) {
|
||||
final ConversationActivity activity = (ConversationActivity) getActivity();
|
||||
askForPassphraseIntent = null;
|
||||
for(int i = 0; i < params.length; ++i) {
|
||||
for (int i = 0; i < params.length; ++i) {
|
||||
if (params[i].getEncryption() == Message.ENCRYPTION_PGP) {
|
||||
String body = params[i].getBody();
|
||||
String decrypted = null;
|
||||
if (activity==null) {
|
||||
if (activity == null) {
|
||||
return false;
|
||||
} else if (!activity.xmppConnectionServiceBound) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
decrypted = activity.xmppConnectionService.getPgpEngine().decrypt(body);
|
||||
decrypted = activity.xmppConnectionService
|
||||
.getPgpEngine().decrypt(body);
|
||||
} catch (UserInputRequiredException e) {
|
||||
askForPassphraseIntent = e.getPendingIntent().getIntentSender();
|
||||
askForPassphraseIntent = e.getPendingIntent()
|
||||
.getIntentSender();
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
pgpInfo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
} catch (OpenPgpException e) {
|
||||
Log.d("gultsch","error decrypting pgp");
|
||||
Log.d("gultsch", "error decrypting pgp");
|
||||
}
|
||||
if (decrypted!=null) {
|
||||
if (decrypted != null) {
|
||||
params[i].setBody(decrypted);
|
||||
params[i].setEncryption(Message.ENCRYPTION_DECRYPTED);
|
||||
activity.xmppConnectionService.updateMessage(params[i]);
|
||||
}
|
||||
if (activity!=null) {
|
||||
if (activity != null) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
messageListAdapter.notifyDataSetChanged();
|
||||
@ -639,9 +631,9 @@ public class ConversationFragment extends Fragment {
|
||||
});
|
||||
}
|
||||
}
|
||||
if (activity!=null) {
|
||||
if (activity != null) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
activity.updateConversationList();
|
||||
@ -651,6 +643,6 @@ public class ConversationFragment extends Fragment {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -54,16 +54,22 @@ public class EditAccount extends DialogFragment {
|
||||
final String okButtonDesc;
|
||||
|
||||
if (account != null) {
|
||||
builder.setTitle("Edit account");
|
||||
registerAccount.setVisibility(View.GONE);
|
||||
jidText.setText(account.getJid());
|
||||
password.setText(account.getPassword());
|
||||
okButtonDesc = "Edit";
|
||||
if (account.isOptionSet(Account.OPTION_USETLS)) {
|
||||
useTLS.setChecked(true);
|
||||
} else {
|
||||
useTLS.setChecked(false);
|
||||
}
|
||||
if (account.isOptionSet(Account.OPTION_REGISTER)) {
|
||||
registerAccount.setChecked(true);
|
||||
builder.setTitle("Add account");
|
||||
okButtonDesc = "Register";
|
||||
} else {
|
||||
registerAccount.setVisibility(View.GONE);
|
||||
builder.setTitle("Edit account");
|
||||
okButtonDesc = "Edit";
|
||||
}
|
||||
} else {
|
||||
builder.setTitle("Add account");
|
||||
okButtonDesc = "Add";
|
||||
@ -110,6 +116,7 @@ public class EditAccount extends DialogFragment {
|
||||
.findViewById(R.id.account_password);
|
||||
String password = passwordEdit.getText().toString();
|
||||
CheckBox useTLS = (CheckBox) d.findViewById(R.id.account_usetls);
|
||||
CheckBox register = (CheckBox) d.findViewById(R.id.edit_account_register_new);
|
||||
String username;
|
||||
String server;
|
||||
if (Validator.isValidJid(jid)) {
|
||||
@ -128,6 +135,7 @@ public class EditAccount extends DialogFragment {
|
||||
account = new Account(username, server, password);
|
||||
}
|
||||
account.setOption(Account.OPTION_USETLS, useTLS.isChecked());
|
||||
account.setOption(Account.OPTION_REGISTER, register.isChecked());
|
||||
if (listener != null) {
|
||||
listener.onAccountEdited(account);
|
||||
d.dismiss();
|
||||
|
@ -64,7 +64,7 @@ public class MucDetailsActivity extends XmppActivity {
|
||||
membersView = (LinearLayout) findViewById(R.id.muc_members);
|
||||
mMoreDetails = (LinearLayout) findViewById(R.id.muc_more_details);
|
||||
mMoreDetails.setVisibility(View.GONE);
|
||||
contactsAdapter = new ArrayAdapter<MucOptions.User>(this,
|
||||
/*contactsAdapter = new ArrayAdapter<MucOptions.User>(this,
|
||||
R.layout.contact, users) {
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup parent) {
|
||||
@ -80,11 +80,10 @@ public class MucDetailsActivity extends XmppActivity {
|
||||
role.setText(getReadableRole(contact.getRole()));
|
||||
ImageView imageView = (ImageView) view
|
||||
.findViewById(R.id.contact_photo);
|
||||
imageView.setImageBitmap(UIHelper.getUnknownContactPicture(
|
||||
getItem(position).getName(), 90));
|
||||
imageView.setImageBitmap(UIHelper.getContactPictureByName(contact.getName(), 90));
|
||||
return view;
|
||||
}
|
||||
};
|
||||
};*/
|
||||
getActionBar().setHomeButtonEnabled(true);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
@ -151,7 +150,7 @@ public class MucDetailsActivity extends XmppActivity {
|
||||
}
|
||||
this.users.clear();
|
||||
this.users.addAll(conversation.getMucOptions().getUsers());
|
||||
contactsAdapter.notifyDataSetChanged();
|
||||
//contactsAdapter.notifyDataSetChanged();
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
membersView.removeAllViews();
|
||||
for(User contact : conversation.getMucOptions().getUsers()) {
|
||||
@ -163,7 +162,7 @@ public class MucDetailsActivity extends XmppActivity {
|
||||
role.setText(getReadableRole(contact.getRole()));
|
||||
ImageView imageView = (ImageView) view
|
||||
.findViewById(R.id.contact_photo);
|
||||
imageView.setImageBitmap(UIHelper.getUnknownContactPicture(contact.getName(), 90));
|
||||
imageView.setImageBitmap(UIHelper.getContactPictureByName(contact.getName(), 90));
|
||||
membersView.addView(view);
|
||||
}
|
||||
}
|
||||
|
@ -135,15 +135,9 @@ public class NewConversationActivity extends XmppActivity {
|
||||
TextView contactJid = (TextView) view
|
||||
.findViewById(R.id.contact_jid);
|
||||
contactJid.setText(contact.getJid());
|
||||
String profilePhoto = getItem(position).getProfilePhoto();
|
||||
ImageView imageView = (ImageView) view
|
||||
.findViewById(R.id.contact_photo);
|
||||
if (profilePhoto != null) {
|
||||
imageView.setImageURI(Uri.parse(profilePhoto));
|
||||
} else {
|
||||
imageView.setImageBitmap(UIHelper.getUnknownContactPicture(
|
||||
getItem(position).getDisplayName(), 90));
|
||||
}
|
||||
imageView.setImageBitmap(UIHelper.getContactPicture(contact,90,this.getContext()));
|
||||
return view;
|
||||
}
|
||||
};
|
||||
|
@ -64,7 +64,7 @@ public class UIHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap getUnknownContactPicture(String name, int size) {
|
||||
private static Bitmap getUnknownContactPicture(String name, int size) {
|
||||
String firstLetter = name.substring(0, 1).toUpperCase(Locale.US);
|
||||
|
||||
int holoColors[] = { 0xFF1da9da, 0xFFb368d9, 0xFF83b600, 0xFFffa713,
|
||||
@ -92,6 +92,9 @@ public class UIHelper {
|
||||
}
|
||||
|
||||
public static Bitmap getContactPicture(Contact contact, int size, Context context) {
|
||||
if (contact==null) {
|
||||
return getUnknownContactPicture(contact.getDisplayName(), size);
|
||||
}
|
||||
String uri = contact.getProfilePhoto();
|
||||
if (uri==null) {
|
||||
return getUnknownContactPicture(contact.getDisplayName(), size);
|
||||
@ -299,4 +302,21 @@ public class UIHelper {
|
||||
builder.setView(view);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
public static Bitmap getSelfContactPicture(Account account, int size, boolean showPhoneSelfContactPicture, Activity activity) {
|
||||
Uri selfiUri = PhoneHelper.getSefliUri(activity);
|
||||
if (selfiUri != null) {
|
||||
try {
|
||||
return BitmapFactory.decodeStream(activity
|
||||
.getContentResolver().openInputStream(selfiUri));
|
||||
} catch (FileNotFoundException e) {
|
||||
return getUnknownContactPicture(account.getJid(), size);
|
||||
}
|
||||
}
|
||||
return getUnknownContactPicture(account.getJid(), size);
|
||||
}
|
||||
|
||||
public static Bitmap getContactPictureByName(String name, int size) {
|
||||
return getUnknownContactPicture(name, size);
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ public class XmppConnection implements Runnable {
|
||||
Log.d(LOGTAG,account.getJid()+ ": connecting");
|
||||
lastConnect = SystemClock.elapsedRealtime();
|
||||
try {
|
||||
shouldAuthenticate = shouldBind = !account.isOptionSet(Account.OPTION_REGISTER);
|
||||
tagReader = new XmlReader(wakeLock);
|
||||
tagWriter = new TagWriter();
|
||||
packetCallbacks.clear();
|
||||
@ -185,6 +186,9 @@ public class XmppConnection implements Runnable {
|
||||
&& (!account.isOptionSet(Account.OPTION_USETLS))) {
|
||||
changeStatus(Account.STATUS_SERVER_REQUIRES_TLS);
|
||||
}
|
||||
if (account.isOptionSet(Account.OPTION_REGISTER)) {
|
||||
Log.d(LOGTAG,account.getJid()+": trying to register");
|
||||
}
|
||||
} else if (nextTag.isStart("proceed")) {
|
||||
switchOverToTls(nextTag);
|
||||
} else if (nextTag.isStart("success")) {
|
||||
|
Loading…
Reference in New Issue
Block a user