Move copy to clipboard to Tools
This commit is contained in:
parent
ec8eaaaedd
commit
38c10bc497
2 changed files with 14 additions and 9 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
|||
|
||||
@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<EntryViewHolder>
|
|||
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();
|
||||
|
|
Loading…
Reference in a new issue