mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-12-23 05:16:58 +00:00
restore location & hashtag stories
This commit is contained in:
parent
96a25f0d35
commit
6bd0b811b1
@ -79,7 +79,8 @@ public final class PostsFetcher extends AsyncTask<Void, Void, List<PostModel>> {
|
||||
"{\"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<PostModel> result = new ArrayList<>();
|
||||
try {
|
||||
@ -153,8 +154,7 @@ public final class PostsFetcher extends AsyncTask<Void, Void, List<PostModel>> {
|
||||
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);
|
||||
|
@ -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<List<StoryModel>>() {
|
||||
@Override
|
||||
public void onSuccess(final List<StoryModel> 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() {
|
||||
|
@ -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<List<StoryModel>>() {
|
||||
@Override
|
||||
public void onSuccess(final List<StoryModel> 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() {
|
||||
|
@ -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) { }
|
||||
|
@ -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();
|
||||
|
@ -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<Void, Void, List<PostModel>> 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<PostModel> postModels = postsViewModel.getList().getValue();
|
||||
List<PostModel> 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<List<StoryModel>>() {
|
||||
@Override
|
||||
public void onSuccess(final List<StoryModel> 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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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\":" +
|
||||
|
@ -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);
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/ivMediaPreview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:adjustViewBounds="true"
|
||||
android:maxHeight="@dimen/dm_media_img_max_height" />
|
||||
|
||||
|
@ -98,6 +98,9 @@
|
||||
<argument
|
||||
android:name="isHashtag"
|
||||
app:argType="boolean" />
|
||||
<argument
|
||||
android:name="isLoc"
|
||||
app:argType="boolean" />
|
||||
<argument
|
||||
android:name="profileId"
|
||||
app:argType="string"
|
||||
|
@ -19,6 +19,15 @@
|
||||
app:argType="boolean" />
|
||||
</action>
|
||||
|
||||
<action
|
||||
android:id="@+id/action_global_profileFragment"
|
||||
app:destination="@id/profile_nav_graph">
|
||||
<argument
|
||||
android:name="username"
|
||||
app:argType="string"
|
||||
app:nullable="false" />
|
||||
</action>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/hashTagFragment"
|
||||
android:name="awais.instagrabber.fragments.HashTagFragment"
|
||||
@ -28,6 +37,37 @@
|
||||
android:name="hashtag"
|
||||
app:argType="string"
|
||||
app:nullable="false" />
|
||||
<action
|
||||
android:id="@+id/action_hashtagFragment_to_storyViewerFragment"
|
||||
app:destination="@id/storyViewerFragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/storyViewerFragment"
|
||||
android:name="awais.instagrabber.fragments.StoryViewerFragment"
|
||||
android:label="StoryViewerFragment"
|
||||
tools:layout="@layout/fragment_story_viewer">
|
||||
<argument
|
||||
android:name="feedStoryIndex"
|
||||
app:argType="integer"
|
||||
app:nullable="false" />
|
||||
<argument
|
||||
android:name="highlight"
|
||||
app:argType="string"
|
||||
app:nullable="true" />
|
||||
<argument
|
||||
android:name="isHashtag"
|
||||
app:argType="boolean" />
|
||||
<argument
|
||||
android:name="isLoc"
|
||||
app:argType="boolean" />
|
||||
<argument
|
||||
android:name="profileId"
|
||||
app:argType="string"
|
||||
app:nullable="true" />
|
||||
<argument
|
||||
android:name="username"
|
||||
app:argType="string"
|
||||
app:nullable="true" />
|
||||
</fragment>
|
||||
<action
|
||||
android:id="@+id/action_global_hashTagFragment"
|
||||
|
@ -30,6 +30,9 @@
|
||||
android:name="locationId"
|
||||
app:argType="string"
|
||||
app:nullable="false" />
|
||||
<action
|
||||
android:id="@+id/action_locationFragment_to_storyViewerFragment"
|
||||
app:destination="@id/storyViewerFragment" />
|
||||
</fragment>
|
||||
<action
|
||||
android:id="@+id/action_global_locationFragment"
|
||||
@ -39,4 +42,32 @@
|
||||
app:argType="string"
|
||||
app:nullable="false" />
|
||||
</action>
|
||||
<fragment
|
||||
android:id="@+id/storyViewerFragment"
|
||||
android:name="awais.instagrabber.fragments.StoryViewerFragment"
|
||||
android:label="StoryViewerFragment"
|
||||
tools:layout="@layout/fragment_story_viewer">
|
||||
<argument
|
||||
android:name="feedStoryIndex"
|
||||
app:argType="integer"
|
||||
app:nullable="false" />
|
||||
<argument
|
||||
android:name="highlight"
|
||||
app:argType="string"
|
||||
app:nullable="true" />
|
||||
<argument
|
||||
android:name="isHashtag"
|
||||
app:argType="boolean" />
|
||||
<argument
|
||||
android:name="isLoc"
|
||||
app:argType="boolean" />
|
||||
<argument
|
||||
android:name="profileId"
|
||||
app:argType="string"
|
||||
app:nullable="true" />
|
||||
<argument
|
||||
android:name="username"
|
||||
app:argType="string"
|
||||
app:nullable="true" />
|
||||
</fragment>
|
||||
</navigation>
|
@ -139,6 +139,9 @@
|
||||
<argument
|
||||
android:name="isHashtag"
|
||||
app:argType="boolean" />
|
||||
<argument
|
||||
android:name="isLoc"
|
||||
app:argType="boolean" />
|
||||
<argument
|
||||
android:name="profileId"
|
||||
app:argType="string"
|
||||
|
Loading…
Reference in New Issue
Block a user