mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Decouple MessageCryptoHelper from MessageList
This commit is contained in:
parent
5d3cdc2724
commit
e0abcc3f67
@ -87,7 +87,6 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
|
||||
private static final int PREVIOUS = 1;
|
||||
private static final int NEXT = 2;
|
||||
|
||||
public static final int REQUEST_CODE_CRYPTO = 1;
|
||||
|
||||
public static void actionDisplaySearch(Context context, SearchSpecification search,
|
||||
boolean noThreading, boolean newTask) {
|
||||
@ -1563,13 +1562,8 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
switch (requestCode) {
|
||||
case REQUEST_CODE_CRYPTO:
|
||||
mMessageViewFragment.handleCryptoResult(resultCode, data);
|
||||
break;
|
||||
if (mMessageViewFragment != null) {
|
||||
mMessageViewFragment.handleCryptoResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import android.util.Log;
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.Identity;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.activity.MessageList;
|
||||
import com.fsck.k9.crypto.MessageDecryptVerifier;
|
||||
import com.fsck.k9.crypto.OpenPgpApiHelper;
|
||||
import com.fsck.k9.helper.IdentityHelper;
|
||||
@ -47,6 +46,9 @@ import org.openintents.openpgp.util.OpenPgpServiceConnection.OnBound;
|
||||
|
||||
|
||||
public class MessageCryptoHelper {
|
||||
private static final int REQUEST_CODE_CRYPTO = 1000;
|
||||
private static final int INVALID_OPENPGP_RESULT_CODE = -1;
|
||||
|
||||
|
||||
private final Context context;
|
||||
private final Activity activity;
|
||||
@ -61,7 +63,6 @@ public class MessageCryptoHelper {
|
||||
|
||||
private MessageCryptoAnnotations messageAnnotations;
|
||||
|
||||
private static final int INVALID_OPENPGP_RESULT_CODE = -1;
|
||||
|
||||
public MessageCryptoHelper(Activity activity, Account account, MessageCryptoCallback callback) {
|
||||
this.context = activity.getApplicationContext();
|
||||
@ -343,7 +344,7 @@ public class MessageCryptoHelper {
|
||||
|
||||
try {
|
||||
activity.startIntentSenderForResult(pendingIntent.getIntentSender(),
|
||||
MessageList.REQUEST_CODE_CRYPTO, null, 0, 0, 0);
|
||||
REQUEST_CODE_CRYPTO, null, 0, 0, 0);
|
||||
} catch (SendIntentException e) {
|
||||
Log.e(K9.LOG_TAG, "Internal error on starting pendingintent!", e);
|
||||
}
|
||||
@ -385,7 +386,11 @@ public class MessageCryptoHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void handleCryptoResult(int resultCode, Intent data) {
|
||||
public void handleCryptoResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode != REQUEST_CODE_CRYPTO) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
decryptOrVerifyNextPart();
|
||||
} else {
|
||||
|
@ -215,8 +215,10 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
||||
mFragmentListener.updateMenu();
|
||||
}
|
||||
|
||||
public void handleCryptoResult(int resultCode, Intent data) {
|
||||
messageCryptoHelper.handleCryptoResult(resultCode, data);
|
||||
public void handleCryptoResult(int requestCode, int resultCode, Intent data) {
|
||||
if (messageCryptoHelper != null) {
|
||||
messageCryptoHelper.handleCryptoResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void startLoadingMessageFromDatabase() {
|
||||
|
Loading…
Reference in New Issue
Block a user