mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-26 03:40:56 +01:00
Make names in group update descriptions tappable.
This commit is contained in:
committed by
Alex Hart
parent
3b17a41415
commit
e2cb535f3f
@@ -104,6 +104,7 @@ public class ConversationAdapter
|
||||
|
||||
private static final int PAYLOAD_TIMESTAMP = 0;
|
||||
public static final int PAYLOAD_NAME_COLORS = 1;
|
||||
public static final int PAYLOAD_SELECTED = 2;
|
||||
|
||||
private final ItemClickListener clickListener;
|
||||
private final Context context;
|
||||
@@ -229,7 +230,7 @@ public class ConversationAdapter
|
||||
}
|
||||
|
||||
private boolean containsValidPayload(@NonNull List<Object> payloads) {
|
||||
return payloads.contains(PAYLOAD_TIMESTAMP) || payloads.contains(PAYLOAD_NAME_COLORS);
|
||||
return payloads.contains(PAYLOAD_TIMESTAMP) || payloads.contains(PAYLOAD_NAME_COLORS) || payloads.contains(PAYLOAD_SELECTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,6 +251,10 @@ public class ConversationAdapter
|
||||
conversationViewHolder.getBindable().updateContactNameColor();
|
||||
}
|
||||
|
||||
if (payloads.contains(PAYLOAD_SELECTED)) {
|
||||
conversationViewHolder.getBindable().updateSelectedState();
|
||||
}
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -522,6 +527,7 @@ public class ConversationAdapter
|
||||
|
||||
public void removeFromSelection(@NonNull Set<MultiselectPart> parts) {
|
||||
selected.removeAll(parts);
|
||||
updateSelected();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -529,6 +535,7 @@ public class ConversationAdapter
|
||||
*/
|
||||
void clearSelection() {
|
||||
selected.clear();
|
||||
updateSelected();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -540,6 +547,11 @@ public class ConversationAdapter
|
||||
} else {
|
||||
selected.add(multiselectPart);
|
||||
}
|
||||
updateSelected();
|
||||
}
|
||||
|
||||
private void updateSelected() {
|
||||
notifyItemRangeChanged(0, getItemCount(), PAYLOAD_SELECTED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,7 +106,7 @@ class ConversationDataSource implements PagedDataSource<MessageId, ConversationM
|
||||
reactionHelper.add(record);
|
||||
attachmentHelper.add(record);
|
||||
|
||||
UpdateDescription description = record.getUpdateDisplayBody(context);
|
||||
UpdateDescription description = record.getUpdateDisplayBody(context, null);
|
||||
if (description != null) {
|
||||
referencedIds.addAll(description.getMentioned());
|
||||
}
|
||||
|
||||
@@ -1928,6 +1928,13 @@ public class ConversationFragment extends LoggingFragment implements Multiselect
|
||||
.setPositiveButton(R.string.ConversationFragment__block_request_button, (d, w) -> handleBlockJoinRequest(recipient))
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecipientNameClicked(@NonNull RecipientId target) {
|
||||
if (getParentFragment() == null) return;
|
||||
|
||||
RecipientBottomSheetDialogFragment.create(target, recipient.get().getGroupId().orElse(null)).show(getParentFragmentManager(), "BOTTOM");
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshList() {
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -107,6 +108,9 @@ public final class ConversationUpdateItem extends FrameLayout
|
||||
this.donateButtonStub = ViewUtil.findStubById(this, R.id.conversation_update_donate_action);
|
||||
this.background = findViewById(R.id.conversation_update_background);
|
||||
|
||||
body.setOnClickListener(v -> performClick());
|
||||
body.setOnLongClickListener(v -> performLongClick());
|
||||
|
||||
this.setOnClickListener(new InternalClickListener(null));
|
||||
}
|
||||
|
||||
@@ -179,7 +183,7 @@ public final class ConversationUpdateItem extends FrameLayout
|
||||
}
|
||||
}
|
||||
|
||||
UpdateDescription updateDescription = Objects.requireNonNull(messageRecord.getUpdateDisplayBody(getContext()));
|
||||
UpdateDescription updateDescription = Objects.requireNonNull(messageRecord.getUpdateDisplayBody(getContext(), eventListener::onRecipientNameClicked));
|
||||
LiveData<SpannableString> liveUpdateMessage = LiveUpdateMessage.fromMessageDescription(getContext(), updateDescription, textColor, true);
|
||||
LiveData<SpannableString> spannableMessage = loading(liveUpdateMessage);
|
||||
|
||||
@@ -190,6 +194,17 @@ public final class ConversationUpdateItem extends FrameLayout
|
||||
presentBackground(shouldCollapse(messageRecord, previousMessageRecord),
|
||||
shouldCollapse(messageRecord, nextMessageRecord),
|
||||
hasWallpaper);
|
||||
|
||||
updateSelectedState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSelectedState() {
|
||||
if (batchSelected.size() > 0) {
|
||||
body.setMovementMethod(null);
|
||||
} else {
|
||||
body.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean shouldCollapse(@NonNull MessageRecord current, @NonNull Optional<MessageRecord> candidate)
|
||||
|
||||
Reference in New Issue
Block a user