implement profile context (backend)
This commit is contained in:
parent
b992456a2c
commit
a37bb2d185
@ -115,7 +115,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, List<CommentMod
|
||||
owner.getString("profile_pic_url"),
|
||||
null,
|
||||
new FriendshipStatus(false, false, false, false, false, false, false, false, false, false),
|
||||
false, false, false, false, false, null, null, 0, 0, 0, 0, null, null, 0, null, null);
|
||||
false, false, false, false, false, null, null, 0, 0, 0, 0, null, null, 0, null, null, null, null);
|
||||
final JSONObject likedBy = childComment.optJSONObject("edge_liked_by");
|
||||
commentModels.add(new CommentModel(childComment.getString(Constants.EXTRAS_ID),
|
||||
childComment.getString("text"),
|
||||
@ -193,7 +193,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, List<CommentMod
|
||||
null,
|
||||
new FriendshipStatus(false, false, false, false, false, false, false, false, false, false),
|
||||
owner.optBoolean("is_verified"),
|
||||
false, false, false, false, null, null, 0, 0, 0, 0, null, null, 0, null, null);
|
||||
false, false, false, false, null, null, 0, 0, 0, 0, null, null, 0, null, null, null, null);
|
||||
final JSONObject likedBy = comment.optJSONObject("edge_liked_by");
|
||||
final String commentId = comment.getString(Constants.EXTRAS_ID);
|
||||
final CommentModel commentModel = new CommentModel(commentId,
|
||||
@ -235,7 +235,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, List<CommentMod
|
||||
null,
|
||||
new FriendshipStatus(false, false, false, false, false, false, false, false, false, false),
|
||||
tempJsonObject.optBoolean("is_verified"), false, false, false, false, null, null, 0, 0, 0, 0, null, null, 0,
|
||||
null, null);
|
||||
null, null, null, null);
|
||||
|
||||
tempJsonObject = childComment.optJSONObject("edge_liked_by");
|
||||
childCommentModels.add(new CommentModel(childComment.getString(Constants.EXTRAS_ID),
|
||||
|
@ -86,6 +86,7 @@ import awais.instagrabber.repositories.responses.FriendshipRestrictResponse;
|
||||
import awais.instagrabber.repositories.responses.FriendshipStatus;
|
||||
import awais.instagrabber.repositories.responses.Media;
|
||||
import awais.instagrabber.repositories.responses.User;
|
||||
import awais.instagrabber.repositories.responses.UserProfileContextLink;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.CookieUtils;
|
||||
import awais.instagrabber.utils.DownloadUtils;
|
||||
@ -692,7 +693,11 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
: profileModel.getFullName());
|
||||
|
||||
final String biography = profileModel.getBiography();
|
||||
if (!TextUtils.isEmpty(biography)) {
|
||||
if (TextUtils.isEmpty(biography)) {
|
||||
profileDetailsBinding.mainBiography.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
profileDetailsBinding.mainBiography.setVisibility(View.VISIBLE);
|
||||
profileDetailsBinding.mainBiography.setText(biography);
|
||||
profileDetailsBinding.mainBiography.addOnHashtagListener(autoLinkItem -> {
|
||||
final NavController navController = NavHostFragment.findNavController(this);
|
||||
@ -757,6 +762,27 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
String profileContext = profileModel.getProfileContext();
|
||||
if (TextUtils.isEmpty(profileContext)) {
|
||||
profileDetailsBinding.profileContext.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
profileDetailsBinding.profileContext.setVisibility(View.VISIBLE);
|
||||
final List<UserProfileContextLink> userProfileContextLinks = profileModel.getProfileContextLinks();
|
||||
for (int i = 0; i < userProfileContextLinks.size(); i++) {
|
||||
final UserProfileContextLink link = userProfileContextLinks.get(i);
|
||||
if (link.getUsername() != null)
|
||||
profileContext = profileContext.substring(0, link.getStart() + i)
|
||||
+ "@" + profileContext.substring(link.getStart() + i);
|
||||
}
|
||||
profileDetailsBinding.profileContext.setText(profileContext);
|
||||
profileDetailsBinding.profileContext.addOnMentionClickListener(autoLinkItem -> {
|
||||
final String originalText = autoLinkItem.getOriginalText().trim();
|
||||
navigateToProfile(originalText);
|
||||
});
|
||||
}
|
||||
|
||||
final String url = profileModel.getExternalUrl();
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
profileDetailsBinding.mainUrl.setVisibility(View.GONE);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package awais.instagrabber.repositories.responses;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class User implements Serializable {
|
||||
@ -27,7 +28,8 @@ public class User implements Serializable {
|
||||
private final long usertagsCount;
|
||||
private final String publicEmail;
|
||||
private final HdProfilePicUrlInfo hdProfilePicUrlInfo;
|
||||
|
||||
private final String profileContext;
|
||||
private final List<UserProfileContextLink> profileContextLinksWithUserIds;
|
||||
|
||||
public User(final long pk,
|
||||
final String username,
|
||||
@ -51,7 +53,9 @@ public class User implements Serializable {
|
||||
final String externalUrl,
|
||||
final long usertagsCount,
|
||||
final String publicEmail,
|
||||
final HdProfilePicUrlInfo hdProfilePicUrlInfo) {
|
||||
final HdProfilePicUrlInfo hdProfilePicUrlInfo,
|
||||
final String profileContext,
|
||||
final List<UserProfileContextLink> profileContextLinksWithUserIds) {
|
||||
this.pk = pk;
|
||||
this.username = username;
|
||||
this.fullName = fullName;
|
||||
@ -75,6 +79,8 @@ public class User implements Serializable {
|
||||
this.usertagsCount = usertagsCount;
|
||||
this.publicEmail = publicEmail;
|
||||
this.hdProfilePicUrlInfo = hdProfilePicUrlInfo;
|
||||
this.profileContext = profileContext;
|
||||
this.profileContextLinksWithUserIds = profileContextLinksWithUserIds;
|
||||
}
|
||||
|
||||
public long getPk() {
|
||||
@ -173,46 +179,13 @@ public class User implements Serializable {
|
||||
return publicEmail;
|
||||
}
|
||||
|
||||
// public boolean isReallyPrivate() {
|
||||
// final FriendshipStatus friendshipStatus = getFriendshipStatus();
|
||||
// !user.optBoolean("followed_by_viewer") && (id != uid && isPrivate)
|
||||
// }
|
||||
public String getProfileContext() {
|
||||
return profileContext;
|
||||
}
|
||||
|
||||
// public static User fromProfileModel(final ProfileModel profileModel) {
|
||||
// return new User(
|
||||
// Long.parseLong(profileModel.getId()),
|
||||
// profileModel.getUsername(),
|
||||
// profileModel.getName(),
|
||||
// profileModel.isPrivate(),
|
||||
// profileModel.getSdProfilePic(),
|
||||
// null,
|
||||
// new FriendshipStatus(
|
||||
// profileModel.isFollowing(),
|
||||
// false,
|
||||
// profileModel.isBlocked(),
|
||||
// false,
|
||||
// profileModel.isPrivate(),
|
||||
// false,
|
||||
// profileModel.isRequested(),
|
||||
// false,
|
||||
// profileModel.isRestricted(),
|
||||
// false),
|
||||
// profileModel.isVerified(),
|
||||
// false,
|
||||
// false,
|
||||
// false,
|
||||
// false,
|
||||
// null,
|
||||
// null,
|
||||
// profileModel.getPostCount(),
|
||||
// profileModel.getFollowersCount(),
|
||||
// profileModel.getFollowingCount(),
|
||||
// 0,
|
||||
// profileModel.getBiography(),
|
||||
// profileModel.getUrl(),
|
||||
// 0,
|
||||
// null);
|
||||
// }
|
||||
public List<UserProfileContextLink> getProfileContextLinks() {
|
||||
return profileContextLinksWithUserIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
|
@ -0,0 +1,21 @@
|
||||
package awais.instagrabber.repositories.responses;
|
||||
|
||||
public class UserProfileContextLink {
|
||||
private final String username;
|
||||
private final int start;
|
||||
private final int end;
|
||||
|
||||
public UserProfileContextLink(final String username, final int start, final int end) {
|
||||
this.username = username;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
}
|
@ -782,7 +782,7 @@ public final class ResponseBodyUtils {
|
||||
null,
|
||||
friendshipStatus,
|
||||
owner.optBoolean("is_verified"),
|
||||
false, false, false, false, null, null, 0, 0, 0, 0, null, null, 0, null, null);
|
||||
false, false, false, false, null, null, 0, 0, 0, 0, null, null, 0, null, null, null, null);
|
||||
}
|
||||
final String id = feedItem.getString(Constants.EXTRAS_ID);
|
||||
final ImageVersions2 imageVersions2 = new ImageVersions2(
|
||||
|
@ -243,6 +243,8 @@ public class GraphQLService extends BaseService {
|
||||
null,
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
));
|
||||
// userModels.add(new ProfileModel(userObject.optBoolean("is_private"),
|
||||
@ -334,6 +336,8 @@ public class GraphQLService extends BaseService {
|
||||
url,
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null));
|
||||
} catch (JSONException e) {
|
||||
Log.e(TAG, "onResponse", e);
|
||||
|
@ -172,6 +172,8 @@ public class StoriesService extends BaseService {
|
||||
null,
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
final String id = node.getString("id");
|
||||
@ -231,6 +233,8 @@ public class StoriesService extends BaseService {
|
||||
null,
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
final String id = node.getString("id");
|
||||
|
Loading…
Reference in New Issue
Block a user