From ddf193cce438063f81ffe41aa1c6bf0aa3db5921 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 2 Feb 2021 17:43:46 +0100 Subject: [PATCH] Refactoring --- .../main/java/eu/faircode/email/ActivityCompose.java | 11 +---------- app/src/main/java/eu/faircode/email/Helper.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityCompose.java b/app/src/main/java/eu/faircode/email/ActivityCompose.java index da24153c94..155ed96ea3 100644 --- a/app/src/main/java/eu/faircode/email/ActivityCompose.java +++ b/app/src/main/java/eu/faircode/email/ActivityCompose.java @@ -19,8 +19,6 @@ package eu.faircode.email; Copyright 2018-2021 by Marcel Bokhorst (M66B) */ -import android.app.ActivityManager; -import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -34,7 +32,6 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; import java.util.ArrayList; -import java.util.List; import java.util.Map; public class ActivityCompose extends ActivityBase implements FragmentManager.OnBackStackChangedListener { @@ -88,13 +85,7 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB Bundle args; String action = intent.getAction(); if (isShared(action)) { - ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); - if (am != null) { - List tasks = am.getAppTasks(); - if (tasks != null && tasks.size() > 0) { - tasks.get(0).setExcludeFromRecents(true); - } - } + Helper.excludeFromRecents(this); args = new Bundle(); args.putString("action", "new"); diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 712cd2fde4..a855e9262f 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -21,6 +21,7 @@ package eu.faircode.email; import android.Manifest; import android.app.Activity; +import android.app.ActivityManager; import android.app.KeyguardManager; import android.content.ActivityNotFoundException; import android.content.ComponentName; @@ -765,6 +766,15 @@ public class Helper { ToastEx.makeText(context, message, Toast.LENGTH_LONG).show(); } + static void excludeFromRecents(Context context) { + ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); + if (am != null) { + List tasks = am.getAppTasks(); + if (tasks != null && tasks.size() > 0) + tasks.get(0).setExcludeFromRecents(true); + } + } + // Graphics static int dp2pixels(Context context, int dp) {