diff --git a/app/src/main/java/awais/instagrabber/asyncs/PostsFetcher.java b/app/src/main/java/awais/instagrabber/asyncs/PostsFetcher.java index 09f49123..6d7eeaa4 100755 --- a/app/src/main/java/awais/instagrabber/asyncs/PostsFetcher.java +++ b/app/src/main/java/awais/instagrabber/asyncs/PostsFetcher.java @@ -79,7 +79,8 @@ public final class PostsFetcher extends AsyncTask> { "{\"id\":\"" + id + "\",\"first\":150,\"after\":\"" + endCursor + "\"}"; break; default: - url = "https://www.instagram.com/graphql/query/?query_id=17880160963012870&id=" + id + "&first=50&after=" + endCursor; + url = "https://www.instagram.com/graphql/query/?query_hash=18a7b935ab438c4514b1f742d8fa07a7&variables=" + + "{\"id\":\"" + id + "\",\"first\":150,\"after\":\"" + endCursor + "\"}"; } List result = new ArrayList<>(); try { @@ -153,8 +154,7 @@ public final class PostsFetcher extends AsyncTask> { mediaNode.getLong("taken_at_timestamp"), mediaNode.optBoolean("viewer_has_liked"), mediaNode.optBoolean("viewer_has_saved"), - mediaNode.getJSONObject("edge_liked_by") - .getLong("count") + mediaNode.isNull("edge_liked_by") ? 0 : mediaNode.getJSONObject("edge_liked_by").getLong("count") ); result.add(model); DownloadUtils.checkExistence(downloadDir, customDir, isSlider, model); diff --git a/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java b/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java index ab5cb671..89941cfe 100644 --- a/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java @@ -1,6 +1,7 @@ package awais.instagrabber.fragments; import android.content.Context; +import android.content.DialogInterface; import android.graphics.Typeface; import android.os.AsyncTask; import android.os.Bundle; @@ -21,6 +22,7 @@ import androidx.activity.OnBackPressedDispatcher; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; import androidx.navigation.NavDirections; @@ -40,7 +42,6 @@ import awais.instagrabber.activities.MainActivity; import awais.instagrabber.adapters.PostsAdapter; import awais.instagrabber.asyncs.HashtagFetcher; import awais.instagrabber.asyncs.PostsFetcher; -import awais.instagrabber.asyncs.i.iStoryStatusFetcher; import awais.instagrabber.customviews.PrimaryActionModeCallback; import awais.instagrabber.customviews.helpers.GridAutofitLayoutManager; import awais.instagrabber.customviews.helpers.GridSpacingItemDecoration; @@ -50,6 +51,7 @@ import awais.instagrabber.databinding.FragmentHashtagBinding; import awais.instagrabber.interfaces.FetchListener; import awais.instagrabber.models.HashtagModel; import awais.instagrabber.models.PostModel; +import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.enums.DownloadMethod; import awais.instagrabber.models.enums.FavoriteType; import awais.instagrabber.models.enums.PostItemType; @@ -61,6 +63,7 @@ import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.Utils; import awais.instagrabber.viewmodels.PostsViewModel; import awais.instagrabber.webservices.ServiceCallback; +import awais.instagrabber.webservices.StoriesService; import awais.instagrabber.webservices.TagsService; import awaisomereport.LogCollector; @@ -73,12 +76,13 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe private MainActivity fragmentActivity; private FragmentHashtagBinding binding; private NestedCoordinatorLayout root; - private boolean shouldRefresh = true; + private boolean shouldRefresh = true, hasStories = false; private String hashtag; private HashtagModel hashtagModel; private PostsViewModel postsViewModel; private PostsAdapter postsAdapter; private ActionMode actionMode; + private StoriesService storiesService; private boolean hasNextPage; private String endCursor; private AsyncTask currentlyExecuting; @@ -155,6 +159,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe super.onCreate(savedInstanceState); fragmentActivity = (MainActivity) requireActivity(); tagsService = TagsService.getInstance(); + storiesService = StoriesService.getInstance(); } @Nullable @@ -184,6 +189,12 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe fetchHashtagModel(); } + @Override + public void onResume() { + super.onResume(); + setTitle(); + } + @Override public void onDestroy() { super.onDestroy(); @@ -286,11 +297,25 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe final Context context = getContext(); if (context == null) return; if (isLoggedIn) { - new iStoryStatusFetcher(hashtagModel.getName(), null, false, true, false, stories -> { - if (stories != null && stories.length > 0) { - binding.mainHashtagImage.setStoriesBorder(); - } - }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + storiesService.getUserStory(hashtagModel.getName(), + null, + false, + true, + false, + new ServiceCallback>() { + @Override + public void onSuccess(final List storyModels) { + if (storyModels != null && !storyModels.isEmpty()) { + binding.mainHashtagImage.setStoriesBorder(); + hasStories = true; + } + } + + @Override + public void onFailure(final Throwable t) { + Log.e(TAG, "Error", t); + } + }); binding.btnFollowTag.setVisibility(View.VISIBLE); binding.btnFollowTag.setText(hashtagModel.getFollowing() ? R.string.unfollow : R.string.follow); binding.btnFollowTag.setChipIconResource(hashtagModel.getFollowing() @@ -394,6 +419,15 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe span.setSpan(new StyleSpan(Typeface.BOLD), 0, postCount.length(), 0); binding.mainTagPostCount.setText(span); binding.mainTagPostCount.setVisibility(View.VISIBLE); + binding.mainHashtagImage.setOnClickListener(v -> { + if (hasStories) { + // show stories + final NavDirections action = HashTagFragmentDirections + .actionHashtagFragmentToStoryViewerFragment(-1, null, true, false, hashtagModel.getName(), hashtagModel.getName()); + NavHostFragment.findNavController(this).navigate(action); + return; + } + }); } public void stopCurrentExecutor() { diff --git a/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java b/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java index f759c624..9808fd85 100644 --- a/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java @@ -52,6 +52,7 @@ import awais.instagrabber.databinding.FragmentLocationBinding; import awais.instagrabber.interfaces.FetchListener; import awais.instagrabber.models.LocationModel; import awais.instagrabber.models.PostModel; +import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.enums.DownloadMethod; import awais.instagrabber.models.enums.FavoriteType; import awais.instagrabber.models.enums.PostItemType; @@ -62,6 +63,8 @@ import awais.instagrabber.utils.DownloadUtils; import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.Utils; import awais.instagrabber.viewmodels.PostsViewModel; +import awais.instagrabber.webservices.ServiceCallback; +import awais.instagrabber.webservices.StoriesService; import awaisomereport.LogCollector; import static awais.instagrabber.utils.Utils.logCollector; @@ -73,12 +76,13 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR private MainActivity fragmentActivity; private FragmentLocationBinding binding; private NestedCoordinatorLayout root; - private boolean shouldRefresh = true; + private boolean shouldRefresh = true, hasStories = false; private String locationId; private LocationModel locationModel; private PostsViewModel postsViewModel; private PostsAdapter postsAdapter; private ActionMode actionMode; + private StoriesService storiesService; private boolean hasNextPage; private String endCursor; private AsyncTask currentlyExecuting; @@ -155,6 +159,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR public void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); fragmentActivity = (MainActivity) requireActivity(); + storiesService = StoriesService.getInstance(); } @Nullable @@ -186,6 +191,12 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR fetchLocationModel(); } + @Override + public void onResume() { + super.onResume(); + setTitle(); + } + @Override public void onDestroy() { super.onDestroy(); @@ -287,17 +298,25 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR final String locationId = locationModel.getId(); binding.swipeRefreshLayout.setRefreshing(true); if (isLoggedIn) { - new iStoryStatusFetcher( - locationId, + storiesService.getUserStory(locationId, null, true, false, false, - stories -> { - if (stories != null && stories.length > 0) { - binding.mainLocationImage.setStoriesBorder(); + new ServiceCallback>() { + @Override + public void onSuccess(final List storyModels) { + if (storyModels != null && !storyModels.isEmpty()) { + binding.mainLocationImage.setStoriesBorder(); + hasStories = true; + } } - }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + + @Override + public void onFailure(final Throwable t) { + Log.e(TAG, "Error", t); + } + }); } binding.mainLocationImage.setImageURI(locationModel.getSdProfilePic()); final String postCount = String.valueOf(locationModel.getPostCount()); @@ -381,6 +400,15 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR .setAnchorView(fragmentActivity.getBottomNavView()) .show(); }); + binding.mainLocationImage.setOnClickListener(v -> { + if (hasStories) { + // show stories + final NavDirections action = LocationFragmentDirections + .actionLocationFragmentToStoryViewerFragment(-1, null, false, true, locationId, locationModel.getName()); + NavHostFragment.findNavController(this).navigate(action); + return; + } + }); } private void fetchPosts() { diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index 8b5f506c..044f9c22 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -71,12 +71,12 @@ import awais.instagrabber.asyncs.direct_messages.CreateThreadAction; import awais.instagrabber.asyncs.direct_messages.DirectThreadBroadcaster; import awais.instagrabber.customviews.helpers.SwipeGestureListener; import awais.instagrabber.databinding.FragmentStoryViewerBinding; +import awais.instagrabber.fragments.main.ProfileFragmentDirections; import awais.instagrabber.interfaces.SwipeEvent; import awais.instagrabber.models.FeedStoryModel; import awais.instagrabber.models.HighlightModel; import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.enums.MediaItemType; -import awais.instagrabber.models.enums.StoryViewerChoice; import awais.instagrabber.models.stickers.PollModel; import awais.instagrabber.models.stickers.QuestionModel; import awais.instagrabber.models.stickers.QuizModel; @@ -115,7 +115,7 @@ public class StoryViewerFragment extends Fragment { private StoryModel currentStory; private int slidePos; private int lastSlidePos; - private String url; + private String url, username; private PollModel poll; private QuestionModel question; private String[] mentions; @@ -123,7 +123,7 @@ public class StoryViewerFragment extends Fragment { private MenuItem menuDownload; private MenuItem menuDm; private SimpleExoPlayer player; - private boolean isHashtag; + private boolean isHashtag, isLoc; private String highlight; private boolean fetching = false; private int currentFeedStoryIndex; @@ -439,7 +439,7 @@ public class StoryViewerFragment extends Fragment { new AlertDialog.Builder(context) .setTitle(R.string.story_mentions) .setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, mentions), (d, w) -> { - // searchUsername(mentions[w]); + openProfile(mentions[w]); }) .setPositiveButton(R.string.cancel, null) .show(); @@ -479,7 +479,6 @@ public class StoryViewerFragment extends Fragment { binding.imageViewer.setController(null); releasePlayer(); String currentStoryMediaId = null; - String username = null; if (currentFeedStoryIndex >= 0) { if (isHighlight) { final HighlightsViewModel highlightsViewModel = (HighlightsViewModel) viewModel; @@ -501,20 +500,13 @@ public class StoryViewerFragment extends Fragment { username = fragmentArgs.getUsername(); } isHashtag = fragmentArgs.getIsHashtag(); + isLoc = fragmentArgs.getIsLoc(); final boolean hasUsername = !TextUtils.isEmpty(currentStoryUsername); if (hasUsername) { currentStoryUsername = currentStoryUsername.replace("@", ""); final ActionBar actionBar = fragmentActivity.getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(currentStoryUsername); - // actionBar.setOnClickListener(v -> { - // searchUsername(username); - // }); - // if (isHighlight) { - // actionBar.setSubtitle(getString(R.string.title_highlight, highlight)); - // } else { - // actionBar.setSubtitle(R.string.title_user_story); - // } } } storiesViewModel.getList().setValue(Collections.emptyList()); @@ -542,8 +534,8 @@ public class StoryViewerFragment extends Fragment { }; storiesService.getUserStory(currentStoryMediaId, username, - false, - false, + isLoc, + isHashtag, isHighlight, storyCallback); } @@ -596,14 +588,11 @@ public class StoryViewerFragment extends Fragment { binding.quiz.setTag(quiz); releasePlayer(); - if (isHashtag) { + if (isHashtag || isLoc) { final ActionBar actionBar = fragmentActivity.getSupportActionBar(); if (actionBar != null) { - actionBar.setTitle(currentStory.getUsername() + " (" + currentStoryUsername + ")"); + actionBar.setTitle(currentStory.getUsername()); } - // binding.toolbar.toolbar.setOnClickListener(v -> { - // searchUsername(currentStory.getUsername()); - // }); } if (itemType == MediaItemType.MEDIA_TYPE_VIDEO) setupVideo(); else setupImage(); @@ -755,6 +744,19 @@ public class StoryViewerFragment extends Fragment { }); } + private void openProfile(final String username) { + final char t = username.charAt(0); + Log.d("austin_debug", username); + if (t == '@') { + final NavDirections action = HashTagFragmentDirections.actionGlobalProfileFragment(username); + NavHostFragment.findNavController(this).navigate(action); + } + else if (t == '#') { + final NavDirections action = HashTagFragmentDirections.actionGlobalHashTagFragment(username.substring(1)); + NavHostFragment.findNavController(this).navigate(action); + } + } + private void releasePlayer() { if (player == null) return; try { player.stop(true); } catch (Exception ignored) { } diff --git a/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java b/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java index a02abbb0..0c312837 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java @@ -371,7 +371,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre private void setupFeedStories() { feedStoriesViewModel = new ViewModelProvider(fragmentActivity).get(FeedStoriesViewModel.class); final FeedStoriesAdapter feedStoriesAdapter = new FeedStoriesAdapter((model, position) -> { - final NavDirections action = FeedFragmentDirections.actionFeedFragmentToStoryViewerFragment(position, null, false, null, null); + final NavDirections action = FeedFragmentDirections.actionFeedFragmentToStoryViewerFragment(position, null, false, false, null, null); NavHostFragment.findNavController(this).navigate(action); }); final Context context = getContext(); diff --git a/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java b/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java index 62672e13..75ddef44 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java @@ -74,7 +74,6 @@ import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.enums.DownloadMethod; import awais.instagrabber.models.enums.FavoriteType; import awais.instagrabber.models.enums.PostItemType; -import awais.instagrabber.models.enums.StoryViewerChoice; import awais.instagrabber.repositories.responses.FriendshipRepoChangeRootResponse; import awais.instagrabber.repositories.responses.FriendshipRepoRestrictRootResponse; import awais.instagrabber.utils.Constants; @@ -87,6 +86,7 @@ import awais.instagrabber.viewmodels.HighlightsViewModel; import awais.instagrabber.viewmodels.PostsViewModel; import awais.instagrabber.webservices.FriendshipService; import awais.instagrabber.webservices.ServiceCallback; +import awais.instagrabber.webservices.StoriesService; import awaisomereport.LogCollector; import static awais.instagrabber.utils.Utils.logCollector; @@ -107,8 +107,8 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe private ActionMode actionMode; private Handler usernameSettingHandler; private FriendshipService friendshipService; - private boolean shouldRefresh = true; - private StoryModel[] storyModels; + private StoriesService storiesService; + private boolean shouldRefresh = true, hasStories = false; private boolean hasNextPage; private String endCursor; private AsyncTask> currentlyExecuting; @@ -172,6 +172,9 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe binding.privatePage.setVisibility(View.VISIBLE); return; } + else { + binding.privatePage.setVisibility(View.GONE); + } binding.mainPosts.post(() -> binding.mainPosts.setVisibility(View.VISIBLE)); final List postModels = postsViewModel.getList().getValue(); List finalList = postModels == null || postModels.isEmpty() ? new ArrayList<>() @@ -214,6 +217,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe super.onCreate(savedInstanceState); fragmentActivity = (MainActivity) requireActivity(); friendshipService = FriendshipService.getInstance(); + storiesService = StoriesService.getInstance(); setHasOptionsMenu(true); } @@ -439,29 +443,35 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe } binding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE); final String profileId = profileModel.getId(); - if (isLoggedIn) { - new iStoryStatusFetcher(profileId, - profileModel.getUsername(), - false, - false, - false, - result -> { - storyModels = result; - if (result != null && result.length > 0) { - binding.mainProfileImage.setStoriesBorder(); - } - }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - new HighlightsFetcher(profileId, - result -> { - if (result != null) { - binding.highlightsList.setVisibility(View.VISIBLE); - highlightsViewModel.getList().postValue(result); - } else binding.highlightsList.setVisibility(View.GONE); - }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } final String myId = CookieUtils.getUserIdFromCookie(cookie); if (isLoggedIn) { + storiesService.getUserStory(profileId, + profileModel.getUsername(), + false, + false, + false, + new ServiceCallback>() { + @Override + public void onSuccess(final List storyModels) { + if (storyModels != null && !storyModels.isEmpty()) { + binding.mainProfileImage.setStoriesBorder(); + hasStories = true; + } + } + + @Override + public void onFailure(final Throwable t) { + Log.e(TAG, "Error", t); + } + }); + new HighlightsFetcher(profileId, + result -> { + if (result != null) { + binding.highlightsList.setVisibility(View.VISIBLE); + highlightsViewModel.getList().postValue(result); + } else binding.highlightsList.setVisibility(View.GONE); + }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); if (profileId.equals(myId)) { binding.btnTagged.setVisibility(View.VISIBLE); binding.btnSaved.setVisibility(View.VISIBLE); @@ -675,7 +685,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe }).execute(); }); binding.mainProfileImage.setOnClickListener(v -> { - if (storyModels == null || storyModels.length <= 0) { + if (!hasStories) { // show profile pic showProfilePicDialog(); return; @@ -690,7 +700,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe if (which == 1) { // show stories final NavDirections action = ProfileFragmentDirections - .actionProfileFragmentToStoryViewerFragment(-1, null, false, profileModel.getId(), username); + .actionProfileFragmentToStoryViewerFragment(-1, null, false, false, profileModel.getId(), username); NavHostFragment.findNavController(this).navigate(action); return; } @@ -819,7 +829,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe highlightsViewModel = new ViewModelProvider(fragmentActivity).get(HighlightsViewModel.class); highlightsAdapter = new HighlightsAdapter((model, position) -> { final NavDirections action = ProfileFragmentDirections - .actionProfileFragmentToStoryViewerFragment(position, model.getTitle(), false, null, null); + .actionProfileFragmentToStoryViewerFragment(position, model.getTitle(), false, false, null, null); NavHostFragment.findNavController(this).navigate(action); }); final Context context = getContext(); @@ -831,6 +841,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe } private void fetchPosts() { + Log.d("austin_debug", "fp"); stopCurrentExecutor(); binding.swipeRefreshLayout.setRefreshing(true); currentlyExecuting = new PostsFetcher(profileModel.getId(), PostItemType.MAIN, endCursor, postsFetchListener) diff --git a/app/src/main/java/awais/instagrabber/models/enums/StoryViewerChoice.java b/app/src/main/java/awais/instagrabber/models/enums/StoryViewerChoice.java deleted file mode 100755 index dd38d7ac..00000000 --- a/app/src/main/java/awais/instagrabber/models/enums/StoryViewerChoice.java +++ /dev/null @@ -1,19 +0,0 @@ -package awais.instagrabber.models.enums; - -import java.io.Serializable; - -public enum StoryViewerChoice implements Serializable { - NONE(0), - ALOINSTAGRAM(1), - INSTADP(2); - - private int value; - - StoryViewerChoice(int value) { - this.value = value; - } - - public String getValue() { - return String.valueOf(value); - } -} \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/utils/Constants.java b/app/src/main/java/awais/instagrabber/utils/Constants.java index 6fc40e6d..bb02453a 100644 --- a/app/src/main/java/awais/instagrabber/utils/Constants.java +++ b/app/src/main/java/awais/instagrabber/utils/Constants.java @@ -54,9 +54,9 @@ public final class Constants { // spoof public static final String USER_AGENT = "Mozilla/5.0 (Linux; Android 8.1.0; motorola one Build/OPKS28.63-18-3; wv) " + "AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36 " + - "Instagram 156.0.0.26.109 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 240726452)"; + "Instagram 160.0.0.25.132 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 246889068)"; public static final String I_USER_AGENT = - "Instagram 156.0.0.26.109 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 240726452)"; + "Instagram 160.0.0.25.132 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 246889068)"; public static final String A_USER_AGENT = "https://InstaGrabber.AustinHuang.me / mailto:InstaGrabber@AustinHuang.me"; // see https://github.com/dilame/instagram-private-api/blob/master/src/core/constants.ts public static final String SUPPORTED_CAPABILITIES = "[ { \"name\": \"SUPPORTED_SDK_VERSIONS\", \"value\":" + diff --git a/app/src/main/java/awais/instagrabber/webservices/StoriesService.java b/app/src/main/java/awais/instagrabber/webservices/StoriesService.java index fb5bba2c..a16381e4 100644 --- a/app/src/main/java/awais/instagrabber/webservices/StoriesService.java +++ b/app/src/main/java/awais/instagrabber/webservices/StoriesService.java @@ -153,6 +153,7 @@ public class StoriesService extends BaseService { model.setTappableShortCode(data.getJSONArray("story_feed_media").getJSONObject(0).optString("media_id")); } + // TODO: this may not be limited to spotify if (!data.isNull("story_app_attribution")) model.setSpotify(data.getJSONObject("story_app_attribution").optString("content_url").split("\\?")[0]); @@ -173,7 +174,7 @@ public class StoriesService extends BaseService { )); } if (data.has("story_questions")) { - JSONObject tappableObject = data.getJSONArray("story_questions").getJSONObject(0).optJSONObject("question_sticker"); + final JSONObject tappableObject = data.getJSONArray("story_questions").getJSONObject(0).optJSONObject("question_sticker"); if (tappableObject != null && !tappableObject.getString("question_type").equals("music")) model.setQuestion(new QuestionModel( String.valueOf(tappableObject.getLong("question_id")), @@ -229,6 +230,9 @@ public class StoriesService extends BaseService { } callback.onSuccess(models); } + else { + callback.onSuccess(null); + } } catch (JSONException e) { Log.e(TAG, "Error parsing string"); } @@ -248,12 +252,13 @@ public class StoriesService extends BaseService { if (isLoc) { builder.append("locations/"); } - if (isHashtag) { + else if (isHashtag) { builder.append("tags/"); } - if (highlight) { + else if (highlight) { builder.append("feed/reels_media?user_ids="); - } else { + } + else { builder.append("feed/user/"); } builder.append(userId); diff --git a/app/src/main/res/layout/layout_dm_media_share.xml b/app/src/main/res/layout/layout_dm_media_share.xml index 49c20a74..d173a206 100644 --- a/app/src/main/res/layout/layout_dm_media_share.xml +++ b/app/src/main/res/layout/layout_dm_media_share.xml @@ -20,8 +20,8 @@ diff --git a/app/src/main/res/navigation/feed_nav_graph.xml b/app/src/main/res/navigation/feed_nav_graph.xml index e5228e0e..406f6b63 100644 --- a/app/src/main/res/navigation/feed_nav_graph.xml +++ b/app/src/main/res/navigation/feed_nav_graph.xml @@ -98,6 +98,9 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/profile_nav_graph.xml b/app/src/main/res/navigation/profile_nav_graph.xml index 082a186d..fbf21f1c 100644 --- a/app/src/main/res/navigation/profile_nav_graph.xml +++ b/app/src/main/res/navigation/profile_nav_graph.xml @@ -139,6 +139,9 @@ +