Skip to content

Commit

Permalink
Merge pull request #408 from FineFindus/feat/recents
Browse files Browse the repository at this point in the history
feat: display URL in recents for more fragments
  • Loading branch information
LucasGGamerM authored May 15, 2024
2 parents e52154f + 88e11f2 commit fea9d6e
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<SimpleViewHolder>{
@NonNull
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -40,7 +42,7 @@
import me.grishka.appkit.utils.V;
import me.grishka.appkit.views.UsableRecyclerView;

public class DiscoverNewsFragment extends BaseRecyclerFragment<CardViewModel> implements ScrollableToTop, IsOnTop{
public class DiscoverNewsFragment extends BaseRecyclerFragment<CardViewModel> implements ScrollableToTop, IsOnTop, ProvidesAssistContent.ProvidesWebUri{
private String accountID;
private DiscoverInfoBannerHelper bannerHelper;
private MergeRecyclerAdapter mergeAdapter;
Expand Down Expand Up @@ -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<BaseLinkViewHolder> implements ImageLoaderRecyclerAdapter{
private final List<CardViewModel> data;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -23,7 +25,7 @@
import me.grishka.appkit.utils.BindableViewHolder;
import me.grishka.appkit.views.UsableRecyclerView;

public class TrendingHashtagsFragment extends BaseRecyclerFragment<Hashtag> implements ScrollableToTop, IsOnTop{
public class TrendingHashtagsFragment extends BaseRecyclerFragment<Hashtag> implements ScrollableToTop, IsOnTop, ProvidesAssistContent.ProvidesWebUri{
private String accountID;

public TrendingHashtagsFragment(){
Expand Down Expand Up @@ -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<HashtagViewHolder>{
@NonNull
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<T> extends MastodonRecyclerFragment<ListItem<T>>{
public abstract class BaseSettingsFragment<T> extends MastodonRecyclerFragment<ListItem<T>> implements HasAccountID, ProvidesAssistContent.ProvidesWebUri{
protected GenericListItemsAdapter<T> itemsAdapter;
protected String accountID;

Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.joinmastodon.android.fragments.settings;

import android.net.Uri;
import android.os.Bundle;

import com.squareup.otto.Subscribe;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,9 @@ private void showUnifiedPushRegisterDialog(List<String> distributors){
rebindItem(unifiedPushItem);
}).setOnCancelListener(d->rebindItem(unifiedPushItem)).show();
}

@Override
public Uri getWebUri(Uri.Builder base) {
return base.path("/settings/preferences/notifications").build();
}
}

0 comments on commit fea9d6e

Please sign in to comment.