Compare commits
10 Commits
2.3.0+fork
...
merge-upst
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c26df5762f | ||
|
|
2021c335ac | ||
|
|
d121f14d30 | ||
|
|
d1a2a70cdc | ||
|
|
89ef482e2e | ||
|
|
9918649d7c | ||
|
|
09185faf9a | ||
|
|
b7e0596014 | ||
|
|
dbef984908 | ||
|
|
55259f103d |
@@ -9,6 +9,7 @@ import android.graphics.Rect;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Pair;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
@@ -709,26 +710,17 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateStatusWithQuote(DisplayItemsParent parent) {
|
public void updateStatusWithQuote(DisplayItemsParent parent) {
|
||||||
int startIndex=-1;
|
Pair<Integer, Integer> items=findAllItemsOfParent(parent);
|
||||||
int endIndex=-1;
|
if (items==null)
|
||||||
for(int i=0; i<displayItems.size(); i++){
|
|
||||||
StatusDisplayItem item = displayItems.get(i);
|
|
||||||
if(item.parentID.equals(parent.getID())) {
|
|
||||||
startIndex= startIndex==-1 ? i : startIndex;
|
|
||||||
endIndex=i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (startIndex==-1 || endIndex==-1)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Only StatusListFragments/NotificationsListFragments can display status with quotes
|
// Only StatusListFragments/NotificationsListFragments can display status with quotes
|
||||||
assert (this instanceof StatusListFragment) || (this instanceof NotificationsListFragment);
|
assert (this instanceof StatusListFragment) || (this instanceof NotificationsListFragment);
|
||||||
List<StatusDisplayItem> oldItems = displayItems.subList(startIndex, endIndex+1);
|
List<StatusDisplayItem> oldItems = displayItems.subList(items.first, items.second+1);
|
||||||
List<StatusDisplayItem> newItems=this.buildDisplayItems((T) parent);
|
List<StatusDisplayItem> newItems=this.buildDisplayItems((T) parent);
|
||||||
int prevSize=oldItems.size();
|
int prevSize=oldItems.size();
|
||||||
oldItems.clear();
|
oldItems.clear();
|
||||||
displayItems.addAll(startIndex, newItems);
|
displayItems.addAll(items.first, newItems);
|
||||||
|
|
||||||
// Update the cache
|
// Update the cache
|
||||||
final CacheController cache=AccountSessionManager.get(accountID).getCacheController();
|
final CacheController cache=AccountSessionManager.get(accountID).getCacheController();
|
||||||
@@ -738,8 +730,19 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
|||||||
cache.updateNotification((Notification) parent);
|
cache.updateNotification((Notification) parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter.notifyItemRangeRemoved(startIndex, prevSize);
|
adapter.notifyItemRangeRemoved(items.first, prevSize);
|
||||||
adapter.notifyItemRangeInserted(startIndex, newItems.size());
|
adapter.notifyItemRangeInserted(items.first, newItems.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeStatus(DisplayItemsParent parent) {
|
||||||
|
Pair<Integer, Integer> items=findAllItemsOfParent(parent);
|
||||||
|
if (items==null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<StatusDisplayItem> statusDisplayItems = displayItems.subList(items.first, items.second+1);
|
||||||
|
int prevSize=statusDisplayItems.size();
|
||||||
|
statusDisplayItems.clear();
|
||||||
|
adapter.notifyItemRangeRemoved(items.first, prevSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onVisibilityIconClick(HeaderStatusDisplayItem.Holder holder) {
|
public void onVisibilityIconClick(HeaderStatusDisplayItem.Holder holder) {
|
||||||
@@ -945,6 +948,23 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
protected Pair<Integer, Integer> findAllItemsOfParent(DisplayItemsParent parent){
|
||||||
|
int startIndex=-1;
|
||||||
|
int endIndex=-1;
|
||||||
|
for(int i=0; i<displayItems.size(); i++){
|
||||||
|
StatusDisplayItem item = displayItems.get(i);
|
||||||
|
if(item.parentID.equals(parent.getID())) {
|
||||||
|
startIndex= startIndex==-1 ? i : startIndex;
|
||||||
|
endIndex=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(startIndex==-1 || endIndex==-1)
|
||||||
|
return null;
|
||||||
|
return Pair.create(startIndex, endIndex);
|
||||||
|
}
|
||||||
|
|
||||||
protected <I extends StatusDisplayItem, H extends StatusDisplayItem.Holder<I>> List<H> findAllHoldersOfType(String id, Class<H> type){
|
protected <I extends StatusDisplayItem, H extends StatusDisplayItem.Holder<I>> List<H> findAllHoldersOfType(String id, Class<H> type){
|
||||||
ArrayList<H> holders=new ArrayList<>();
|
ArrayList<H> holders=new ArrayList<>();
|
||||||
for(int i=0;i<list.getChildCount();i++){
|
for(int i=0;i<list.getChildCount();i++){
|
||||||
|
|||||||
@@ -297,8 +297,8 @@ public class FollowRequestsListFragment extends MastodonRecyclerFragment<FollowR
|
|||||||
cover.setImageDrawable(image);
|
cover.setImageDrawable(image);
|
||||||
}else{
|
}else{
|
||||||
item.emojiHelper.setImageDrawable(index-2, image);
|
item.emojiHelper.setImageDrawable(index-2, image);
|
||||||
name.invalidate();
|
name.setText(name.getText());
|
||||||
bio.invalidate();
|
bio.setText(bio.getText());
|
||||||
}
|
}
|
||||||
if(image instanceof Animatable a && !a.isRunning())
|
if(image instanceof Animatable a && !a.isRunning())
|
||||||
a.start();
|
a.start();
|
||||||
|
|||||||
@@ -1587,8 +1587,9 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
|||||||
public void setImage(int index, Drawable image){
|
public void setImage(int index, Drawable image){
|
||||||
CustomEmojiSpan span=index>=item.nameEmojis.length ? item.valueEmojis[index-item.nameEmojis.length] : item.nameEmojis[index];
|
CustomEmojiSpan span=index>=item.nameEmojis.length ? item.valueEmojis[index-item.nameEmojis.length] : item.nameEmojis[index];
|
||||||
span.setDrawable(image);
|
span.setDrawable(image);
|
||||||
title.invalidate();
|
title.setText(title.getText());
|
||||||
value.invalidate();
|
value.setText(value.getText());
|
||||||
|
toolbarTitleView.setText(toolbarTitleView.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -279,8 +279,8 @@ public class DiscoverAccountsFragment extends MastodonRecyclerFragment<DiscoverA
|
|||||||
cover.setImageDrawable(image);
|
cover.setImageDrawable(image);
|
||||||
}else{
|
}else{
|
||||||
item.emojiHelper.setImageDrawable(index-2, image);
|
item.emojiHelper.setImageDrawable(index-2, image);
|
||||||
name.invalidate();
|
name.setText(name.getText());
|
||||||
bio.invalidate();
|
bio.setText(bio.getText());
|
||||||
}
|
}
|
||||||
if(image instanceof Animatable a && !a.isRunning())
|
if(image instanceof Animatable a && !a.isRunning())
|
||||||
a.start();
|
a.start();
|
||||||
|
|||||||
@@ -131,8 +131,7 @@ public class DiscoverTrendingLinkTimelineFragment extends StatusListFragment{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Uri getWebUri(Uri.Builder base) {
|
public Uri getWebUri(Uri.Builder base) {
|
||||||
//TODO: add URL link once web version implements a UI
|
return base.path("/links").appendPath(trendingLink.url).build();
|
||||||
return base.path("/explore/links").build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class EmojiReaction {
|
|||||||
reaction.staticUrl=info.staticUrl;
|
reaction.staticUrl=info.staticUrl;
|
||||||
reaction.accounts=new ArrayList<>(Collections.singleton(me));
|
reaction.accounts=new ArrayList<>(Collections.singleton(me));
|
||||||
reaction.accountIds=new ArrayList<>(Collections.singleton(me.id));
|
reaction.accountIds=new ArrayList<>(Collections.singleton(me.id));
|
||||||
reaction.request=new UrlImageLoaderRequest(info.url, V.sp(24), V.sp(24));
|
reaction.request=new UrlImageLoaderRequest(info.url, 0, V.sp(24));
|
||||||
return reaction;
|
return reaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -225,8 +225,8 @@ public class AccountCardStatusDisplayItem extends StatusDisplayItem{
|
|||||||
cover.setImageDrawable(image);
|
cover.setImageDrawable(image);
|
||||||
}else{
|
}else{
|
||||||
item.emojiHelper.setImageDrawable(index-2, image);
|
item.emojiHelper.setImageDrawable(index-2, image);
|
||||||
name.invalidate();
|
name.setText(name.getText());
|
||||||
bio.invalidate();
|
bio.setText(bio.getText());
|
||||||
}
|
}
|
||||||
if(image instanceof Animatable && !((Animatable) image).isRunning())
|
if(image instanceof Animatable && !((Animatable) image).isRunning())
|
||||||
((Animatable) image).start();
|
((Animatable) image).start();
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem {
|
|||||||
addButton.setSelected(false);
|
addButton.setSelected(false);
|
||||||
AccountSession session=item.parentFragment.getSession();
|
AccountSession session=item.parentFragment.getSession();
|
||||||
item.status.reactions.forEach(r->r.request=r.getUrl(item.playGifs)!=null
|
item.status.reactions.forEach(r->r.request=r.getUrl(item.playGifs)!=null
|
||||||
? new UrlImageLoaderRequest(r.getUrl(item.playGifs), V.sp(24), V.sp(24))
|
? new UrlImageLoaderRequest(r.getUrl(item.playGifs), 0, V.sp(24))
|
||||||
: null);
|
: null);
|
||||||
emojiKeyboard=new CustomEmojiPopupKeyboard(
|
emojiKeyboard=new CustomEmojiPopupKeyboard(
|
||||||
(Activity) item.parentFragment.getContext(),
|
(Activity) item.parentFragment.getContext(),
|
||||||
@@ -342,7 +342,9 @@ public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setImage(int index, Drawable drawable){
|
public void setImage(int index, Drawable drawable){
|
||||||
drawable.setBounds(0, 0, V.sp(24), V.sp(24));
|
int height=V.sp(24);
|
||||||
|
int width=drawable.getIntrinsicWidth()*height/drawable.getIntrinsicHeight();
|
||||||
|
drawable.setBounds(0, 0, width, height);
|
||||||
btn.setCompoundDrawablesRelative(drawable, null, null, null);
|
btn.setCompoundDrawablesRelative(drawable, null, null, null);
|
||||||
if(drawable instanceof Animatable) ((Animatable) drawable).start();
|
if(drawable instanceof Animatable) ((Animatable) drawable).start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
public void setImage(int index, Drawable drawable){
|
public void setImage(int index, Drawable drawable){
|
||||||
if(index>0){
|
if(index>0){
|
||||||
item.emojiHelper.setImageDrawable(index-1, drawable);
|
item.emojiHelper.setImageDrawable(index-1, drawable);
|
||||||
name.invalidate();
|
name.setText(name.getText());
|
||||||
}else{
|
}else{
|
||||||
avatar.setImageDrawable(drawable);
|
avatar.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
avatar.setImageDrawable(image);
|
avatar.setImageDrawable(image);
|
||||||
}else{
|
}else{
|
||||||
item.emojiHelper.setImageDrawable(index-1, image);
|
item.emojiHelper.setImageDrawable(index-1, image);
|
||||||
text.invalidate();
|
text.setText(text.getText());
|
||||||
}
|
}
|
||||||
if(image instanceof Animatable)
|
if(image instanceof Animatable)
|
||||||
((Animatable) image).start();
|
((Animatable) image).start();
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class PollOptionStatusDisplayItem extends StatusDisplayItem{
|
|||||||
@Override
|
@Override
|
||||||
public void setImage(int index, Drawable image){
|
public void setImage(int index, Drawable image){
|
||||||
item.emojiHelper.setImageDrawable(index, image);
|
item.emojiHelper.setImageDrawable(index, image);
|
||||||
text.invalidate();
|
text.setText(text.getText());
|
||||||
if(image instanceof Animatable){
|
if(image instanceof Animatable){
|
||||||
((Animatable) image).start();
|
((Animatable) image).start();
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ public class PollOptionStatusDisplayItem extends StatusDisplayItem{
|
|||||||
@Override
|
@Override
|
||||||
public void clearImage(int index){
|
public void clearImage(int index){
|
||||||
item.emojiHelper.setImageDrawable(index, null);
|
item.emojiHelper.setImageDrawable(index, null);
|
||||||
text.invalidate();
|
text.setText(text.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onButtonClick(View v){
|
private void onButtonClick(View v){
|
||||||
|
|||||||
@@ -152,8 +152,8 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{
|
|||||||
int firstHelperCount=item.emojiHelper.getImageCount();
|
int firstHelperCount=item.emojiHelper.getImageCount();
|
||||||
CustomEmojiHelper helper=index<firstHelperCount ? item.emojiHelper : item.extra.emojiHelper;
|
CustomEmojiHelper helper=index<firstHelperCount ? item.emojiHelper : item.extra.emojiHelper;
|
||||||
helper.setImageDrawable(firstHelperCount>0 ? index%firstHelperCount : index, image);
|
helper.setImageDrawable(firstHelperCount>0 ? index%firstHelperCount : index, image);
|
||||||
text.invalidate();
|
text.setText(text.getText());
|
||||||
extraText.invalidate();
|
extraText.setText(extraText.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class SpoilerStatusDisplayItem extends StatusDisplayItem{
|
|||||||
@Override
|
@Override
|
||||||
public void setImage(int index, Drawable image){
|
public void setImage(int index, Drawable image){
|
||||||
item.emojiHelper.setImageDrawable(index, image);
|
item.emojiHelper.setImageDrawable(index, image);
|
||||||
title.invalidate();
|
title.setText(title.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ import android.view.ViewGroup;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
|
import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships;
|
||||||
import org.joinmastodon.android.api.requests.search.GetSearchResults;
|
import org.joinmastodon.android.api.requests.search.GetSearchResults;
|
||||||
import org.joinmastodon.android.api.session.AccountLocalPreferences;
|
import org.joinmastodon.android.api.session.AccountLocalPreferences;
|
||||||
|
import org.joinmastodon.android.api.session.AccountSession;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||||
import org.joinmastodon.android.fragments.HashtagTimelineFragment;
|
import org.joinmastodon.android.fragments.HashtagTimelineFragment;
|
||||||
@@ -35,6 +37,7 @@ import org.joinmastodon.android.model.FilterResult;
|
|||||||
import org.joinmastodon.android.model.LegacyFilter;
|
import org.joinmastodon.android.model.LegacyFilter;
|
||||||
import org.joinmastodon.android.model.Notification;
|
import org.joinmastodon.android.model.Notification;
|
||||||
import org.joinmastodon.android.model.Poll;
|
import org.joinmastodon.android.model.Poll;
|
||||||
|
import org.joinmastodon.android.model.Relationship;
|
||||||
import org.joinmastodon.android.model.ScheduledStatus;
|
import org.joinmastodon.android.model.ScheduledStatus;
|
||||||
import org.joinmastodon.android.model.SearchResults;
|
import org.joinmastodon.android.model.SearchResults;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
@@ -339,7 +342,7 @@ public abstract class StatusDisplayItem{
|
|||||||
contentItems.add(new DummyStatusDisplayItem(parentID, fragment));
|
contentItems.add(new DummyStatusDisplayItem(parentID, fragment));
|
||||||
contentItems.addAll(buildItems(fragment, statusForContent.quote, accountID, parentObject, knownAccounts, filterContext, FLAG_NO_FOOTER|FLAG_INSET|FLAG_NO_EMOJI_REACTIONS|FLAG_IS_FOR_QUOTE));
|
contentItems.addAll(buildItems(fragment, statusForContent.quote, accountID, parentObject, knownAccounts, filterContext, FLAG_NO_FOOTER|FLAG_INSET|FLAG_NO_EMOJI_REACTIONS|FLAG_IS_FOR_QUOTE));
|
||||||
} else if((flags & FLAG_INSET)==0 && statusForContent.mediaAttachments.isEmpty()){
|
} else if((flags & FLAG_INSET)==0 && statusForContent.mediaAttachments.isEmpty()){
|
||||||
tryAddNonOfficialQuote(statusForContent, fragment, accountID);
|
tryAddNonOfficialQuote(statusForContent, fragment, accountID, filterContext);
|
||||||
}
|
}
|
||||||
if(contentItems!=items && statusForContent.spoilerRevealed){
|
if(contentItems!=items && statusForContent.spoilerRevealed){
|
||||||
items.addAll(contentItems);
|
items.addAll(contentItems);
|
||||||
@@ -421,29 +424,54 @@ public abstract class StatusDisplayItem{
|
|||||||
* Tries to adds a non-official quote to a status.
|
* Tries to adds a non-official quote to a status.
|
||||||
* A non-official quote is a quote on an instance that does not support quotes officially.
|
* A non-official quote is a quote on an instance that does not support quotes officially.
|
||||||
*/
|
*/
|
||||||
private static void tryAddNonOfficialQuote(Status status, BaseStatusListFragment fragment, String accountID) {
|
private static void tryAddNonOfficialQuote(Status status, BaseStatusListFragment fragment, String accountID, FilterContext filterContext) {
|
||||||
Matcher matcher=QUOTE_PATTERN.matcher(status.getStrippedText());
|
Matcher matcher=QUOTE_PATTERN.matcher(status.getStrippedText());
|
||||||
|
|
||||||
if(!matcher.find())
|
if(!matcher.find())
|
||||||
return;
|
return;
|
||||||
String quoteURL=matcher.group();
|
String quoteURL=matcher.group();
|
||||||
|
|
||||||
if (UiUtils.looksLikeFediverseUrl(quoteURL)) {
|
if (!UiUtils.looksLikeFediverseUrl(quoteURL))
|
||||||
new GetSearchResults(quoteURL, GetSearchResults.Type.STATUSES, true, null, 0, 0).setCallback(new Callback<>(){
|
return;
|
||||||
@Override
|
|
||||||
public void onSuccess(SearchResults results){
|
|
||||||
if (results.statuses != null && !results.statuses.isEmpty()){
|
|
||||||
status.quote=results.statuses.get(0);
|
|
||||||
fragment.updateStatusWithQuote(status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
new GetSearchResults(quoteURL, GetSearchResults.Type.STATUSES, true, null, 0, 0).setCallback(new Callback<>(){
|
||||||
public void onError(ErrorResponse error){
|
@Override
|
||||||
Log.w("StatusDisplayItem", "onError: failed to find quote status with URL: " + quoteURL + " " + error);
|
public void onSuccess(SearchResults results){
|
||||||
}
|
AccountSessionManager.get(accountID).filterStatuses(results.statuses, filterContext);
|
||||||
}).exec(accountID);
|
if (results.statuses == null || results.statuses.isEmpty())
|
||||||
}
|
return;
|
||||||
|
|
||||||
|
Status quote=results.statuses.get(0);
|
||||||
|
new GetAccountRelationships(Collections.singletonList(quote.account.id))
|
||||||
|
.setCallback(new Callback<>(){
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<Relationship> relationships){
|
||||||
|
if(relationships.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Relationship relationship=relationships.get(0);
|
||||||
|
String selfId=AccountSessionManager.get(accountID).self.id;
|
||||||
|
if(!status.account.id.equals(selfId) && (relationship.domainBlocking || relationship.muting || relationship.blocking)) {
|
||||||
|
// do not show posts that are quoting a muted/blocked user
|
||||||
|
fragment.removeStatus(status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
status.quote=results.statuses.get(0);
|
||||||
|
fragment.updateStatusWithQuote(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(ErrorResponse error){}
|
||||||
|
})
|
||||||
|
.exec(accountID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(ErrorResponse error){
|
||||||
|
Log.w("StatusDisplayItem", "onError: failed to find quote status with URL: " + quoteURL + " " + error);
|
||||||
|
}
|
||||||
|
}).exec(accountID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Type{
|
public enum Type{
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
|
|||||||
@Override
|
@Override
|
||||||
public void setImage(int index, Drawable image){
|
public void setImage(int index, Drawable image){
|
||||||
getEmojiHelper().setImageDrawable(index, image);
|
getEmojiHelper().setImageDrawable(index, image);
|
||||||
text.invalidate();
|
text.setText(text.getText());
|
||||||
if(image instanceof Animatable){
|
if(image instanceof Animatable){
|
||||||
((Animatable) image).start();
|
((Animatable) image).start();
|
||||||
if(image instanceof MovieDrawable)
|
if(image instanceof MovieDrawable)
|
||||||
@@ -184,7 +184,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
|
|||||||
@Override
|
@Override
|
||||||
public void clearImage(int index){
|
public void clearImage(int index){
|
||||||
getEmojiHelper().setImageDrawable(index, null);
|
getEmojiHelper().setImageDrawable(index, null);
|
||||||
text.invalidate();
|
text.setText(text.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
private CustomEmojiHelper getEmojiHelper(){
|
private CustomEmojiHelper getEmojiHelper(){
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ public class CustomEmojiSpan extends ReplacementSpan{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, @Nullable Paint.FontMetricsInt fm){
|
public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, @Nullable Paint.FontMetricsInt fm){
|
||||||
return Math.round(paint.descent()-paint.ascent());
|
int size = Math.round(paint.descent()-paint.ascent());
|
||||||
|
return drawable!=null ? (int) (drawable.getIntrinsicWidth()*(size/(float) drawable.getIntrinsicHeight())) : size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,7 +46,8 @@ public class CustomEmojiSpan extends ReplacementSpan{
|
|||||||
}
|
}
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(x, top);
|
canvas.translate(x, top);
|
||||||
canvas.scale(size/(float)dw, size/(float)dh, 0f, 0f);
|
float scale = size/(float)dh;
|
||||||
|
canvas.scale(scale, scale, 0f, 0f);
|
||||||
drawable.draw(canvas);
|
drawable.draw(canvas);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
@@ -56,7 +58,6 @@ public class CustomEmojiSpan extends ReplacementSpan{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UrlImageLoaderRequest createImageLoaderRequest(){
|
public UrlImageLoaderRequest createImageLoaderRequest(){
|
||||||
int size=V.dp(20);
|
return new UrlImageLoaderRequest(GlobalUserPreferences.playGifs ? emoji.url : emoji.staticUrl, 0, V.dp(20));
|
||||||
return new UrlImageLoaderRequest(GlobalUserPreferences.playGifs ? emoji.url : emoji.staticUrl, size, size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -417,7 +417,6 @@ public class UiUtils {
|
|||||||
CustomEmojiSpan[] spans = text.getSpans(0, text.length(), CustomEmojiSpan.class);
|
CustomEmojiSpan[] spans = text.getSpans(0, text.length(), CustomEmojiSpan.class);
|
||||||
if (spans.length == 0)
|
if (spans.length == 0)
|
||||||
return;
|
return;
|
||||||
int emojiSize = V.dp(20);
|
|
||||||
Map<Emoji, List<CustomEmojiSpan>> spansByEmoji = Arrays.stream(spans).collect(Collectors.groupingBy(s -> s.emoji));
|
Map<Emoji, List<CustomEmojiSpan>> spansByEmoji = Arrays.stream(spans).collect(Collectors.groupingBy(s -> s.emoji));
|
||||||
for (Map.Entry<Emoji, List<CustomEmojiSpan>> emoji : spansByEmoji.entrySet()) {
|
for (Map.Entry<Emoji, List<CustomEmojiSpan>> emoji : spansByEmoji.entrySet()) {
|
||||||
ViewImageLoader.load(new ViewImageLoader.Target() {
|
ViewImageLoader.load(new ViewImageLoader.Target() {
|
||||||
@@ -428,14 +427,14 @@ public class UiUtils {
|
|||||||
for (CustomEmojiSpan span : emoji.getValue()) {
|
for (CustomEmojiSpan span : emoji.getValue()) {
|
||||||
span.setDrawable(d);
|
span.setDrawable(d);
|
||||||
}
|
}
|
||||||
view.invalidate();
|
view.setText(view.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView() {
|
public View getView() {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
}, null, new UrlImageLoaderRequest(emoji.getKey().url, emojiSize, emojiSize), null, false, true);
|
}, null, new UrlImageLoaderRequest(emoji.getKey().url, 0, V.dp(20)), null, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,8 +185,8 @@ public class AccountViewHolder extends BindableViewHolder<AccountViewModel> impl
|
|||||||
avatar.setImageDrawable(image);
|
avatar.setImageDrawable(image);
|
||||||
}else{
|
}else{
|
||||||
item.emojiHelper.setImageDrawable(index-1, image);
|
item.emojiHelper.setImageDrawable(index-1, image);
|
||||||
name.invalidate();
|
name.setText(name.getText());
|
||||||
bio.invalidate();
|
bio.setText(bio.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(image instanceof Animatable a && !a.isRunning())
|
if(image instanceof Animatable a && !a.isRunning())
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:pathData="M17.75,2.007a2.25,2.25 0,0 1,2.245 2.096l0.005,0.154v15.498A2.25,2.25 0,0 1,17.904 22l-0.154,0.005H6.25a2.25,2.25 0,0 1,-2.245 -2.096L4,19.755V4.257a2.25,2.25 0,0 1,2.096 -2.245l0.154,-0.005h11.5ZM7.75,7a0.75,0.75 0,1 0,0 1.5h8.5a0.75,0.75 0,0 0,0 -1.5h-8.5ZM7,11.75c0,0.414 0.336,0.75 0.75,0.75h8.5a0.75,0.75 0,0 0,0 -1.5h-8.5a0.75,0.75 0,0 0,-0.75 0.75ZM7.75,15a0.75,0.75 0,1 0,0 1.5h8.5a0.75,0.75 0,0 0,0 -1.5h-8.5Z"
|
|
||||||
android:fillColor="#212121"/>
|
|
||||||
</vector>
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/open_link"
|
android:id="@+id/open_link"
|
||||||
android:icon="@drawable/ic_fluent_document_one_page_24_filled"
|
android:icon="@drawable/ic_fluent_open_24_regular"
|
||||||
android:showAsAction="always"
|
android:showAsAction="always"
|
||||||
android:title="@string/mo_trending_link_read"/>
|
android:title="@string/mo_trending_link_read"/>
|
||||||
</menu>
|
</menu>
|
||||||
Reference in New Issue
Block a user