From 41cb0f2e094ec80b995a7e8a69e4ddc74070b6ca Mon Sep 17 00:00:00 2001 From: sk Date: Thu, 1 Jun 2023 18:38:45 +0200 Subject: [PATCH] implement assist url in instance rules --- .../android/api/session/AccountSession.java | 2 +- .../onboarding/InstanceRulesFragment.java | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java index bf4d45ca9..f8b201bda 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java @@ -99,7 +99,7 @@ public class AccountSession{ public Uri getInstanceUri() { return new Uri.Builder() .scheme("https") - .authority(domain) + .authority(getInstance().map(i -> i.uri).orElse(domain)) .build(); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceRulesFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceRulesFragment.java index c2c4fcf62..42583c5ef 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceRulesFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceRulesFragment.java @@ -2,7 +2,9 @@ package org.joinmastodon.android.fragments.onboarding; import android.annotation.SuppressLint; import android.app.Activity; +import android.app.assist.AssistContent; import android.graphics.Typeface; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.text.Html; @@ -24,6 +26,7 @@ import org.joinmastodon.android.ui.DividerItemDecoration; import org.joinmastodon.android.ui.text.HtmlParser; import org.joinmastodon.android.ui.utils.UiUtils; import org.joinmastodon.android.utils.ElevationOnScrollListener; +import org.joinmastodon.android.utils.ProvidesAssistContent; import org.parceler.Parcels; import androidx.annotation.NonNull; @@ -38,7 +41,7 @@ import me.grishka.appkit.utils.V; import me.grishka.appkit.views.FragmentRootLinearLayout; import me.grishka.appkit.views.UsableRecyclerView; -public class InstanceRulesFragment extends ToolbarFragment{ +public class InstanceRulesFragment extends ToolbarFragment implements ProvidesAssistContent { private UsableRecyclerView list; private MergeRecyclerAdapter adapter; private Button btn; @@ -47,6 +50,7 @@ public class InstanceRulesFragment extends ToolbarFragment{ private ElevationOnScrollListener onScrollListener; private static final int RULES_REQUEST=376; + private String domain; @Override public void onCreate(Bundle savedInstanceState){ @@ -59,6 +63,10 @@ public class InstanceRulesFragment extends ToolbarFragment{ super.onAttach(activity); setNavigationBarColor(UiUtils.getThemeColor(activity, R.attr.colorWindowBackground)); instance=Parcels.unwrap(getArguments().getParcelable("instance")); + // akkoma says uri is "https://example.social" while just "example.social" on mastodon + domain = instance.uri + .replaceFirst("^https://", "") + .replaceFirst("/$", ""); setTitle(R.string.instance_rules_title); } @@ -130,6 +138,15 @@ public class InstanceRulesFragment extends ToolbarFragment{ } } + @Override + public void onProvideAssistContent(AssistContent assistContent) { + assistContent.setWebUri(new Uri.Builder() + .scheme("https") + .authority(domain) + .path("/about") + .build()); + } + private class ItemsAdapter extends RecyclerView.Adapter{ @NonNull