forked from mirrors/Fedilab
Fix issue #473 - Transparent background
This commit is contained in:
parent
96a0d5e485
commit
5b164d60da
7 changed files with 77 additions and 19 deletions
|
@ -378,6 +378,8 @@ public class Timeline {
|
|||
TREND_TAG("TREND_TAG"),
|
||||
@SerializedName("TREND_MESSAGE")
|
||||
TREND_MESSAGE("TREND_MESSAGE"),
|
||||
@SerializedName("PUBLIC_TREND_MESSAGE")
|
||||
PUBLIC_TREND_MESSAGE("PUBLIC_TREND_MESSAGE"),
|
||||
@SerializedName("STATUS_HISTORY")
|
||||
STATUS_HISTORY("STATUS_HISTORY"),
|
||||
@SerializedName("ACCOUNT_TIMELINE")
|
||||
|
|
|
@ -213,6 +213,8 @@ public class Helper {
|
|||
public static final String RECEIVE_REDRAW_PROFILE = "RECEIVE_REDRAW_PROFILE";
|
||||
|
||||
public static final String ARG_TIMELINE_TYPE = "ARG_TIMELINE_TYPE";
|
||||
public static final String ARG_REMOTE_INSTANCE_STRING = "ARG_REMOTE_INSTANCE_STRING";
|
||||
|
||||
public static final String ARG_NOTIFICATION_TYPE = "ARG_NOTIFICATION_TYPE";
|
||||
public static final String ARG_EXCLUDED_NOTIFICATION_TYPE = "ARG_EXCLUDED_NOTIFICATION_TYPE";
|
||||
public static final String ARG_STATUS = "ARG_STATUS";
|
||||
|
|
|
@ -38,9 +38,28 @@ import app.fedilab.android.helper.Helper;
|
|||
|
||||
public class InstanceRegAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private final List<JoinMastodonInstance> joinMastodonInstanceList;
|
||||
public RecyclerViewClickListener itemListener;
|
||||
private Context context;
|
||||
private ViewHolder holder;
|
||||
public ActionClick actionClick;
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||
JoinMastodonInstance joinMastodonInstance = joinMastodonInstanceList.get(position);
|
||||
|
||||
ViewHolder holder = (ViewHolder) viewHolder;
|
||||
holder.binding.instanceCountUser.setText(context.getString(R.string.users, Helper.withSuffix(joinMastodonInstance.total_users)));
|
||||
holder.binding.instanceDescription.setText(joinMastodonInstance.description);
|
||||
holder.binding.instanceHost.setText(joinMastodonInstance.domain);
|
||||
holder.binding.instanceVersion.setText(String.format("%s - %s", joinMastodonInstance.categories, joinMastodonInstance.version));
|
||||
Glide.with(context)
|
||||
.load(joinMastodonInstance.proxied_thumbnail)
|
||||
.apply(new RequestOptions().transform(new FitCenter(), new RoundedCorners(10)))
|
||||
.into(holder.binding.instancePp);
|
||||
|
||||
holder.binding.getRoot().setOnClickListener(v -> actionClick.instance(position));
|
||||
|
||||
holder.binding.watchTrendig.setOnClickListener(v -> actionClick.trends(position));
|
||||
}
|
||||
|
||||
|
||||
public InstanceRegAdapter(List<JoinMastodonInstance> joinMastodonInstanceList) {
|
||||
this.joinMastodonInstanceList = joinMastodonInstanceList;
|
||||
|
@ -62,21 +81,10 @@ public class InstanceRegAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
return new ViewHolder(itemBinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||
JoinMastodonInstance joinMastodonInstance = joinMastodonInstanceList.get(position);
|
||||
public interface ActionClick {
|
||||
void instance(int position);
|
||||
|
||||
holder = (ViewHolder) viewHolder;
|
||||
holder.binding.instanceCountUser.setText(context.getString(R.string.users, Helper.withSuffix(joinMastodonInstance.total_users)));
|
||||
holder.binding.instanceDescription.setText(joinMastodonInstance.description);
|
||||
holder.binding.instanceHost.setText(joinMastodonInstance.domain);
|
||||
holder.binding.instanceVersion.setText(String.format("%s - %s", joinMastodonInstance.categories, joinMastodonInstance.version));
|
||||
Glide.with(context)
|
||||
.load(joinMastodonInstance.proxied_thumbnail)
|
||||
.apply(new RequestOptions().transform(new FitCenter(), new RoundedCorners(10)))
|
||||
.into(holder.binding.instancePp);
|
||||
|
||||
holder.binding.getRoot().setOnClickListener(v -> itemListener.recyclerViewListClicked(v, position));
|
||||
void trends(int position);
|
||||
}
|
||||
|
||||
public long getItemId(int position) {
|
||||
|
|
|
@ -31,12 +31,14 @@ import java.util.List;
|
|||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.client.entities.api.JoinMastodonInstance;
|
||||
import app.fedilab.android.client.entities.app.Timeline;
|
||||
import app.fedilab.android.databinding.FragmentLoginPickInstanceMastodonBinding;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.ui.drawer.InstanceRegAdapter;
|
||||
import app.fedilab.android.ui.fragment.timeline.FragmentMastodonTimeline;
|
||||
import app.fedilab.android.viewmodel.mastodon.JoinInstancesVM;
|
||||
|
||||
public class FragmentLoginPickInstanceMastodon extends Fragment implements InstanceRegAdapter.RecyclerViewClickListener {
|
||||
public class FragmentLoginPickInstanceMastodon extends Fragment implements InstanceRegAdapter.ActionClick {
|
||||
|
||||
|
||||
private List<JoinMastodonInstance> joinMastodonInstanceList;
|
||||
|
@ -94,7 +96,7 @@ public class FragmentLoginPickInstanceMastodon extends Fragment implements Insta
|
|||
joinMastodonInstanceList = instances;
|
||||
if (instances != null) {
|
||||
InstanceRegAdapter instanceRegAdapter = new InstanceRegAdapter(instances);
|
||||
instanceRegAdapter.itemListener = currentFragment;
|
||||
instanceRegAdapter.actionClick = currentFragment;
|
||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(requireActivity());
|
||||
binding.regCategoryView.setLayoutManager(mLayoutManager);
|
||||
binding.regCategoryView.setNestedScrollingEnabled(false);
|
||||
|
@ -122,7 +124,7 @@ public class FragmentLoginPickInstanceMastodon extends Fragment implements Insta
|
|||
|
||||
|
||||
@Override
|
||||
public void recyclerViewListClicked(View v, int position) {
|
||||
public void instance(int position) {
|
||||
if (joinMastodonInstanceList != null) {
|
||||
JoinMastodonInstance clickedInstance = joinMastodonInstanceList.get(position);
|
||||
Bundle args = new Bundle();
|
||||
|
@ -132,4 +134,19 @@ public class FragmentLoginPickInstanceMastodon extends Fragment implements Insta
|
|||
args, null, FragmentLoginRegisterMastodon.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trends(int position) {
|
||||
if (joinMastodonInstanceList != null) {
|
||||
JoinMastodonInstance clickedInstance = joinMastodonInstanceList.get(position);
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(Helper.ARG_MINIFIED, true);
|
||||
args.putSerializable(Helper.ARG_REMOTE_INSTANCE_STRING, clickedInstance.domain);
|
||||
args.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.TREND_MESSAGE);
|
||||
|
||||
Helper.addFragment(
|
||||
getParentFragmentManager(), android.R.id.content, new FragmentMastodonTimeline(),
|
||||
args, null, FragmentLoginRegisterMastodon.class.getName());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -166,6 +166,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
private String slug;
|
||||
private boolean canBeFederated;
|
||||
private boolean rememberPosition;
|
||||
private String publicTrendsDomain;
|
||||
|
||||
//Allow to recreate data when detaching/attaching fragment
|
||||
public void recreate() {
|
||||
|
@ -298,6 +299,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
canBeFederated = false;
|
||||
}
|
||||
}
|
||||
publicTrendsDomain = getArguments().getString(Helper.ARG_REMOTE_INSTANCE_STRING, null);
|
||||
isViewInitialized = getArguments().getBoolean(Helper.ARG_INITIALIZE_VIEW, true);
|
||||
tagTimeline = (TagTimeline) getArguments().getSerializable(Helper.ARG_TAG_TIMELINE);
|
||||
accountTimeline = (Account) getArguments().getSerializable(Helper.ARG_ACCOUNT);
|
||||
|
@ -986,6 +988,19 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
initializeStatusesCommonView(statuses);
|
||||
});
|
||||
}
|
||||
} else if (timelineType == Timeline.TimeLineEnum.PUBLIC_TREND_MESSAGE) {
|
||||
if (direction == null) {
|
||||
timelinesVM.getStatusTrends(null, publicTrendsDomain)
|
||||
.observe(getViewLifecycleOwner(), statusesTrends -> {
|
||||
Statuses statuses = new Statuses();
|
||||
statuses.statuses = new ArrayList<>();
|
||||
if (statusesTrends != null) {
|
||||
statuses.statuses.addAll(statusesTrends);
|
||||
}
|
||||
statuses.pagination = new Pagination();
|
||||
initializeStatusesCommonView(statuses);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,6 +82,19 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/instance_pp"
|
||||
tools:text="General-purpose server run by the lead developer of Mastodon" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/watch_trendig"
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="@string/watch_trends_for_instance"
|
||||
android:textColor="@color/cyanea_accent_dark_reference"
|
||||
app:icon="@drawable/ic_baseline_remove_red_eye_24"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/instance_description"
|
||||
app:strokeColor="@color/cyanea_accent_dark_reference" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
|
@ -1986,4 +1986,5 @@
|
|||
<string name="action_lists_edit">Edit list</string>
|
||||
<string name="profiles">Profiles</string>
|
||||
<string name="toast_feature_not_supported">Your instance does not seem to support that feature!</string>
|
||||
<string name="watch_trends_for_instance">Watch trends for this instance</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue