diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index 15aa323e66..2a7d7a390f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -732,10 +732,11 @@ public void getOutline(View view, Outline outline){ ? UiUtils.formatRelativeTimestamp(getContext(), status.createdAt) : getString(R.string.edited_timestamp, UiUtils.formatRelativeTimestamp(getContext(), status.editedAt)); - String sepp = getString(R.string.sk_separator); - String username = status.account.getDisplayUsername(); - ((TextView) view.findViewById(R.id.time_and_username)).setText(time == null ? username : - username + " " + sepp + " " + time); + ((TextView) view.findViewById(R.id.username)).setText(status.account.getDisplayUsername()); + view.findViewById(R.id.separator).setVisibility(time==null ? View.GONE : View.VISIBLE); + view.findViewById(R.id.time).setVisibility(time==null ? View.GONE : View.VISIBLE); + if(time!=null) ((TextView) view.findViewById(R.id.time)).setText(time); + if (status.spoilerText != null && !status.spoilerText.isBlank()) { TextView replyToSpoiler = view.findViewById(R.id.reply_to_spoiler); replyToSpoiler.setVisibility(View.VISIBLE); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/FollowRequestsListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/FollowRequestsListFragment.java index d5cdf7cc3d..87e9d28d89 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/FollowRequestsListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/FollowRequestsListFragment.java @@ -201,7 +201,7 @@ else if(image==1) } // literally the same as AccountCardStatusDisplayItem and DiscoverAccountsFragment. code should be generalized - private class AccountViewHolder extends BindableViewHolder implements ImageLoaderViewHolder, UsableRecyclerView.Clickable{ + private class AccountViewHolder extends BindableViewHolder implements ImageLoaderViewHolder, UsableRecyclerView.DisableableClickable{ private final ImageView cover, avatar; private final TextView name, username, bio, followersCount, followingCount, postsCount, followersLabel, followingLabel, postsLabel; private final ProgressBarButton actionButton, acceptButton, rejectButton; @@ -233,15 +233,24 @@ public AccountViewHolder(){ rejectProgress=findViewById(R.id.reject_progress); rejectWrap=findViewById(R.id.reject_btn_wrap); - itemView.setOutlineProvider(OutlineProviders.roundedRect(6)); - itemView.setClipToOutline(true); - avatar.setOutlineProvider(OutlineProviders.roundedRect(12)); + avatar.setOutlineProvider(OutlineProviders.roundedRect(15)); avatar.setClipToOutline(true); - cover.setOutlineProvider(OutlineProviders.roundedRect(3)); + View border=findViewById(R.id.avatar_border); + border.setOutlineProvider(OutlineProviders.roundedRect(17)); + border.setClipToOutline(true); + cover.setOutlineProvider(OutlineProviders.roundedRect(9)); cover.setClipToOutline(true); + itemView.setOutlineProvider(OutlineProviders.roundedRect(12)); + itemView.setClipToOutline(true); actionButton.setOnClickListener(this::onActionButtonClick); acceptButton.setOnClickListener(this::onFollowRequestButtonClick); rejectButton.setOnClickListener(this::onFollowRequestButtonClick); + itemView.setOnClickListener(v->this.onClick()); + } + + @Override + public boolean isEnabled(){ + return false; } @Override @@ -254,26 +263,23 @@ public void onBind(AccountWrapper item){ postsCount.setText(UiUtils.abbreviateNumber(item.account.statusesCount)); followersLabel.setText(getResources().getQuantityString(R.plurals.followers, (int)Math.min(999, item.account.followersCount))); followingLabel.setText(getResources().getQuantityString(R.plurals.following, (int)Math.min(999, item.account.followingCount))); - postsLabel.setText(getResources().getQuantityString(R.plurals.x_posts, (int)(item.account.statusesCount%1000), item.account.statusesCount)); + postsLabel.setText(getResources().getQuantityString(R.plurals.sk_posts_count_label, (int)(item.account.statusesCount%1000), item.account.statusesCount)); followersCount.setVisibility(item.account.followersCount < 0 ? View.GONE : View.VISIBLE); followersLabel.setVisibility(item.account.followersCount < 0 ? View.GONE : View.VISIBLE); followingCount.setVisibility(item.account.followingCount < 0 ? View.GONE : View.VISIBLE); followingLabel.setVisibility(item.account.followingCount < 0 ? View.GONE : View.VISIBLE); relationship=relationships.get(item.account.id); - if(relationship == null || !relationship.followedBy){ + UiUtils.setExtraTextInfo(getContext(), null, findViewById(R.id.pronouns), true, false, false, item.account); + + if(relationship==null || !relationship.followedBy){ actionWrap.setVisibility(View.GONE); acceptWrap.setVisibility(View.VISIBLE); rejectWrap.setVisibility(View.VISIBLE); - // i hate that i wasn't able to do this in xml acceptButton.setCompoundDrawableTintList(acceptButton.getTextColors()); acceptProgress.setIndeterminateTintList(acceptButton.getTextColors()); rejectButton.setCompoundDrawableTintList(rejectButton.getTextColors()); rejectProgress.setIndeterminateTintList(rejectButton.getTextColors()); - }else if(relationship==null){ - actionWrap.setVisibility(View.GONE); - acceptWrap.setVisibility(View.GONE); - rejectWrap.setVisibility(View.GONE); }else{ actionWrap.setVisibility(View.VISIBLE); acceptWrap.setVisibility(View.GONE); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java index 33cba9f522..92171e3801 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java @@ -30,7 +30,6 @@ import org.joinmastodon.android.ui.utils.DiscoverInfoBannerHelper; import org.joinmastodon.android.ui.utils.InsetStatusItemDecoration; import org.joinmastodon.android.ui.utils.UiUtils; -import org.joinmastodon.android.utils.ElevationOnScrollListener; import org.joinmastodon.android.utils.ObjectIdComparator; import org.parceler.Parcels; diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index 6581efba73..8e1bd0beaf 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -265,6 +265,8 @@ public View onCreateContentView(LayoutInflater inflater, ViewGroup container, Bu list=content.findViewById(R.id.metadata); rolesView=content.findViewById(R.id.roles); + avatarBorder.setOutlineProvider(OutlineProviders.roundedRect(26)); + avatarBorder.setClipToOutline(true); avatar.setOutlineProvider(OutlineProviders.roundedRect(24)); avatar.setClipToOutline(true); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverAccountsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverAccountsFragment.java index 8df794d56a..dff5d11e13 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverAccountsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverAccountsFragment.java @@ -43,7 +43,6 @@ import me.grishka.appkit.api.Callback; import me.grishka.appkit.api.ErrorResponse; import me.grishka.appkit.api.SimpleCallback; -import me.grishka.appkit.fragments.BaseRecyclerFragment; import me.grishka.appkit.imageloader.ImageLoaderRecyclerAdapter; import me.grishka.appkit.imageloader.ImageLoaderViewHolder; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; @@ -198,7 +197,7 @@ else if(image==1) } } - private class AccountViewHolder extends BindableViewHolder implements ImageLoaderViewHolder, UsableRecyclerView.Clickable{ + private class AccountViewHolder extends BindableViewHolder implements ImageLoaderViewHolder, UsableRecyclerView.DisableableClickable{ private final ImageView cover, avatar; private final TextView name, username, bio, followersCount, followingCount, postsCount, followersLabel, followingLabel, postsLabel; private final ProgressBarButton actionButton; @@ -224,13 +223,22 @@ public AccountViewHolder(){ actionProgress=findViewById(R.id.action_progress); actionWrap=findViewById(R.id.action_btn_wrap); - itemView.setOutlineProvider(OutlineProviders.roundedRect(12)); - itemView.setClipToOutline(true); - avatar.setOutlineProvider(OutlineProviders.roundedRect(12)); + avatar.setOutlineProvider(OutlineProviders.roundedRect(15)); avatar.setClipToOutline(true); - cover.setOutlineProvider(OutlineProviders.roundedRect(12)); + View border=findViewById(R.id.avatar_border); + border.setOutlineProvider(OutlineProviders.roundedRect(17)); + border.setClipToOutline(true); + cover.setOutlineProvider(OutlineProviders.roundedRect(9)); cover.setClipToOutline(true); + itemView.setOutlineProvider(OutlineProviders.roundedRect(12)); + itemView.setClipToOutline(true); actionButton.setOnClickListener(this::onActionButtonClick); + itemView.setOnClickListener(v->this.onClick()); + } + + @Override + public boolean isEnabled(){ + return false; } @Override @@ -243,12 +251,14 @@ public void onBind(AccountWrapper item){ postsCount.setText(UiUtils.abbreviateNumber(item.account.statusesCount)); followersLabel.setText(getResources().getQuantityString(R.plurals.followers, (int)Math.min(999, item.account.followersCount))); followingLabel.setText(getResources().getQuantityString(R.plurals.following, (int)Math.min(999, item.account.followingCount))); - postsLabel.setText(getResources().getQuantityString(R.plurals.x_posts, (int)(item.account.statusesCount%1000), item.account.statusesCount)); + postsLabel.setText(getResources().getQuantityString(R.plurals.sk_posts_count_label, (int)(item.account.statusesCount%1000), item.account.statusesCount)); followersCount.setVisibility(item.account.followersCount < 0 ? View.GONE : View.VISIBLE); followersLabel.setVisibility(item.account.followersCount < 0 ? View.GONE : View.VISIBLE); followingCount.setVisibility(item.account.followingCount < 0 ? View.GONE : View.VISIBLE); followingLabel.setVisibility(item.account.followingCount < 0 ? View.GONE : View.VISIBLE); relationship=relationships.get(item.account.id); + UiUtils.setExtraTextInfo(getContext(), null, findViewById(R.id.pronouns), true, false, false, item.account); + if(relationship==null){ actionWrap.setVisibility(View.GONE); }else{ diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/CustomWelcomeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/CustomWelcomeFragment.java index 6a2d4e2a68..2b9217d36e 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/CustomWelcomeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/CustomWelcomeFragment.java @@ -139,7 +139,9 @@ protected RecyclerView.Adapter getAdapter(){ headerView.findViewById(R.id.more).setVisibility(View.GONE); headerView.findViewById(R.id.visibility).setVisibility(View.GONE); headerView.findViewById(R.id.unread_indicator).setVisibility(View.GONE); - ((TextView) headerView.findViewById(R.id.time_and_username)).setText(R.string.mo_app_username); + headerView.findViewById(R.id.separator).setVisibility(View.GONE); + headerView.findViewById(R.id.time).setVisibility(View.GONE); + ((TextView) headerView.findViewById(R.id.username)).setText(R.string.mo_app_username); ((TextView) headerView.findViewById(R.id.name)).setText(R.string.mo_app_name); ((ImageView) headerView.findViewById(R.id.avatar)).setImageDrawable(getActivity().getDrawable(R.mipmap.ic_launcher)); ((FragmentStackActivity) getActivity()).invalidateSystemBarColors(this); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsNotificationsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsNotificationsFragment.java index d42679d913..2af1a4436b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsNotificationsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsNotificationsFragment.java @@ -102,6 +102,7 @@ public void onCreate(Bundle savedInstanceState){ typeItems=List.of(mentionsItem, boostsItem, favoritesItem, followersItem, pollsItem, updateItem, postsItem); pauseItem.checkedChangeListener=checked->onPauseNotificationsClick(true); + unifiedPushItem.checkedChangeListener=checked->onUnifiedPush(); updatePolicyItem(null); updatePauseItem(); } @@ -352,7 +353,7 @@ private void onUnifiedPush(){ private void showUnifiedPushRegisterDialog(List distributors){ new M3AlertDialogBuilder(getContext()).setTitle(R.string.sk_settings_unifiedpush_choose).setItems(distributors.toArray(String[]::new), - (dialog, which) ->{ + (dialog, which)->{ String userDistrib = distributors.get(which); UnifiedPush.saveDistributor(getContext(), userDistrib); UnifiedPush.registerApp( @@ -363,6 +364,6 @@ private void showUnifiedPushRegisterDialog(List distributors){ ); unifiedPushItem.toggle(); rebindItem(unifiedPushItem); - }).show(); + }).setOnCancelListener(d->rebindItem(unifiedPushItem)).show(); } } \ No newline at end of file diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/FilterResult.java b/mastodon/src/main/java/org/joinmastodon/android/model/FilterResult.java index fd5088bbc5..8a705eba77 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/FilterResult.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/FilterResult.java @@ -14,6 +14,7 @@ public class FilterResult extends BaseModel { @Override public void postprocess() throws ObjectValidationException { super.postprocess(); - if (filter != null) filter.postprocess(); + if(filter!=null) filter.postprocess(); + if(keywordMatches==null) keywordMatches=List.of(); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AccountCardStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AccountCardStatusDisplayItem.java index 1d2da2f318..c3f013d0b7 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AccountCardStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AccountCardStatusDisplayItem.java @@ -113,13 +113,22 @@ public Holder(Context context, ViewGroup parent){ View card=findViewById(R.id.card); card.setOutlineProvider(OutlineProviders.roundedRect(12)); card.setClipToOutline(true); - avatar.setOutlineProvider(OutlineProviders.roundedRect(12)); + avatar.setOutlineProvider(OutlineProviders.roundedRect(15)); avatar.setClipToOutline(true); - cover.setOutlineProvider(OutlineProviders.roundedRect(12)); + View border=findViewById(R.id.avatar_border); + border.setOutlineProvider(OutlineProviders.roundedRect(17)); + border.setClipToOutline(true); + cover.setOutlineProvider(OutlineProviders.roundedRect(9)); cover.setClipToOutline(true); actionButton.setOnClickListener(this::onActionButtonClick); acceptButton.setOnClickListener(this::onFollowRequestButtonClick); rejectButton.setOnClickListener(this::onFollowRequestButtonClick); + card.setOnClickListener(v->onClick()); + } + + @Override + public boolean isEnabled(){ + return false; } @Override @@ -132,18 +141,19 @@ public void onBind(AccountCardStatusDisplayItem item){ postsCount.setText(UiUtils.abbreviateNumber(item.account.statusesCount)); followersLabel.setText(item.parentFragment.getResources().getQuantityString(R.plurals.followers, (int)Math.min(999, item.account.followersCount))); followingLabel.setText(item.parentFragment.getResources().getQuantityString(R.plurals.following, (int)Math.min(999, item.account.followingCount))); - postsLabel.setText(item.parentFragment.getResources().getQuantityString(R.plurals.x_posts, (int)(item.account.statusesCount%1000), item.account.statusesCount)); + postsLabel.setText(item.parentFragment.getResources().getQuantityString(R.plurals.sk_posts_count_label, (int)(item.account.statusesCount%1000), item.account.statusesCount)); followersCount.setVisibility(item.account.followersCount < 0 ? View.GONE : View.VISIBLE); followersLabel.setVisibility(item.account.followersCount < 0 ? View.GONE : View.VISIBLE); followingCount.setVisibility(item.account.followingCount < 0 ? View.GONE : View.VISIBLE); followingLabel.setVisibility(item.account.followingCount < 0 ? View.GONE : View.VISIBLE); relationship=item.parentFragment.getRelationship(item.account.id); - if(item.notification.type == Notification.Type.FOLLOW_REQUEST && (relationship == null || !relationship.followedBy)){ + UiUtils.setExtraTextInfo(item.parentFragment.getContext(), null, findViewById(R.id.pronouns), true, false, false, item.account); + + if(item.notification.type==Notification.Type.FOLLOW_REQUEST && (relationship==null || !relationship.followedBy)){ actionWrap.setVisibility(View.GONE); acceptWrap.setVisibility(View.VISIBLE); rejectWrap.setVisibility(View.VISIBLE); - // i hate that i wasn't able to do this in xml acceptButton.setCompoundDrawableTintList(acceptButton.getTextColors()); acceptProgress.setIndeterminateTintList(acceptButton.getTextColors()); rejectButton.setCompoundDrawableTintList(rejectButton.getTextColors()); @@ -163,7 +173,7 @@ public void onBind(AccountCardStatusDisplayItem item){ private void onFollowRequestButtonClick(View v) { itemView.setHasTransientState(true); UiUtils.handleFollowRequest((Activity) v.getContext(), item.account, item.parentFragment.getAccountID(), null, v == acceptButton, relationship, rel -> { - if(v.getContext()==null) return; + if(v.getContext()==null || rel==null) return; itemView.setHasTransientState(false); item.parentFragment.putRelationship(item.account.id, rel); RecyclerView.Adapter adapter = getBindingAdapter(); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java index 41f9d7ede6..6425f2af3b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java @@ -132,8 +132,8 @@ public ImageLoaderRequest getImageRequest(int index){ } public static class Holder extends StatusDisplayItem.Holder implements ImageLoaderViewHolder{ - private final TextView name, timeAndUsername, extraText, pronouns; - private final View collapseBtn; + private final TextView name, time, username, extraText, pronouns; + private final View collapseBtn, timeUsernameSeparator; private final ImageView avatar, more, visibility, deleteNotification, unreadIndicator, markAsRead, collapseBtnIcon; private final PopupMenu optionsMenu; private Relationship relationship; @@ -148,7 +148,9 @@ public Holder(Activity activity, ViewGroup parent){ protected Holder(Activity activity, @LayoutRes int layout, ViewGroup parent){ super(activity, layout, parent); name=findViewById(R.id.name); - timeAndUsername=findViewById(R.id.time_and_username); + time=findViewById(R.id.time); + username=findViewById(R.id.username); + timeUsernameSeparator=findViewById(R.id.separator); avatar=findViewById(R.id.avatar); more=findViewById(R.id.more); visibility=findViewById(R.id.visibility); @@ -318,10 +320,10 @@ public void onBind(HeaderStatusDisplayItem item){ else if (item.status != null && item.status.editedAt != null) time=item.parentFragment.getString(R.string.edited_timestamp, UiUtils.formatRelativeTimestamp(itemView.getContext(), item.status.editedAt)); - String sepp = item.parentFragment.getString(R.string.sk_separator); - String username = "@" + item.user.acct; - timeAndUsername.setText(time == null ? username : - username + " " + sepp + " " + time); + this.username.setText(item.user.getDisplayUsername()); + this.timeUsernameSeparator.setVisibility(time==null ? View.GONE : View.VISIBLE); + this.time.setVisibility(time==null ? View.GONE : View.VISIBLE); + if(time!=null) this.time.setText(time); deleteNotification.setVisibility(GlobalUserPreferences.enableDeleteNotifications && item.notification!=null && !item.inset ? View.VISIBLE : View.GONE); if (item.hasVisibilityToggle){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/LinkCardStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/LinkCardStatusDisplayItem.java index 454a94491e..6425775f6e 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/LinkCardStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/LinkCardStatusDisplayItem.java @@ -6,6 +6,7 @@ import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; @@ -13,12 +14,14 @@ import org.joinmastodon.android.fragments.BaseStatusListFragment; 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.utils.UiUtils; import me.grishka.appkit.imageloader.ImageLoaderViewHolder; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest; +import me.grishka.appkit.utils.V; public class LinkCardStatusDisplayItem extends StatusDisplayItem{ private final Status status; @@ -51,6 +54,7 @@ public ImageLoaderRequest getImageRequest(int index){ public static class Holder extends StatusDisplayItem.Holder implements ImageLoaderViewHolder{ private final TextView title, description, domain; private final ImageView photo; + private final View inner; private BlurhashCrossfadeDrawable crossfadeDrawable=new BlurhashCrossfadeDrawable(); private boolean didClear; @@ -60,7 +64,8 @@ public Holder(Context context, ViewGroup parent){ description=findViewById(R.id.description); domain=findViewById(R.id.domain); photo=findViewById(R.id.photo); - findViewById(R.id.inner).setOnClickListener(this::onClick); + inner=findViewById(R.id.inner); + inner.setOnClickListener(this::onClick); } @Override @@ -85,6 +90,15 @@ public void onBind(LinkCardStatusDisplayItem item){ photo.setImageDrawable(crossfadeDrawable); didClear=false; } + + // if there's no image, we don't want to cover the inset borders + FrameLayout.LayoutParams params=(FrameLayout.LayoutParams) inner.getLayoutParams(); + int margin=item.inset && item.imgRequest == null ? V.dp(1) : 0; + params.setMargins(margin, 0, margin, margin); + + boolean insetAndLast=item.inset && isLastDisplayItemForStatus(); + inner.setClipToOutline(insetAndLast); + inner.setOutlineProvider(insetAndLast ? OutlineProviders.bottomRoundedRect(12) : null); } @Override diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/MediaGridStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/MediaGridStatusDisplayItem.java index b47d82234c..989522f995 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/MediaGridStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/MediaGridStatusDisplayItem.java @@ -26,6 +26,7 @@ import org.joinmastodon.android.fragments.BaseStatusListFragment; import org.joinmastodon.android.model.Attachment; import org.joinmastodon.android.model.Status; +import org.joinmastodon.android.ui.OutlineProviders; import org.joinmastodon.android.ui.PhotoLayoutHelper; import org.joinmastodon.android.ui.drawables.SpoilerStripesDrawable; import org.joinmastodon.android.ui.photoviewer.PhotoViewerHost; @@ -210,6 +211,10 @@ else if (!item.status.sensitive) sensitiveText.setText(R.string.media_hidden); else sensitiveText.setText(R.string.sensitive_content_explain); + + boolean insetAndLast=item.inset && isLastDisplayItemForStatus(); + wrapper.setClipToOutline(insetAndLast); + wrapper.setOutlineProvider(insetAndLast ? OutlineProviders.bottomRoundedRect(12) : null); } @Override diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java index a62feed76e..b53eec55a3 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java @@ -18,7 +18,6 @@ import org.joinmastodon.android.fragments.HomeTabFragment; import org.joinmastodon.android.fragments.ListTimelineFragment; import org.joinmastodon.android.fragments.ProfileFragment; -import org.joinmastodon.android.fragments.ScheduledStatusListFragment; import org.joinmastodon.android.fragments.ThreadFragment; import org.joinmastodon.android.model.Account; import org.joinmastodon.android.model.Attachment; @@ -51,7 +50,7 @@ public abstract class StatusDisplayItem{ public final String parentID; public final BaseStatusListFragment parentFragment; - public boolean inset; + public boolean inset, insetPadding=true; public int index; public boolean hasDescendantNeighbor = false, @@ -392,6 +391,43 @@ public void onClick(){ item.parentFragment.onItemClick(item.parentID); } + public Optional getNextVisibleDisplayItem(){ + Optional next=getNextDisplayItem(); + for(int offset=1; next.isPresent(); next=getDisplayItemOffset(++offset)){ + if(!next.map(n-> + (n instanceof EmojiReactionsStatusDisplayItem e && e.isHidden()) || + (n instanceof DummyStatusDisplayItem) + ).orElse(false)) return next; + } + return Optional.empty(); + } +// int nextNextPos=getAbsoluteAdapterPosition() + 2; +// if(next.map(n->n instanceof EmojiReactionsStatusDisplayItem e && e.isHidden()).orElse(false)){ +// List displayItems=item.parentFragment.getDisplayItems(); +// return displayItems.size() > nextNextPos +// ? Optional.of(displayItems.get(nextNextPos)) +// : Optional.empty(); +// }else{ +// return next; +// } + public Optional getNextDisplayItem(){ + return getDisplayItemOffset(1); + } + + public Optional getDisplayItemOffset(int offset){ + int nextPos=getAbsoluteAdapterPosition() + offset; + List displayItems=item.parentFragment.getDisplayItems(); + return displayItems.size() > nextPos + ? Optional.of(displayItems.get(nextPos)) + : Optional.empty(); + } + + public boolean isLastDisplayItemForStatus(){ + return getNextVisibleDisplayItem() + .map(n->!n.parentID.equals(item.parentID)) + .orElse(true); + } + @Override public boolean isEnabled(){ return item.parentFragment.isItemEnabled(item.parentID); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java index 49de5f1aa5..8512569a30 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java @@ -32,8 +32,6 @@ import org.joinmastodon.android.ui.views.LinkedTextView; import org.joinmastodon.android.utils.StatusTextEncoder; -import java.util.ArrayList; -import java.util.List; import java.util.Locale; import java.util.regex.Pattern; @@ -185,21 +183,13 @@ public void onBind(TextStatusDisplayItem item){ readMore.setText(item.status.textExpanded ? R.string.sk_collapse : R.string.sk_expand); - // remove additional padding when (transparently padded) translate button is visible - int nextPos=getAbsoluteAdapterPosition() + 1; - int bottomPadding=V.dp(12); - List displayItems=item.parentFragment.getDisplayItems(); - if(displayItems.size() > nextPos){ - StatusDisplayItem next=displayItems.get(nextPos); - if(next instanceof EmojiReactionsStatusDisplayItem e && e.isHidden()){ - next=displayItems.size() > ++nextPos ? displayItems.get(nextPos) : null; - } - - if(next instanceof FooterStatusDisplayItem) bottomPadding=V.dp(6); - else if((!item.inset && next instanceof DummyStatusDisplayItem) - || next instanceof EmojiReactionsStatusDisplayItem e && !e.isHidden() - ) bottomPadding=0; - } + StatusDisplayItem next=getNextVisibleDisplayItem().orElse(null); + int bottomPadding=next instanceof FooterStatusDisplayItem + ? V.dp(6) + : (!item.inset && next instanceof DummyStatusDisplayItem) || + next instanceof EmojiReactionsStatusDisplayItem e && !e.isHidden() + ? 0 + : V.dp(12); itemView.setPadding(itemView.getPaddingLeft(), itemView.getPaddingTop(), itemView.getPaddingRight(), bottomPadding); if (!GlobalUserPreferences.collapseLongPosts) { diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/InsetStatusItemDecoration.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/InsetStatusItemDecoration.java index 4f9df284d7..6361ab7c65 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/InsetStatusItemDecoration.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/InsetStatusItemDecoration.java @@ -8,8 +8,6 @@ import org.joinmastodon.android.R; import org.joinmastodon.android.fragments.BaseStatusListFragment; -import org.joinmastodon.android.ui.displayitems.LinkCardStatusDisplayItem; -import org.joinmastodon.android.ui.displayitems.MediaGridStatusDisplayItem; import org.joinmastodon.android.ui.displayitems.StatusDisplayItem; import java.util.List; @@ -97,10 +95,10 @@ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull R pad=V.dp(16); // else // pad=V.dp(12); - boolean insetLeft=true, insetRight=true; - if(insetLeft) + boolean insetPadding=((StatusDisplayItem.Holder) holder).getItem().insetPadding; + if(insetPadding) outRect.left=pad; - if(insetRight) + if(insetPadding) outRect.right=pad; // had to comment this out because animations with offsets aren't handled properly. diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index 7f2367bafa..8d73e27408 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -756,9 +756,6 @@ public static void setRelationshipToActionButtonM3(Relationship relationship, Bu if(relationship.blocking){ button.setText(R.string.button_blocked); styleRes=R.style.Widget_Mastodon_M3_Button_Tonal_Error; - }else if(relationship.blockedBy){ - button.setText(R.string.button_follow); - styleRes=R.style.Widget_Mastodon_M3_Button_Filled; }else if(relationship.requested){ button.setText(R.string.button_follow_pending); styleRes=R.style.Widget_Mastodon_M3_Button_Tonal; @@ -770,7 +767,6 @@ public static void setRelationshipToActionButtonM3(Relationship relationship, Bu styleRes=R.style.Widget_Mastodon_M3_Button_Tonal; } - button.setEnabled(!relationship.blockedBy); TypedArray ta=button.getContext().obtainStyledAttributes(styleRes, new int[]{android.R.attr.background}); button.setBackground(ta.getDrawable(0)); ta.recycle(); @@ -1107,8 +1103,8 @@ public static MenuItem makeBackItem(Menu m) { return back; } - public static boolean setExtraTextInfo(Context ctx, TextView extraText, TextView pronouns, boolean displayPronouns, boolean mentionedOnly, boolean localOnly, @Nullable Account account) { - List extraParts = new ArrayList<>(); + public static boolean setExtraTextInfo(Context ctx, @Nullable TextView extraText, @Nullable TextView pronouns, boolean displayPronouns, boolean mentionedOnly, boolean localOnly, @Nullable Account account) { + List extraParts = extraText!=null && (localOnly || mentionedOnly) ? new ArrayList<>() : null; Optional p=pronouns==null || !displayPronouns ? Optional.empty() : extractPronouns(ctx, account); if(p.isPresent()) { HtmlParser.setTextWithCustomEmoji(pronouns, p.get(), account.emojis); @@ -1120,7 +1116,7 @@ public static boolean setExtraTextInfo(Context ctx, TextView extraText, TextView extraParts.add(ctx.getString(R.string.sk_inline_local_only)); if(mentionedOnly) extraParts.add(ctx.getString(R.string.sk_inline_direct)); - if(!extraParts.isEmpty()) { + if(extraText!=null && extraParts!=null && !extraParts.isEmpty()) { String sepp = ctx.getString(R.string.sk_separator); String text = String.join(" " + sepp + " ", extraParts); if(account == null) extraText.setText(text); @@ -1128,7 +1124,7 @@ public static boolean setExtraTextInfo(Context ctx, TextView extraText, TextView extraText.setVisibility(View.VISIBLE); return true; }else{ - extraText.setVisibility(View.GONE); + if(extraText!=null) extraText.setVisibility(View.GONE); return false; } } diff --git a/mastodon/src/main/res/drawable/bg_button_m3_tonal_error.xml b/mastodon/src/main/res/drawable/bg_button_m3_tonal_error.xml index f68223dd12..844e37ac5b 100644 --- a/mastodon/src/main/res/drawable/bg_button_m3_tonal_error.xml +++ b/mastodon/src/main/res/drawable/bg_button_m3_tonal_error.xml @@ -2,7 +2,7 @@ - + @@ -11,9 +11,13 @@ - - - - + + + + + + + + \ No newline at end of file diff --git a/mastodon/src/main/res/drawable/bg_filled_card.xml b/mastodon/src/main/res/drawable/bg_filled_card.xml new file mode 100644 index 0000000000..99cbc0946e --- /dev/null +++ b/mastodon/src/main/res/drawable/bg_filled_card.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mastodon/src/main/res/drawable/ic_fluent_alert_arrow_up_24_regular.xml b/mastodon/src/main/res/drawable/ic_fluent_alert_arrow_up_24_regular.xml index b6cca57608..e5fdceaf0b 100644 --- a/mastodon/src/main/res/drawable/ic_fluent_alert_arrow_up_24_regular.xml +++ b/mastodon/src/main/res/drawable/ic_fluent_alert_arrow_up_24_regular.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="@color/fluent_default_icon_tint"/> + android:fillColor="@color/fluent_default_icon_tint"/> diff --git a/mastodon/src/main/res/drawable/profile_ava_bg.xml b/mastodon/src/main/res/drawable/profile_ava_bg.xml deleted file mode 100644 index a8ae1c611f..0000000000 --- a/mastodon/src/main/res/drawable/profile_ava_bg.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/mastodon/src/main/res/layout/display_item_header.xml b/mastodon/src/main/res/layout/display_item_header.xml index 57752e2db7..abf47a7bbd 100644 --- a/mastodon/src/main/res/layout/display_item_header.xml +++ b/mastodon/src/main/res/layout/display_item_header.xml @@ -152,20 +152,51 @@ - + android:layout_marginBottom="3sp"> + + + + + + + + + \ No newline at end of file diff --git a/mastodon/src/main/res/layout/fragment_profile.xml b/mastodon/src/main/res/layout/fragment_profile.xml index 405170f7b5..cb77e81ee3 100644 --- a/mastodon/src/main/res/layout/fragment_profile.xml +++ b/mastodon/src/main/res/layout/fragment_profile.xml @@ -62,8 +62,7 @@ android:layout_alignParentStart="true" android:layout_marginStart="12dp" android:layout_marginTop="-44dp" - android:background="@drawable/profile_ava_bg" - android:outlineProvider="@null"> + android:background="?colorM3Surface"> + android:background="@drawable/bg_filled_card"> - + android:layout_marginTop="-12dp" + android:layout_marginStart="13dp" + android:layout_marginEnd="12dp"> - + - + + + + + + android:layout_above="@+id/username"> + + + + + + + + @android:color/system_neutral2_100 @android:color/system_neutral2_50 @android:color/system_neutral2_50 - @android:color/system_neutral2_10 + @android:color/system_neutral2_10 @android:color/system_accent2_10 @android:color/system_accent2_50 diff --git a/mastodon/src/main/res/values/attrs.xml b/mastodon/src/main/res/values/attrs.xml index 78f2b69062..1afa2fd236 100644 --- a/mastodon/src/main/res/values/attrs.xml +++ b/mastodon/src/main/res/values/attrs.xml @@ -35,6 +35,7 @@ + diff --git a/mastodon/src/main/res/values/colors.xml b/mastodon/src/main/res/values/colors.xml index 629fdeb1f4..13a2729cd9 100644 --- a/mastodon/src/main/res/values/colors.xml +++ b/mastodon/src/main/res/values/colors.xml @@ -126,7 +126,7 @@ @color/gray_100 @color/gray_50t @color/gray_50 - @color/gray_25 + @color/gray_25 @color/primary_25 @color/primary_50 diff --git a/mastodon/src/main/res/values/palettes.xml b/mastodon/src/main/res/values/palettes.xml index 9d8163c4a7..f49fc48210 100644 --- a/mastodon/src/main/res/values/palettes.xml +++ b/mastodon/src/main/res/values/palettes.xml @@ -31,6 +31,7 @@