bug fix, license update, version upgrade

This commit is contained in:
nuclearfog 2021-12-24 12:50:05 +01:00
parent 1d0b1daae1
commit 7a5b354dae
No known key found for this signature in database
GPG Key ID: AA0271FBE406DB98
4 changed files with 30 additions and 32 deletions

View File

@ -12,8 +12,8 @@ android {
applicationId 'org.nuclearfog.twidda' applicationId 'org.nuclearfog.twidda'
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 31 targetSdkVersion 31
versionCode 50 versionCode 51
versionName '1.10.5' versionName '1.10.6'
// limiting language support for smaller APK size // limiting language support for smaller APK size
resConfigs 'en', 'de-rDE', 'zh-rCN' resConfigs 'en', 'de-rDE', 'zh-rCN'
vectorDrawables.useSupportLibrary true vectorDrawables.useSupportLibrary true

View File

@ -175,7 +175,8 @@ public class TwitterEngine {
public String request() throws EngineException { public String request() throws EngineException {
try { try {
if (reqToken == null) { if (reqToken == null) {
reqToken = twitter.getOAuthRequestToken(); // request token without redirecting to the callback url
reqToken = twitter.getOAuthRequestToken("oob");
} }
} catch (Exception err) { } catch (Exception err) {
throw new EngineException(err); throw new EngineException(err);
@ -881,8 +882,12 @@ public class TwitterEngine {
try { try {
UsersResponse response = LikesExKt.getLikingUsers(twitter, tweetId, null, null, null); UsersResponse response = LikesExKt.getLikingUsers(twitter, tweetId, null, null, null);
List<User2> users = response.getUsers(); List<User2> users = response.getUsers();
long[] ids = new long[users.size()];
for (int i = 0 ; i < ids.length ; i++)
ids[i] = users.get(i).getId();
// lookup users with Twitter4J for maximum compability
UserList result = new UserList(cursor, 0); UserList result = new UserList(cursor, 0);
result.addAll(convertUser2List(users)); result.addAll(convertUserList(twitter.lookupUsers(ids)));
return result; return result;
} catch (TwitterException err) { } catch (TwitterException err) {
throw new EngineException(err); throw new EngineException(err);
@ -1316,24 +1321,6 @@ public class TwitterEngine {
return result; return result;
} }
/**
* convert {@link User2} list to user list
*
* @param users list of user from version 2
* @return user list
*/
private List<User> convertUser2List(List<User2> users) throws TwitterException {
long id = twitter.getId();
ArrayList<User> result = new ArrayList<>();
result.ensureCapacity(users.size());
for (User2 user : users) {
if (user.getPublicMetrics() != null) {
result.add(new User(user, user.getPublicMetrics(), id));
}
}
return result;
}
/** /**
* create paging for tweets * create paging for tweets
* *

View File

@ -5,7 +5,6 @@ import androidx.annotation.NonNull;
import java.io.Serializable; import java.io.Serializable;
import twitter4j.URLEntity; import twitter4j.URLEntity;
import twitter4j.User2;
/** /**
* Container class for a twitter user * Container class for a twitter user
@ -82,15 +81,6 @@ public class User implements Serializable {
isCurrentUser = twitterId == userID; isCurrentUser = twitterId == userID;
} }
public User(User2 user, User2.PublicMetrics metrics, long id) {
this(user.getId(), user.getUsername(), user.getName(), user.getProfileImageUrl(),
user.getDescription(), user.getLocation(), id, user.getVerified(),
user.getProtected(), false, true, "", "", user.getCreatedAt().getTime(),
metrics.getFollowingCount(), metrics.getFollowersCount(),
metrics.getTweetCount(), metrics.getListedCount());
}
/** /**
* @param userID ID of the user * @param userID ID of the user
* @param username username * @param username username

View File

@ -42,6 +42,27 @@
limitations under the License. limitations under the License.
</license> </license>
<license
name="Twitter4J-V2"
type="library">
Copyright 2020 takke
Licensed under the Apache License,
Version 2.0 (the "License");
you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law
or agreed to in writing,
software distributed under the License
is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied.
See the License for the specific
language governing permissions and
limitations under the License.
</license>
<license <license
name="Picasso" name="Picasso"
type="library"> type="library">