some code cleanup to deal with the roster mgmt changes from earlier

This commit is contained in:
Daniel Gultsch 2014-05-19 15:39:50 +02:00
parent 993477cd83
commit a6f9a742c0
3 changed files with 53 additions and 76 deletions

View file

@ -329,7 +329,8 @@ public class ConversationFragment extends Fragment {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(ImageProvider.getContentUri(message), "image/*");
intent.setDataAndType(
ImageProvider.getContentUri(message), "image/*");
startActivity(intent);
}
});
@ -583,7 +584,9 @@ public class ConversationFragment extends Fragment {
ConversationActivity activity = (ConversationActivity) getActivity();
if (this.conversation != null) {
for (Message message : this.conversation.getMessages()) {
if ((message.getEncryption() == Message.ENCRYPTION_PGP)&&((message.getStatus() == Message.STATUS_RECIEVED)||(message.getStatus() == Message.STATUS_SEND))) {
if ((message.getEncryption() == Message.ENCRYPTION_PGP)
&& ((message.getStatus() == Message.STATUS_RECIEVED) || (message
.getStatus() == Message.STATUS_SEND))) {
decryptMessage(message);
break;
}
@ -623,7 +626,6 @@ public class ConversationFragment extends Fragment {
protected void makeFingerprintWarning(int latestEncryption) {
final LinearLayout fingerprintWarning = (LinearLayout) getView()
.findViewById(R.id.new_fingerprint);
if (conversation.getContact() != null) {
Set<String> knownFingerprints = conversation.getContact()
.getOtrFingerprints();
if ((latestEncryption == Message.ENCRYPTION_OTR)
@ -638,19 +640,15 @@ public class ConversationFragment extends Fragment {
@Override
public void onClick(View v) {
AlertDialog dialog = UIHelper
.getVerifyFingerprintDialog(
(ConversationActivity) getActivity(),
conversation, fingerprintWarning);
AlertDialog dialog = UIHelper.getVerifyFingerprintDialog(
(ConversationActivity) getActivity(), conversation,
fingerprintWarning);
dialog.show();
}
});
} else {
fingerprintWarning.setVisibility(View.GONE);
}
} else {
fingerprintWarning.setVisibility(View.GONE);
}
}
protected void sendPlainTextMessage(Message message) {
@ -666,13 +664,11 @@ public class ConversationFragment extends Fragment {
final Contact contact = message.getConversation().getContact();
if (activity.hasPgp()) {
if (contact.getPgpKeyId() != 0) {
xmppService.getPgpEngine().hasKey(contact,
new UiCallback() {
xmppService.getPgpEngine().hasKey(contact, new UiCallback() {
@Override
public void userInputRequried(PendingIntent pi) {
activity.runIntent(
pi,
activity.runIntent(pi,
ConversationActivity.REQUEST_ENCRYPT_MESSAGE);
}
@ -691,10 +687,8 @@ public class ConversationFragment extends Fragment {
showNoPGPKeyDialog(new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
conversation
.setNextEncryption(Message.ENCRYPTION_NONE);
public void onClick(DialogInterface dialog, int which) {
conversation.setNextEncryption(Message.ENCRYPTION_NONE);
message.setEncryption(Message.ENCRYPTION_NONE);
xmppService.sendMessage(message, null);
chatMsg.setText("");
@ -705,13 +699,13 @@ public class ConversationFragment extends Fragment {
}
public void showNoPGPKeyDialog(DialogInterface.OnClickListener listener) {
AlertDialog.Builder builder = new AlertDialog.Builder(
getActivity());
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(getString(R.string.no_pgp_key));
builder.setIconAttribute(android.R.attr.alertDialogIcon);
builder.setMessage(getText(R.string.contact_has_no_pgp_key));
builder.setNegativeButton(getString(R.string.cancel), null);
builder.setPositiveButton(getString(R.string.send_unencrypted),listener);
builder.setPositiveButton(getString(R.string.send_unencrypted),
listener);
builder.create().show();
}

View file

@ -17,7 +17,6 @@ import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
@ -29,15 +28,6 @@ public class ShareWithActivity extends XmppActivity {
private LinearLayout conversations;
private LinearLayout contacts;
private OnClickListener click = new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -71,7 +61,7 @@ public class ShareWithActivity extends XmppActivity {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean useSubject = preferences.getBoolean("use_subject_in_muc", true);
Set<String> displayedContacts = new HashSet<String>();
Set<Contact> displayedContacts = new HashSet<Contact>();
conversations.removeAllViews();
List<Conversation> convList = xmppConnectionService.getConversations();
Collections.sort(convList, new Comparator<Conversation>() {
@ -95,15 +85,13 @@ public class ShareWithActivity extends XmppActivity {
}
});
conversations.addView(view);
if (conversation.getContact() != null) {
displayedContacts.add(conversation.getContact().getUuid());
}
displayedContacts.add(conversation.getContact());
}
contacts.removeAllViews();
final List<Contact> contactsList = new ArrayList<Contact>();
List<Contact> contactsList = new ArrayList<Contact>();
for(Account account : xmppConnectionService.getAccounts()) {
for(final Contact contact : account.getRoster().getContacts()) {
if (!displayedContacts.contains(contact.getUuid())) {
for(Contact contact : account.getRoster().getContacts()) {
if (!displayedContacts.contains(contact)&&(contact.getOption(Contact.Options.IN_ROSTER))) {
contactsList.add(contact);
}
}

View file

@ -247,13 +247,8 @@ public class UIHelper {
public static Bitmap getContactPicture(Conversation conversation, int dpSize, Context context, boolean notification) {
if(conversation.getMode() == Conversation.MODE_SINGLE) {
if (conversation.getContact() != null){
return getContactPicture(conversation.getContact(), dpSize,
context, notification);
} else {
return getContactPicture(conversation.getName(false), dpSize,
context, notification);
}
} else{
int fgColor = UIHelper.FG_COLOR,
bgColor = (notification) ?