diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-03-30 13:17:08 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-03-30 13:17:08 +0300 |
commit | 4b16591a3320f5dc7b022326e0c6ba87024b1cd4 (patch) | |
tree | 6ac89a10e608e4c3dbdf2566e109cd629f93040f /app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments | |
parent | ac21907128cd8f81618fe61922010e113eaadb68 (diff) | |
parent | f274819bda7ad9fb22dde5511ecfea90932f105f (diff) |
Merge branch 'master' into refactor-drawer-and-main-and-use-viewpager2
# Conflicts:
# app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardAttachmentAdapter.java
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java index e0dc06d2c..bde3436d0 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsAdapter.java @@ -1,20 +1,16 @@ package it.niedermann.nextcloud.deck.ui.card.comments; -import android.content.ClipData; -import android.content.ClipboardManager; import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.style.ImageSpan; -import android.util.Log; import android.view.LayoutInflater; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -38,8 +34,7 @@ import it.niedermann.nextcloud.deck.model.ocs.comment.Mention; import it.niedermann.nextcloud.deck.util.DateUtil; import it.niedermann.nextcloud.deck.util.ViewUtil; -import static android.content.Context.CLIPBOARD_SERVICE; -import static androidx.constraintlayout.widget.Constraints.TAG; +import static it.niedermann.nextcloud.deck.util.ClipboardUtil.copyToClipboard; import static it.niedermann.nextcloud.deck.util.DimensionUtil.getAvatarDimension; public class CardCommentsAdapter extends RecyclerView.Adapter<CardCommentsAdapter.ItemCommentViewHolder> { @@ -84,18 +79,7 @@ public class CardCommentsAdapter extends RecyclerView.Adapter<CardCommentsAdapte holder.itemView.setOnClickListener(View::showContextMenu); holder.itemView.setOnCreateContextMenuListener((menu, v, menuInfo) -> { menuInflater.inflate(R.menu.comment_menu, menu); - menu.findItem(android.R.id.copy).setOnMenuItemClickListener(item -> { - final ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE); - ClipData clipData = ClipData.newPlainText(comment.getMessage(), comment.getMessage()); - if (clipboardManager == null) { - Log.e(TAG, "clipboardManager is null"); - Toast.makeText(context, R.string.could_not_copy_to_clipboard, Toast.LENGTH_SHORT).show(); - return false; - } - clipboardManager.setPrimaryClip(clipData); - Toast.makeText(context, R.string.simple_copied, Toast.LENGTH_SHORT).show(); - return true; - }); + menu.findItem(android.R.id.copy).setOnMenuItemClickListener(item -> copyToClipboard(context, comment.getMessage())); menu.findItem(R.id.delete).setOnMenuItemClickListener(item -> { commentDeletedListener.onCommentDeleted(comment.getLocalId()); return true; |