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 PREVIOUS = 1;
|
||||||
private static final int NEXT = 2;
|
private static final int NEXT = 2;
|
||||||
|
|
||||||
public static final int REQUEST_CODE_CRYPTO = 1;
|
|
||||||
|
|
||||||
public static void actionDisplaySearch(Context context, SearchSpecification search,
|
public static void actionDisplaySearch(Context context, SearchSpecification search,
|
||||||
boolean noThreading, boolean newTask) {
|
boolean noThreading, boolean newTask) {
|
||||||
@ -1563,13 +1562,8 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
|
|||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
switch (requestCode) {
|
if (mMessageViewFragment != null) {
|
||||||
case REQUEST_CODE_CRYPTO:
|
mMessageViewFragment.handleCryptoResult(requestCode, resultCode, data);
|
||||||
mMessageViewFragment.handleCryptoResult(resultCode, data);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import android.util.Log;
|
|||||||
import com.fsck.k9.Account;
|
import com.fsck.k9.Account;
|
||||||
import com.fsck.k9.Identity;
|
import com.fsck.k9.Identity;
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.activity.MessageList;
|
|
||||||
import com.fsck.k9.crypto.MessageDecryptVerifier;
|
import com.fsck.k9.crypto.MessageDecryptVerifier;
|
||||||
import com.fsck.k9.crypto.OpenPgpApiHelper;
|
import com.fsck.k9.crypto.OpenPgpApiHelper;
|
||||||
import com.fsck.k9.helper.IdentityHelper;
|
import com.fsck.k9.helper.IdentityHelper;
|
||||||
@ -47,6 +46,9 @@ import org.openintents.openpgp.util.OpenPgpServiceConnection.OnBound;
|
|||||||
|
|
||||||
|
|
||||||
public class MessageCryptoHelper {
|
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 Context context;
|
||||||
private final Activity activity;
|
private final Activity activity;
|
||||||
@ -61,7 +63,6 @@ public class MessageCryptoHelper {
|
|||||||
|
|
||||||
private MessageCryptoAnnotations messageAnnotations;
|
private MessageCryptoAnnotations messageAnnotations;
|
||||||
|
|
||||||
private static final int INVALID_OPENPGP_RESULT_CODE = -1;
|
|
||||||
|
|
||||||
public MessageCryptoHelper(Activity activity, Account account, MessageCryptoCallback callback) {
|
public MessageCryptoHelper(Activity activity, Account account, MessageCryptoCallback callback) {
|
||||||
this.context = activity.getApplicationContext();
|
this.context = activity.getApplicationContext();
|
||||||
@ -343,7 +344,7 @@ public class MessageCryptoHelper {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
activity.startIntentSenderForResult(pendingIntent.getIntentSender(),
|
activity.startIntentSenderForResult(pendingIntent.getIntentSender(),
|
||||||
MessageList.REQUEST_CODE_CRYPTO, null, 0, 0, 0);
|
REQUEST_CODE_CRYPTO, null, 0, 0, 0);
|
||||||
} catch (SendIntentException e) {
|
} catch (SendIntentException e) {
|
||||||
Log.e(K9.LOG_TAG, "Internal error on starting pendingintent!", 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) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
decryptOrVerifyNextPart();
|
decryptOrVerifyNextPart();
|
||||||
} else {
|
} else {
|
||||||
|
@ -215,8 +215,10 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
|||||||
mFragmentListener.updateMenu();
|
mFragmentListener.updateMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleCryptoResult(int resultCode, Intent data) {
|
public void handleCryptoResult(int requestCode, int resultCode, Intent data) {
|
||||||
messageCryptoHelper.handleCryptoResult(resultCode, data);
|
if (messageCryptoHelper != null) {
|
||||||
|
messageCryptoHelper.handleCryptoResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startLoadingMessageFromDatabase() {
|
private void startLoadingMessageFromDatabase() {
|
||||||
|
Loading…
Reference in New Issue
Block a user