Skip to content
This repository has been archived by the owner on Feb 8, 2025. It is now read-only.

Commit

Permalink
bug fix, license update, version upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearfog committed Dec 24, 2021
1 parent 1d0b1da commit 7a5b354
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 32 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId 'org.nuclearfog.twidda'
minSdkVersion 16
targetSdkVersion 31
versionCode 50
versionName '1.10.5'
versionCode 51
versionName '1.10.6'
// limiting language support for smaller APK size
resConfigs 'en', 'de-rDE', 'zh-rCN'
vectorDrawables.useSupportLibrary true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ public static void resetTwitter() {
public String request() throws EngineException {
try {
if (reqToken == null) {
reqToken = twitter.getOAuthRequestToken();
// request token without redirecting to the callback url
reqToken = twitter.getOAuthRequestToken("oob");
}
} catch (Exception err) {
throw new EngineException(err);
Expand Down Expand Up @@ -881,8 +882,12 @@ public UserList getFavoriter(long tweetId, long cursor) throws EngineException {
try {
UsersResponse response = LikesExKt.getLikingUsers(twitter, tweetId, null, null, null);
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);
result.addAll(convertUser2List(users));
result.addAll(convertUserList(twitter.lookupUsers(ids)));
return result;
} catch (TwitterException err) {
throw new EngineException(err);
Expand Down Expand Up @@ -1316,24 +1321,6 @@ private List<User> convertUserListFiltered(List<twitter4j.User> users) throws Tw
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
*
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/java/org/nuclearfog/twidda/backend/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.io.Serializable;

import twitter4j.URLEntity;
import twitter4j.User2;

/**
* Container class for a twitter user
Expand Down Expand Up @@ -82,15 +81,6 @@ public User(twitter4j.User user, long twitterId) {
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 username username
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/res/xml/licenses.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@
limitations under the 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
name="Picasso"
type="library">
Expand Down

0 comments on commit 7a5b354

Please sign in to comment.