bug fix, cleanup

This commit is contained in:
nuclearfog 2023-06-12 21:26:56 +02:00
parent 819f414ed9
commit c38ccc9e8d
No known key found for this signature in database
GPG Key ID: 03488A185C476379
10 changed files with 55 additions and 32 deletions

View File

@ -38,8 +38,6 @@ android {
excludes += ['/META-INF/CHANGES', '/META-INF/DEPENDENCIES', '/META-INF/README.md', '/META-INF/androidx.*', '/META-INF/kotlin*', '/META-INF/com.*', '/META-INF/services/**', '/META-INF/com/**', '/kotlin/**', '/Debug*'] excludes += ['/META-INF/CHANGES', '/META-INF/DEPENDENCIES', '/META-INF/README.md', '/META-INF/androidx.*', '/META-INF/kotlin*', '/META-INF/com.*', '/META-INF/services/**', '/META-INF/com/**', '/kotlin/**', '/Debug*']
} }
} }
} }
dependencies { dependencies {

View File

@ -551,7 +551,7 @@ public class Mastodon implements Connection {
Statuses result = new Statuses(); Statuses result = new Statuses();
for (Status status : statusThreads) { for (Status status : statusThreads) {
// Mastodon doesn't support min/max ID. // Mastodon doesn't support min/max ID.
if (status.getRepliedStatusId() == id && (minId == 0 || status.getId() > minId) && (maxId == 0 || status.getId() < maxId)) { if (status.getRepliedStatusId() == id && (minId == 0L || status.getId() > minId) && (maxId == 0L || status.getId() < maxId)) {
result.add(status); result.add(status);
} }
} }

View File

@ -3,6 +3,7 @@ package org.nuclearfog.twidda.backend.api.mastodon.impl;
import android.util.Patterns; import android.util.Patterns;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -62,6 +63,15 @@ public class MastodonCard implements Card {
} }
@Override
public boolean equals(@Nullable Object obj) {
if (!(obj instanceof Card))
return false;
Card card = (Card) obj;
return card.getTitle().equals(getTitle()) && card.getUrl().equals(getUrl()) && card.getImageUrl().equals(getImageUrl());
}
@NonNull @NonNull
@Override @Override
public String toString() { public String toString() {

View File

@ -920,7 +920,7 @@ public class TwitterV1 implements Connection {
root.put("event", event); root.put("event", event);
if (!message.isEmpty()) if (!message.isEmpty())
data.put("text", message); data.put("text", message);
if (mediaId != 0) { if (mediaId != 0L) {
JSONObject attachment = new JSONObject(); JSONObject attachment = new JSONObject();
JSONObject media = new JSONObject(); JSONObject media = new JSONObject();
attachment.put("type", "media"); attachment.put("type", "media");

View File

@ -3,6 +3,7 @@ package org.nuclearfog.twidda.backend.api.twitter.v2.impl;
import android.util.Patterns; import android.util.Patterns;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -67,6 +68,15 @@ public class TwitterCard implements Card {
} }
@Override
public boolean equals(@Nullable Object obj) {
if (!(obj instanceof Card))
return false;
Card card = (Card) obj;
return card.getTitle().equals(getTitle()) && card.getUrl().equals(getUrl()) && card.getImageUrl().equals(getImageUrl());
}
@NonNull @NonNull
@Override @Override
public String toString() { public String toString() {

View File

@ -410,7 +410,7 @@ public class StatusUpdate implements Serializable, Closeable {
@NonNull @NonNull
@Override @Override
public String toString() { public String toString() {
if (replyId != 0) if (replyId != 0L)
return "to=" + replyId + " status=\"" + text + "\""; return "to=" + replyId + " status=\"" + text + "\"";
return "status=\"" + text + "\""; return "status=\"" + text + "\"";
} }

View File

@ -1078,7 +1078,7 @@ public class GlobalSettings {
String bearerToken = settings.getString(BEARER_TOKEN, ""); String bearerToken = settings.getString(BEARER_TOKEN, "");
String hostname = settings.getString(HOSTNAME, TWITTER_HOST); String hostname = settings.getString(HOSTNAME, TWITTER_HOST);
int apiId = settings.getInt(CURRENT_API, 0); int apiId = settings.getInt(CURRENT_API, 0);
long userId = settings.getLong(CURRENT_ID, 0); long userId = settings.getLong(CURRENT_ID, 0L);
if ((apiId == Account.API_TWITTER_1 || apiId == Account.API_TWITTER_2) && twitterAlt) if ((apiId == Account.API_TWITTER_1 || apiId == Account.API_TWITTER_2) && twitterAlt)
hostname = TWITTER_ALT_HOST; hostname = TWITTER_ALT_HOST;
login = new ConfigAccount(userId, oauthToken, oauthSecret, consumerToken, consumerSecret, bearerToken, hostname, apiId); login = new ConfigAccount(userId, oauthToken, oauthSecret, consumerToken, consumerSecret, bearerToken, hostname, apiId);

View File

@ -54,6 +54,8 @@ public class CardHolder extends ViewHolder implements OnClickListener {
private GlobalSettings settings; private GlobalSettings settings;
private OnHolderClickListener listener; private OnHolderClickListener listener;
private Card card;
/** /**
* *
*/ */
@ -93,6 +95,7 @@ public class CardHolder extends ViewHolder implements OnClickListener {
* @param card card content * @param card card content
*/ */
public void setContent(Card card) { public void setContent(Card card) {
if (!card.equals(this.card)) {
SpannableStringBuilder urlDescription = new SpannableStringBuilder(); SpannableStringBuilder urlDescription = new SpannableStringBuilder();
Drawable placeholder = new ColorDrawable(EMPTY_COLOR); Drawable placeholder = new ColorDrawable(EMPTY_COLOR);
// set url preview image // set url preview image
@ -120,5 +123,7 @@ public class CardHolder extends ViewHolder implements OnClickListener {
} }
// apply description // apply description
linkText.setText(urlDescription); linkText.setText(urlDescription);
this.card = card;
}
} }
} }

View File

@ -133,7 +133,7 @@ public class StatusFragment extends ListFragment implements StatusSelectListener
Bundle param = getArguments(); Bundle param = getArguments();
if (param != null) { if (param != null) {
mode = param.getInt(KEY_MODE, 0); mode = param.getInt(KEY_MODE, 0);
id = param.getLong(KEY_ID, 0); id = param.getLong(KEY_ID, 0L);
search = param.getString(KEY_SEARCH, ""); search = param.getString(KEY_SEARCH, "");
} }
if (savedInstanceState != null) { if (savedInstanceState != null) {

View File

@ -175,7 +175,7 @@ public class UserFragment extends ListFragment implements UserClickListener, OnC
Bundle param = getArguments(); Bundle param = getArguments();
if (param != null) { if (param != null) {
mode = param.getInt(KEY_MODE, 0); mode = param.getInt(KEY_MODE, 0);
id = param.getLong(KEY_ID, 0); id = param.getLong(KEY_ID, 0L);
search = param.getString(KEY_SEARCH, ""); search = param.getString(KEY_SEARCH, "");
boolean delUser = param.getBoolean(KEY_DELETE, false); boolean delUser = param.getBoolean(KEY_DELETE, false);
adapter.enableDeleteButton(delUser); adapter.enableDeleteButton(delUser);