Provide URLs for the link button thing in system app switcher

closes #632
This commit is contained in:
Grishka 2024-10-30 14:27:44 +03:00
parent 3de494f9e9
commit 6082a0bcd8
5 changed files with 42 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package org.joinmastodon.android;
import android.Manifest;
import android.app.Application;
import android.app.Fragment;
import android.app.assist.AssistContent;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
@ -16,6 +17,7 @@ import org.joinmastodon.android.api.ObjectValidationException;
import org.joinmastodon.android.api.requests.search.GetSearchResults;
import org.joinmastodon.android.api.session.AccountSession;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.fragments.AssistContentProviderFragment;
import org.joinmastodon.android.fragments.ComposeFragment;
import org.joinmastodon.android.fragments.HomeFragment;
import org.joinmastodon.android.fragments.ProfileFragment;
@ -229,4 +231,11 @@ public class MainActivity extends FragmentStackActivity{
return null;
return getFragmentManager().findFragmentById(fragmentContainers.get(fragmentContainers.size()-1).getId());
}
@Override
public void onProvideAssistContent(AssistContent outContent){
if(getTopmostFragment() instanceof AssistContentProviderFragment provider){
provider.onProvideAssistContent(outContent);
}
}
}

View File

@ -0,0 +1,7 @@
package org.joinmastodon.android.fragments;
import android.app.assist.AssistContent;
public interface AssistContentProviderFragment{
void onProvideAssistContent(AssistContent content);
}

View File

@ -3,6 +3,7 @@ package org.joinmastodon.android.fragments;
import android.annotation.SuppressLint;
import android.app.Fragment;
import android.app.NotificationManager;
import android.app.assist.AssistContent;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -57,7 +58,7 @@ import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest;
import me.grishka.appkit.utils.V;
import me.grishka.appkit.views.FragmentRootLinearLayout;
public class HomeFragment extends AppKitFragment{
public class HomeFragment extends AppKitFragment implements AssistContentProviderFragment{
private FragmentRootLinearLayout content;
private HomeTimelineFragment homeTimelineFragment;
private NotificationsListFragment notificationsFragment;
@ -379,4 +380,11 @@ public class HomeFragment extends AppKitFragment{
if(notificationsFragment.loaded)
notificationsFragment.rebuildAllDisplayItems();
}
@Override
public void onProvideAssistContent(AssistContent content){
if(fragmentForTab(currentTab) instanceof AssistContentProviderFragment provider){
provider.onProvideAssistContent(content);
}
}
}

View File

@ -6,6 +6,7 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.Fragment;
import android.app.assist.AssistContent;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
@ -108,7 +109,7 @@ import me.grishka.appkit.utils.CubicBezierInterpolator;
import me.grishka.appkit.utils.V;
import me.grishka.appkit.views.FragmentRootLinearLayout;
public class ProfileFragment extends LoaderFragment implements ScrollableToTop{
public class ProfileFragment extends LoaderFragment implements ScrollableToTop, AssistContentProviderFragment{
private static final int AVATAR_RESULT=722;
private static final int COVER_RESULT=343;
@ -1218,6 +1219,13 @@ public class ProfileFragment extends LoaderFragment implements ScrollableToTop{
return actionButton.getVisibility()==View.VISIBLE && actionButtonWrap.getTop()+actionButtonWrap.getHeight()>scrollView.getScrollY();
}
@Override
public void onProvideAssistContent(AssistContent content){
if(account!=null){
content.setWebUri(Uri.parse(account.url));
}
}
private class ProfilePagerAdapter extends RecyclerView.Adapter<SimpleViewHolder>{
@NonNull
@Override

View File

@ -1,8 +1,10 @@
package org.joinmastodon.android.fragments;
import android.app.assist.AssistContent;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
@ -46,7 +48,7 @@ import me.grishka.appkit.utils.MergeRecyclerAdapter;
import me.grishka.appkit.utils.SingleViewRecyclerAdapter;
import me.grishka.appkit.utils.V;
public class ThreadFragment extends StatusListFragment{
public class ThreadFragment extends StatusListFragment implements AssistContentProviderFragment{
private Status mainStatus;
private ImageView endMark;
private FrameLayout replyContainer;
@ -260,6 +262,11 @@ public class ThreadFragment extends StatusListFragment{
return null;
}
@Override
public void onProvideAssistContent(AssistContent content){
content.setWebUri(Uri.parse(mainStatus.url));
}
private class ReplyLinesItemDecoration extends RecyclerView.ItemDecoration{
private Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG);