Replace getParcelable calls with their counterparts from BundleCompat and IntentCompat
This commit is contained in:
parent
a863974bda
commit
fd8d038bc7
12 changed files with 119 additions and 38 deletions
|
@ -5,11 +5,11 @@ import java.io.InputStream;
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.annotation.WorkerThread;
|
import androidx.annotation.WorkerThread;
|
||||||
|
import androidx.core.content.IntentCompat;
|
||||||
import org.openintents.openpgp.OpenPgpError;
|
import org.openintents.openpgp.OpenPgpError;
|
||||||
import org.openintents.openpgp.util.OpenPgpApi;
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
@ -34,11 +34,19 @@ public class AutocryptStatusInteractor {
|
||||||
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
|
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
|
||||||
case OpenPgpApi.RESULT_CODE_SUCCESS:
|
case OpenPgpApi.RESULT_CODE_SUCCESS:
|
||||||
RecipientAutocryptStatusType type = getRecipientAutocryptStatusFromIntent(result);
|
RecipientAutocryptStatusType type = getRecipientAutocryptStatusFromIntent(result);
|
||||||
PendingIntent pendingIntent = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
|
PendingIntent pendingIntent = IntentCompat.getParcelableExtra(
|
||||||
|
result,
|
||||||
|
OpenPgpApi.RESULT_INTENT,
|
||||||
|
PendingIntent.class
|
||||||
|
);
|
||||||
return new RecipientAutocryptStatus(type, pendingIntent);
|
return new RecipientAutocryptStatus(type, pendingIntent);
|
||||||
|
|
||||||
case OpenPgpApi.RESULT_CODE_ERROR:
|
case OpenPgpApi.RESULT_CODE_ERROR:
|
||||||
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
|
OpenPgpError error = IntentCompat.getParcelableExtra(
|
||||||
|
result,
|
||||||
|
OpenPgpApi.RESULT_ERROR,
|
||||||
|
OpenPgpError.class
|
||||||
|
);
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
Timber.w("OpenPGP API Error #%s: %s", error.getErrorId(), error.getMessage());
|
Timber.w("OpenPGP API Error #%s: %s", error.getErrorId(), error.getMessage());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,10 +9,11 @@ import java.util.Arrays;
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
import androidx.core.content.IntentCompat;
|
||||||
import com.fsck.k9.CoreResourceProvider;
|
import com.fsck.k9.CoreResourceProvider;
|
||||||
import com.fsck.k9.DI;
|
import com.fsck.k9.DI;
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
|
@ -27,7 +28,6 @@ import com.fsck.k9.mail.Message.RecipientType;
|
||||||
import com.fsck.k9.mail.MessagingException;
|
import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.mail.filter.EOLConvertingOutputStream;
|
import com.fsck.k9.mail.filter.EOLConvertingOutputStream;
|
||||||
import com.fsck.k9.mail.internet.BinaryTempFileBody;
|
import com.fsck.k9.mail.internet.BinaryTempFileBody;
|
||||||
import com.fsck.k9.mail.internet.Headers;
|
|
||||||
import com.fsck.k9.mail.internet.MessageIdGenerator;
|
import com.fsck.k9.mail.internet.MessageIdGenerator;
|
||||||
import com.fsck.k9.mail.internet.MimeBodyPart;
|
import com.fsck.k9.mail.internet.MimeBodyPart;
|
||||||
import com.fsck.k9.mail.internet.MimeHeader;
|
import com.fsck.k9.mail.internet.MimeHeader;
|
||||||
|
@ -310,14 +310,22 @@ public class PgpMessageBuilder extends MessageBuilder {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
|
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
|
||||||
PendingIntent returnedPendingIntent = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
|
PendingIntent returnedPendingIntent = IntentCompat.getParcelableExtra(
|
||||||
|
result,
|
||||||
|
OpenPgpApi.RESULT_INTENT,
|
||||||
|
PendingIntent.class
|
||||||
|
);
|
||||||
if (returnedPendingIntent == null) {
|
if (returnedPendingIntent == null) {
|
||||||
throw new MessagingException("openpgp api needs user interaction, but returned no pendingintent!");
|
throw new MessagingException("openpgp api needs user interaction, but returned no pendingintent!");
|
||||||
}
|
}
|
||||||
return returnedPendingIntent;
|
return returnedPendingIntent;
|
||||||
|
|
||||||
case OpenPgpApi.RESULT_CODE_ERROR:
|
case OpenPgpApi.RESULT_CODE_ERROR:
|
||||||
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
|
OpenPgpError error = IntentCompat.getParcelableExtra(
|
||||||
|
result,
|
||||||
|
OpenPgpApi.RESULT_ERROR,
|
||||||
|
OpenPgpError.class
|
||||||
|
);
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
throw new MessagingException("internal openpgp api error");
|
throw new MessagingException("internal openpgp api error");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.CheckBox
|
import android.widget.CheckBox
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.core.content.IntentCompat
|
||||||
|
import androidx.core.os.BundleCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.doAfterTextChanged
|
import androidx.core.widget.doAfterTextChanged
|
||||||
import com.fsck.k9.Account
|
import com.fsck.k9.Account
|
||||||
|
@ -44,8 +46,16 @@ class EditIdentity : K9Activity() {
|
||||||
account = Preferences.getPreferences().getAccount(accountUuid) ?: error("Couldn't find account")
|
account = Preferences.getPreferences().getAccount(accountUuid) ?: error("Couldn't find account")
|
||||||
|
|
||||||
identity = when {
|
identity = when {
|
||||||
savedInstanceState != null -> savedInstanceState.getParcelable(EXTRA_IDENTITY) ?: error("Missing state")
|
savedInstanceState != null -> {
|
||||||
identityIndex != -1 -> intent.getParcelableExtra(EXTRA_IDENTITY) ?: error("Missing argument")
|
BundleCompat.getParcelable(savedInstanceState, EXTRA_IDENTITY, Identity::class.java)
|
||||||
|
?: error("Missing state")
|
||||||
|
}
|
||||||
|
|
||||||
|
identityIndex != -1 -> {
|
||||||
|
IntentCompat.getParcelableExtra(intent, EXTRA_IDENTITY, Identity::class.java)
|
||||||
|
?: error("Missing argument")
|
||||||
|
}
|
||||||
|
|
||||||
else -> Identity()
|
else -> Identity()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@ import android.widget.Toast;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.core.content.IntentCompat;
|
||||||
|
import androidx.core.os.BundleCompat;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
import com.fsck.k9.Account;
|
import com.fsck.k9.Account;
|
||||||
|
@ -428,7 +430,11 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||||
if (action == Action.FORWARD_AS_ATTACHMENT) {
|
if (action == Action.FORWARD_AS_ATTACHMENT) {
|
||||||
messageLoaderHelper.asyncStartOrResumeLoadingMessageMetadata(relatedMessageReference);
|
messageLoaderHelper.asyncStartOrResumeLoadingMessageMetadata(relatedMessageReference);
|
||||||
} else {
|
} else {
|
||||||
Parcelable cachedDecryptionResult = intent.getParcelableExtra(EXTRA_MESSAGE_DECRYPTION_RESULT);
|
Parcelable cachedDecryptionResult = IntentCompat.getParcelableExtra(
|
||||||
|
intent,
|
||||||
|
EXTRA_MESSAGE_DECRYPTION_RESULT,
|
||||||
|
Parcelable.class
|
||||||
|
);
|
||||||
messageLoaderHelper.asyncStartOrResumeLoadingMessage(
|
messageLoaderHelper.asyncStartOrResumeLoadingMessage(
|
||||||
relatedMessageReference, cachedDecryptionResult);
|
relatedMessageReference, cachedDecryptionResult);
|
||||||
}
|
}
|
||||||
|
@ -536,12 +542,16 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||||
|
|
||||||
String type = intent.getType();
|
String type = intent.getType();
|
||||||
if (Intent.ACTION_SEND.equals(action)) {
|
if (Intent.ACTION_SEND.equals(action)) {
|
||||||
Uri stream = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
Uri stream = IntentCompat.getParcelableExtra(intent,Intent.EXTRA_STREAM, Uri.class);
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
attachmentPresenter.addExternalAttachment(stream, type);
|
attachmentPresenter.addExternalAttachment(stream, type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
|
List<Parcelable> list = IntentCompat.getParcelableArrayListExtra(
|
||||||
|
intent,
|
||||||
|
Intent.EXTRA_STREAM,
|
||||||
|
Parcelable.class
|
||||||
|
);
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
for (Parcelable parcelable : list) {
|
for (Parcelable parcelable : list) {
|
||||||
Uri stream = (Uri) parcelable;
|
Uri stream = (Uri) parcelable;
|
||||||
|
@ -650,7 +660,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
||||||
} else {
|
} else {
|
||||||
draftMessageId = null;
|
draftMessageId = null;
|
||||||
}
|
}
|
||||||
identity = savedInstanceState.getParcelable(STATE_IDENTITY);
|
identity = BundleCompat.getParcelable(savedInstanceState, STATE_IDENTITY, Identity.class);
|
||||||
identityChanged = savedInstanceState.getBoolean(STATE_IDENTITY_CHANGED);
|
identityChanged = savedInstanceState.getBoolean(STATE_IDENTITY_CHANGED);
|
||||||
repliedToMessageId = savedInstanceState.getString(STATE_IN_REPLY_TO);
|
repliedToMessageId = savedInstanceState.getString(STATE_IN_REPLY_TO);
|
||||||
referencedMessageIds = savedInstanceState.getString(STATE_REFERENCES);
|
referencedMessageIds = savedInstanceState.getString(STATE_REFERENCES);
|
||||||
|
|
|
@ -8,16 +8,17 @@ import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.core.content.IntentCompat;
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
import com.fsck.k9.Account;
|
import com.fsck.k9.Account;
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.Preferences;
|
import com.fsck.k9.Preferences;
|
||||||
import com.fsck.k9.ui.R;
|
|
||||||
import com.fsck.k9.controller.MessagingController;
|
import com.fsck.k9.controller.MessagingController;
|
||||||
import com.fsck.k9.mailstore.LocalStore;
|
import com.fsck.k9.mailstore.LocalStore;
|
||||||
import com.fsck.k9.service.DatabaseUpgradeService;
|
import com.fsck.k9.service.DatabaseUpgradeService;
|
||||||
|
import com.fsck.k9.ui.R;
|
||||||
import com.fsck.k9.ui.base.K9Activity;
|
import com.fsck.k9.ui.base.K9Activity;
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,7 +138,7 @@ public class UpgradeDatabases extends K9Activity {
|
||||||
*/
|
*/
|
||||||
private void decodeExtras() {
|
private void decodeExtras() {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
mStartIntent = intent.getParcelableExtra(EXTRA_START_INTENT);
|
mStartIntent = IntentCompat.getParcelableExtra(intent, EXTRA_START_INTENT, Intent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,9 +13,10 @@ import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import androidx.core.os.BundleCompat;
|
||||||
import androidx.loader.app.LoaderManager;
|
import androidx.loader.app.LoaderManager;
|
||||||
import androidx.loader.content.Loader;
|
import androidx.loader.content.Loader;
|
||||||
|
|
||||||
import com.fsck.k9.activity.compose.ComposeCryptoStatus.AttachErrorState;
|
import com.fsck.k9.activity.compose.ComposeCryptoStatus.AttachErrorState;
|
||||||
import com.fsck.k9.activity.loader.AttachmentContentLoader;
|
import com.fsck.k9.activity.loader.AttachmentContentLoader;
|
||||||
import com.fsck.k9.activity.loader.AttachmentInfoLoader;
|
import com.fsck.k9.activity.loader.AttachmentInfoLoader;
|
||||||
|
@ -286,7 +287,7 @@ public class AttachmentPresenter {
|
||||||
new LoaderManager.LoaderCallbacks<Attachment>() {
|
new LoaderManager.LoaderCallbacks<Attachment>() {
|
||||||
@Override
|
@Override
|
||||||
public Loader<Attachment> onCreateLoader(int id, Bundle args) {
|
public Loader<Attachment> onCreateLoader(int id, Bundle args) {
|
||||||
Uri uri = args.getParcelable(LOADER_ARG_ATTACHMENT);
|
Uri uri = BundleCompat.getParcelable(args, LOADER_ARG_ATTACHMENT, Uri.class);
|
||||||
return new AttachmentInfoLoader(context, attachments.get(uri));
|
return new AttachmentInfoLoader(context, attachments.get(uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +320,7 @@ public class AttachmentPresenter {
|
||||||
new LoaderManager.LoaderCallbacks<Attachment>() {
|
new LoaderManager.LoaderCallbacks<Attachment>() {
|
||||||
@Override
|
@Override
|
||||||
public Loader<Attachment> onCreateLoader(int id, Bundle args) {
|
public Loader<Attachment> onCreateLoader(int id, Bundle args) {
|
||||||
Uri uri = args.getParcelable(LOADER_ARG_ATTACHMENT);
|
Uri uri = BundleCompat.getParcelable(args, LOADER_ARG_ATTACHMENT, Uri.class);
|
||||||
return new AttachmentContentLoader(context, attachments.get(uri));
|
return new AttachmentContentLoader(context, attachments.get(uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +354,7 @@ public class AttachmentPresenter {
|
||||||
new LoaderManager.LoaderCallbacks<Attachment>() {
|
new LoaderManager.LoaderCallbacks<Attachment>() {
|
||||||
@Override
|
@Override
|
||||||
public Loader<Attachment> onCreateLoader(int id, Bundle args) {
|
public Loader<Attachment> onCreateLoader(int id, Bundle args) {
|
||||||
Uri uri = args.getParcelable(LOADER_ARG_ATTACHMENT);
|
Uri uri = BundleCompat.getParcelable(args, LOADER_ARG_ATTACHMENT, Uri.class);
|
||||||
return new AttachmentContentLoader(context, inlineAttachments.get(uri).getAttachment());
|
return new AttachmentContentLoader(context, inlineAttachments.get(uri).getAttachment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,11 @@ import android.app.Activity;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.WorkerThread;
|
import androidx.annotation.WorkerThread;
|
||||||
|
import androidx.core.content.IntentCompat;
|
||||||
import com.fsck.k9.autocrypt.AutocryptOperations;
|
import com.fsck.k9.autocrypt.AutocryptOperations;
|
||||||
import com.fsck.k9.crypto.MessageCryptoStructureDetector;
|
import com.fsck.k9.crypto.MessageCryptoStructureDetector;
|
||||||
import com.fsck.k9.mail.Address;
|
import com.fsck.k9.mail.Address;
|
||||||
|
@ -537,7 +538,11 @@ public class MessageCryptoHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleUserInteractionRequest() {
|
private void handleUserInteractionRequest() {
|
||||||
PendingIntent pendingIntent = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
|
PendingIntent pendingIntent = IntentCompat.getParcelableExtra(
|
||||||
|
currentCryptoResult,
|
||||||
|
OpenPgpApi.RESULT_INTENT,
|
||||||
|
PendingIntent.class
|
||||||
|
);
|
||||||
if (pendingIntent == null) {
|
if (pendingIntent == null) {
|
||||||
throw new AssertionError("Expecting PendingIntent on USER_INTERACTION_REQUIRED!");
|
throw new AssertionError("Expecting PendingIntent on USER_INTERACTION_REQUIRED!");
|
||||||
}
|
}
|
||||||
|
@ -546,22 +551,40 @@ public class MessageCryptoHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCryptoOperationError() {
|
private void handleCryptoOperationError() {
|
||||||
OpenPgpError error = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
|
OpenPgpError error = IntentCompat.getParcelableExtra(
|
||||||
|
currentCryptoResult,
|
||||||
|
OpenPgpApi.RESULT_ERROR,
|
||||||
|
OpenPgpError.class
|
||||||
|
);
|
||||||
Timber.w("OpenPGP API error: %s", error.getMessage());
|
Timber.w("OpenPGP API error: %s", error.getMessage());
|
||||||
|
|
||||||
onCryptoOperationFailed(error);
|
onCryptoOperationFailed(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCryptoOperationSuccess(MimeBodyPart outputPart) {
|
private void handleCryptoOperationSuccess(MimeBodyPart outputPart) {
|
||||||
OpenPgpDecryptionResult decryptionResult =
|
OpenPgpDecryptionResult decryptionResult = IntentCompat.getParcelableExtra(
|
||||||
currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_DECRYPTION);
|
currentCryptoResult,
|
||||||
OpenPgpSignatureResult signatureResult =
|
OpenPgpApi.RESULT_DECRYPTION,
|
||||||
currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE);
|
OpenPgpDecryptionResult.class
|
||||||
|
);
|
||||||
|
OpenPgpSignatureResult signatureResult = IntentCompat.getParcelableExtra(
|
||||||
|
currentCryptoResult,
|
||||||
|
OpenPgpApi.RESULT_SIGNATURE,
|
||||||
|
OpenPgpSignatureResult.class
|
||||||
|
);
|
||||||
if (decryptionResult.getResult() == OpenPgpDecryptionResult.RESULT_ENCRYPTED) {
|
if (decryptionResult.getResult() == OpenPgpDecryptionResult.RESULT_ENCRYPTED) {
|
||||||
parseAutocryptGossipHeadersFromDecryptedPart(outputPart);
|
parseAutocryptGossipHeadersFromDecryptedPart(outputPart);
|
||||||
}
|
}
|
||||||
PendingIntent pendingIntent = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
|
PendingIntent pendingIntent = IntentCompat.getParcelableExtra(
|
||||||
PendingIntent insecureWarningPendingIntent = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_INSECURE_DETAIL_INTENT);
|
currentCryptoResult,
|
||||||
|
OpenPgpApi.RESULT_INTENT,
|
||||||
|
PendingIntent.class
|
||||||
|
);
|
||||||
|
PendingIntent insecureWarningPendingIntent = IntentCompat.getParcelableExtra(
|
||||||
|
currentCryptoResult,
|
||||||
|
OpenPgpApi.RESULT_INSECURE_DETAIL_INTENT,
|
||||||
|
PendingIntent.class
|
||||||
|
);
|
||||||
boolean overrideCryptoWarning = currentCryptoResult.getBooleanExtra(
|
boolean overrideCryptoWarning = currentCryptoResult.getBooleanExtra(
|
||||||
OpenPgpApi.RESULT_OVERRIDE_CRYPTO_WARNING, false);
|
OpenPgpApi.RESULT_OVERRIDE_CRYPTO_WARNING, false);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.fsck.k9.ui.endtoend
|
||||||
|
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import androidx.core.content.IntentCompat
|
||||||
import com.fsck.k9.Account
|
import com.fsck.k9.Account
|
||||||
import com.fsck.k9.autocrypt.AutocryptTransferMessageCreator
|
import com.fsck.k9.autocrypt.AutocryptTransferMessageCreator
|
||||||
import com.fsck.k9.helper.SingleLiveEvent
|
import com.fsck.k9.helper.SingleLiveEvent
|
||||||
|
@ -36,7 +37,11 @@ class AutocryptSetupMessageLiveEvent(
|
||||||
val result = openPgpApi.executeApi(intent, null as InputStream?, baos)
|
val result = openPgpApi.executeApi(intent, null as InputStream?, baos)
|
||||||
|
|
||||||
val keyData = baos.toByteArray()
|
val keyData = baos.toByteArray()
|
||||||
val pi: PendingIntent = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT) ?: error("Missing result intent")
|
val pi: PendingIntent = IntentCompat.getParcelableExtra(
|
||||||
|
result,
|
||||||
|
OpenPgpApi.RESULT_INTENT,
|
||||||
|
PendingIntent::class.java,
|
||||||
|
) ?: error("Missing result intent")
|
||||||
|
|
||||||
val setupMessage = messageCreator.createAutocryptTransferMessage(keyData, address)
|
val setupMessage = messageCreator.createAutocryptTransferMessage(keyData, address)
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
|
import androidx.core.os.BundleCompat
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
@ -207,7 +208,7 @@ class MessageListFragment :
|
||||||
val arguments = requireArguments()
|
val arguments = requireArguments()
|
||||||
showingThreadedList = arguments.getBoolean(ARG_THREADED_LIST, false)
|
showingThreadedList = arguments.getBoolean(ARG_THREADED_LIST, false)
|
||||||
isThreadDisplay = arguments.getBoolean(ARG_IS_THREAD_DISPLAY, false)
|
isThreadDisplay = arguments.getBoolean(ARG_IS_THREAD_DISPLAY, false)
|
||||||
localSearch = arguments.getParcelable(ARG_SEARCH)!!
|
localSearch = BundleCompat.getParcelable(arguments, ARG_SEARCH, LocalSearch::class.java)!!
|
||||||
|
|
||||||
allAccounts = localSearch.searchAllAccounts()
|
allAccounts = localSearch.searchAllAccounts()
|
||||||
val searchAccounts = localSearch.getAccounts(accountManager)
|
val searchAccounts = localSearch.getAccounts(accountManager)
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.fsck.k9.ui.settings.export
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.core.os.BundleCompat
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
@ -101,7 +102,7 @@ class SettingsExportViewModel(
|
||||||
statusText = StatusText.valueOf(savedInstanceState.getString(STATE_STATUS_TEXT, StatusText.HIDDEN.name))
|
statusText = StatusText.valueOf(savedInstanceState.getString(STATE_STATUS_TEXT, StatusText.HIDDEN.name))
|
||||||
}
|
}
|
||||||
|
|
||||||
contentUri = savedInstanceState.getParcelable(STATE_CONTENT_URI)
|
contentUri = BundleCompat.getParcelable(savedInstanceState, STATE_CONTENT_URI, Uri::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onExportButtonClicked() {
|
fun onExportButtonClicked() {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
|
import androidx.core.os.BundleCompat
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
@ -70,7 +71,7 @@ internal class SettingsImportViewModel(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initializeFromSavedState(savedInstanceState: Bundle) {
|
fun initializeFromSavedState(savedInstanceState: Bundle) {
|
||||||
contentUri = savedInstanceState.getParcelable(STATE_CONTENT_URI)
|
contentUri = BundleCompat.getParcelable(savedInstanceState, STATE_CONTENT_URI, Uri::class.java)
|
||||||
currentlyAuthorizingAccountUuid = savedInstanceState.getString(STATE_CURRENTLY_AUTHORIZING_ACCOUNT_UUID)
|
currentlyAuthorizingAccountUuid = savedInstanceState.getString(STATE_CURRENTLY_AUTHORIZING_ACCOUNT_UUID)
|
||||||
|
|
||||||
updateUiModel {
|
updateUiModel {
|
||||||
|
@ -204,12 +205,15 @@ internal class SettingsImportViewModel(
|
||||||
ImportStatus.NOT_AVAILABLE -> updateUiModel {
|
ImportStatus.NOT_AVAILABLE -> updateUiModel {
|
||||||
toggleSettingsListItemSelection(position)
|
toggleSettingsListItemSelection(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportStatus.IMPORT_SUCCESS_AUTHORIZATION_REQUIRED -> {
|
ImportStatus.IMPORT_SUCCESS_AUTHORIZATION_REQUIRED -> {
|
||||||
startAuthorization(settingsListItem as SettingsListItem.Account)
|
startAuthorization(settingsListItem as SettingsListItem.Account)
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportStatus.IMPORT_SUCCESS_PASSWORD_REQUIRED -> {
|
ImportStatus.IMPORT_SUCCESS_PASSWORD_REQUIRED -> {
|
||||||
showPasswordPromptDialog(settingsListItem as SettingsListItem.Account)
|
showPasswordPromptDialog(settingsListItem as SettingsListItem.Account)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,12 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentSender;
|
import android.content.IntentSender;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import androidx.core.content.IntentCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.preference.Preference;
|
||||||
import org.openintents.openpgp.OpenPgpApiManager;
|
import org.openintents.openpgp.OpenPgpApiManager;
|
||||||
import org.openintents.openpgp.OpenPgpApiManager.OpenPgpApiManagerCallback;
|
import org.openintents.openpgp.OpenPgpApiManager.OpenPgpApiManagerCallback;
|
||||||
import org.openintents.openpgp.OpenPgpApiManager.OpenPgpProviderError;
|
import org.openintents.openpgp.OpenPgpApiManager.OpenPgpProviderError;
|
||||||
|
@ -146,7 +147,11 @@ public class OpenPgpKeyPreference extends Preference implements OpenPgpApiManage
|
||||||
switch (resultCode) {
|
switch (resultCode) {
|
||||||
case OpenPgpApi.RESULT_CODE_SUCCESS:
|
case OpenPgpApi.RESULT_CODE_SUCCESS:
|
||||||
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
|
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
|
||||||
PendingIntent pendingIntentSelectKey = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
|
PendingIntent pendingIntentSelectKey = IntentCompat.getParcelableExtra(
|
||||||
|
result,
|
||||||
|
OpenPgpApi.RESULT_INTENT,
|
||||||
|
PendingIntent.class
|
||||||
|
);
|
||||||
|
|
||||||
if (result.hasExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID)) {
|
if (result.hasExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID)) {
|
||||||
long keyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, NO_KEY);
|
long keyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, NO_KEY);
|
||||||
|
@ -161,7 +166,11 @@ public class OpenPgpKeyPreference extends Preference implements OpenPgpApiManage
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OpenPgpApi.RESULT_CODE_ERROR: {
|
case OpenPgpApi.RESULT_CODE_ERROR: {
|
||||||
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
|
OpenPgpError error = IntentCompat.getParcelableExtra(
|
||||||
|
result,
|
||||||
|
OpenPgpApi.RESULT_ERROR,
|
||||||
|
OpenPgpError.class
|
||||||
|
);
|
||||||
Timber.e("RESULT_CODE_ERROR: %s", error.getMessage());
|
Timber.e("RESULT_CODE_ERROR: %s", error.getMessage());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue