some code cleanup to deal with the roster mgmt changes from earlier
This commit is contained in:
parent
993477cd83
commit
a6f9a742c0
|
@ -263,7 +263,7 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayInfoMessage(ViewHolder viewHolder, int r) {
|
private void displayInfoMessage(ViewHolder viewHolder, int r) {
|
||||||
if (viewHolder.download_button!=null) {
|
if (viewHolder.download_button != null) {
|
||||||
viewHolder.download_button.setVisibility(View.GONE);
|
viewHolder.download_button.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
viewHolder.image.setVisibility(View.GONE);
|
viewHolder.image.setVisibility(View.GONE);
|
||||||
|
@ -329,7 +329,8 @@ public class ConversationFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setDataAndType(ImageProvider.getContentUri(message), "image/*");
|
intent.setDataAndType(
|
||||||
|
ImageProvider.getContentUri(message), "image/*");
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -486,7 +487,7 @@ public class ConversationFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
if (this.conversation!=null) {
|
if (this.conversation != null) {
|
||||||
this.conversation.setNextMessage(chatMsg.getText().toString());
|
this.conversation.setNextMessage(chatMsg.getText().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -577,13 +578,15 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMessages() {
|
public void updateMessages() {
|
||||||
if (getView()==null) {
|
if (getView() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ConversationActivity activity = (ConversationActivity) getActivity();
|
ConversationActivity activity = (ConversationActivity) getActivity();
|
||||||
if (this.conversation != null) {
|
if (this.conversation != null) {
|
||||||
for (Message message : this.conversation.getMessages()) {
|
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);
|
decryptMessage(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -623,31 +626,26 @@ public class ConversationFragment extends Fragment {
|
||||||
protected void makeFingerprintWarning(int latestEncryption) {
|
protected void makeFingerprintWarning(int latestEncryption) {
|
||||||
final LinearLayout fingerprintWarning = (LinearLayout) getView()
|
final LinearLayout fingerprintWarning = (LinearLayout) getView()
|
||||||
.findViewById(R.id.new_fingerprint);
|
.findViewById(R.id.new_fingerprint);
|
||||||
if (conversation.getContact() != null) {
|
Set<String> knownFingerprints = conversation.getContact()
|
||||||
Set<String> knownFingerprints = conversation.getContact()
|
.getOtrFingerprints();
|
||||||
.getOtrFingerprints();
|
if ((latestEncryption == Message.ENCRYPTION_OTR)
|
||||||
if ((latestEncryption == Message.ENCRYPTION_OTR)
|
&& (conversation.hasValidOtrSession()
|
||||||
&& (conversation.hasValidOtrSession()
|
&& (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!knownFingerprints
|
||||||
&& (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!knownFingerprints
|
.contains(conversation.getOtrFingerprint())))) {
|
||||||
.contains(conversation.getOtrFingerprint())))) {
|
fingerprintWarning.setVisibility(View.VISIBLE);
|
||||||
fingerprintWarning.setVisibility(View.VISIBLE);
|
TextView fingerprint = (TextView) getView().findViewById(
|
||||||
TextView fingerprint = (TextView) getView().findViewById(
|
R.id.otr_fingerprint);
|
||||||
R.id.otr_fingerprint);
|
fingerprint.setText(conversation.getOtrFingerprint());
|
||||||
fingerprint.setText(conversation.getOtrFingerprint());
|
fingerprintWarning.setOnClickListener(new OnClickListener() {
|
||||||
fingerprintWarning.setOnClickListener(new OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
AlertDialog dialog = UIHelper
|
AlertDialog dialog = UIHelper.getVerifyFingerprintDialog(
|
||||||
.getVerifyFingerprintDialog(
|
(ConversationActivity) getActivity(), conversation,
|
||||||
(ConversationActivity) getActivity(),
|
fingerprintWarning);
|
||||||
conversation, fingerprintWarning);
|
dialog.show();
|
||||||
dialog.show();
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
} else {
|
|
||||||
fingerprintWarning.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
fingerprintWarning.setVisibility(View.GONE);
|
fingerprintWarning.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -666,35 +664,31 @@ public class ConversationFragment extends Fragment {
|
||||||
final Contact contact = message.getConversation().getContact();
|
final Contact contact = message.getConversation().getContact();
|
||||||
if (activity.hasPgp()) {
|
if (activity.hasPgp()) {
|
||||||
if (contact.getPgpKeyId() != 0) {
|
if (contact.getPgpKeyId() != 0) {
|
||||||
xmppService.getPgpEngine().hasKey(contact,
|
xmppService.getPgpEngine().hasKey(contact, new UiCallback() {
|
||||||
new UiCallback() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void userInputRequried(PendingIntent pi) {
|
public void userInputRequried(PendingIntent pi) {
|
||||||
activity.runIntent(
|
activity.runIntent(pi,
|
||||||
pi,
|
ConversationActivity.REQUEST_ENCRYPT_MESSAGE);
|
||||||
ConversationActivity.REQUEST_ENCRYPT_MESSAGE);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
activity.encryptTextMessage();
|
activity.encryptTextMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(int error) {
|
public void error(int error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
showNoPGPKeyDialog(new DialogInterface.OnClickListener() {
|
showNoPGPKeyDialog(new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int which) {
|
conversation.setNextEncryption(Message.ENCRYPTION_NONE);
|
||||||
conversation
|
|
||||||
.setNextEncryption(Message.ENCRYPTION_NONE);
|
|
||||||
message.setEncryption(Message.ENCRYPTION_NONE);
|
message.setEncryption(Message.ENCRYPTION_NONE);
|
||||||
xmppService.sendMessage(message, null);
|
xmppService.sendMessage(message, null);
|
||||||
chatMsg.setText("");
|
chatMsg.setText("");
|
||||||
|
@ -705,13 +699,13 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showNoPGPKeyDialog(DialogInterface.OnClickListener listener) {
|
public void showNoPGPKeyDialog(DialogInterface.OnClickListener listener) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
getActivity());
|
|
||||||
builder.setTitle(getString(R.string.no_pgp_key));
|
builder.setTitle(getString(R.string.no_pgp_key));
|
||||||
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||||
builder.setMessage(getText(R.string.contact_has_no_pgp_key));
|
builder.setMessage(getText(R.string.contact_has_no_pgp_key));
|
||||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
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();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import android.content.SharedPreferences;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
@ -29,15 +28,6 @@ public class ShareWithActivity extends XmppActivity {
|
||||||
private LinearLayout conversations;
|
private LinearLayout conversations;
|
||||||
private LinearLayout contacts;
|
private LinearLayout contacts;
|
||||||
|
|
||||||
private OnClickListener click = new OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
@ -71,7 +61,7 @@ public class ShareWithActivity extends XmppActivity {
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
boolean useSubject = preferences.getBoolean("use_subject_in_muc", true);
|
boolean useSubject = preferences.getBoolean("use_subject_in_muc", true);
|
||||||
|
|
||||||
Set<String> displayedContacts = new HashSet<String>();
|
Set<Contact> displayedContacts = new HashSet<Contact>();
|
||||||
conversations.removeAllViews();
|
conversations.removeAllViews();
|
||||||
List<Conversation> convList = xmppConnectionService.getConversations();
|
List<Conversation> convList = xmppConnectionService.getConversations();
|
||||||
Collections.sort(convList, new Comparator<Conversation>() {
|
Collections.sort(convList, new Comparator<Conversation>() {
|
||||||
|
@ -95,15 +85,13 @@ public class ShareWithActivity extends XmppActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
conversations.addView(view);
|
conversations.addView(view);
|
||||||
if (conversation.getContact() != null) {
|
displayedContacts.add(conversation.getContact());
|
||||||
displayedContacts.add(conversation.getContact().getUuid());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
contacts.removeAllViews();
|
contacts.removeAllViews();
|
||||||
final List<Contact> contactsList = new ArrayList<Contact>();
|
List<Contact> contactsList = new ArrayList<Contact>();
|
||||||
for(Account account : xmppConnectionService.getAccounts()) {
|
for(Account account : xmppConnectionService.getAccounts()) {
|
||||||
for(final Contact contact : account.getRoster().getContacts()) {
|
for(Contact contact : account.getRoster().getContacts()) {
|
||||||
if (!displayedContacts.contains(contact.getUuid())) {
|
if (!displayedContacts.contains(contact)&&(contact.getOption(Contact.Options.IN_ROSTER))) {
|
||||||
contactsList.add(contact);
|
contactsList.add(contact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,13 +247,8 @@ public class UIHelper {
|
||||||
|
|
||||||
public static Bitmap getContactPicture(Conversation conversation, int dpSize, Context context, boolean notification) {
|
public static Bitmap getContactPicture(Conversation conversation, int dpSize, Context context, boolean notification) {
|
||||||
if(conversation.getMode() == Conversation.MODE_SINGLE) {
|
if(conversation.getMode() == Conversation.MODE_SINGLE) {
|
||||||
if (conversation.getContact() != null){
|
|
||||||
return getContactPicture(conversation.getContact(), dpSize,
|
return getContactPicture(conversation.getContact(), dpSize,
|
||||||
context, notification);
|
context, notification);
|
||||||
} else {
|
|
||||||
return getContactPicture(conversation.getName(false), dpSize,
|
|
||||||
context, notification);
|
|
||||||
}
|
|
||||||
} else{
|
} else{
|
||||||
int fgColor = UIHelper.FG_COLOR,
|
int fgColor = UIHelper.FG_COLOR,
|
||||||
bgColor = (notification) ?
|
bgColor = (notification) ?
|
||||||
|
|
Loading…
Reference in New Issue