made publish pgp work from conversation view
This commit is contained in:
parent
6b55f05e27
commit
5ed94d5ab0
|
@ -31,6 +31,7 @@ package eu.siacs.conversations.ui;
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.FragmentManager;
|
import android.app.FragmentManager;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
|
@ -43,6 +44,7 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.annotation.IdRes;
|
import android.support.annotation.IdRes;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -50,6 +52,8 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
|
@ -63,6 +67,7 @@ import eu.siacs.conversations.ui.interfaces.OnConversationRead;
|
||||||
import eu.siacs.conversations.ui.interfaces.OnConversationSelected;
|
import eu.siacs.conversations.ui.interfaces.OnConversationSelected;
|
||||||
import eu.siacs.conversations.ui.interfaces.OnConversationsListItemUpdated;
|
import eu.siacs.conversations.ui.interfaces.OnConversationsListItemUpdated;
|
||||||
import eu.siacs.conversations.ui.service.EmojiService;
|
import eu.siacs.conversations.ui.service.EmojiService;
|
||||||
|
import eu.siacs.conversations.ui.util.ActivityResult;
|
||||||
import eu.siacs.conversations.ui.util.PendingItem;
|
import eu.siacs.conversations.ui.util.PendingItem;
|
||||||
import eu.siacs.conversations.utils.ExceptionHelper;
|
import eu.siacs.conversations.utils.ExceptionHelper;
|
||||||
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
|
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
|
||||||
|
@ -83,6 +88,7 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
||||||
private static final @IdRes
|
private static final @IdRes
|
||||||
int[] FRAGMENT_ID_NOTIFICATION_ORDER = {R.id.secondary_fragment, R.id.main_fragment};
|
int[] FRAGMENT_ID_NOTIFICATION_ORDER = {R.id.secondary_fragment, R.id.main_fragment};
|
||||||
private final PendingItem<Intent> pendingViewIntent = new PendingItem<>();
|
private final PendingItem<Intent> pendingViewIntent = new PendingItem<>();
|
||||||
|
private final PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>();
|
||||||
private ActivityConversationsBinding binding;
|
private ActivityConversationsBinding binding;
|
||||||
private boolean mActivityPaused = true;
|
private boolean mActivityPaused = true;
|
||||||
private AtomicBoolean mRedirectInProcess = new AtomicBoolean(false);
|
private AtomicBoolean mRedirectInProcess = new AtomicBoolean(false);
|
||||||
|
@ -124,6 +130,12 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
||||||
for (@IdRes int id : FRAGMENT_ID_NOTIFICATION_ORDER) {
|
for (@IdRes int id : FRAGMENT_ID_NOTIFICATION_ORDER) {
|
||||||
notifyFragmentOfBackendConnected(id);
|
notifyFragmentOfBackendConnected(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActivityResult activityResult = postponedActivityResult.pop();
|
||||||
|
if (activityResult != null) {
|
||||||
|
handleActivityResult(activityResult);
|
||||||
|
}
|
||||||
|
|
||||||
invalidateActionBarTitle();
|
invalidateActionBarTitle();
|
||||||
if (binding.secondaryFragment != null && ConversationFragment.getConversation(this) == null) {
|
if (binding.secondaryFragment != null && ConversationFragment.getConversation(this) == null) {
|
||||||
Conversation conversation = ConversationsOverviewFragment.getSuggestion(this);
|
Conversation conversation = ConversationsOverviewFragment.getSuggestion(this);
|
||||||
|
@ -267,23 +279,33 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode,@NonNull String permissions[], @NonNull int[] grantResults) {
|
||||||
UriHandlerActivity.onRequestPermissionResult(this, requestCode, grantResults);
|
UriHandlerActivity.onRequestPermissionResult(this, requestCode, grantResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, final Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, final Intent data) {
|
||||||
if (resultCode == RESULT_OK) {
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
handlePositiveActivityResult(requestCode, data);
|
ActivityResult activityResult = ActivityResult.of(requestCode, resultCode, data);
|
||||||
|
if (xmppConnectionService != null) {
|
||||||
|
handleActivityResult(activityResult);
|
||||||
} else {
|
} else {
|
||||||
handleNegativeActivityResult(requestCode);
|
this.postponedActivityResult.push(activityResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleActivityResult(ActivityResult activityResult) {
|
||||||
|
if (activityResult.resultCode == Activity.RESULT_OK) {
|
||||||
|
handlePositiveActivityResult(activityResult.requestCode, activityResult.data);
|
||||||
|
} else {
|
||||||
|
handleNegativeActivityResult(activityResult.requestCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleNegativeActivityResult(int requestCode) {
|
private void handleNegativeActivityResult(int requestCode) {
|
||||||
|
Conversation conversation = ConversationFragment.getConversationReliable(this);
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case REQUEST_DECRYPT_PGP:
|
case REQUEST_DECRYPT_PGP:
|
||||||
Conversation conversation = ConversationFragment.getConversationReliable(this);
|
|
||||||
if (conversation == null) {
|
if (conversation == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -296,14 +318,28 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePositiveActivityResult(int requestCode, final Intent data) {
|
private void handlePositiveActivityResult(int requestCode, final Intent data) {
|
||||||
switch (requestCode) {
|
Log.d(Config.LOGTAG,"positive activity result");
|
||||||
case REQUEST_DECRYPT_PGP:
|
|
||||||
Conversation conversation = ConversationFragment.getConversationReliable(this);
|
Conversation conversation = ConversationFragment.getConversationReliable(this);
|
||||||
if (conversation == null) {
|
if (conversation == null) {
|
||||||
break;
|
Log.d(Config.LOGTAG,"conversation not found");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
switch (requestCode) {
|
||||||
|
case REQUEST_DECRYPT_PGP:
|
||||||
conversation.getAccount().getPgpDecryptionService().continueDecryption(data);
|
conversation.getAccount().getPgpDecryptionService().continueDecryption(data);
|
||||||
break;
|
break;
|
||||||
|
case REQUEST_CHOOSE_PGP_ID:
|
||||||
|
long id = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0);
|
||||||
|
if (id != 0) {
|
||||||
|
conversation.getAccount().setPgpSignId(id);
|
||||||
|
announcePgp(conversation.getAccount(), null, null, onOpenPGPKeyPublished);
|
||||||
|
} else {
|
||||||
|
choosePgpSignId(conversation.getAccount());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case REQUEST_ANNOUNCE_PGP:
|
||||||
|
announcePgp(conversation.getAccount(), conversation, data, onOpenPGPKeyPublished);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +548,6 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
||||||
Conversation suggestion = ConversationsOverviewFragment.getSuggestion(this, conversation);
|
Conversation suggestion = ConversationsOverviewFragment.getSuggestion(this, conversation);
|
||||||
if (suggestion != null) {
|
if (suggestion != null) {
|
||||||
openConversation(suggestion, null);
|
openConversation(suggestion, null);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -686,18 +686,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
int choice = data.getIntExtra("choice", ATTACHMENT_CHOICE_INVALID);
|
int choice = data.getIntExtra("choice", ATTACHMENT_CHOICE_INVALID);
|
||||||
selectPresenceToAttachFile(choice);
|
selectPresenceToAttachFile(choice);
|
||||||
break;
|
break;
|
||||||
case REQUEST_CHOOSE_PGP_ID:
|
|
||||||
long id = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0);
|
|
||||||
if (id != 0) {
|
|
||||||
conversation.getAccount().setPgpSignId(id);
|
|
||||||
activity.announcePgp(conversation.getAccount(), null, null, activity.onOpenPGPKeyPublished);
|
|
||||||
} else {
|
|
||||||
activity.choosePgpSignId(conversation.getAccount());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case REQUEST_ANNOUNCE_PGP:
|
|
||||||
activity.announcePgp(conversation.getAccount(), conversation, data, activity.onOpenPGPKeyPublished);
|
|
||||||
break;
|
|
||||||
case ATTACHMENT_CHOICE_CHOOSE_IMAGE:
|
case ATTACHMENT_CHOICE_CHOOSE_IMAGE:
|
||||||
List<Uri> imageUris = AttachmentTool.extractUriFromIntent(data);
|
List<Uri> imageUris = AttachmentTool.extractUriFromIntent(data);
|
||||||
for (Iterator<Uri> i = imageUris.iterator(); i.hasNext(); i.remove()) {
|
for (Iterator<Uri> i = imageUris.iterator(); i.hasNext(); i.remove()) {
|
||||||
|
@ -2359,10 +2347,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
setScrollPosition(scrollState);
|
setScrollPosition(scrollState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ActivityResult activityResult = postponedActivityResult.pop();
|
|
||||||
if (activityResult != null) {
|
|
||||||
handleActivityResult(activityResult);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearPending() {
|
public void clearPending() {
|
||||||
|
|
Loading…
Reference in New Issue