Fix Nitter Pagination + Allow to share through Nitter

This commit is contained in:
Thomas 2022-07-10 12:20:18 +02:00
parent b158d01311
commit c17e2c4ba4
4 changed files with 63 additions and 3 deletions

View File

@ -105,8 +105,8 @@ public class Nitter implements Serializable {
}
}
Nitter nitterAccount = accounts.get(feedItem.creator);
app.fedilab.android.client.entities.api.Account account = new app.fedilab.android.client.entities.api.Account();
if (nitterAccount != null) {
app.fedilab.android.client.entities.api.Account account = new app.fedilab.android.client.entities.api.Account();
String[] names = nitterAccount.image.title.split("/");
account.id = feedItem.guid;
account.acct = names[1].replace("@", "");
@ -116,6 +116,15 @@ public class Nitter implements Serializable {
account.avatar_static = nitterAccount.image.url;
account.url = nitterAccount.image.link;
status.account = account;
} else {
account.id = feedItem.guid;
account.acct = feedItem.creator.replace("@", "");
account.username = feedItem.creator.replace("@", "");
account.display_name = feedItem.creator.replace("@", "");
account.avatar = "";
account.avatar_static = "";
account.url = feedItem.link;
status.account = account;
}
if (feedItem.description != null) {

View File

@ -471,6 +471,35 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
} else {
holder.binding.card.setVisibility(View.GONE);
}
if (!canBeFederated) {
holder.binding.actionShareContainer.setVisibility(View.VISIBLE);
holder.binding.actionShare.setOnClickListener(v -> {
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
String url;
if (statusToDeal.uri.startsWith("http"))
url = status.uri;
else
url = status.url;
String extra_text;
if (share_details) {
extra_text = statusToDeal.account.acct;
if (extra_text.split("@").length == 1)
extra_text = "@" + extra_text + "@" + BaseMainActivity.currentInstance;
else
extra_text = "@" + extra_text;
extra_text += " \uD83D\uDD17 " + url + "\r\n-\n";
extra_text += statusToDeal.text;
} else {
extra_text = url;
}
sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
});
} else {
holder.binding.actionShareContainer.setVisibility(View.GONE);
}
if (minified || !canBeFederated) {
holder.binding.actionButtons.setVisibility(View.GONE);
} else {

View File

@ -219,7 +219,6 @@ public class TimelinesVM extends AndroidViewModel {
statusesMutableLiveData = new MutableLiveData<>();
new Thread(() -> {
Call<Nitter> publicTlCall = mastodonTimelinesService.getNitter(accountsStr, max_position);
Statuses statuses = new Statuses();
if (publicTlCall != null) {
try {
@ -234,7 +233,9 @@ public class TimelinesVM extends AndroidViewModel {
}
}
statuses.statuses = SpannableHelper.convertNitterStatus(getApplication().getApplicationContext(), statusList);
statuses.pagination = MastodonHelper.getPagination(publicTlResponse.headers());
String max_id = publicTlResponse.headers().get("min-id");
statuses.pagination = new Pagination();
statuses.pagination.max_id = max_id;
}
} catch (Exception e) {
e.printStackTrace();

View File

@ -492,6 +492,27 @@
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/action_share_container"
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_marginStart="48dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="6dp"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="end"
android:visibility="gone">
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/action_share"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="28dp"
android:layout_height="28dp"
android:adjustViewBounds="true"
app:srcCompat="@drawable/ic_baseline_share_24" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/action_buttons"
android:layout_width="match_parent"