mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Pass first message
This commit is contained in:
parent
7cfe2cbecf
commit
cbd1332213
6 changed files with 22 additions and 7 deletions
|
@ -21,6 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import app.fedilab.android.R;
|
import app.fedilab.android.R;
|
||||||
import app.fedilab.android.databinding.ActivityTimelineBinding;
|
import app.fedilab.android.databinding.ActivityTimelineBinding;
|
||||||
|
import app.fedilab.android.mastodon.client.entities.api.Status;
|
||||||
import app.fedilab.android.mastodon.client.entities.app.PinnedTimeline;
|
import app.fedilab.android.mastodon.client.entities.app.PinnedTimeline;
|
||||||
import app.fedilab.android.mastodon.client.entities.app.Timeline;
|
import app.fedilab.android.mastodon.client.entities.app.Timeline;
|
||||||
import app.fedilab.android.mastodon.helper.Helper;
|
import app.fedilab.android.mastodon.helper.Helper;
|
||||||
|
@ -45,19 +46,24 @@ public class TimelineActivity extends BaseBarActivity {
|
||||||
Timeline.TimeLineEnum timelineType = null;
|
Timeline.TimeLineEnum timelineType = null;
|
||||||
String lemmy_post_id = null;
|
String lemmy_post_id = null;
|
||||||
PinnedTimeline pinnedTimeline = null;
|
PinnedTimeline pinnedTimeline = null;
|
||||||
|
Status status = null;
|
||||||
if (b != null) {
|
if (b != null) {
|
||||||
timelineType = (Timeline.TimeLineEnum) b.get(Helper.ARG_TIMELINE_TYPE);
|
timelineType = (Timeline.TimeLineEnum) b.get(Helper.ARG_TIMELINE_TYPE);
|
||||||
lemmy_post_id = b.getString(Helper.ARG_LEMMY_POST_ID, null);
|
lemmy_post_id = b.getString(Helper.ARG_LEMMY_POST_ID, null);
|
||||||
pinnedTimeline = (PinnedTimeline) b.getSerializable(Helper.ARG_REMOTE_INSTANCE);
|
pinnedTimeline = (PinnedTimeline) b.getSerializable(Helper.ARG_REMOTE_INSTANCE);
|
||||||
|
status = (Status) b.getSerializable(Helper.ARG_STATUS);
|
||||||
}
|
}
|
||||||
if (pinnedTimeline != null && pinnedTimeline.remoteInstance != null) {
|
if (pinnedTimeline != null && pinnedTimeline.remoteInstance != null) {
|
||||||
setTitle(pinnedTimeline.remoteInstance.displayName);
|
setTitle(pinnedTimeline.remoteInstance.host);
|
||||||
}
|
}
|
||||||
FragmentMastodonTimeline fragmentMastodonTimeline = new FragmentMastodonTimeline();
|
FragmentMastodonTimeline fragmentMastodonTimeline = new FragmentMastodonTimeline();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, timelineType);
|
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, timelineType);
|
||||||
bundle.putSerializable(Helper.ARG_REMOTE_INSTANCE, pinnedTimeline);
|
bundle.putSerializable(Helper.ARG_REMOTE_INSTANCE, pinnedTimeline);
|
||||||
bundle.putSerializable(Helper.ARG_LEMMY_POST_ID, lemmy_post_id);
|
bundle.putSerializable(Helper.ARG_LEMMY_POST_ID, lemmy_post_id);
|
||||||
|
if (status != null) {
|
||||||
|
bundle.putSerializable(Helper.ARG_STATUS, status);
|
||||||
|
}
|
||||||
fragmentMastodonTimeline.setArguments(bundle);
|
fragmentMastodonTimeline.setArguments(bundle);
|
||||||
|
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
|
|
@ -139,6 +139,7 @@ public class Status implements Serializable, Cloneable {
|
||||||
public transient Spannable contentSpoilerSpan;
|
public transient Spannable contentSpoilerSpan;
|
||||||
public transient Spannable contentTranslateSpan;
|
public transient Spannable contentTranslateSpan;
|
||||||
public transient MathJaxView mathJaxView;
|
public transient MathJaxView mathJaxView;
|
||||||
|
public String lemmy_post_id;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object obj) {
|
public boolean equals(@Nullable Object obj) {
|
||||||
|
|
|
@ -33,8 +33,8 @@ public class LemmyPost implements Serializable {
|
||||||
public Comment comment;
|
public Comment comment;
|
||||||
@SerializedName("creator")
|
@SerializedName("creator")
|
||||||
public Creator creator;
|
public Creator creator;
|
||||||
@SerializedName("community")
|
/*@SerializedName("community")
|
||||||
public Community community;
|
public Community community;*/
|
||||||
@SerializedName("counts")
|
@SerializedName("counts")
|
||||||
public Counts counts;
|
public Counts counts;
|
||||||
@SerializedName("creator_banned_from_community")
|
@SerializedName("creator_banned_from_community")
|
||||||
|
@ -63,6 +63,9 @@ public class LemmyPost implements Serializable {
|
||||||
status.id = lemmyPost.comment == null ? lemmyPost.post.id : lemmyPost.comment.id;
|
status.id = lemmyPost.comment == null ? lemmyPost.post.id : lemmyPost.comment.id;
|
||||||
if (lemmyPost.comment != null) {
|
if (lemmyPost.comment != null) {
|
||||||
status.in_reply_to_id = lemmyPost.comment.post_id;
|
status.in_reply_to_id = lemmyPost.comment.post_id;
|
||||||
|
status.lemmy_post_id = null;
|
||||||
|
} else {
|
||||||
|
status.lemmy_post_id = lemmyPost.post.id;
|
||||||
}
|
}
|
||||||
status.content = lemmyPost.comment == null ? lemmyPost.post.name : lemmyPost.comment.content;
|
status.content = lemmyPost.comment == null ? lemmyPost.post.name : lemmyPost.comment.content;
|
||||||
status.visibility = "public";
|
status.visibility = "public";
|
||||||
|
|
|
@ -1995,15 +1995,15 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
} else {
|
} else {
|
||||||
if (remote) {
|
if (remote) {
|
||||||
//Lemmy main post that should open Lemmy threads
|
//Lemmy main post that should open Lemmy threads
|
||||||
if (adapter instanceof StatusAdapter && ((StatusAdapter) adapter).type == RemoteInstance.InstanceType.LEMMY) {
|
if (adapter instanceof StatusAdapter && ((StatusAdapter) adapter).type == RemoteInstance.InstanceType.LEMMY && status.lemmy_post_id != null) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable(Helper.ARG_REMOTE_INSTANCE, ((StatusAdapter) adapter).pinnedTimeline);
|
bundle.putSerializable(Helper.ARG_REMOTE_INSTANCE, ((StatusAdapter) adapter).pinnedTimeline);
|
||||||
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.REMOTE);
|
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.REMOTE);
|
||||||
bundle.putString(Helper.ARG_LEMMY_POST_ID, status.id);
|
bundle.putString(Helper.ARG_LEMMY_POST_ID, status.lemmy_post_id);
|
||||||
|
bundle.putSerializable(Helper.ARG_STATUS, status);
|
||||||
Intent intent = new Intent(context, TimelineActivity.class);
|
Intent intent = new Intent(context, TimelineActivity.class);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
} //Classic other cases for remote instances that will search the remote context
|
} //Classic other cases for remote instances that will search the remote context
|
||||||
else if (!(context instanceof ContextActivity)) { //We are not already checking a remote conversation
|
else if (!(context instanceof ContextActivity)) { //We are not already checking a remote conversation
|
||||||
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
private AccountsVM accountsVM;
|
private AccountsVM accountsVM;
|
||||||
private boolean flagLoading;
|
private boolean flagLoading;
|
||||||
private String search, searchCache;
|
private String search, searchCache;
|
||||||
private Status statusReport;
|
private Status statusReport, initialStatus /*Used to put a message at the top*/;
|
||||||
private String max_id, min_id, min_id_fetch_more, max_id_fetch_more;
|
private String max_id, min_id, min_id_fetch_more, max_id_fetch_more;
|
||||||
private Integer offset;
|
private Integer offset;
|
||||||
private StatusAdapter statusAdapter;
|
private StatusAdapter statusAdapter;
|
||||||
|
@ -414,6 +414,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
viewModelKey = getArguments().getString(Helper.ARG_VIEW_MODEL_KEY, "");
|
viewModelKey = getArguments().getString(Helper.ARG_VIEW_MODEL_KEY, "");
|
||||||
minified = getArguments().getBoolean(Helper.ARG_MINIFIED, false);
|
minified = getArguments().getBoolean(Helper.ARG_MINIFIED, false);
|
||||||
statusReport = (Status) getArguments().getSerializable(Helper.ARG_STATUS_REPORT);
|
statusReport = (Status) getArguments().getSerializable(Helper.ARG_STATUS_REPORT);
|
||||||
|
initialStatus = (Status) getArguments().getSerializable(Helper.ARG_STATUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -615,6 +616,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
if (statusReport != null) {
|
if (statusReport != null) {
|
||||||
timelineStatuses.add(statusReport);
|
timelineStatuses.add(statusReport);
|
||||||
}
|
}
|
||||||
|
if (initialStatus != null) {
|
||||||
|
timelineStatuses.add(initialStatus);
|
||||||
|
}
|
||||||
timelineStatuses.addAll(statuses.statuses);
|
timelineStatuses.addAll(statuses.statuses);
|
||||||
if (max_id == null || (statuses.pagination.max_id != null && Helper.compareTo(statuses.pagination.max_id, max_id) < 0) || timelineType.getValue().startsWith("TREND_")) {
|
if (max_id == null || (statuses.pagination.max_id != null && Helper.compareTo(statuses.pagination.max_id, max_id) < 0) || timelineType.getValue().startsWith("TREND_")) {
|
||||||
max_id = statuses.pagination.max_id;
|
max_id = statuses.pagination.max_id;
|
||||||
|
|
|
@ -336,6 +336,7 @@ public class TimelinesVM extends AndroidViewModel {
|
||||||
return statusesMutableLiveData;
|
return statusesMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public timeline for Lemmy
|
* Public timeline for Lemmy
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue