diff --git a/mastodon/src/main/java/org/joinmastodon/android/ExternalShareActivity.java b/mastodon/src/main/java/org/joinmastodon/android/ExternalShareActivity.java index c94a91d9ed..96e145d012 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ExternalShareActivity.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ExternalShareActivity.java @@ -35,7 +35,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState){ Optional text = Optional.ofNullable(getIntent().getStringExtra(Intent.EXTRA_TEXT)); Optional>> fediHandle = text.flatMap(UiUtils::parseFediverseHandle); - boolean isFediUrl = text.map(UiUtils::looksLikeMastodonUrl).orElse(false); + boolean isFediUrl = text.map(UiUtils::looksLikeFediverseUrl).orElse(false); boolean isOpenable = isFediUrl || fediHandle.isPresent(); List sessions=AccountSessionManager.getInstance().getLoggedInAccounts(); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index 55796ca855..d78771c06d 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -35,7 +35,9 @@ import org.joinmastodon.android.model.Poll; import org.joinmastodon.android.model.Relationship; import org.joinmastodon.android.model.Status; +import org.joinmastodon.android.model.Translation; import org.joinmastodon.android.ui.BetterItemAnimator; +import org.joinmastodon.android.ui.M3AlertDialogBuilder; import org.joinmastodon.android.ui.displayitems.AccountStatusDisplayItem; import org.joinmastodon.android.ui.displayitems.EmojiReactionsStatusDisplayItem; import org.joinmastodon.android.ui.displayitems.ExtendedFooterStatusDisplayItem; @@ -63,6 +65,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HashtagTimelineFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HashtagTimelineFragment.java index 39b8e16dec..f372108afb 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HashtagTimelineFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HashtagTimelineFragment.java @@ -16,12 +16,20 @@ import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + import org.joinmastodon.android.R; import org.joinmastodon.android.api.MastodonErrorResponse; +import org.joinmastodon.android.api.requests.filters.CreateFilter; +import org.joinmastodon.android.api.requests.filters.DeleteFilter; import org.joinmastodon.android.api.requests.tags.GetTag; import org.joinmastodon.android.api.requests.tags.SetTagFollowed; import org.joinmastodon.android.api.requests.timelines.GetHashtagTimeline; +import org.joinmastodon.android.model.Filter; +import org.joinmastodon.android.model.FilterAction; import org.joinmastodon.android.model.FilterContext; +import org.joinmastodon.android.model.FilterKeyword; import org.joinmastodon.android.model.Hashtag; import org.joinmastodon.android.model.Status; import org.joinmastodon.android.model.TimelineDefinition; @@ -62,6 +70,8 @@ public class HashtagTimelineFragment extends PinnableStatusListFragment{ private Menu optionsMenu; private MenuInflater optionsMenuInflater; + private Optional filter = Optional.empty(); + @Override protected boolean wantsComposeButton() { return true; @@ -191,14 +201,14 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy){ @Override public boolean onFabLongClick(View v) { - return UiUtils.pickAccountForCompose(getActivity(), accountID, '#'+hashtag+' '); + return UiUtils.pickAccountForCompose(getActivity(), accountID, '#'+hashtagName+' '); } @Override public void onFabClick(View v){ Bundle args=new Bundle(); args.putString("account", accountID); - args.putString("prefilledText", '#'+hashtag+' '); + args.putString("prefilledText", '#'+hashtagName+' '); Nav.go(getActivity(), ComposeFragment.class, args); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/TrendingHashtagsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/TrendingHashtagsFragment.java index 26b9a8439a..de7b26bd22 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/TrendingHashtagsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/TrendingHashtagsFragment.java @@ -111,7 +111,7 @@ public void onBind(Hashtag item){ @Override public void onClick(){ - UiUtils.openHashtagTimeline(getActivity(), accountID, item.name, item.following); + UiUtils.openHashtagTimeline(getActivity(), accountID, item.name); } } } 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 19dc38d6bf..4ba17bca1a 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 @@ -19,8 +19,6 @@ import org.joinmastodon.android.fragments.BaseStatusListFragment; import org.joinmastodon.android.model.Status; import org.joinmastodon.android.model.Translation; -import org.joinmastodon.android.model.StatusPrivacy; -import org.joinmastodon.android.model.TranslatedStatus; import org.joinmastodon.android.ui.text.HtmlParser; import org.joinmastodon.android.ui.utils.CustomEmojiHelper; import org.joinmastodon.android.ui.utils.UiUtils; 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 cd5b18b6d0..8cab117d78 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 @@ -220,11 +220,20 @@ public static String formatPeriodBetween(Context context, Instant since, Instant if(diff<1000L){ return context.getString(R.string.time_now); }else if(diff<60_000L){ - return context.getString(ago ? R.string.time_seconds_ago_short : R.string.sk_time_seconds, diff/1000L); + long time = diff/1000L; + return ago ? + context.getString(R.string.time_seconds_ago_short, time) : + context.getResources().getQuantityString(R.plurals.sk_time_seconds, (int) time, time); }else if(diff<3600_000L){ - return context.getString(ago ? R.string.time_minutes_ago_short : R.string.sk_time_minutes, diff/60_000L); + long time = diff/60_000L; + return ago ? + context.getString(R.string.time_minutes_ago_short, time) : + context.getResources().getQuantityString(R.plurals.sk_time_minutes, (int) time, time); }else if(diff<3600_000L*24L){ - return context.getString(ago ? R.string.time_hours_ago_short : R.string.sk_time_hours, diff/3600_000L); + long time = diff/3600_000L; + return ago ? + context.getString(R.string.time_hours_ago_short, time) : + context.getResources().getQuantityString(R.plurals.sk_time_hours, (int) time, time); } else { int days = (int) (diff / (3600_000L * 24L)); if (ago && days > 30) { @@ -235,7 +244,7 @@ public static String formatPeriodBetween(Context context, Instant since, Instant return DATE_FORMATTER_SHORT_WITH_YEAR.format(dt); } } - return context.getString(ago ? R.string.time_days_ago_short : R.string.sk_time_days, days); + return ago ? context.getString(R.string.time_days_ago_short, days) : context.getResources().getQuantityString(R.plurals.sk_time_days, days, days); } } @@ -1094,7 +1103,7 @@ public static Optional>> parseFediverseHandle(Stri // https://foo.microblog.pub/o/5b64045effd24f48a27d7059f6cb38f5 // // COPIED FROM https://github.com/tuskyapp/Tusky/blob/develop/app/src/main/java/com/keylesspalace/tusky/util/LinkHelper.kt - public static boolean looksLikeMastodonUrl(String urlString) { + public static boolean looksLikeFediverseUrl(String urlString) { if(urlString == null) return false; URI uri;