From d508aefbfc6143ae546e333448ff7bd5d9049444 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 28 Jun 2023 12:42:56 +0200 Subject: [PATCH] Android 14: fixed PGP --- app/src/main/java/eu/faircode/email/FragmentBase.java | 3 ++- app/src/main/java/eu/faircode/email/FragmentCompose.java | 5 +++-- .../main/java/eu/faircode/email/FragmentMessages.java | 3 ++- app/src/main/java/eu/faircode/email/Helper.java | 9 +++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentBase.java b/app/src/main/java/eu/faircode/email/FragmentBase.java index 09c161f8b8..3e412f0d4f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentBase.java +++ b/app/src/main/java/eu/faircode/email/FragmentBase.java @@ -718,7 +718,8 @@ public class FragmentBase extends Fragment { startIntentSenderForResult( ex.getUserAction().getActionIntent().getIntentSender(), REQUEST_RECOVERABLE_PERMISSION, - null, 0, 0, 0, null); + null, 0, 0, 0, + Helper.getBackgroundActivityOptions()); } catch (IntentSender.SendIntentException ex) { Log.w(ex); } diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 9ed9dbf85a..4d7c4d3008 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -26,6 +26,7 @@ import static android.view.inputmethod.EditorInfo.IME_FLAG_NO_FULLSCREEN; import android.Manifest; import android.app.Activity; +import android.app.ActivityOptions; import android.app.PendingIntent; import android.content.ClipData; import android.content.ClipboardManager; @@ -4098,9 +4099,9 @@ public class FragmentCompose extends FragmentBase { startIntentSenderForResult( pi.getIntentSender(), REQUEST_OPENPGP, - null, 0, 0, 0, null); + null, 0, 0, 0, + Helper.getBackgroundActivityOptions()); } catch (IntentSender.SendIntentException ex) { - Log.e(ex); Log.unexpectedError(getParentFragmentManager(), ex); } else { diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 4475f668de..fbd67a7106 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -8885,7 +8885,8 @@ public class FragmentMessages extends FragmentBase startIntentSenderForResult( pi.getIntentSender(), REQUEST_OPENPGP, - null, 0, 0, 0, null); + null, 0, 0, 0, + Helper.getBackgroundActivityOptions()); } catch (IntentSender.SendIntentException ex) { // Likely cancelled Log.w(ex); diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 3dbfa9cdeb..b066e33a61 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -30,6 +30,7 @@ import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.app.Activity; import android.app.ActivityManager; +import android.app.ActivityOptions; import android.app.ApplicationExitInfo; import android.app.KeyguardManager; import android.app.NotificationManager; @@ -1769,6 +1770,14 @@ public class Helper { } } + static Bundle getBackgroundActivityOptions() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) + return null; + ActivityOptions options = ActivityOptions.makeBasic(); + options.setPendingIntentBackgroundActivityLaunchAllowed(true); + return options.toBundle(); + } + // Graphics static int dp2pixels(Context context, int dp) {