aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java44
-rw-r--r--app/src/main/res/layout/item_private_message_received.xml19
-rw-r--r--app/src/main/res/layout/item_private_message_sent.xml14
4 files changed, 69 insertions, 20 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
index 33add2f0..dce42d12 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java
@@ -225,12 +225,6 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor());
mActivity.startActivity(intent);
});
-
- ((DataViewHolder) holder).contentCustomMarkwonView.setOnClickListener(view -> {
- if (((DataViewHolder) holder).contentCustomMarkwonView.getSelectionStart() == -1 && ((DataViewHolder) holder).contentCustomMarkwonView.getSelectionEnd() == -1) {
- holder.itemView.performClick();
- }
- });
}
}
}
@@ -330,6 +324,12 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
contentCustomMarkwonView.setTextColor(mSecondaryTextColor);
contentCustomMarkwonView.setMovementMethod(LinkMovementMethod.getInstance());
+
+ contentCustomMarkwonView.setOnClickListener(view -> {
+ if (contentCustomMarkwonView.getSelectionStart() == -1 && contentCustomMarkwonView.getSelectionEnd() == -1) {
+ itemView.performClick();
+ }
+ });
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java
index eaf50978..474ec4d1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java
@@ -1,5 +1,8 @@
package ml.docilealligator.infinityforreddit.adapters;
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
@@ -11,6 +14,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
@@ -154,7 +158,6 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
if (holder instanceof MessageViewHolder) {
mMarkwon.setMarkdown(((MessageViewHolder) holder).messageTextView, message.getBody());
- ((MessageViewHolder) holder).messageTextView.setOnClickListener(view -> ((MessageViewHolder) holder).itemView.performClick());
if (mShowElapsedTime) {
((MessageViewHolder) holder).timeTextView.setText(Utils.getElapsedTime(mViewPrivateMessagesActivity, message.getTimeUTC()));
} else {
@@ -164,11 +167,12 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
((MessageViewHolder) holder).messageTextView.setOnClickListener(view -> {
if (((MessageViewHolder) holder).timeTextView.getVisibility() != View.VISIBLE) {
((MessageViewHolder) holder).timeTextView.setVisibility(View.VISIBLE);
- mViewPrivateMessagesActivity.delayTransition();
+ ((MessageViewHolder) holder).copyImageView.setVisibility(View.VISIBLE);
} else {
((MessageViewHolder) holder).timeTextView.setVisibility(View.GONE);
- mViewPrivateMessagesActivity.delayTransition();
+ ((MessageViewHolder) holder).copyImageView.setVisibility(View.GONE);
}
+ mViewPrivateMessagesActivity.delayTransition();
});
}
@@ -246,17 +250,40 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
class MessageViewHolder extends RecyclerView.ViewHolder {
TextView messageTextView;
TextView timeTextView;
+ ImageView copyImageView;
public MessageViewHolder(@NonNull View itemView) {
super(itemView);
}
- void setBaseView(TextView messageTextView, TextView timeTextView) {
+ void setBaseView(TextView messageTextView, TextView timeTextView, ImageView copyImageView) {
this.messageTextView = messageTextView;
this.timeTextView = timeTextView;
+ this.copyImageView = copyImageView;
messageTextView.setTextColor(Color.WHITE);
timeTextView.setTextColor(mSecondaryTextColor);
+
+ copyImageView.setColorFilter(mSecondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN);
+
+ copyImageView.setOnClickListener(view -> {
+ Message message;
+ if (getBindingAdapterPosition() == 0) {
+ message = mMessage;
+ } else {
+ message = mMessage.getReplies().get(getBindingAdapterPosition() - 1);
+ }
+ if (message != null) {
+ ClipboardManager clipboard = (ClipboardManager) mViewPrivateMessagesActivity.getSystemService(Context.CLIPBOARD_SERVICE);
+ if (clipboard != null) {
+ ClipData clip = ClipData.newPlainText("simple text", message.getBody());
+ clipboard.setPrimaryClip(clip);
+ Toast.makeText(mViewPrivateMessagesActivity, R.string.copy_success, Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(mViewPrivateMessagesActivity, R.string.copy_failed, Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
}
}
@@ -265,14 +292,15 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
TextView messageTextView;
@BindView(R.id.time_text_view_item_private_message_sent)
TextView timeTextView;
+ @BindView(R.id.copy_image_view_item_private_message_sent)
+ ImageView copyImageView;
SentMessageViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
- setBaseView(messageTextView, timeTextView);
+ setBaseView(messageTextView, timeTextView, copyImageView);
messageTextView.setTextColor(mSentMessageTextColor);
-
}
}
@@ -283,11 +311,13 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
TextView messageTextView;
@BindView(R.id.time_text_view_item_private_message_received)
TextView timeTextView;
+ @BindView(R.id.copy_image_view_item_private_message_received)
+ ImageView copyImageView;
ReceivedMessageViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
- setBaseView(messageTextView, timeTextView);
+ setBaseView(messageTextView, timeTextView, copyImageView);
messageTextView.setTextColor(mReceivedMessageTextColor);
}
diff --git a/app/src/main/res/layout/item_private_message_received.xml b/app/src/main/res/layout/item_private_message_received.xml
index f3ba1c88..861495bf 100644
--- a/app/src/main/res/layout/item_private_message_received.xml
+++ b/app/src/main/res/layout/item_private_message_received.xml
@@ -15,8 +15,7 @@
android:layout_height="36dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintEnd_toStartOf="@id/barrier3" />
+ app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/message_text_view_item_private_message_received"
@@ -44,18 +43,24 @@
android:textSize="?attr/font_default"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/avatar_image_view_item_private_message_received"
app:layout_constraintTop_toBottomOf="@id/message_text_view_item_private_message_received"
app:layout_constraintWidth_max="wrap"
app:layout_constraintWidth_percent="0.7"
app:layout_constraintHorizontal_bias="0" />
- <androidx.constraintlayout.widget.Barrier
- android:id="@+id/barrier3"
+ <ImageView
+ android:id="@+id/copy_image_view_item_private_message_received"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- app:barrierDirection="start"
- app:constraint_referenced_ids="message_text_view_item_private_message_received, time_text_view_item_private_message_received" />
+ android:padding="16dp"
+ android:src="@drawable/ic_copy_24dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/actionBarItemBackground"
+ android:visibility="gone"
+ app:layout_constraintStart_toEndOf="@id/time_text_view_item_private_message_received"
+ app:layout_constraintTop_toBottomOf="@id/message_text_view_item_private_message_received"
+ app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/item_private_message_sent.xml b/app/src/main/res/layout/item_private_message_sent.xml
index 62951ba4..c2a1cb3a 100644
--- a/app/src/main/res/layout/item_private_message_sent.xml
+++ b/app/src/main/res/layout/item_private_message_sent.xml
@@ -40,4 +40,18 @@
app:layout_constraintWidth_percent="0.7"
app:layout_constraintHorizontal_bias="1" />
+ <ImageView
+ android:id="@+id/copy_image_view_item_private_message_sent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ android:src="@drawable/ic_copy_24dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/actionBarItemBackground"
+ android:visibility="gone"
+ app:layout_constraintEnd_toStartOf="@id/time_text_view_item_private_message_sent"
+ app:layout_constraintTop_toBottomOf="@id/message_text_view_item_private_message_sent"
+ app:layout_constraintBottom_toBottomOf="parent" />
+
</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file