Merge branch 'master' into donations

This commit is contained in:
Grishka 2024-06-29 09:13:29 +03:00
commit 027b873f13
7 changed files with 43 additions and 12 deletions

View File

@ -10,7 +10,7 @@ public class GlobalUserPreferences{
public static boolean playGifs; public static boolean playGifs;
public static boolean useCustomTabs; public static boolean useCustomTabs;
public static boolean altTextReminders, confirmUnfollow, confirmBoost, confirmDeletePost; public static boolean altTextReminders, confirmUnfollow, confirmBoost, confirmDeletePost;
public static ThemePreference theme; public static ThemePreference theme=ThemePreference.AUTO;
private static SharedPreferences getPrefs(){ private static SharedPreferences getPrefs(){
return MastodonApp.context.getSharedPreferences("global", Context.MODE_PRIVATE); return MastodonApp.context.getSharedPreferences("global", Context.MODE_PRIVATE);

View File

@ -105,7 +105,7 @@ public class AccountSessionManager{
Log.e(TAG, "Error loading accounts", x); Log.e(TAG, "Error loading accounts", x);
} }
lastActiveAccountID=prefs.getString("lastActiveAccount", null); lastActiveAccountID=prefs.getString("lastActiveAccount", null);
MastodonAPIController.runInBackground(()->readInstanceInfo(domains)); readInstanceInfo(domains);
maybeUpdateShortcuts(); maybeUpdateShortcuts();
} }

View File

@ -666,7 +666,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
proceed.run(); proceed.run();
}, status.account, accountID).show(); }, status.account, accountID).show();
}else if(!GlobalUserPreferences.isOptedOutOfPreReplySheet(GlobalUserPreferences.PreReplySheetType.OLD_POST, null, null) && }else if(!GlobalUserPreferences.isOptedOutOfPreReplySheet(GlobalUserPreferences.PreReplySheetType.OLD_POST, null, null) &&
status.createdAt.isBefore(Instant.now().minus(90, ChronoUnit.DAYS))){ status.createdAt.isBefore(Instant.now().minus(90, ChronoUnit.DAYS)) && !status.account.id.equals(AccountSessionManager.get(accountID).self.id)){
new OldPostPreReplySheet(getActivity(), notAgain->{ new OldPostPreReplySheet(getActivity(), notAgain->{
if(notAgain) if(notAgain)
GlobalUserPreferences.optOutOfPreReplySheet(GlobalUserPreferences.PreReplySheetType.OLD_POST, null, null); GlobalUserPreferences.optOutOfPreReplySheet(GlobalUserPreferences.PreReplySheetType.OLD_POST, null, null);

View File

@ -544,7 +544,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements ComposeE
ignoreSelectionChanges=true; ignoreSelectionChanges=true;
mainEditText.setSelection(mainEditText.length()); mainEditText.setSelection(mainEditText.length());
ignoreSelectionChanges=false; ignoreSelectionChanges=false;
mediaViewController.onViewCreated(savedInstanceState);; mediaViewController.onViewCreated(savedInstanceState);
}else{ }else{
String prefilledText=getArguments().getString("prefilledText"); String prefilledText=getArguments().getString("prefilledText");
if(!TextUtils.isEmpty(prefilledText)){ if(!TextUtils.isEmpty(prefilledText)){

View File

@ -37,6 +37,7 @@ public class Card extends BaseModel{
public List<History> history; public List<History> history;
public Instant publishedAt; public Instant publishedAt;
public Account authorAccount; public Account authorAccount;
public List<Author> authors;
public transient Drawable blurhashPlaceholder; public transient Drawable blurhashPlaceholder;
@ -52,6 +53,11 @@ public class Card extends BaseModel{
} }
if(authorAccount!=null) if(authorAccount!=null)
authorAccount.postprocess(); authorAccount.postprocess();
if(authors!=null){
for(Author a:authors){
a.postprocess();
}
}
} }
@Override @Override
@ -85,4 +91,19 @@ public class Card extends BaseModel{
@SerializedName("rich") @SerializedName("rich")
RICH RICH
} }
@Parcel
public static class Author extends BaseModel{
@RequiredField
public String name;
public String url;
public Account account;
@Override
public void postprocess() throws ObjectValidationException{
super.postprocess();
if(account!=null)
account.postprocess();
}
}
} }

View File

@ -5,6 +5,7 @@ import android.text.TextUtils;
import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.GlobalUserPreferences;
import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.Card; import org.joinmastodon.android.model.Card;
import org.joinmastodon.android.ui.text.HtmlParser; import org.joinmastodon.android.ui.text.HtmlParser;
import org.joinmastodon.android.ui.utils.CustomEmojiHelper; import org.joinmastodon.android.ui.utils.CustomEmojiHelper;
@ -26,12 +27,18 @@ public class CardViewModel{
this.parentObject=parentObject; this.parentObject=parentObject;
this.imageRequest=TextUtils.isEmpty(card.image) ? null : new UrlImageLoaderRequest(card.image, V.dp(width), V.dp(height)); this.imageRequest=TextUtils.isEmpty(card.image) ? null : new UrlImageLoaderRequest(card.image, V.dp(width), V.dp(height));
if(card.authorAccount!=null){ Account authorAccount;
parsedAuthorName=new SpannableStringBuilder(card.authorAccount.displayName); if(card.authors!=null && !card.authors.isEmpty() && card.authors.get(0).account!=null)
authorAccount=card.authors.get(0).account;
else
authorAccount=card.authorAccount;
if(authorAccount!=null){
parsedAuthorName=new SpannableStringBuilder(authorAccount.displayName);
if(AccountSessionManager.get(accountID).getLocalPreferences().customEmojiInNames) if(AccountSessionManager.get(accountID).getLocalPreferences().customEmojiInNames)
HtmlParser.parseCustomEmoji(parsedAuthorName, card.authorAccount.emojis); HtmlParser.parseCustomEmoji(parsedAuthorName, authorAccount.emojis);
authorNameEmojiHelper.setText(parsedAuthorName); authorNameEmojiHelper.setText(parsedAuthorName);
authorAvaRequest=new UrlImageLoaderRequest(GlobalUserPreferences.playGifs ? card.authorAccount.avatar : card.authorAccount.avatarStatic, V.dp(50), V.dp(50)); authorAvaRequest=new UrlImageLoaderRequest(GlobalUserPreferences.playGifs ? authorAccount.avatar : authorAccount.avatarStatic, V.dp(50), V.dp(50));
}else{ }else{
parsedAuthorName=null; parsedAuthorName=null;
authorAvaRequest=null; authorAvaRequest=null;

View File

@ -14,6 +14,7 @@ import android.widget.TextView;
import org.joinmastodon.android.R; import org.joinmastodon.android.R;
import org.joinmastodon.android.fragments.ProfileFragment; import org.joinmastodon.android.fragments.ProfileFragment;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.Card; import org.joinmastodon.android.model.Card;
import org.joinmastodon.android.model.viewmodel.CardViewModel; import org.joinmastodon.android.model.viewmodel.CardViewModel;
import org.joinmastodon.android.ui.OutlineProviders; import org.joinmastodon.android.ui.OutlineProviders;
@ -86,7 +87,9 @@ public class LinkCardHolder<T extends LinkCardHolder.LinkCardProvider> extends S
} }
String cardDomain=HtmlParser.normalizeDomain(Objects.requireNonNull(Uri.parse(card.url).getHost())); String cardDomain=HtmlParser.normalizeDomain(Objects.requireNonNull(Uri.parse(card.url).getHost()));
domain.setText(TextUtils.isEmpty(card.providerName) ? cardDomain : card.providerName); domain.setText(TextUtils.isEmpty(card.providerName) ? cardDomain : card.providerName);
if(card.authorAccount!=null){ String authorName=card.authors!=null && !card.authors.isEmpty() ? card.authors.get(0).name : card.authorName;
if(cardVM.parsedAuthorName!=null){
authorFooter.setVisibility(View.VISIBLE); authorFooter.setVisibility(View.VISIBLE);
authorChip.setVisibility(View.VISIBLE); authorChip.setVisibility(View.VISIBLE);
authorBefore.setVisibility(View.VISIBLE); authorBefore.setVisibility(View.VISIBLE);
@ -102,15 +105,15 @@ public class LinkCardHolder<T extends LinkCardHolder.LinkCardProvider> extends S
authorAfter.setVisibility(View.VISIBLE); authorAfter.setVisibility(View.VISIBLE);
authorAfter.setText(after); authorAfter.setText(after);
} }
authorName.setText(cardVM.parsedAuthorName); this.authorName.setText(cardVM.parsedAuthorName);
authorBefore.setCompoundDrawablesRelative(logoIcon, null, null, null); authorBefore.setCompoundDrawablesRelative(logoIcon, null, null, null);
}else if(!TextUtils.isEmpty(card.authorName)){ }else if(!TextUtils.isEmpty(authorName)){
authorFooter.setVisibility(View.VISIBLE); authorFooter.setVisibility(View.VISIBLE);
authorBefore.setVisibility(View.VISIBLE); authorBefore.setVisibility(View.VISIBLE);
authorBefore.setCompoundDrawables(null, null, null, null); authorBefore.setCompoundDrawables(null, null, null, null);
authorChip.setVisibility(View.GONE); authorChip.setVisibility(View.GONE);
authorAfter.setVisibility(View.GONE); authorAfter.setVisibility(View.GONE);
authorBefore.setText(itemView.getContext().getString(R.string.article_by_author, card.authorName)); authorBefore.setText(itemView.getContext().getString(R.string.article_by_author, authorName));
}else{ }else{
authorFooter.setVisibility(View.GONE); authorFooter.setVisibility(View.GONE);
} }