diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Tools.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Tools.java index e3598028..3696b28f 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Tools.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Tools.java @@ -22,6 +22,8 @@ package org.shadowice.flocke.andotp.Utilities; +import android.content.ClipData; +import android.content.ClipboardManager; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; @@ -31,6 +33,9 @@ import android.graphics.PorterDuffColorFilter; import android.net.Uri; import android.os.Build; import android.os.Environment; +import android.widget.Toast; + +import org.shadowice.flocke.andotp.R; import java.io.File; import java.text.DateFormat; @@ -125,4 +130,12 @@ public class Tools { Date now = Calendar.getInstance().getTime(); return df.format(now); } + + public static void copyToClipboard(Context context, String text) { + ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText(context.getString(R.string.label_clipboard_content), text); + clipboard.setPrimaryClip(clip); + + Toast.makeText(context, R.string.toast_copied_to_clipboard, Toast.LENGTH_LONG).show(); + } } diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java index 6b4bb14e..208b2427 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java @@ -303,7 +303,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter @Override public void onCopyButtonClicked(String text, int position) { - copyToClipboard(text); + Tools.copyToClipboard(context, text); updateLastUsedAndFrequency(position, getRealIndex(position)); if(context != null && settings.isMinimizeAppOnCopyEnabled()) { ((MainActivity)context).moveTaskToBack(true); @@ -636,14 +636,6 @@ public class EntriesCardAdapter extends RecyclerView.Adapter popup.show(); } - private void copyToClipboard(String text) { - ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); - ClipData clip = ClipData.newPlainText(context.getString(R.string.label_clipboard_content), text); - clipboard.setPrimaryClip(clip); - - Toast.makeText(context, R.string.toast_copied_to_clipboard, Toast.LENGTH_LONG).show(); - } - public void setSortMode(SortMode mode) { this.sortMode = mode; entriesChanged();