Poll notifications (#1229)
* show poll notifications in the app * show poll notifications in the app * allow filtering poll notifications in the poll fragment * show poll notifications in system notifications
This commit is contained in:
parent
647238052b
commit
e735e4843e
44 changed files with 1076 additions and 318 deletions
|
|
@ -29,18 +29,19 @@ import com.keylesspalace.tusky.viewdata.StatusViewData;
|
|||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import at.connyduck.sparkbutton.helpers.Utils;
|
||||
|
||||
public class StatusViewHolder extends StatusBaseViewHolder {
|
||||
private static final InputFilter[] COLLAPSE_INPUT_FILTER = new InputFilter[]{SmartLengthInputFilter.INSTANCE};
|
||||
private static final InputFilter[] NO_INPUT_FILTER = new InputFilter[0];
|
||||
|
||||
private TextView rebloggedBar;
|
||||
private TextView statusInfo;
|
||||
private ToggleButton contentCollapseButton;
|
||||
|
||||
StatusViewHolder(View itemView, boolean useAbsoluteTime) {
|
||||
super(itemView, useAbsoluteTime);
|
||||
rebloggedBar = itemView.findViewById(R.id.status_reblogged);
|
||||
statusInfo = itemView.findViewById(R.id.status_info);
|
||||
contentCollapseButton = itemView.findViewById(R.id.button_toggle_content);
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +72,7 @@ public class StatusViewHolder extends StatusBaseViewHolder {
|
|||
@Override
|
||||
protected void setupWithStatus(StatusViewData.Concrete status, final StatusActionListener listener,
|
||||
boolean mediaPreviewEnabled, @Nullable Object payloads) {
|
||||
if (status == null || payloads==null) {
|
||||
if (status == null || payloads == null) {
|
||||
if (status == null) {
|
||||
showContent(false);
|
||||
} else {
|
||||
|
|
@ -81,30 +82,39 @@ public class StatusViewHolder extends StatusBaseViewHolder {
|
|||
|
||||
String rebloggedByDisplayName = status.getRebloggedByUsername();
|
||||
if (rebloggedByDisplayName == null) {
|
||||
hideRebloggedByDisplayName();
|
||||
hideStatusInfo();
|
||||
} else {
|
||||
setRebloggedByDisplayName(rebloggedByDisplayName);
|
||||
statusInfo.setOnClickListener(v -> listener.onOpenReblog(getAdapterPosition()));
|
||||
}
|
||||
|
||||
rebloggedBar.setOnClickListener(v -> listener.onOpenReblog(getAdapterPosition()));}
|
||||
}
|
||||
else{
|
||||
}
|
||||
} else {
|
||||
super.setupWithStatus(status, listener, mediaPreviewEnabled, payloads);
|
||||
}
|
||||
}
|
||||
|
||||
private void setRebloggedByDisplayName(final String name) {
|
||||
Context context = rebloggedBar.getContext();
|
||||
Context context = statusInfo.getContext();
|
||||
String boostedText = context.getString(R.string.status_boosted_format, name);
|
||||
rebloggedBar.setText(boostedText);
|
||||
rebloggedBar.setVisibility(View.VISIBLE);
|
||||
statusInfo.setText(boostedText);
|
||||
statusInfo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void hideRebloggedByDisplayName() {
|
||||
if (rebloggedBar == null) {
|
||||
// don't use this on the same ViewHolder as setRebloggedByDisplayName, will cause recycling issues as paddings are changed
|
||||
void setPollInfo(final boolean ownPoll) {
|
||||
statusInfo.setText(ownPoll ? R.string.poll_ended_created : R.string.poll_ended_voted);
|
||||
statusInfo.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_poll_24dp, 0, 0, 0);
|
||||
statusInfo.setCompoundDrawablePadding(Utils.dpToPx(statusInfo.getContext(), 10));
|
||||
statusInfo.setPaddingRelative(Utils.dpToPx(statusInfo.getContext(), 28), 0, 0, 0);
|
||||
statusInfo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
void hideStatusInfo() {
|
||||
if (statusInfo == null) {
|
||||
return;
|
||||
}
|
||||
rebloggedBar.setVisibility(View.GONE);
|
||||
statusInfo.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void setupCollapsedState(final StatusViewData.Concrete status, final StatusActionListener listener) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue