Add 'reply to' text to notifications

main
Karol Kosek 4 years ago committed by Gitea
parent 7ba55d97d5
commit 987db39d2c
  1. 25
      app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java
  2. 22
      app/src/main/res/layout/item_status_notification.xml

@ -19,6 +19,7 @@ import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.Paint;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.InputFilter; import android.text.InputFilter;
import android.text.SpannableString; import android.text.SpannableString;
@ -336,6 +337,8 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
* @param position The position of the status in the list. * @param position The position of the status in the list.
*/ */
void onNotificationContentCollapsedChange(boolean isCollapsed, int position); void onNotificationContentCollapsedChange(boolean isCollapsed, int position);
void onViewReplyTo(int position);
} }
private static class FollowViewHolder extends RecyclerView.ViewHolder { private static class FollowViewHolder extends RecyclerView.ViewHolder {
@ -411,6 +414,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
private final TextView statusContent; private final TextView statusContent;
private final ImageView statusAvatar; private final ImageView statusAvatar;
private final ImageView notificationAvatar; private final ImageView notificationAvatar;
private final TextView replyInfo;
private final TextView contentWarningDescriptionTextView; private final TextView contentWarningDescriptionTextView;
private final Button contentWarningButton; private final Button contentWarningButton;
private final Button contentCollapseButton; // TODO: This code SHOULD be based on StatusBaseViewHolder private final Button contentCollapseButton; // TODO: This code SHOULD be based on StatusBaseViewHolder
@ -433,6 +437,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
statusContent = itemView.findViewById(R.id.notification_content); statusContent = itemView.findViewById(R.id.notification_content);
statusAvatar = itemView.findViewById(R.id.notification_status_avatar); statusAvatar = itemView.findViewById(R.id.notification_status_avatar);
notificationAvatar = itemView.findViewById(R.id.notification_notification_avatar); notificationAvatar = itemView.findViewById(R.id.notification_notification_avatar);
replyInfo = itemView.findViewById(R.id.notification_reply_info);
contentWarningDescriptionTextView = itemView.findViewById(R.id.notification_content_warning_description); contentWarningDescriptionTextView = itemView.findViewById(R.id.notification_content_warning_description);
contentWarningButton = itemView.findViewById(R.id.notification_content_warning_button); contentWarningButton = itemView.findViewById(R.id.notification_content_warning_button);
contentCollapseButton = itemView.findViewById(R.id.button_toggle_notification_content); contentCollapseButton = itemView.findViewById(R.id.button_toggle_notification_content);
@ -456,6 +461,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
statusContent.setVisibility(show ? View.VISIBLE : View.GONE); statusContent.setVisibility(show ? View.VISIBLE : View.GONE);
statusAvatar.setVisibility(show ? View.VISIBLE : View.GONE); statusAvatar.setVisibility(show ? View.VISIBLE : View.GONE);
notificationAvatar.setVisibility(show ? View.VISIBLE : View.GONE); notificationAvatar.setVisibility(show ? View.VISIBLE : View.GONE);
replyInfo.setVisibility(show ? View.VISIBLE : View.GONE);
} }
private void setDisplayName(String name, List<Emoji> emojis) { private void setDisplayName(String name, List<Emoji> emojis) {
@ -577,6 +583,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
}); });
setupContentAndSpoiler(listener); setupContentAndSpoiler(listener);
setupReplyInfo();
} }
} }
@ -658,5 +665,23 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
CustomEmojiHelper.emojify(statusViewData.getSpoilerText(), statusViewData.getStatusEmojis(), contentWarningDescriptionTextView); CustomEmojiHelper.emojify(statusViewData.getSpoilerText(), statusViewData.getStatusEmojis(), contentWarningDescriptionTextView);
contentWarningDescriptionTextView.setText(emojifiedContentWarning); contentWarningDescriptionTextView.setText(emojifiedContentWarning);
} }
private void setupReplyInfo() {
if (statusViewData.getInReplyToId() != null) {
Context context = replyInfo.getContext();
String replyToAccount = statusViewData.getInReplyToAccountAcct();
replyInfo.setText(context.getString(R.string.status_replied_to_format, replyToAccount));
if (statusViewData.getParentVisible() == false)
replyInfo.setPaintFlags(replyInfo.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
else
replyInfo.setPaintFlags(replyInfo.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
replyInfo.setOnClickListener(v -> notificationActionListener.onViewReplyTo(getAdapterPosition()));
replyInfo.setVisibility(View.VISIBLE);
} else {
replyInfo.setVisibility(View.GONE);
}
}
} }
} }

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?><!--This applies only to favourite and rebnotificationsEnabledions.--> <?xml version="1.0" encoding="utf-8"?><!--This applies only to favourite and rebnotificationsEnabledions.-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/notification_container" android:id="@+id/notification_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -29,8 +30,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/notification_top_text" android:layout_below="@+id/notification_top_text"
android:layout_toEndOf="@+id/notification_status_avatar" android:layout_toEndOf="@+id/notification_status_avatar">
android:paddingBottom="4dp">
<androidx.emoji.widget.EmojiTextView <androidx.emoji.widget.EmojiTextView
android:id="@+id/status_display_name" android:id="@+id/status_display_name"
@ -72,11 +72,26 @@
</RelativeLayout> </RelativeLayout>
<TextView
android:id="@+id/notification_reply_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/status_name_bar"
android:layout_toEndOf="@id/notification_status_avatar"
android:drawablePadding="6dp"
android:layout_marginTop="2dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
app:drawableStartCompat="@drawable/ic_reply_18dp"
tools:text="Reply to a1batross" />
<com.keylesspalace.tusky.view.CustomEmojiTextView <com.keylesspalace.tusky.view.CustomEmojiTextView
android:id="@+id/notification_content_warning_description" android:id="@+id/notification_content_warning_description"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/status_name_bar" android:layout_below="@id/notification_reply_info"
android:layout_toEndOf="@id/notification_status_avatar" android:layout_toEndOf="@id/notification_status_avatar"
android:hyphenationFrequency="full" android:hyphenationFrequency="full"
android:breakStrategy="high_quality" android:breakStrategy="high_quality"
@ -108,6 +123,7 @@
android:id="@+id/notification_content" android:id="@+id/notification_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_below="@id/notification_content_warning_button" android:layout_below="@id/notification_content_warning_button"
android:layout_toEndOf="@+id/notification_status_avatar" android:layout_toEndOf="@+id/notification_status_avatar"
android:hyphenationFrequency="full" android:hyphenationFrequency="full"

Loading…
Cancel
Save