From f82beb4287138aa7e8f5dd2f2d4c2e28809b0e35 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 6 Feb 2017 03:24:57 +0100 Subject: [PATCH 1/2] Change ClipboardManager to no longer be a singleton This avoids holding onto a Context instance in a static field. --- .../main/java/com/fsck/k9/helper/ClipboardManager.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/helper/ClipboardManager.java b/k9mail/src/main/java/com/fsck/k9/helper/ClipboardManager.java index c60b6f62a..c0f5149f8 100644 --- a/k9mail/src/main/java/com/fsck/k9/helper/ClipboardManager.java +++ b/k9mail/src/main/java/com/fsck/k9/helper/ClipboardManager.java @@ -8,17 +8,9 @@ import android.content.Context; * Access the system clipboard using the new {@link ClipboardManager} introduced with API 11 */ public class ClipboardManager { - - private static ClipboardManager sInstance = null; - public static ClipboardManager getInstance(Context context) { Context appContext = context.getApplicationContext(); - - if (sInstance == null) { - sInstance = new ClipboardManager(appContext); - } - - return sInstance; + return new ClipboardManager(appContext); } From 15b6a919142511c80c04bb60ecf999a36ba1f0be Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 6 Feb 2017 03:27:48 +0100 Subject: [PATCH 2/2] Clean up ClipboardManager --- .../java/com/fsck/k9/helper/ClipboardManager.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/helper/ClipboardManager.java b/k9mail/src/main/java/com/fsck/k9/helper/ClipboardManager.java index c0f5149f8..8ccf7d933 100644 --- a/k9mail/src/main/java/com/fsck/k9/helper/ClipboardManager.java +++ b/k9mail/src/main/java/com/fsck/k9/helper/ClipboardManager.java @@ -14,16 +14,10 @@ public class ClipboardManager { } - protected Context mContext; + private Context context; - /** - * Constructor - * - * @param context - * A {@link Context} instance. - */ - protected ClipboardManager(Context context) { - mContext = context; + private ClipboardManager(Context context) { + this.context = context; } /** @@ -36,7 +30,7 @@ public class ClipboardManager { */ public void setText(String label, String text) { android.content.ClipboardManager clipboardManager = - (android.content.ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE); + (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(label, text); clipboardManager.setPrimaryClip(clip); }