From 938643f9e2d22545d354515976118709b0a8c025 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Wed, 15 May 2024 15:35:30 +0200 Subject: [PATCH 1/4] fix(discover): provide WebUri for fragments Fixes an issue, where the discover fragments did not display their URL in the recents overview. --- .../fragments/discover/DiscoverFragment.java | 11 ++++++++++- .../fragments/discover/DiscoverNewsFragment.java | 14 +++++++++++++- .../discover/TrendingHashtagsFragment.java | 14 +++++++++++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java index b09cadc343..69872bd7a3 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java @@ -1,6 +1,7 @@ package org.joinmastodon.android.fragments.discover; import android.app.Fragment; +import android.app.assist.AssistContent; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; @@ -24,6 +25,7 @@ import org.joinmastodon.android.ui.tabs.TabLayout; import org.joinmastodon.android.ui.tabs.TabLayoutMediator; import org.joinmastodon.android.ui.utils.UiUtils; +import org.joinmastodon.android.utils.ProvidesAssistContent; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -35,7 +37,7 @@ import me.grishka.appkit.fragments.OnBackPressedListener; import me.grishka.appkit.utils.V; -public class DiscoverFragment extends AppKitFragment implements ScrollableToTop, OnBackPressedListener, IsOnTop { +public class DiscoverFragment extends AppKitFragment implements ScrollableToTop, OnBackPressedListener, IsOnTop, ProvidesAssistContent{ private static final int QUERY_RESULT=937; private TabLayout tabLayout; @@ -291,6 +293,13 @@ public void onFragmentResult(int reqCode, boolean success, Bundle result){ } } + @Override + public void onProvideAssistContent(AssistContent assistContent) { + callFragmentToProvideAssistContent(searchActive + ? searchFragment + : getFragmentForPage(pager.getCurrentItem()), assistContent); + } + private class DiscoverPagerAdapter extends RecyclerView.Adapter{ @NonNull @Override diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverNewsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverNewsFragment.java index b4a8d0950e..74ddb63ac7 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverNewsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverNewsFragment.java @@ -2,6 +2,7 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.view.View; @@ -19,6 +20,7 @@ import org.joinmastodon.android.ui.drawables.BlurhashCrossfadeDrawable; import org.joinmastodon.android.ui.utils.DiscoverInfoBannerHelper; import org.joinmastodon.android.ui.utils.UiUtils; +import org.joinmastodon.android.utils.ProvidesAssistContent; import java.util.ArrayList; import java.util.List; @@ -40,7 +42,7 @@ import me.grishka.appkit.utils.V; import me.grishka.appkit.views.UsableRecyclerView; -public class DiscoverNewsFragment extends BaseRecyclerFragment implements ScrollableToTop, IsOnTop{ +public class DiscoverNewsFragment extends BaseRecyclerFragment implements ScrollableToTop, IsOnTop, ProvidesAssistContent.ProvidesWebUri{ private String accountID; private DiscoverInfoBannerHelper bannerHelper; private MergeRecyclerAdapter mergeAdapter; @@ -115,6 +117,16 @@ public boolean isOnTop(){ return isRecyclerViewOnTop(list); } + @Override + public String getAccountID() { + return accountID; + } + + @Override + public Uri getWebUri(Uri.Builder base) { + return isInstanceAkkoma() ? null : base.path("/explore/links").build(); + } + private class LinksAdapter extends UsableRecyclerView.Adapter implements ImageLoaderRecyclerAdapter{ private final List data; 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 9ec45d5f14..65ef865937 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 @@ -1,5 +1,6 @@ package org.joinmastodon.android.fragments.discover; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.view.View; @@ -13,6 +14,7 @@ import org.joinmastodon.android.model.Hashtag; import org.joinmastodon.android.ui.utils.UiUtils; import org.joinmastodon.android.ui.views.HashtagChartView; +import org.joinmastodon.android.utils.ProvidesAssistContent; import java.util.List; @@ -23,7 +25,7 @@ import me.grishka.appkit.utils.BindableViewHolder; import me.grishka.appkit.views.UsableRecyclerView; -public class TrendingHashtagsFragment extends BaseRecyclerFragment implements ScrollableToTop, IsOnTop{ +public class TrendingHashtagsFragment extends BaseRecyclerFragment implements ScrollableToTop, IsOnTop, ProvidesAssistContent.ProvidesWebUri{ private String accountID; public TrendingHashtagsFragment(){ @@ -65,6 +67,16 @@ public boolean isOnTop(){ return isRecyclerViewOnTop(list); } + @Override + public String getAccountID() { + return accountID; + } + + @Override + public Uri getWebUri(Uri.Builder base) { + return isInstanceAkkoma() ? null : base.path("/explore/tags").build(); + } + private class HashtagsAdapter extends RecyclerView.Adapter{ @NonNull @Override From 1d45899f8cc658c15d2e92d2c90e065c226e93ee Mon Sep 17 00:00:00 2001 From: FineFindus Date: Wed, 15 May 2024 15:36:47 +0200 Subject: [PATCH 2/4] feat(settings): display URL in recents overview --- .../fragments/settings/BaseSettingsFragment.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/BaseSettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/BaseSettingsFragment.java index 8f0643841d..6d925fd6e6 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/BaseSettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/BaseSettingsFragment.java @@ -1,11 +1,13 @@ package org.joinmastodon.android.fragments.settings; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.view.View; import android.view.WindowInsets; import org.joinmastodon.android.R; +import org.joinmastodon.android.fragments.HasAccountID; import org.joinmastodon.android.fragments.MastodonRecyclerFragment; import org.joinmastodon.android.model.viewmodel.CheckableListItem; import org.joinmastodon.android.model.viewmodel.ListItem; @@ -14,10 +16,11 @@ import org.joinmastodon.android.ui.adapters.GenericListItemsAdapter; import org.joinmastodon.android.ui.viewholders.ListItemViewHolder; import org.joinmastodon.android.ui.viewholders.SimpleListItemViewHolder; +import org.joinmastodon.android.utils.ProvidesAssistContent; import androidx.recyclerview.widget.RecyclerView; -public abstract class BaseSettingsFragment extends MastodonRecyclerFragment>{ +public abstract class BaseSettingsFragment extends MastodonRecyclerFragment> implements HasAccountID, ProvidesAssistContent.ProvidesWebUri{ protected GenericListItemsAdapter itemsAdapter; protected String accountID; @@ -83,4 +86,14 @@ public void onApplyWindowInsets(WindowInsets insets){ } super.onApplyWindowInsets(insets); } + + @Override + public String getAccountID() { + return accountID; + } + + @Override + public Uri getWebUri(Uri.Builder base) { + return base.path("/settings").build(); + } } From 6faa497569f6fed0b546f4676f99d5ac9a24a3f9 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Wed, 15 May 2024 15:37:33 +0200 Subject: [PATCH 3/4] feat(settings): display notifications URL in recents --- .../fragments/settings/SettingsNotificationsFragment.java | 5 +++++ 1 file changed, 5 insertions(+) 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 edaf6b6d66..f7acc54963 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 @@ -363,4 +363,9 @@ private void showUnifiedPushRegisterDialog(List distributors){ rebindItem(unifiedPushItem); }).setOnCancelListener(d->rebindItem(unifiedPushItem)).show(); } + + @Override + public Uri getWebUri(Uri.Builder base) { + return base.path("/settings/preferences/notifications").build(); + } } \ No newline at end of file From 88e11f25a78f7daa4b33e209e23da16de5c5045e Mon Sep 17 00:00:00 2001 From: FineFindus Date: Wed, 15 May 2024 15:38:03 +0200 Subject: [PATCH 4/4] feat(settings): display filter URL in recents --- .../android/fragments/settings/EditFilterFragment.java | 5 +++++ .../android/fragments/settings/SettingsFiltersFragment.java | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/EditFilterFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/EditFilterFragment.java index 6aa1edea0d..aaea4b942f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/EditFilterFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/EditFilterFragment.java @@ -1,6 +1,7 @@ package org.joinmastodon.android.fragments.settings; import android.app.AlertDialog; +import android.net.Uri; import android.os.Bundle; import android.os.Parcelable; import android.view.Menu; @@ -329,4 +330,8 @@ public boolean onBackPressed(){ } return false; } + @Override + public Uri getWebUri(Uri.Builder base) { + return base.path(filter == null ? "/filters/new" : "/filters/"+ filter.id + "/edit").build(); + } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsFiltersFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsFiltersFragment.java index b2a40c9532..d0cdb6f789 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsFiltersFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsFiltersFragment.java @@ -1,5 +1,6 @@ package org.joinmastodon.android.fragments.settings; +import android.net.Uri; import android.os.Bundle; import com.squareup.otto.Subscribe; @@ -107,4 +108,9 @@ public void onFilterCreatedOrUpdated(SettingsFilterCreatedOrUpdatedEvent ev){ data.add(makeListItem(ev.filter)); itemsAdapter.notifyItemInserted(data.size()-1); } + + @Override + public Uri getWebUri(Uri.Builder base) { + return base.path("/filters").build(); + } }