improve custom emoji support (#687)
This commit is contained in:
parent
6e43d3fbe8
commit
e8d1b16b39
|
@ -9,6 +9,7 @@ import com.keylesspalace.tusky.R;
|
||||||
import com.keylesspalace.tusky.entity.Account;
|
import com.keylesspalace.tusky.entity.Account;
|
||||||
import com.keylesspalace.tusky.interfaces.AccountActionListener;
|
import com.keylesspalace.tusky.interfaces.AccountActionListener;
|
||||||
import com.keylesspalace.tusky.interfaces.LinkListener;
|
import com.keylesspalace.tusky.interfaces.LinkListener;
|
||||||
|
import com.keylesspalace.tusky.util.CustomEmojiHelper;
|
||||||
import com.pkmmte.view.CircularImageView;
|
import com.pkmmte.view.CircularImageView;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
@ -32,7 +33,8 @@ class AccountViewHolder extends RecyclerView.ViewHolder {
|
||||||
String format = username.getContext().getString(R.string.status_username_format);
|
String format = username.getContext().getString(R.string.status_username_format);
|
||||||
String formattedUsername = String.format(format, account.getUsername());
|
String formattedUsername = String.format(format, account.getUsername());
|
||||||
username.setText(formattedUsername);
|
username.setText(formattedUsername);
|
||||||
displayName.setText(account.getName());
|
CharSequence emojifiedName = CustomEmojiHelper.emojifyString(account.getName(), account.getEmojis(), displayName);
|
||||||
|
displayName.setText(emojifiedName);
|
||||||
Context context = avatar.getContext();
|
Context context = avatar.getContext();
|
||||||
Picasso.with(context)
|
Picasso.with(context)
|
||||||
.load(account.getAvatar())
|
.load(account.getAvatar())
|
||||||
|
@ -41,20 +43,10 @@ class AccountViewHolder extends RecyclerView.ViewHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupActionListener(final AccountActionListener listener) {
|
void setupActionListener(final AccountActionListener listener) {
|
||||||
container.setOnClickListener(new View.OnClickListener() {
|
container.setOnClickListener(v -> listener.onViewAccount(accountId));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
listener.onViewAccount(accountId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupLinkListener(final LinkListener listener) {
|
void setupLinkListener(final LinkListener listener) {
|
||||||
container.setOnClickListener(new View.OnClickListener() {
|
container.setOnClickListener(v -> listener.onViewAccount(accountId));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
listener.onViewAccount(accountId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
package com.keylesspalace.tusky.adapter;
|
package com.keylesspalace.tusky.adapter;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -25,6 +26,7 @@ import android.widget.TextView;
|
||||||
import com.keylesspalace.tusky.R;
|
import com.keylesspalace.tusky.R;
|
||||||
import com.keylesspalace.tusky.entity.Account;
|
import com.keylesspalace.tusky.entity.Account;
|
||||||
import com.keylesspalace.tusky.interfaces.AccountActionListener;
|
import com.keylesspalace.tusky.interfaces.AccountActionListener;
|
||||||
|
import com.keylesspalace.tusky.util.CustomEmojiHelper;
|
||||||
import com.pkmmte.view.CircularImageView;
|
import com.pkmmte.view.CircularImageView;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
@ -36,8 +38,9 @@ public class BlocksAdapter extends AccountAdapter {
|
||||||
super(accountActionListener);
|
super(accountActionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
switch (viewType) {
|
switch (viewType) {
|
||||||
default:
|
default:
|
||||||
case VIEW_TYPE_BLOCKED_USER: {
|
case VIEW_TYPE_BLOCKED_USER: {
|
||||||
|
@ -54,11 +57,11 @@ public class BlocksAdapter extends AccountAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||||
if (position < accountList.size()) {
|
if (position < accountList.size()) {
|
||||||
BlockedUserViewHolder holder = (BlockedUserViewHolder) viewHolder;
|
BlockedUserViewHolder holder = (BlockedUserViewHolder) viewHolder;
|
||||||
holder.setupWithAccount(accountList.get(position));
|
holder.setupWithAccount(accountList.get(position));
|
||||||
holder.setupActionListener(accountActionListener, true);
|
holder.setupActionListener(accountActionListener);
|
||||||
} else {
|
} else {
|
||||||
FooterViewHolder holder = (FooterViewHolder) viewHolder;
|
FooterViewHolder holder = (FooterViewHolder) viewHolder;
|
||||||
holder.setState(footerState);
|
holder.setState(footerState);
|
||||||
|
@ -91,7 +94,8 @@ public class BlocksAdapter extends AccountAdapter {
|
||||||
|
|
||||||
void setupWithAccount(Account account) {
|
void setupWithAccount(Account account) {
|
||||||
id = account.getId();
|
id = account.getId();
|
||||||
displayName.setText(account.getName());
|
CharSequence emojifiedName = CustomEmojiHelper.emojifyString(account.getName(), account.getEmojis(), displayName);
|
||||||
|
displayName.setText(emojifiedName);
|
||||||
String format = username.getContext().getString(R.string.status_username_format);
|
String format = username.getContext().getString(R.string.status_username_format);
|
||||||
String formattedUsername = String.format(format, account.getUsername());
|
String formattedUsername = String.format(format, account.getUsername());
|
||||||
username.setText(formattedUsername);
|
username.setText(formattedUsername);
|
||||||
|
@ -101,22 +105,14 @@ public class BlocksAdapter extends AccountAdapter {
|
||||||
.into(avatar);
|
.into(avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupActionListener(final AccountActionListener listener, final boolean blocked) {
|
void setupActionListener(final AccountActionListener listener) {
|
||||||
unblock.setOnClickListener(new View.OnClickListener() {
|
unblock.setOnClickListener(v -> {
|
||||||
@Override
|
int position = getAdapterPosition();
|
||||||
public void onClick(View v) {
|
if (position != RecyclerView.NO_POSITION) {
|
||||||
int position = getAdapterPosition();
|
listener.onBlock(false, id, position);
|
||||||
if (position != RecyclerView.NO_POSITION) {
|
|
||||||
listener.onBlock(!blocked, id, position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
avatar.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
listener.onViewAccount(id);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
avatar.setOnClickListener(v -> listener.onViewAccount(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
package com.keylesspalace.tusky.adapter;
|
package com.keylesspalace.tusky.adapter;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -32,8 +33,9 @@ public class FollowAdapter extends AccountAdapter {
|
||||||
super(accountActionListener);
|
super(accountActionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
switch (viewType) {
|
switch (viewType) {
|
||||||
default:
|
default:
|
||||||
case VIEW_TYPE_ACCOUNT: {
|
case VIEW_TYPE_ACCOUNT: {
|
||||||
|
@ -50,7 +52,7 @@ public class FollowAdapter extends AccountAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||||
if (position < accountList.size()) {
|
if (position < accountList.size()) {
|
||||||
AccountViewHolder holder = (AccountViewHolder) viewHolder;
|
AccountViewHolder holder = (AccountViewHolder) viewHolder;
|
||||||
holder.setupWithAccount(accountList.get(position));
|
holder.setupWithAccount(accountList.get(position));
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
package com.keylesspalace.tusky.adapter;
|
package com.keylesspalace.tusky.adapter;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -25,6 +26,7 @@ import android.widget.TextView;
|
||||||
import com.keylesspalace.tusky.interfaces.AccountActionListener;
|
import com.keylesspalace.tusky.interfaces.AccountActionListener;
|
||||||
import com.keylesspalace.tusky.R;
|
import com.keylesspalace.tusky.R;
|
||||||
import com.keylesspalace.tusky.entity.Account;
|
import com.keylesspalace.tusky.entity.Account;
|
||||||
|
import com.keylesspalace.tusky.util.CustomEmojiHelper;
|
||||||
import com.pkmmte.view.CircularImageView;
|
import com.pkmmte.view.CircularImageView;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
@ -36,8 +38,9 @@ public class FollowRequestsAdapter extends AccountAdapter {
|
||||||
super(accountActionListener);
|
super(accountActionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
switch (viewType) {
|
switch (viewType) {
|
||||||
default:
|
default:
|
||||||
case VIEW_TYPE_FOLLOW_REQUEST: {
|
case VIEW_TYPE_FOLLOW_REQUEST: {
|
||||||
|
@ -54,7 +57,7 @@ public class FollowRequestsAdapter extends AccountAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||||
if (position < accountList.size()) {
|
if (position < accountList.size()) {
|
||||||
FollowRequestViewHolder holder = (FollowRequestViewHolder) viewHolder;
|
FollowRequestViewHolder holder = (FollowRequestViewHolder) viewHolder;
|
||||||
holder.setupWithAccount(accountList.get(position));
|
holder.setupWithAccount(accountList.get(position));
|
||||||
|
@ -93,7 +96,8 @@ public class FollowRequestsAdapter extends AccountAdapter {
|
||||||
|
|
||||||
void setupWithAccount(Account account) {
|
void setupWithAccount(Account account) {
|
||||||
id = account.getId();
|
id = account.getId();
|
||||||
displayName.setText(account.getName());
|
CharSequence emojifiedName = CustomEmojiHelper.emojifyString(account.getName(), account.getEmojis(), displayName);
|
||||||
|
displayName.setText(emojifiedName);
|
||||||
String format = username.getContext().getString(R.string.status_username_format);
|
String format = username.getContext().getString(R.string.status_username_format);
|
||||||
String formattedUsername = String.format(format, account.getUsername());
|
String formattedUsername = String.format(format, account.getUsername());
|
||||||
username.setText(formattedUsername);
|
username.setText(formattedUsername);
|
||||||
|
@ -104,30 +108,19 @@ public class FollowRequestsAdapter extends AccountAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupActionListener(final AccountActionListener listener) {
|
void setupActionListener(final AccountActionListener listener) {
|
||||||
accept.setOnClickListener(new View.OnClickListener() {
|
accept.setOnClickListener(v -> {
|
||||||
@Override
|
int position = getAdapterPosition();
|
||||||
public void onClick(View v) {
|
if (position != RecyclerView.NO_POSITION) {
|
||||||
int position = getAdapterPosition();
|
listener.onRespondToFollowRequest(true, id, position);
|
||||||
if (position != RecyclerView.NO_POSITION) {
|
|
||||||
listener.onRespondToFollowRequest(true, id, position);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
reject.setOnClickListener(new View.OnClickListener() {
|
reject.setOnClickListener(v -> {
|
||||||
@Override
|
int position = getAdapterPosition();
|
||||||
public void onClick(View v) {
|
if (position != RecyclerView.NO_POSITION) {
|
||||||
int position = getAdapterPosition();
|
listener.onRespondToFollowRequest(false, id, position);
|
||||||
if (position != RecyclerView.NO_POSITION) {
|
|
||||||
listener.onRespondToFollowRequest(false, id, position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
avatar.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
listener.onViewAccount(id);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
avatar.setOnClickListener(v -> listener.onViewAccount(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.keylesspalace.tusky.adapter;
|
package com.keylesspalace.tusky.adapter;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -10,6 +11,7 @@ import android.widget.TextView;
|
||||||
import com.keylesspalace.tusky.R;
|
import com.keylesspalace.tusky.R;
|
||||||
import com.keylesspalace.tusky.entity.Account;
|
import com.keylesspalace.tusky.entity.Account;
|
||||||
import com.keylesspalace.tusky.interfaces.AccountActionListener;
|
import com.keylesspalace.tusky.interfaces.AccountActionListener;
|
||||||
|
import com.keylesspalace.tusky.util.CustomEmojiHelper;
|
||||||
import com.pkmmte.view.CircularImageView;
|
import com.pkmmte.view.CircularImageView;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
@ -21,8 +23,9 @@ public class MutesAdapter extends AccountAdapter {
|
||||||
super(accountActionListener);
|
super(accountActionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
switch (viewType) {
|
switch (viewType) {
|
||||||
default:
|
default:
|
||||||
case VIEW_TYPE_MUTED_USER: {
|
case VIEW_TYPE_MUTED_USER: {
|
||||||
|
@ -39,11 +42,11 @@ public class MutesAdapter extends AccountAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||||
if (position < accountList.size()) {
|
if (position < accountList.size()) {
|
||||||
MutedUserViewHolder holder = (MutedUserViewHolder) viewHolder;
|
MutedUserViewHolder holder = (MutedUserViewHolder) viewHolder;
|
||||||
holder.setupWithAccount(accountList.get(position));
|
holder.setupWithAccount(accountList.get(position));
|
||||||
holder.setupActionListener(accountActionListener, true, position);
|
holder.setupActionListener(accountActionListener, position);
|
||||||
} else {
|
} else {
|
||||||
FooterViewHolder holder = (FooterViewHolder) viewHolder;
|
FooterViewHolder holder = (FooterViewHolder) viewHolder;
|
||||||
holder.setState(footerState);
|
holder.setState(footerState);
|
||||||
|
@ -76,7 +79,8 @@ public class MutesAdapter extends AccountAdapter {
|
||||||
|
|
||||||
void setupWithAccount(Account account) {
|
void setupWithAccount(Account account) {
|
||||||
id = account.getId();
|
id = account.getId();
|
||||||
displayName.setText(account.getName());
|
CharSequence emojifiedName = CustomEmojiHelper.emojifyString(account.getName(), account.getEmojis(), displayName);
|
||||||
|
displayName.setText(emojifiedName);
|
||||||
String format = username.getContext().getString(R.string.status_username_format);
|
String format = username.getContext().getString(R.string.status_username_format);
|
||||||
String formattedUsername = String.format(format, account.getUsername());
|
String formattedUsername = String.format(format, account.getUsername());
|
||||||
username.setText(formattedUsername);
|
username.setText(formattedUsername);
|
||||||
|
@ -86,20 +90,9 @@ public class MutesAdapter extends AccountAdapter {
|
||||||
.into(avatar);
|
.into(avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupActionListener(final AccountActionListener listener, final boolean muted,
|
void setupActionListener(final AccountActionListener listener, final int position) {
|
||||||
final int position) {
|
unmute.setOnClickListener(v -> listener.onMute(false, id, position));
|
||||||
unmute.setOnClickListener(new View.OnClickListener() {
|
avatar.setOnClickListener(v -> listener.onViewAccount(id));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
listener.onMute(!muted, id, position);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
avatar.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
listener.onViewAccount(id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
} else {
|
} else {
|
||||||
holder.showNotificationContent(true);
|
holder.showNotificationContent(true);
|
||||||
|
|
||||||
holder.setDisplayName(statusViewData.getUserFullName());
|
holder.setDisplayName(statusViewData.getUserFullName(), statusViewData.getAccountEmojis());
|
||||||
holder.setUsername(statusViewData.getNickname());
|
holder.setUsername(statusViewData.getNickname());
|
||||||
holder.setCreatedAt(statusViewData.getCreatedAt());
|
holder.setCreatedAt(statusViewData.getCreatedAt());
|
||||||
|
|
||||||
|
@ -352,8 +352,9 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDisplayName(String name) {
|
private void setDisplayName(String name, List<Emoji> emojis) {
|
||||||
displayName.setText(name);
|
CharSequence emojifiedName = CustomEmojiHelper.emojifyString(name, emojis, displayName);
|
||||||
|
displayName.setText(emojifiedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUsername(String name) {
|
private void setUsername(String name) {
|
||||||
|
@ -489,7 +490,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
Spanned content = statusViewData.getContent();
|
Spanned content = statusViewData.getContent();
|
||||||
List<Emoji> emojis = statusViewData.getEmojis();
|
List<Emoji> emojis = statusViewData.getStatusEmojis();
|
||||||
|
|
||||||
Spanned emojifiedText = CustomEmojiHelper.emojifyText(content, emojis, statusContent);
|
Spanned emojifiedText = CustomEmojiHelper.emojifyText(content, emojis, statusContent);
|
||||||
|
|
||||||
|
@ -497,7 +498,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
|
|
||||||
|
|
||||||
Spanned emojifiedContentWarning =
|
Spanned emojifiedContentWarning =
|
||||||
CustomEmojiHelper.emojifyString(statusViewData.getSpoilerText(), statusViewData.getEmojis(), contentWarningDescriptionTextView);
|
CustomEmojiHelper.emojifyString(statusViewData.getSpoilerText(), statusViewData.getStatusEmojis(), contentWarningDescriptionTextView);
|
||||||
contentWarningDescriptionTextView.setText(emojifiedContentWarning);
|
contentWarningDescriptionTextView.setText(emojifiedContentWarning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,8 +96,9 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
protected abstract int getMediaPreviewHeight(Context context);
|
protected abstract int getMediaPreviewHeight(Context context);
|
||||||
|
|
||||||
private void setDisplayName(String name) {
|
private void setDisplayName(String name, List<Emoji> customEmojis) {
|
||||||
displayName.setText(name);
|
CharSequence emojifiedName = CustomEmojiHelper.emojifyString(name, customEmojis, displayName);
|
||||||
|
displayName.setText(emojifiedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUsername(String name) {
|
private void setUsername(String name) {
|
||||||
|
@ -399,19 +400,11 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
* bugs where other statuses in the list would be removed or added and cause the position
|
* bugs where other statuses in the list would be removed or added and cause the position
|
||||||
* here to become outdated. So, getting the adapter position at the time the listener is
|
* here to become outdated. So, getting the adapter position at the time the listener is
|
||||||
* actually called is the appropriate solution. */
|
* actually called is the appropriate solution. */
|
||||||
avatar.setOnClickListener(new View.OnClickListener() {
|
avatar.setOnClickListener(v -> listener.onViewAccount(accountId));
|
||||||
@Override
|
replyButton.setOnClickListener(v -> {
|
||||||
public void onClick(View v) {
|
int position = getAdapterPosition();
|
||||||
listener.onViewAccount(accountId);
|
if (position != RecyclerView.NO_POSITION) {
|
||||||
}
|
listener.onReply(position);
|
||||||
});
|
|
||||||
replyButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
int position = getAdapterPosition();
|
|
||||||
if (position != RecyclerView.NO_POSITION) {
|
|
||||||
listener.onReply(position);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
reblogButton.setEventListener(new SparkEventListener() {
|
reblogButton.setEventListener(new SparkEventListener() {
|
||||||
|
@ -448,13 +441,10 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
public void onEventAnimationStart(ImageView button, boolean buttonState) {
|
public void onEventAnimationStart(ImageView button, boolean buttonState) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
moreButton.setOnClickListener(new View.OnClickListener() {
|
moreButton.setOnClickListener(v -> {
|
||||||
@Override
|
int position = getAdapterPosition();
|
||||||
public void onClick(View v) {
|
if (position != RecyclerView.NO_POSITION) {
|
||||||
int position = getAdapterPosition();
|
listener.onMore(v, position);
|
||||||
if (position != RecyclerView.NO_POSITION) {
|
|
||||||
listener.onMore(v, position);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/* Even though the content TextView is a child of the container, it won't respond to clicks
|
/* Even though the content TextView is a child of the container, it won't respond to clicks
|
||||||
|
@ -473,11 +463,11 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
void setupWithStatus(StatusViewData.Concrete status, final StatusActionListener listener,
|
void setupWithStatus(StatusViewData.Concrete status, final StatusActionListener listener,
|
||||||
boolean mediaPreviewEnabled) {
|
boolean mediaPreviewEnabled) {
|
||||||
setDisplayName(status.getUserFullName());
|
setDisplayName(status.getUserFullName(), status.getAccountEmojis());
|
||||||
setUsername(status.getNickname());
|
setUsername(status.getNickname());
|
||||||
setCreatedAt(status.getCreatedAt());
|
setCreatedAt(status.getCreatedAt());
|
||||||
setIsReply(status.getInReplyToId() != null);
|
setIsReply(status.getInReplyToId() != null);
|
||||||
setContent(status.getContent(), status.getMentions(), status.getEmojis(), listener);
|
setContent(status.getContent(), status.getMentions(), status.getStatusEmojis(), listener);
|
||||||
setAvatar(status.getAvatar(), status.getRebloggedAvatar());
|
setAvatar(status.getAvatar(), status.getRebloggedAvatar());
|
||||||
setReblogged(status.isReblogged());
|
setReblogged(status.isReblogged());
|
||||||
setFavourited(status.isFavourited());
|
setFavourited(status.isFavourited());
|
||||||
|
@ -488,7 +478,6 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
if (attachments.size() == 0) {
|
if (attachments.size() == 0) {
|
||||||
hideSensitiveMediaWarning();
|
hideSensitiveMediaWarning();
|
||||||
// videoIndicator.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
// Hide the unused label.
|
// Hide the unused label.
|
||||||
mediaLabel.setVisibility(View.GONE);
|
mediaLabel.setVisibility(View.GONE);
|
||||||
|
@ -500,7 +489,6 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
mediaPreview2.setVisibility(View.GONE);
|
mediaPreview2.setVisibility(View.GONE);
|
||||||
mediaPreview3.setVisibility(View.GONE);
|
mediaPreview3.setVisibility(View.GONE);
|
||||||
hideSensitiveMediaWarning();
|
hideSensitiveMediaWarning();
|
||||||
// videoIndicator.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setupButtons(listener, status.getSenderId());
|
setupButtons(listener, status.getSenderId());
|
||||||
|
@ -508,7 +496,7 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
if (status.getSpoilerText() == null || status.getSpoilerText().isEmpty()) {
|
if (status.getSpoilerText() == null || status.getSpoilerText().isEmpty()) {
|
||||||
hideSpoilerText();
|
hideSpoilerText();
|
||||||
} else {
|
} else {
|
||||||
setSpoilerText(status.getSpoilerText(), status.getEmojis(), status.isExpanded(), listener);
|
setSpoilerText(status.getSpoilerText(), status.getStatusEmojis(), status.isExpanded(), listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class CustomEmojiHelper {
|
||||||
* @param textView a reference to the textView the emojis will be shown in
|
* @param textView a reference to the textView the emojis will be shown in
|
||||||
* @return the text with the shortcodes replaced by EmojiSpans
|
* @return the text with the shortcodes replaced by EmojiSpans
|
||||||
*/
|
*/
|
||||||
public static Spanned emojifyText(Spanned text, List<Emoji> emojis, final TextView textView) {
|
public static Spanned emojifyText(@NonNull Spanned text, @NonNull List<Emoji> emojis, @NonNull final TextView textView) {
|
||||||
|
|
||||||
if (!emojis.isEmpty()) {
|
if (!emojis.isEmpty()) {
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class CustomEmojiHelper {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Spanned emojifyString(String string, List<Emoji> emojis, final TextView textView) {
|
public static Spanned emojifyString(@NonNull String string, @NonNull List<Emoji> emojis, @NonNull final TextView textView) {
|
||||||
return emojifyText(new SpannedString(string), emojis, textView);
|
return emojifyText(new SpannedString(string), emojis, textView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,8 @@ public final class ViewDataUtils {
|
||||||
.setSenderId(visibleStatus.getAccount().getId())
|
.setSenderId(visibleStatus.getAccount().getId())
|
||||||
.setRebloggingEnabled(visibleStatus.rebloggingAllowed())
|
.setRebloggingEnabled(visibleStatus.rebloggingAllowed())
|
||||||
.setApplication(visibleStatus.getApplication())
|
.setApplication(visibleStatus.getApplication())
|
||||||
.setEmojis(visibleStatus.getEmojis())
|
.setStatusEmojis(visibleStatus.getEmojis())
|
||||||
|
.setAccountEmojis(visibleStatus.getAccount().getEmojis())
|
||||||
.createStatusViewData();
|
.createStatusViewData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,8 @@ public abstract class StatusViewData {
|
||||||
private final String senderId;
|
private final String senderId;
|
||||||
private final boolean rebloggingEnabled;
|
private final boolean rebloggingEnabled;
|
||||||
private final Status.Application application;
|
private final Status.Application application;
|
||||||
private final List<Emoji> emojis;
|
private final List<Emoji> statusEmojis;
|
||||||
|
private final List<Emoji> accountEmojis;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Card card;
|
private final Card card;
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ public abstract class StatusViewData {
|
||||||
boolean isShowingContent, String userFullName, String nickname, String avatar,
|
boolean isShowingContent, String userFullName, String nickname, String avatar,
|
||||||
Date createdAt, int reblogsCount, int favouritesCount, @Nullable String inReplyToId,
|
Date createdAt, int reblogsCount, int favouritesCount, @Nullable String inReplyToId,
|
||||||
@Nullable Status.Mention[] mentions, String senderId, boolean rebloggingEnabled,
|
@Nullable Status.Mention[] mentions, String senderId, boolean rebloggingEnabled,
|
||||||
Status.Application application, List<Emoji> emojis, @Nullable Card card) {
|
Status.Application application, List<Emoji> statusEmojis, List<Emoji> accountEmojis, @Nullable Card card) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.content = content;
|
this.content = content;
|
||||||
this.reblogged = reblogged;
|
this.reblogged = reblogged;
|
||||||
|
@ -110,7 +111,8 @@ public abstract class StatusViewData {
|
||||||
this.senderId = senderId;
|
this.senderId = senderId;
|
||||||
this.rebloggingEnabled = rebloggingEnabled;
|
this.rebloggingEnabled = rebloggingEnabled;
|
||||||
this.application = application;
|
this.application = application;
|
||||||
this.emojis = emojis;
|
this.statusEmojis = statusEmojis;
|
||||||
|
this.accountEmojis = accountEmojis;
|
||||||
this.card = card;
|
this.card = card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,8 +213,12 @@ public abstract class StatusViewData {
|
||||||
return application;
|
return application;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Emoji> getEmojis() {
|
public List<Emoji> getStatusEmojis() {
|
||||||
return emojis;
|
return statusEmojis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Emoji> getAccountEmojis() {
|
||||||
|
return accountEmojis;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -252,7 +258,8 @@ public abstract class StatusViewData {
|
||||||
Arrays.equals(mentions, concrete.mentions) &&
|
Arrays.equals(mentions, concrete.mentions) &&
|
||||||
Objects.equals(senderId, concrete.senderId) &&
|
Objects.equals(senderId, concrete.senderId) &&
|
||||||
Objects.equals(application, concrete.application) &&
|
Objects.equals(application, concrete.application) &&
|
||||||
Objects.equals(emojis, concrete.emojis) &&
|
Objects.equals(statusEmojis, concrete.statusEmojis) &&
|
||||||
|
Objects.equals(accountEmojis, concrete.accountEmojis) &&
|
||||||
Objects.equals(card, concrete.card);
|
Objects.equals(card, concrete.card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,7 +331,8 @@ public abstract class StatusViewData {
|
||||||
private String senderId;
|
private String senderId;
|
||||||
private boolean rebloggingEnabled;
|
private boolean rebloggingEnabled;
|
||||||
private Status.Application application;
|
private Status.Application application;
|
||||||
private List<Emoji> emojis;
|
private List<Emoji> statusEmojis;
|
||||||
|
private List<Emoji> accountEmojis;
|
||||||
private Card card;
|
private Card card;
|
||||||
|
|
||||||
public Builder() {
|
public Builder() {
|
||||||
|
@ -354,7 +362,8 @@ public abstract class StatusViewData {
|
||||||
senderId = viewData.senderId;
|
senderId = viewData.senderId;
|
||||||
rebloggingEnabled = viewData.rebloggingEnabled;
|
rebloggingEnabled = viewData.rebloggingEnabled;
|
||||||
application = viewData.application;
|
application = viewData.application;
|
||||||
emojis = viewData.getEmojis();
|
statusEmojis = viewData.getStatusEmojis();
|
||||||
|
accountEmojis = viewData.getAccountEmojis();
|
||||||
card = viewData.getCard();
|
card = viewData.getCard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,8 +482,13 @@ public abstract class StatusViewData {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setEmojis(List<Emoji> emojis) {
|
public Builder setStatusEmojis(List<Emoji> emojis) {
|
||||||
this.emojis = emojis;
|
this.statusEmojis = emojis;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setAccountEmojis(List<Emoji> emojis) {
|
||||||
|
this.accountEmojis = emojis;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,14 +498,15 @@ public abstract class StatusViewData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatusViewData.Concrete createStatusViewData() {
|
public StatusViewData.Concrete createStatusViewData() {
|
||||||
if (this.emojis == null) emojis = Collections.emptyList();
|
if (this.statusEmojis == null) statusEmojis = Collections.emptyList();
|
||||||
|
if (this.accountEmojis == null) accountEmojis = Collections.emptyList();
|
||||||
if (this.createdAt == null) createdAt = new Date();
|
if (this.createdAt == null) createdAt = new Date();
|
||||||
|
|
||||||
return new StatusViewData.Concrete(id, content, reblogged, favourited, spoilerText, visibility,
|
return new StatusViewData.Concrete(id, content, reblogged, favourited, spoilerText, visibility,
|
||||||
attachments, rebloggedByUsername, rebloggedAvatar, isSensitive, isExpanded,
|
attachments, rebloggedByUsername, rebloggedAvatar, isSensitive, isExpanded,
|
||||||
isShowingContent, userFullName, nickname, avatar, createdAt, reblogsCount,
|
isShowingContent, userFullName, nickname, avatar, createdAt, reblogsCount,
|
||||||
favouritesCount, inReplyToId, mentions, senderId, rebloggingEnabled, application,
|
favouritesCount, inReplyToId, mentions, senderId, rebloggingEnabled, application,
|
||||||
emojis, card);
|
statusEmojis, accountEmojis, card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue