Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.gotify.messages;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.text.util.Linkify;
import android.view.LayoutInflater;
Expand All @@ -8,6 +10,7 @@
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
Expand Down Expand Up @@ -133,6 +136,7 @@ static class ViewHolder extends RecyclerView.ViewHolder {
ButterKnife.bind(this, view);
preciseDate = false;
dateTime = null;
enableCopyToClipboard();
}

void switchPreciseDate() {
Expand All @@ -157,6 +161,33 @@ void updateDate() {
}
date.setText(text);
}

private void enableCopyToClipboard() {
super.itemView.setOnLongClickListener(
view -> {
ClipboardManager clipboard =
(ClipboardManager)
view.getContext()
.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip =
ClipData.newPlainText(
"GotifyMessageContent", message.getText().toString());

if (clipboard != null) {
clipboard.setPrimaryClip(clip);
Toast toast =
Toast.makeText(
view.getContext(),
view.getContext()
.getString(
R.string.message_copied_to_clipboard),
Toast.LENGTH_SHORT);
toast.show();
}

return true;
});
}
}

public interface Delete {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@
<string name="push_title_hint">Title</string>
<string name="push_content_hint">Content</string>
<string name="push_priority_hint">Priority</string>
<string name="message_copied_to_clipboard">Content copied to clipboard</string>
</resources>