Status: Implement clicking on 'Reply to' text

Co-Authored-By: fruye <fruye@unix.dog>
This commit is contained in:
Karol Kosek 2020-10-02 23:00:15 +02:00 committed by fruye
parent 471562f7c6
commit fe83987f90
8 changed files with 42 additions and 2 deletions

View File

@ -416,7 +416,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
replyCountLabel.setText((repliesCount > 1 ? replyCountLabel.getContext().getString(R.string.status_count_one_plus) : Integer.toString(repliesCount)));
}
private void setReplyInfo(StatusViewData.Concrete status) {
private void setReplyInfo(StatusViewData.Concrete status, final StatusActionListener listener) {
@Nullable String replyToAccountAcct = status.getInReplyToAccountAcct();
if (replyToAccountAcct == null || status.getHideReplyInfo()) {
replyInfo.setVisibility(View.GONE);
@ -428,6 +428,10 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
else
replyInfo.setPaintFlags(replyInfo.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
replyInfo.setText(context.getString(R.string.status_replied_to_format, replyToAccountAcct));
replyInfo.setOnClickListener(v -> {
if (getBindingAdapterPosition() != RecyclerView.NO_POSITION) {
listener.onViewReplyTo(getBindingAdapterPosition());
}});
replyInfo.setVisibility(View.VISIBLE);
}
@ -812,7 +816,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
setUsername(status.getUsername());
setMetaData(status, statusDisplayOptions, listener);
setIsReply(actionable.getInReplyToId() != null);
setReplyInfo(status);
setReplyInfo(status, listener);
setReplyCount(actionable.getRepliesCount(), statusDisplayOptions.showStatsInline());
setAvatar(actionable.getAccount().getAvatar(), status.getRebloggedAvatar(),
actionable.getAccount().getBot(), statusDisplayOptions);

View File

@ -301,6 +301,10 @@ class ConversationsFragment :
}
}
override fun onViewReplyTo(position: Int) {
// there are no reply-tos in conversations
}
override fun onOpenReblog(position: Int) {
// there are no reblogs in conversations
}

View File

@ -526,6 +526,11 @@ class NotificationsFragment :
super.viewThread(status.actionableId, status.actionableStatus.url)
}
override fun onViewReplyTo(position: Int) {
val status = adapter.peek(position)?.statusViewData?.status ?: return
super.viewReplyTo(status.actionableStatus.inReplyToId)
}
override fun onOpenReblog(position: Int) {
val account = adapter.peek(position)?.account!!
onViewAccount(account.id)

View File

@ -167,6 +167,13 @@ class SearchStatusesFragment : SearchFragment<StatusViewData.Concrete>(), Status
}
}
override fun onViewReplyTo(position: Int) {
searchAdapter.peek(position)?.status?.let { status ->
val actionableStatus = status.actionableStatus
bottomSheetActivity?.viewThread(actionableStatus.inReplyToId!!, null)
}
}
override fun onOpenReblog(position: Int) {
searchAdapter.peek(position)?.status?.let { status ->
bottomSheetActivity?.viewAccount(status.account.id)

View File

@ -492,6 +492,11 @@ class TimelineFragment :
super.viewThread(status.actionable.id, status.actionable.url)
}
override fun onViewReplyTo(position: Int) {
val status = adapter.peek(position)?.asStatusOrNull() ?: return
super.viewReplyTo(status.actionable.inReplyToId);
}
override fun onViewTag(tag: String) {
if (viewModel.kind == TimelineViewModel.Kind.TAG && viewModel.tags.size == 1 &&
viewModel.tags.contains(tag)

View File

@ -356,6 +356,16 @@ class ViewThreadFragment :
super.viewThread(status.actionableId, status.actionable.url)
}
override fun onViewReplyTo(position: Int) {
val status = adapter.currentList[position]
val id = status.actionable.inReplyToId
if (thisThreadsStatusId == id) {
// If already viewing this thread, don't reopen it.
return
}
super.viewReplyTo(id)
}
override fun onViewUrl(url: String) {
val status: StatusViewData.Concrete? = viewModel.detailedStatus()
if (status != null && status.status.url == url) {

View File

@ -105,6 +105,10 @@ abstract class SFragment : Fragment(), Injectable {
bottomSheetActivity.viewThread(statusId!!, statusUrl)
}
protected fun viewReplyTo(replyToStatusId: String?) {
bottomSheetActivity.viewThread(replyToStatusId!!, null)
}
protected fun viewAccount(accountId: String?) {
bottomSheetActivity.viewAccount(accountId!!)
}

View File

@ -32,6 +32,7 @@ public interface StatusActionListener extends LinkListener {
void onMore(@NonNull View view, final int position);
void onViewMedia(int position, int attachmentIndex, @Nullable View view);
void onViewThread(int position);
void onViewReplyTo(int position);
/**
* Open reblog author for the status.