Remove "www." from more places

This commit is contained in:
Grishka 2024-02-26 23:58:57 +03:00
parent b51cccf1d7
commit b8ae79faa1
3 changed files with 13 additions and 5 deletions

View File

@ -34,6 +34,7 @@ import org.joinmastodon.android.ui.views.SizeListenerFrameLayout;
import org.parceler.Parcels;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom;
import androidx.annotation.Nullable;
@ -263,7 +264,7 @@ public class SplashFragment extends AppKitFragment{
String clipText=clipData.getItemAt(0).coerceToText(getActivity()).toString();
if(HtmlParser.isValidInviteUrl(clipText)){
currentInviteLink=Uri.parse(clipText);
defaultServerButton.setText(getString(R.string.join_server_x_with_invite, currentInviteLink.getHost()));
defaultServerButton.setText(getString(R.string.join_server_x_with_invite, HtmlParser.normalizeDomain(Objects.requireNonNull(currentInviteLink.getHost()))));
}
}else{
loadingDefaultServer=true;
@ -315,7 +316,7 @@ public class SplashFragment extends AppKitFragment{
if(defaultServerButton!=null && getActivity()!=null && currentInviteLink==null){
defaultServerButton.setTextVisible(true);
defaultServerProgress.setVisibility(View.GONE);
defaultServerButton.setText(getString(R.string.join_default_server, chosenDefaultServer));
defaultServerButton.setText(getString(R.string.join_default_server, HtmlParser.normalizeDomain(chosenDefaultServer)));
}
}
}

View File

@ -17,8 +17,11 @@ import org.joinmastodon.android.model.Card;
import org.joinmastodon.android.model.Status;
import org.joinmastodon.android.ui.OutlineProviders;
import org.joinmastodon.android.ui.drawables.BlurhashCrossfadeDrawable;
import org.joinmastodon.android.ui.text.HtmlParser;
import org.joinmastodon.android.ui.utils.UiUtils;
import java.util.Objects;
import me.grishka.appkit.imageloader.ImageLoaderViewHolder;
import me.grishka.appkit.imageloader.requests.ImageLoaderRequest;
import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest;
@ -82,9 +85,7 @@ public class LinkCardStatusDisplayItem extends StatusDisplayItem{
description.setText(card.description);
description.setVisibility(TextUtils.isEmpty(card.description) ? View.GONE : View.VISIBLE);
}
String cardDomain=Uri.parse(card.url).getHost();
if(cardDomain.startsWith("www."))
cardDomain=cardDomain.substring(4);
String cardDomain=HtmlParser.normalizeDomain(Objects.requireNonNull(Uri.parse(card.url).getHost()));
if(isLarge && !TextUtils.isEmpty(card.authorName)){
domain.setText(itemView.getContext().getString(R.string.article_by_author, card.authorName)+" · "+cardDomain);
}else{

View File

@ -263,4 +263,10 @@ public class HtmlParser{
public static boolean isValidInviteUrl(String url){
return url.startsWith("https://") && INVITE_LINK_PATH.matcher(url).find();
}
public static String normalizeDomain(String domain){
if(domain.startsWith("www."))
domain=domain.substring(4);
return domain;
}
}