avoid some null pointers when pgp api is not installed
This commit is contained in:
parent
c609eefefa
commit
69af009c88
|
@ -439,34 +439,32 @@ public class ConversationFragment extends Fragment {
|
||||||
ConversationActivity activity = (ConversationActivity) getActivity();
|
ConversationActivity activity = (ConversationActivity) getActivity();
|
||||||
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
||||||
Contact contact = message.getConversation().getContact();
|
Contact contact = message.getConversation().getContact();
|
||||||
if (contact.getPgpKeyId() != 0) {
|
if (activity.hasPgp()) {
|
||||||
xmppService.sendMessage(message, null);
|
if (contact.getPgpKeyId() != 0) {
|
||||||
chatMsg.setText("");
|
xmppService.sendMessage(message, null);
|
||||||
} else {
|
chatMsg.setText("");
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
} else {
|
||||||
builder.setTitle("No openPGP key found");
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
builder.setTitle("No openPGP key found");
|
||||||
builder.setMessage("There is no openPGP key assoziated with this contact");
|
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||||
builder.setNegativeButton("Cancel", null);
|
builder.setMessage("There is no openPGP key assoziated with this contact");
|
||||||
builder.setPositiveButton("Send plain text",
|
builder.setNegativeButton("Cancel", null);
|
||||||
new DialogInterface.OnClickListener() {
|
builder.setPositiveButton("Send plain text",
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
@Override
|
||||||
conversation.nextMessageEncryption = Message.ENCRYPTION_NONE;
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
message.setEncryption(Message.ENCRYPTION_NONE);
|
conversation.nextMessageEncryption = Message.ENCRYPTION_NONE;
|
||||||
xmppService.sendMessage(message, null);
|
message.setEncryption(Message.ENCRYPTION_NONE);
|
||||||
chatMsg.setText("");
|
xmppService.sendMessage(message, null);
|
||||||
}
|
chatMsg.setText("");
|
||||||
});
|
}
|
||||||
builder.create().show();
|
});
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resendPgpMessage(String msg) {
|
|
||||||
this.queuedPqpMessage = msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void sendOtrMessage(final Message message) {
|
protected void sendOtrMessage(final Message message) {
|
||||||
ConversationActivity activity = (ConversationActivity) getActivity();
|
ConversationActivity activity = (ConversationActivity) getActivity();
|
||||||
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
||||||
|
|
|
@ -237,14 +237,16 @@ public class ManageAccountActivity extends XmppActivity implements ActionMode.Ca
|
||||||
builder.setNegativeButton("Cancel",null);
|
builder.setNegativeButton("Cancel",null);
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
} else if (item.getItemId()==R.id.announce_pgp) {
|
} else if (item.getItemId()==R.id.announce_pgp) {
|
||||||
mode.finish();
|
if (this.hasPgp()) {
|
||||||
try {
|
mode.finish();
|
||||||
xmppConnectionService.generatePgpAnnouncement(selectedAccountForActionMode);
|
|
||||||
} catch (PgpEngine.UserInputRequiredException e) {
|
|
||||||
try {
|
try {
|
||||||
startIntentSenderForResult(e.getPendingIntent().getIntentSender(), REQUEST_ANNOUNCE_PGP, null, 0, 0, 0);
|
xmppConnectionService.generatePgpAnnouncement(selectedAccountForActionMode);
|
||||||
} catch (SendIntentException e1) {
|
} catch (PgpEngine.UserInputRequiredException e) {
|
||||||
Log.d("gultsch","sending intent failed");
|
try {
|
||||||
|
startIntentSenderForResult(e.getPendingIntent().getIntentSender(), REQUEST_ANNOUNCE_PGP, null, 0, 0, 0);
|
||||||
|
} catch (SendIntentException e1) {
|
||||||
|
Log.d("gultsch","sending intent failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package eu.siacs.conversations.ui;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder;
|
import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.AlertDialog.Builder;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -63,5 +65,18 @@ public abstract class XmppActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasPgp() {
|
||||||
|
if (xmppConnectionService.getPgpEngine()!=null) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
Builder builder = new AlertDialog.Builder(getApplicationContext());
|
||||||
|
builder.setTitle("OpenKeychain not found");
|
||||||
|
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||||
|
builder.setMessage("Please make sure you have installed OpenKeychain");
|
||||||
|
builder.create().show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
abstract void onBackendConnected();
|
abstract void onBackendConnected();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue