1
0
Fork 0
mirror of https://github.com/KokaKiwi/BarInsta synced 2026-03-04 11:31:35 +00:00

v16.9 part whatever

This commit is contained in:
Austin Huang 2020-07-27 11:29:13 -04:00
parent 86d94d3c97
commit 2f30eec0a3
No known key found for this signature in database
GPG key ID: 84C23AA04587A91F
20 changed files with 114 additions and 68 deletions

View file

@ -870,7 +870,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
main.mainBinding.mainFullName.setSelected(true);
main.mainBinding.mainBiography.setEnabled(true);
if (!profileModel.isPrivate()) {
if (!profileModel.isReallyPrivate()) {
main.mainBinding.mainFollowing.setClickable(true);
main.mainBinding.mainFollowers.setClickable(true);
main.mainBinding.privatePage.setVisibility(View.GONE);

View file

@ -42,7 +42,7 @@ import awais.instagrabber.utils.Utils;
public final class DirectMessagesUserInbox extends AppCompatActivity {
private DirectItemModel directItemModel;
private final ProfileModel myProfileHolder =
new ProfileModel(false, false, null, null, null, null, null, null, null, 0, 0, 0, false, false, false, false);
new ProfileModel(false, false, false, null, null, null, null, null, null, null, 0, 0, 0, false, false, false, false);
private final ArrayList<ProfileModel> users = new ArrayList<>();
private final ArrayList<DirectItemModel> directItemModels = new ArrayList<>();
private final FetchListener<InboxThreadModel> fetchListener = new FetchListener<InboxThreadModel>() {

View file

@ -317,7 +317,7 @@ public final class Main extends BaseLanguageActivity {
searchView.setQueryHint(getResources().getString(R.string.action_search));
searchView.setSuggestionsAdapter(suggestionAdapter);
searchView.setOnSearchClickListener(v -> {
searchView.setQuery(userQuery.equals(cookieModel.getUsername()) ? "" : userQuery, false);
searchView.setQuery((cookieModel != null && userQuery.equals(cookieModel.getUsername())) ? "" : userQuery, false);
menu.findItem(R.id.action_about).setVisible(false);
menu.findItem(R.id.action_settings).setVisible(false);
menu.findItem(R.id.action_dms).setVisible(false);

View file

@ -139,11 +139,14 @@ public final class PostViewer extends BaseLanguageActivity {
iconRes = R.drawable.ic_fullscreen_exit;
topPanelRoot.setVisibility(View.GONE);
viewerBinding.btnDownload.setVisibility(View.VISIBLE);
viewerBinding.bottomPanel.tvPostDate.setVisibility(View.GONE);
} else {
containerLayoutParams.weight = (viewerBinding.mediaList.getVisibility() == View.VISIBLE) ? 1.35f : 1.9f;
containerLayoutParams.weight += (Utils.isEmpty(settingsHelper.getString(Constants.COOKIE))) ? 0.3f : 0;
iconRes = R.drawable.ic_fullscreen;
topPanelRoot.setVisibility(View.VISIBLE);
viewerBinding.btnDownload.setVisibility(View.GONE);
viewerBinding.bottomPanel.tvPostDate.setVisibility(View.VISIBLE);
}
viewerBinding.ivToggleFullScreen.setImageResource(iconRes);
@ -203,7 +206,19 @@ public final class PostViewer extends BaseLanguageActivity {
resources = getResources();
final View viewStoryPost = findViewById(R.id.viewStoryPost);
if (viewStoryPost != null) viewStoryPost.setVisibility(View.GONE);
if (viewStoryPost != null) {
viewStoryPost.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (profileModel.isPrivate())
Toast.makeText(getApplicationContext(), R.string.share_private_post, Toast.LENGTH_LONG).show();
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://instagram.com/p/"+postShortCode);
startActivity(Intent.createChooser(sharingIntent,
(profileModel.isPrivate()) ? getString(R.string.share_private_post) : getString(R.string.share_public_post)));
}
});
}
viewerBinding.topPanel.title.setMovementMethod(new LinkMovementMethod());
viewerBinding.topPanel.title.setMentionClickListener((view, text, isHashtag) ->
@ -218,7 +233,7 @@ public final class PostViewer extends BaseLanguageActivity {
viewerBinding.postActions.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, 0, 0
));
containerLayoutParams.weight = 2.2f;
containerLayoutParams.weight = (containerLayoutParams.weight == 3.3f) ? 3.3f : 2.2f;
viewerBinding.container.setLayoutParams(containerLayoutParams);
}
else {
@ -339,6 +354,21 @@ public final class PostViewer extends BaseLanguageActivity {
viewerBinding.mediaList.setVisibility(View.VISIBLE);
}
final View viewStoryPost = findViewById(R.id.viewStoryPost);
if (viewStoryPost != null) {
viewStoryPost.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (profileModel.isPrivate())
Toast.makeText(getApplicationContext(), R.string.share_private_post, Toast.LENGTH_LONG).show();
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://instagram.com/p/"+postModel.getShortCode());
startActivity(Intent.createChooser(sharingIntent,
(profileModel.isPrivate()) ? getString(R.string.share_private_post) : getString(R.string.share_public_post)));
}
});
}
viewerCaptionParent.setOnTouchListener(gestureTouchListener);
viewerBinding.playerView.setOnTouchListener(gestureTouchListener);
viewerBinding.imageViewer.setOnSingleFlingListener((e1, e2, velocityX, velocityY) -> {
@ -560,10 +590,6 @@ public final class PostViewer extends BaseLanguageActivity {
}
lastSlidePos = slidePos;
containerLayoutParams.weight = (viewerBinding.mediaList.getVisibility() == View.VISIBLE) ? 1.35f : 1.9f;
containerLayoutParams.weight += (Utils.isEmpty(settingsHelper.getString(Constants.COOKIE))) ? 0.3f : 0;
viewerBinding.container.setLayoutParams(containerLayoutParams);
postCaption = viewerPostModel.getPostCaption();
if (Utils.hasMentions(postCaption)) {
@ -588,12 +614,12 @@ public final class PostViewer extends BaseLanguageActivity {
postModel.setLike(viewerPostModel.getLike());
postModel.setBookmark(viewerPostModel.getBookmark());
if (viewerPostModel.getLike() == true) {
viewerBinding.btnLike.setText(resources.getString(R.string.unlike, postModel.getLikes()));
viewerBinding.btnLike.setText(resources.getString(R.string.unlike, viewerPostModel.getLikes()));
viewerBinding.btnLike.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
R.color.btn_pink_background, null)));
}
else {
viewerBinding.btnLike.setText(resources.getString(R.string.like, postModel.getLikes()));
viewerBinding.btnLike.setText(resources.getString(R.string.like, viewerPostModel.getLikes()));
viewerBinding.btnLike.setBackgroundTintList(ColorStateList.valueOf(resources.getColor(
R.color.btn_lightpink_background, null)));
}
@ -610,7 +636,7 @@ public final class PostViewer extends BaseLanguageActivity {
}
viewerBinding.bottomPanel.tvPostDate.setText(viewerPostModel.getPostDate());
viewerBinding.bottomPanel.tvPostDate.setVisibility(View.VISIBLE);
viewerBinding.bottomPanel.tvPostDate.setVisibility(containerLayoutParams.weight != 3.3f ? View.VISIBLE : View.GONE);
viewerBinding.bottomPanel.tvPostDate.setSelected(true);
url = viewerPostModel.getDisplayUrl();
@ -718,7 +744,7 @@ public final class PostViewer extends BaseLanguageActivity {
if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
ok = true;
}
else Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT);
else Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
urlConnection.disconnect();
} catch (Throwable ex) {
Log.e("austin_debug", action+": " + ex);
@ -729,8 +755,8 @@ public final class PostViewer extends BaseLanguageActivity {
@Override
protected void onPostExecute(Void result) {
if (ok == true && action == "likes") {
viewerPostModel.setLike(!postModel.getLike());
postModel.setManualLike(!postModel.getLike());
postModel.setLike(!postModel.getLike());
viewerPostModel.setManualLike(!postModel.getLike());
refreshPost();
}
else if (ok == true && action == "save") {

View file

@ -46,7 +46,7 @@ import static awais.instagrabber.models.direct_messages.DirectItemModel.RavenExp
public final class MessageItemsAdapter extends RecyclerView.Adapter<TextMessageViewHolder> {
private static final int MESSAGE_INCOMING = 69, MESSAGE_OUTGOING = 420;
private final ProfileModel myProfileHolder =
new ProfileModel(false, false, null, null, null, null, null, null, null, 0, 0, 0, false, false, false, false);
new ProfileModel(false, false, false, null, null, null, null, null, null, null, 0, 0, 0, false, false, false, false);
private final ArrayList<DirectItemModel> directItemModels;
private final ArrayList<ProfileModel> users;
private final View.OnClickListener onClickListener;

View file

@ -109,8 +109,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, CommentModel[]>
if (childComment != null) {
final JSONObject owner = childComment.getJSONObject("owner");
final ProfileModel profileModel = new ProfileModel(false,
false,
final ProfileModel profileModel = new ProfileModel(false, false, false,
owner.getString(Constants.EXTRAS_ID),
owner.getString(Constants.EXTRAS_USERNAME),
null, null, null,
@ -188,7 +187,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, CommentModel[]>
final JSONObject comment = comments.getJSONObject(i).getJSONObject("node");
final JSONObject owner = comment.getJSONObject("owner");
final ProfileModel profileModel = new ProfileModel(false,
final ProfileModel profileModel = new ProfileModel(false, false,
owner.optBoolean("is_verified"),
owner.getString(Constants.EXTRAS_ID),
owner.getString(Constants.EXTRAS_USERNAME),
@ -229,6 +228,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, CommentModel[]>
tempJsonObject = childComment.getJSONObject("owner");
final ProfileModel childProfileModel = new ProfileModel(false, false,
tempJsonObject.optBoolean("is_verified"),
tempJsonObject.getString(Constants.EXTRAS_ID),
tempJsonObject.getString(Constants.EXTRAS_USERNAME),
null, null, null,

View file

@ -98,6 +98,7 @@ public final class FeedFetcher extends AsyncTask<Void, Void, FeedModel[]> {
if (feedItem.has("owner")) {
final JSONObject owner = feedItem.getJSONObject("owner");
profileModel = new ProfileModel(owner.optBoolean("is_private"),
false, // if you can see it then you def follow
owner.optBoolean("is_verified"),
owner.getString(Constants.EXTRAS_ID),
owner.getString(Constants.EXTRAS_USERNAME),
@ -153,7 +154,8 @@ public final class FeedFetcher extends AsyncTask<Void, Void, FeedModel[]> {
node.getString(Constants.EXTRAS_ID),
isChildVideo ? node.getString("video_url") : Utils.getHighQualityImage(node),
null, null, null,
node.optLong("video_view_count", -1), -1, false, false);
node.optLong("video_view_count", -1), -1, false, false,
feedItem.getJSONObject("edge_media_preview_like").getLong("count"));
sliderItems[j].setSliderDisplayUrl(node.getString("display_url"));
}

View file

@ -56,7 +56,7 @@ public final class FeedStoriesFetcher extends AsyncTask<Void, Void, FeedStoryMod
final JSONObject node = feedStoriesReel.getJSONObject(i).getJSONObject("node");
final JSONObject user = node.getJSONObject(node.has("user") ? "user" : "owner");
final ProfileModel profileModel = new ProfileModel(false, false,
final ProfileModel profileModel = new ProfileModel(false, false, false,
user.getString("id"),
user.getString("username"),
null, null, null,

View file

@ -81,7 +81,6 @@ public final class PostFetcher extends AsyncTask<Void, Void, ViewerPostModel[]>
endCursor = commentObject.optString("end_cursor");
if (mediaItemType != MediaItemType.MEDIA_TYPE_SLIDER) {
Log.d("austin_debug", "m: "+media);
final ViewerPostModel postModel = new ViewerPostModel(mediaItemType,
media.getString(Constants.EXTRAS_ID),
isVideo ? media.getString("video_url") : Utils.getHighQualityImage(media),
@ -89,7 +88,8 @@ public final class PostFetcher extends AsyncTask<Void, Void, ViewerPostModel[]>
Utils.isEmpty(postCaption) ? null : postCaption,
username,
isVideo && media.has("video_view_count") ? media.getLong("video_view_count") : -1,
timestamp, media.getBoolean("viewer_has_liked"), media.getBoolean("viewer_has_saved"));
timestamp, media.getBoolean("viewer_has_liked"), media.getBoolean("viewer_has_saved"),
media.getJSONObject("edge_media_preview_like").getLong("count"));
postModel.setCommentsCount(commentsCount);
postModel.setCommentsEndCursor(endCursor);
@ -107,13 +107,14 @@ public final class PostFetcher extends AsyncTask<Void, Void, ViewerPostModel[]>
final boolean isChildVideo = node.getBoolean("is_video");
postModels[i] = new ViewerPostModel(isChildVideo ? MediaItemType.MEDIA_TYPE_VIDEO : MediaItemType.MEDIA_TYPE_IMAGE,
node.getString(Constants.EXTRAS_ID),
media.getString(Constants.EXTRAS_ID),
isChildVideo ? node.getString("video_url") : Utils.getHighQualityImage(node),
node.getString(Constants.EXTRAS_SHORTCODE),
postCaption,
username,
isChildVideo && node.has("video_view_count") ? node.getLong("video_view_count") : -1,
timestamp, media.getBoolean("viewer_has_liked"), media.getBoolean("viewer_has_saved"));
timestamp, media.getBoolean("viewer_has_liked"), media.getBoolean("viewer_has_saved"),
media.getJSONObject("edge_media_preview_like").getLong("count"));
postModels[i].setSliderDisplayUrl(node.getString("display_url"));
Utils.checkExistence(downloadDir, customDir, username, true, i, postModels[i]);

View file

@ -43,16 +43,18 @@ public final class ProfileFetcher extends AsyncTask<Void, Void, ProfileModel> {
final JSONObject user = new JSONObject(Utils.readFromConnection(conn)).getJSONObject("graphql").getJSONObject(Constants.EXTRAS_USER);
boolean isPrivate = user.getBoolean("is_private");
boolean reallyPrivate = isPrivate;
final JSONObject timelineMedia = user.getJSONObject("edge_owner_to_timeline_media");
if (timelineMedia.has("edges")) {
final JSONArray edges = timelineMedia.getJSONArray("edges");
if (edges.length() > 0) isPrivate = false;
if (edges.length() > 0) reallyPrivate = false;
}
String url = user.optString("external_url");
if (Utils.isEmpty(url)) url = null;
result = new ProfileModel(isPrivate,
reallyPrivate,
user.getBoolean("is_verified"),
user.getString(Constants.EXTRAS_ID),
userName,

View file

@ -19,14 +19,11 @@ public abstract class BasePostModel implements Serializable {
protected long timestamp;
protected int position;
boolean liked, bookmarked;
long likes;
public boolean getLike() {
return liked;
}
public long getLikes() {
return likes;
}
public boolean getBookmark() {
return bookmarked;
}
@ -35,13 +32,6 @@ public abstract class BasePostModel implements Serializable {
liked = like; return liked;
}
// setManualLike means user liked from InstaGrabber
public boolean setManualLike(final boolean like) {
liked = like;
likes = (like) ? (likes + 1) : (likes - 1);
return liked;
}
public boolean setBookmark(final boolean bookmark) {
bookmarked = bookmark; return bookmarked;
}

View file

@ -23,7 +23,6 @@ public class PostModel extends BasePostModel {
this.postCaption = postCaption;
this.timestamp = timestamp;
this.liked = liked;
this.likes = likes;
this.bookmarked = bookmarked;
}
@ -35,10 +34,6 @@ public class PostModel extends BasePostModel {
return endCursor;
}
public long getLikes() {
return likes;
}
public boolean hasNextPage() {
return endCursor != null && hasNextPage;
}

View file

@ -3,15 +3,17 @@ package awais.instagrabber.models;
import java.io.Serializable;
public final class ProfileModel implements Serializable {
private final boolean isPrivate, isVerified, following, restricted, blocked, requested;
private final boolean isPrivate, reallyPrivate, isVerified, following, restricted, blocked, requested;
private final long postCount, followersCount, followingCount;
private final String id, username, name, biography, url, sdProfilePic, hdProfilePic;
public ProfileModel(final boolean isPrivate, final boolean isVerified, final String id, final String username,
final String name, final String biography, final String url, final String sdProfilePic, final String hdProfilePic,
final long postCount, final long followersCount, final long followingCount, final boolean following,
final boolean restricted, final boolean blocked, final boolean requested) {
public ProfileModel(final boolean isPrivate, final boolean reallyPrivate,
final boolean isVerified, final String id, final String username, final String name, final String biography,
final String url, final String sdProfilePic, final String hdProfilePic, final long postCount,
final long followersCount, final long followingCount, final boolean following, final boolean restricted,
final boolean blocked, final boolean requested) {
this.isPrivate = isPrivate;
this.reallyPrivate = reallyPrivate;
this.isVerified = isVerified;
this.id = id;
this.url = url;
@ -33,6 +35,10 @@ public final class ProfileModel implements Serializable {
return isPrivate;
}
public boolean isReallyPrivate() {
return reallyPrivate;
}
public boolean isVerified() {
return isVerified;
}

View file

@ -6,12 +6,12 @@ public final class ViewerPostModel extends BasePostModel {
protected final String username;
protected final long videoViews;
protected String sliderDisplayUrl, commentsEndCursor;
protected long commentsCount;
protected long commentsCount, likes;
private boolean isCurrentSlide = false;
public ViewerPostModel(final MediaItemType itemType, final String postId, final String displayUrl, final String shortCode,
final String postCaption, final String username, final long videoViews, final long timestamp,
boolean liked, boolean bookmarked) {
boolean liked, boolean bookmarked, long likes) {
this.itemType = itemType;
this.postId = postId;
this.displayUrl = displayUrl;
@ -21,6 +21,7 @@ public final class ViewerPostModel extends BasePostModel {
this.videoViews = videoViews;
this.timestamp = timestamp;
this.liked = liked;
this.likes = likes;
this.bookmarked = bookmarked;
}
@ -44,6 +45,17 @@ public final class ViewerPostModel extends BasePostModel {
return videoViews;
}
public long getLikes() {
return likes;
}
// setManualLike means user liked from InstaGrabber
public boolean setManualLike(final boolean like) {
liked = like;
likes = (like) ? (likes + 1) : (likes - 1);
return liked;
}
public void setSliderDisplayUrl(final String sliderDisplayUrl) {
this.sliderDisplayUrl = sliderDisplayUrl;
}

View file

@ -63,6 +63,8 @@ public final class LocaleUtils {
if (appLanguageIndex == 4) return "zh";
if (appLanguageIndex == 5) return "in";
if (appLanguageIndex == 6) return "it";
if (appLanguageIndex == 7) return "de";
if (appLanguageIndex == 8) return "pl";
return null;
}

View file

@ -382,6 +382,7 @@ public final class Utils {
if (userObj != null) {
user = new ProfileModel(
userObj.getBoolean("is_private"),
false, // temporary
userObj.optBoolean("is_verified"),
String.valueOf(userObj.get("pk")),
userObj.getString("username"),
@ -459,6 +460,7 @@ public final class Utils {
for (int j = 0; j < usersLen; ++j) {
final JSONObject userObject = users.getJSONObject(j);
userModels[j] = new ProfileModel(userObject.getBoolean("is_private"),
false,
userObject.optBoolean("is_verified"),
String.valueOf(userObject.get("pk")),
userObject.getString("username"),
@ -608,6 +610,7 @@ public final class Utils {
case PROFILE: {
final JSONObject profile = itemObject.getJSONObject("profile");
profileModel = new ProfileModel(profile.getBoolean("is_private"),
false,
profile.getBoolean("is_verified"),
Long.toString(profile.getLong("pk")),
profile.getString("username"),