bug fix, version upgrade
This commit is contained in:
parent
8d0971b284
commit
2ef2f8acec
|
@ -12,8 +12,8 @@ android {
|
|||
applicationId 'org.nuclearfog.twidda'
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 31
|
||||
versionCode 54
|
||||
versionName '2.0.1'
|
||||
versionCode 55
|
||||
versionName '2.0.2'
|
||||
// limiting language support for smaller APK size
|
||||
resConfigs 'en', 'de-rDE', 'zh-rCN'
|
||||
vectorDrawables.useSupportLibrary true
|
||||
|
|
|
@ -208,7 +208,7 @@ public class UserlistEditor extends AppCompatActivity implements OnClickListener
|
|||
mHolder = new UserlistUpdate(titleStr, descrStr, isPublic, userList.getId());
|
||||
} else {
|
||||
// create new one
|
||||
mHolder = new UserlistUpdate(titleStr, descrStr, isPublic);
|
||||
mHolder = new UserlistUpdate(titleStr, descrStr, isPublic, UserlistUpdate.NEW_LIST);
|
||||
}
|
||||
updaterAsync = new ListUpdater(this, mHolder);
|
||||
updaterAsync.execute();
|
||||
|
|
|
@ -43,7 +43,7 @@ public class MessageUpdater extends AsyncTask<Void, Void, Boolean> {
|
|||
protected Boolean doInBackground(Void[] v) {
|
||||
try {
|
||||
// first check if user exists
|
||||
long id = twitter.showUser(message.getReceiver()).getId();
|
||||
long id = twitter.showUser(message.getName()).getId();
|
||||
// upload media if any
|
||||
long mediaId = -1;
|
||||
if (message.getMediaStream() != null) {
|
||||
|
|
|
@ -80,6 +80,7 @@ class TweetV1 implements Tweet {
|
|||
coordinates = getLocation(json);
|
||||
mediaLinks = addMedia(json);
|
||||
text = createText(json);
|
||||
userMentions = StringTools.getUserMentions(text, author.getScreenname());
|
||||
|
||||
String replyName = json.optString("in_reply_to_screen_name");
|
||||
JSONObject locationJson = json.optJSONObject("place");
|
||||
|
@ -92,11 +93,6 @@ class TweetV1 implements Tweet {
|
|||
if (!replyName.equals("null")) {
|
||||
this.replyName = '@' + replyName;
|
||||
}
|
||||
if (author.isCurrentUser()) {
|
||||
this.userMentions = StringTools.getUserMentions(text);
|
||||
} else {
|
||||
this.userMentions = author.getScreenname() + ' ' + StringTools.getUserMentions(text);
|
||||
}
|
||||
if (user_retweet != null)
|
||||
retweetId = user_retweet.optLong("id");
|
||||
if (quoted_tweet != null) {
|
||||
|
|
|
@ -63,6 +63,7 @@ public class Twitter implements GlobalSettings.SettingsListener {
|
|||
private static final String OAUTH = "1.0";
|
||||
private static final String API = "https://api.twitter.com/";
|
||||
private static final String UPLOAD = "https://upload.twitter.com/";
|
||||
private static final String DOWNLOAD = "https://ton.twitter.com/";
|
||||
private static final String AUTHENTICATE = API + "oauth/authenticate";
|
||||
public static final String REQUEST_URL = AUTHENTICATE + "?oauth_token=";
|
||||
private static final String REQUEST_TOKEN = API + "oauth/request_token";
|
||||
|
@ -1187,7 +1188,7 @@ public class Twitter implements GlobalSettings.SettingsListener {
|
|||
public MediaStream downloadImage(String link) throws TwitterException {
|
||||
try {
|
||||
// this type of link requires authentication
|
||||
if (link.startsWith("https://ton.twitter.com/")) {
|
||||
if (link.startsWith(DOWNLOAD)) {
|
||||
Response response = get(link, new ArrayList<>(0));
|
||||
if (response.code() == 200 && response.body() != null) {
|
||||
MediaType type = response.body().contentType();
|
||||
|
|
|
@ -43,7 +43,7 @@ public class DirectmessageUpdate {
|
|||
*
|
||||
* @return screen name
|
||||
*/
|
||||
public String getReceiver() {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -79,15 +79,19 @@ public class DirectmessageUpdate {
|
|||
*
|
||||
* @param context context used to create inputstream and mime type
|
||||
* @param uri uri of a local media file
|
||||
* @return true if file is valid
|
||||
*/
|
||||
public boolean addMedia(Context context, @NonNull Uri uri) {
|
||||
// check if file is valid
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
DocumentFile file = DocumentFile.fromSingleUri(context, uri);
|
||||
if (file != null && file.exists() && file.canRead() && file.length() > 0) {
|
||||
this.uri = uri;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
// skip validation for old android versions
|
||||
else {
|
||||
this.uri = uri;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public class ProfileUpdate {
|
|||
*
|
||||
* @param context context used to resolve Uri
|
||||
* @param imageUrl Uri of the local image file
|
||||
* @return true if file is valid, false otherwise
|
||||
*/
|
||||
public boolean setImage(Context context, @NonNull Uri imageUrl) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
|
@ -67,6 +68,7 @@ public class ProfileUpdate {
|
|||
*
|
||||
* @param context context used to resolve Uri
|
||||
* @param bannerUrl Uri of the local image file
|
||||
* @return true if file is valid, false otherwise
|
||||
*/
|
||||
public boolean setBanner(Context context, @NonNull Uri bannerUrl) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
|
|
|
@ -7,12 +7,15 @@ package org.nuclearfog.twidda.backend.api.holder;
|
|||
*/
|
||||
public class UserlistUpdate {
|
||||
|
||||
/**
|
||||
* this ID indicates that the list isn't created yet
|
||||
*/
|
||||
public static final long NEW_LIST = -1;
|
||||
|
||||
private long listId;
|
||||
private final String title;
|
||||
private final String description;
|
||||
private final boolean isPublic;
|
||||
private String title;
|
||||
private String description;
|
||||
private boolean isPublic;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -22,20 +25,10 @@ public class UserlistUpdate {
|
|||
* @param listId ID of the list to update or {@link UserlistUpdate#NEW_LIST} to create a new list
|
||||
*/
|
||||
public UserlistUpdate(String title, String description, boolean isPublic, long listId) {
|
||||
this(title, description, isPublic);
|
||||
this.listId = listId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title Title of the list
|
||||
* @param description short description of the list
|
||||
* @param isPublic true if list should be public
|
||||
*/
|
||||
public UserlistUpdate(String title, String description, boolean isPublic) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.isPublic = isPublic;
|
||||
this.listId = NEW_LIST;
|
||||
this.listId = listId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,8 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -138,16 +140,26 @@ public final class StringTools {
|
|||
/**
|
||||
* append user mentions in a text to a string
|
||||
*
|
||||
* @param text text with user mentions (e.g. tweet)
|
||||
* @param text text with user mentions (e.g. tweet)
|
||||
* @param author additional text author name
|
||||
* @return mentioned usernames in one string
|
||||
*/
|
||||
public static String getUserMentions(String text) {
|
||||
public static String getUserMentions(String text, String author) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
Matcher m = MENTION.matcher(text);
|
||||
while (m.find()) {
|
||||
int start = m.start();
|
||||
int end = m.end();
|
||||
buf.append(text.substring(start, end)).append(' ');
|
||||
Set<String> sorted = new TreeSet<>(String::compareToIgnoreCase);
|
||||
Matcher matcher = MENTION.matcher(text);
|
||||
|
||||
while (matcher.find()) {
|
||||
int start = matcher.start();
|
||||
int end = matcher.end();
|
||||
sorted.add(text.substring(start, end));
|
||||
}
|
||||
if (!author.isEmpty()) {
|
||||
buf.append(author).append(' ');
|
||||
sorted.remove(author);
|
||||
}
|
||||
for (String item : sorted) {
|
||||
buf.append(item).append(' ');
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class TweetImpl implements Tweet {
|
|||
retweeted = (tweetRegister & RTW_MASK) != 0;
|
||||
sensitive = (tweetRegister & MEDIA_SENS_MASK) != 0;
|
||||
mediaLinks = SEPARATOR.split(linkStr);
|
||||
String userMentions = StringTools.getUserMentions(text);
|
||||
String userMentions = StringTools.getUserMentions(text, "");
|
||||
// get media type
|
||||
if ((tweetRegister & MEDIA_ANGIF_MASK) == MEDIA_ANGIF_MASK) {
|
||||
mediaType = MEDIA_GIF;
|
||||
|
|
Loading…
Reference in New Issue