fix: hide link card to akkoma hastags (#939)

* fix: hide link card to akkoma hastags

* generify method name

---------

Co-authored-by: sk <sk22@mailbox.org>
This commit is contained in:
FineFindus 2023-11-27 19:07:43 +01:00 committed by GitHub
parent d96b9558b4
commit 70b9d08830
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package org.joinmastodon.android.model;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import com.google.gson.annotations.SerializedName;
@ -47,6 +48,13 @@ public class Card extends BaseModel{
}
}
public boolean isHashtagUrl(String statusUrl){
Uri parsedUrl=Uri.parse(url);
Uri parsedStatusUrl=Uri.parse(statusUrl);
if(parsedUrl.getHost()==null || parsedUrl.getPath()==null || parsedStatusUrl.getHost()==null) return false;
return title.equals("Akkoma") && parsedUrl.getHost().equals(parsedStatusUrl.getHost()) && parsedUrl.getPath().startsWith("/tag/");
}
@Override
public String toString(){
return "Card{"+

View File

@ -28,7 +28,6 @@ import org.joinmastodon.android.fragments.ThreadFragment;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.Attachment;
import org.joinmastodon.android.model.DisplayItemsParent;
import org.joinmastodon.android.model.FilterAction;
import org.joinmastodon.android.model.LegacyFilter;
import org.joinmastodon.android.model.FilterContext;
import org.joinmastodon.android.model.FilterResult;
@ -293,7 +292,7 @@ public abstract class StatusDisplayItem{
if(statusForContent.poll!=null){
buildPollItems(parentID, fragment, statusForContent.poll, status, contentItems);
}
if(statusForContent.card!=null && statusForContent.mediaAttachments.isEmpty() && statusForContent.quote==null){
if(statusForContent.card!=null && statusForContent.mediaAttachments.isEmpty() && statusForContent.quote==null && !statusForContent.card.isHashtagUrl(statusForContent.url)){
contentItems.add(new LinkCardStatusDisplayItem(parentID, fragment, statusForContent));
}
if(statusForContent.quote!=null && !(parentObject instanceof Notification)){